X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Finclude%2Fltt%2Fltt.h;h=74cbacebacbf6d3686e0117e179b421cb6d0473a;hb=b9f095dbe5986f50ca4665d976735bbb8c639c12;hp=eda0a766d8963457e330ebd42756493038fcf4b7;hpb=8a2d0e7181075408c8fa1b35b2a755e200863997;p=lttv.git diff --git a/ltt/branches/poly/include/ltt/ltt.h b/ltt/branches/poly/include/ltt/ltt.h index eda0a766..74cbaceb 100644 --- a/ltt/branches/poly/include/ltt/ltt.h +++ b/ltt/branches/poly/include/ltt/ltt.h @@ -75,10 +75,20 @@ typedef unsigned long LttChecksum; times per second) of the real time clock with their corresponding cycle count values. */ -typedef struct timespec LttTime; +typedef struct _LttTime { + unsigned long tv_sec; + unsigned long tv_nsec; +} LttTime; typedef uint64_t LttCycleCount; +#define NANSECOND_CONST 1000000000 + +/* Event positions are used to seek within a tracefile based on + the block number and event position within the block. */ + +typedef struct _LttEventPosition LttEventPosition; + /* Differences between architectures include word sizes, endianess, alignment, floating point format and calling conventions. For a @@ -94,6 +104,53 @@ typedef enum _LttArchEndian { LTT_LITTLE_ENDIAN, LTT_BIG_ENDIAN } LttArchEndian; +/* Time operation macros for LttTime (struct timespec) */ +/* (T3 = T2 - T1) */ +#define TimeSub(T3, T2, T1) \ +do \ +{\ + (T3).tv_sec = (T2).tv_sec - (T1).tv_sec; \ + if((T2).tv_nsec < (T1).tv_nsec)\ + {\ + (T3).tv_sec--;\ + (T3).tv_nsec = NANSECOND_CONST - (T1).tv_nsec + (T2).tv_nsec;\ + }\ + else\ + {\ + (T3).tv_nsec = (T2).tv_nsec - (T1).tv_nsec;\ + }\ +} while(0) + +/* (T3 = T2 + T1) */ +#define TimeAdd(T3, T2, T1) \ +do \ +{\ + (T3).tv_sec = (T2).tv_sec + (T1).tv_sec; \ + (T3).tv_nsec = (T2).tv_nsec + (T1).tv_nsec; \ + if((T3).tv_nsec >= NANSECOND_CONST)\ + {\ + (T3).tv_sec += (T3).tv_nsec / NANSECOND_CONST;\ + (T3).tv_nsec = (T3).tv_nsec % NANSECOND_CONST;\ + }\ +} while(0) + +/* (T2 = T1 * FLOAT) */ +/* WARNING : use this multiplicator carefully : on 32 bits, multiplying + * by more than 4 could overflow the tv_nsec. + */ +#define TimeMul(T2, T1, FLOAT) \ +do \ +{\ + (T2).tv_sec = (T1).tv_sec * (FLOAT); \ + (T2).tv_nsec = (T1).tv_nsec * (FLOAT); \ + if((T2).tv_nsec >= NANSECOND_CONST)\ + {\ + (T2).tv_sec += (T2).tv_nsec / NANSECOND_CONST;\ + (T2).tv_nsec = (T2).tv_nsec % NANSECOND_CONST;\ + }\ +} while(0) + + #include