From f9b5dafe2997082e2d65d87dc6506e789742859f Mon Sep 17 00:00:00 2001 From: Cedric Roux <cedric.roux@eurecom.fr> Date: Fri, 17 Feb 2017 18:16:22 +0100 Subject: [PATCH] T: let it compile with C++ We now have 4 versions of T_HEADER: - bad quality C++ version with time - good quality C version with time - bad quality C++ version without time - good quality C version without time --- common/utils/T/T.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/common/utils/T/T.h b/common/utils/T/T.h index 819615131e..37668a8309 100644 --- a/common/utils/T/T.h +++ b/common/utils/T/T.h @@ -184,8 +184,30 @@ extern T_cache_t *T_cache; } while (0) #endif +/* we have 4 versions of T_HEADER: + * - bad quality C++ version with time + * - good quality C version with time + * - bad quality C++ version without time + * - good quality C version without time + */ + #ifdef T_SEND_TIME +#ifdef __cplusplus + +/* C++ version of T_HEADER with time */ +#define T_HEADER(x) \ + do { \ + 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 __cplusplus */ + +/* C version of T_HEADER with time */ #define T_HEADER(x) \ do { \ if (!__builtin_types_compatible_p(typeof(x), struct T_header *)) { \ @@ -201,8 +223,21 @@ extern T_cache_t *T_cache; T_PUT_int(1, (int)(uintptr_t)(x)); \ } while (0) +#endif /* #ifdef __cplusplus */ + #else /* #ifdef T_SEND_TIME */ +#ifdef __cplusplus + +/* C++ version of T_HEADER without time */ +#define T_HEADER(x) \ + do { \ + T_PUT_int(1, (int)(uintptr_t)(x)); \ + } while (0) + +#else /* #ifdef __cplusplus */ + +/* C version of T_HEADER without time */ #define T_HEADER(x) \ do { \ if (!__builtin_types_compatible_p(typeof(x), struct T_header *)) { \ @@ -214,6 +249,8 @@ extern T_cache_t *T_cache; T_PUT_int(1, (int)(uintptr_t)(x)); \ } while (0) +#endif /* #ifdef __cplusplus */ + #endif /* #ifdef T_SEND_TIME */ #define T1(t) \ -- GitLab