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:
@@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
#include "T_defs.h"
|
#include "T_defs.h"
|
||||||
|
|
||||||
|
#ifdef T_SEND_TIME
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* T message IDs */
|
/* T message IDs */
|
||||||
#include "T_IDs.h"
|
#include "T_IDs.h"
|
||||||
|
|
||||||
@@ -187,6 +191,25 @@ extern T_cache_t *T_cache;
|
|||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#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) \
|
#define T_HEADER(x) \
|
||||||
do { \
|
do { \
|
||||||
if (!__builtin_types_compatible_p(typeof(x), struct T_header *)) { \
|
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)); \
|
T_PUT_int(1, (int)(uintptr_t)(x)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#endif /* #ifdef T_SEND_TIME */
|
||||||
|
|
||||||
#define T1(t) \
|
#define T1(t) \
|
||||||
do { \
|
do { \
|
||||||
if (T_ACTIVE(t)) { \
|
if (T_ACTIVE(t)) { \
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#ifndef _T_defs_H_
|
#ifndef _T_defs_H_
|
||||||
#define _T_defs_H_
|
#define _T_defs_H_
|
||||||
|
|
||||||
|
/* comment (and recompile everything) to not send time in events */
|
||||||
|
#define T_SEND_TIME
|
||||||
|
|
||||||
/* maximum number of arguments for the T macro */
|
/* maximum number of arguments for the T macro */
|
||||||
#define T_MAX_ARGS 16
|
#define T_MAX_ARGS 16
|
||||||
|
|
||||||
|
|||||||
@@ -84,10 +84,15 @@ int fullread(int fd, void *_buf, int count)
|
|||||||
|
|
||||||
event get_event(int s, char *v, void *d)
|
event get_event(int s, char *v, void *d)
|
||||||
{
|
{
|
||||||
|
struct timespec t;
|
||||||
int type;
|
int type;
|
||||||
int32_t length;
|
int32_t length;
|
||||||
|
|
||||||
fullread(s, &length, 4);
|
fullread(s, &length, 4);
|
||||||
|
#ifdef T_SEND_TIME
|
||||||
|
fullread(s, &t, sizeof(struct timespec));
|
||||||
|
length -= sizeof(struct timespec);
|
||||||
|
#endif
|
||||||
fullread(s, &type, sizeof(int));
|
fullread(s, &type, sizeof(int));
|
||||||
length -= sizeof(int);
|
length -= sizeof(int);
|
||||||
fullread(s, v, length);
|
fullread(s, v, length);
|
||||||
|
|||||||
Reference in New Issue
Block a user