Commit f9b5dafe authored by Cedric Roux's avatar Cedric Roux

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
parent 603c84c7
...@@ -184,8 +184,30 @@ extern T_cache_t *T_cache; ...@@ -184,8 +184,30 @@ extern T_cache_t *T_cache;
} while (0) } while (0)
#endif #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 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) \ #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 *)) { \
...@@ -201,8 +223,21 @@ extern T_cache_t *T_cache; ...@@ -201,8 +223,21 @@ 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 __cplusplus */
#else /* #ifdef T_SEND_TIME */ #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) \ #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 *)) { \
...@@ -214,6 +249,8 @@ extern T_cache_t *T_cache; ...@@ -214,6 +249,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 __cplusplus */
#endif /* #ifdef T_SEND_TIME */ #endif /* #ifdef T_SEND_TIME */
#define T1(t) \ #define T1(t) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment