From: compudj Date: Tue, 23 Aug 2005 20:11:48 +0000 (+0000) Subject: use proper lib for byte swapping of double and float X-Git-Tag: v0.12.20~2426 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d421441814ae10380308a411418c53ea5f05d858;p=lttv.git use proper lib for byte swapping of double and float git-svn-id: http://ltt.polymtl.ca/svn@1063 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/ltt/event.c b/ltt/branches/poly/ltt/event.c index 207c5d55..2827cff9 100644 --- a/ltt/branches/poly/ltt/event.c +++ b/ltt/branches/poly/ltt/event.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include "parser.h" #include @@ -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); } }