add..
[lttv.git] / ltt / branches / poly / include / ltt / ltt.h
index 7c347414926d7804d2119128b646c2a89924124b..fc00a14d78888728966de71933f30437c0496674 100644 (file)
@@ -61,6 +61,7 @@ typedef struct _LttField LttField;
 
 typedef struct _LttEvent LttEvent;
 
+typedef struct _LttSystemDescription LttSystemDescription;
 
 /* Checksums are used to differentiate facilities which have the same name
    but differ. */
@@ -74,7 +75,10 @@ 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;
 
@@ -93,6 +97,50 @@ 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;  \
+  (T3).tv_nsec = (T2).tv_nsec - (T1).tv_nsec; \
+  if((T3).tv_nsec < 0)\
+    {\
+    (T3).tv_sec--;\
+    (T3).tv_nsec += 1000000000;\
+    }\
+} 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 >= 1000000000)\
+    {\
+    (T3).tv_sec += (T3).tv_nsec / 1000000000;\
+    (T3).tv_nsec = (T3).tv_nsec % 1000000000;\
+    }\
+} 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 >= 1000000000)\
+    {\
+    (T2).tv_sec += (T3).tv_nsec / 1000000000;\
+    (T2).tv_nsec = (T3).tv_nsec % 1000000000;\
+    }\
+} while(0)
+
+
 
 
 #include <ltt/ltt-private.h>
This page took 0.023103 seconds and 4 git commands to generate.