X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Ftime.h;h=483e2e58a5bf3a8d21fb8c9572506ad55173d36b;hb=dfb73233deab2c53c00874997d6c03110588c5ee;hp=6ab53fcac3039310e11dae5c4593c91dee4be5f9;hpb=57df94dd8dd13258d6a5a83406f2f76a045a7cc3;p=lttv.git diff --git a/ltt/branches/poly/ltt/time.h b/ltt/branches/poly/ltt/time.h index 6ab53fca..483e2e58 100644 --- a/ltt/branches/poly/ltt/time.h +++ b/ltt/branches/poly/ltt/time.h @@ -29,10 +29,17 @@ typedef struct _LttTime { #define NANOSECONDS_PER_SECOND 1000000000 + +/* We give the DIV and MUL constants so we can always multiply, for a + * division as well as a multiplication of NANOSECONDS_PER_SECOND */ /* 2^30/1.07374182400631629848 = 1000000000.0 */ -#define DOUBLE_SHIFT_CONST 1.07374182400631629848 +#define DOUBLE_SHIFT_CONST_DIV 1.07374182400631629848 #define DOUBLE_SHIFT 30 +/* 2^30*0.93132257461547851562 = 1000000000.0000000000 */ +#define DOUBLE_SHIFT_CONST_MUL 0.93132257461547851562 + + /* 1953125 * 2^9 = NANOSECONDS_PER_SECOND */ #define LTT_TIME_UINT_SHIFT_CONST 1953125 #define LTT_TIME_UINT_SHIFT 9 @@ -109,7 +116,7 @@ static inline double ltt_time_to_double(LttTime t1) g_warning("Precision loss in conversion LttTime to double"); #endif //EXTRA_CHECK return ((double)((guint64)t1.tv_sec<> DOUBLE_SHIFT; + res.tv_sec = (guint64)(t1 * DOUBLE_SHIFT_CONST_DIV) >> DOUBLE_SHIFT; res.tv_nsec = (t1 - (((guint64)res.tv_sec<