use proper lib for byte swapping of double and float
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 23 Aug 2005 20:11:48 +0000 (20:11 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 23 Aug 2005 20:11:48 +0000 (20:11 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1063 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/event.c

index 207c5d552fa8f444022eacdd35c52741992fe174..2827cff9aaf7fd1b038f643b0d96088eff671d09 100644 (file)
@@ -26,7 +26,7 @@
 #include <glib.h>
 
 #include <asm/types.h>
-#include <linux/byteorder/swab.h>
+#include <byteswap.h>
 
 #include "parser.h"
 #include <ltt/ltt.h>
@@ -620,10 +620,12 @@ float ltt_event_get_float(LttEvent *e, LttField *f)
 
   if(reverse_byte_order == 0) return *(float *)(e->data + f->offset_root);
   else{
-    guint32 aInt;
-    memcpy((void*)&aInt, e->data + f->offset_root, 4);
-    aInt = ___swab32(aInt);
-    return ((float)aInt);
+//    guint32 aInt;
+    void *ptr = e->data + f->offset_root;
+//    memcpy((void*)&aInt, e->data + f->offset_root, 4);
+//    aInt = bswap_32();
+//    return ((float)aInt);
+    return *(float*)bswap_32(*(guint32*)ptr);
   }
 }
 
@@ -635,10 +637,12 @@ double ltt_event_get_double(LttEvent *e, LttField *f)
 
   if(reverse_byte_order == 0) return *(double *)(e->data + f->offset_root);
   else{
-    guint64 aInt;
-    memcpy((void*)&aInt, e->data + f->offset_root, 8);
-    aInt = ___swab64(aInt);
-    return ((double)aInt);
+    void *ptr = e->data + f->offset_root;
+    return *(double*)bswap_64(*(guint64*)ptr);
+    //guint64 aInt;
+    //memcpy((void*)&aInt, e->data + f->offset_root, 8);
+    //aInt = ___swab64(aInt);
+    //return ((double)aInt);
   }
 }
 
This page took 0.026237 seconds and 4 git commands to generate.