send time in events

this calls clock_gettime for each active T macro, hopefully it
does not eat too much CPU

can be deactivated by commenting one line in T_defs.h
This commit is contained in:
Cedric Roux
2016-05-11 18:26:30 +02:00
parent 3e38cd2651
commit aacb2ff7c2
3 changed files with 33 additions and 0 deletions
+25
View File
@@ -7,6 +7,10 @@
#include "T_defs.h"
#ifdef T_SEND_TIME
#include <time.h>
#endif
/* T message IDs */
#include "T_IDs.h"
@@ -187,6 +191,25 @@ extern T_cache_t *T_cache;
} while (0)
#endif
#ifdef T_SEND_TIME
#define T_HEADER(x) \
do { \
if (!__builtin_types_compatible_p(typeof(x), struct T_header *)) { \
printf("%s:%d:%s: " \
"bad use of T, pass a message ID as first parameter\n", \
__FILE__, __LINE__, __FUNCTION__); \
abort(); \
} \
struct timespec T_HEADER_time; \
if (clock_gettime(CLOCK_REALTIME, &T_HEADER_time)) abort(); \
memcpy(T_LOCAL_buf, &T_HEADER_time, sizeof(struct timespec)); \
T_LOCAL_size += sizeof(struct timespec); \
T_PUT_int(1, (int)(uintptr_t)(x)); \
} while (0)
#else /* #ifdef T_SEND_TIME */
#define T_HEADER(x) \
do { \
if (!__builtin_types_compatible_p(typeof(x), struct T_header *)) { \
@@ -198,6 +221,8 @@ extern T_cache_t *T_cache;
T_PUT_int(1, (int)(uintptr_t)(x)); \
} while (0)
#endif /* #ifdef T_SEND_TIME */
#define T1(t) \
do { \
if (T_ACTIVE(t)) { \