From 339a1bd639b48cd9fdcedb108669f33c80c064ce Mon Sep 17 00:00:00 2001 From: David Joseph Date: Sun, 24 Feb 2013 18:26:55 -0600 Subject: [PATCH] regressions: Add prefix to common alarm interface. --- regressions/common.h | 53 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/regressions/common.h b/regressions/common.h index ee6ce83..eccb853 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -37,7 +37,6 @@ #elif defined(__MACH__) #include #include -#include #endif #if defined(_WIN32) @@ -150,13 +149,13 @@ common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration) #ifndef SECOND_TIMER #define SECOND_TIMER 10000000 #endif -#define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) \ -static HANDLE common_win_alarm_timer; \ -static HANDLE alarm_event_name; \ -static LARGE_INTEGER common_alarm_timer_length; \ +#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) \ +static HANDLE prefix##_common_win_alarm_timer; \ +static HANDLE prefix##_alarm_event_name; \ +static LARGE_INTEGER prefix##_common_alarm_timer_length; \ \ static void CALLBACK \ -common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ +prefix##_common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ { \ (void)arg; \ (void)timer_low_value; \ @@ -166,7 +165,7 @@ common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_val } \ \ static void * \ -common_win_alarm(void *unused) \ +prefix##_common_win_alarm(void *unused) \ { \ (void)unused; \ bool timer_success = false; \ @@ -183,28 +182,28 @@ common_win_alarm(void *unused) \ return NULL; \ } -#define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name, local_name) \ - int64_t common_alarm_tl_#local_name; \ - pthread_t common_win_alarm_thread_#local_name; - -#define COMMON_ALARM_INIT(alarm_event_name, duration, local_name) \ - common_alarm_tl_#local_name = -1 * (duration) * SECOND_TIMER; \ - common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \ - common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \ - alarm_event_name = CreateEvent(NULL, false, false, NULL); \ - assert(alarm_event_name != NULL); \ - common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ - assert(common_win_alarm_timer != NULL); \ - if (pthread_create(&common_win_alarm_thread_#local_name, \ - NULL, \ - common_win_alarm, \ - NULL) != 0) \ +#define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \ + int64_t prefix##_common_alarm_tl; \ + pthread_t prefix##_common_win_alarm_thread; + +#define COMMON_ALARM_INIT(prefix, alarm_event_name, duration) \ + prefix##_common_alarm_tl = -1 * (duration) * SECOND_TIMER; \ + prefix##_common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \ + prefix##_common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \ + prefix##_alarm_event_name = CreateEvent(NULL, false, false, NULL); \ + assert(prefix##_alarm_event_name != NULL); \ + prefix##_common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ + assert(prefix##_common_win_alarm_timer != NULL); \ + if (pthread_create(&prefix##_common_win_alarm_thread, \ + NULL, \ + prefix##_common_win_alarm, \ + NULL) != 0) \ ck_error("ERROR: Failed to create common_win_alarm thread.\n"); #else -#define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) -#define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name, local_name) \ - int alarm_event_name = 0; -#define COMMON_ALARM_INIT(alarm_event_name, duration) +#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) +#define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \ + int prefix##_alarm_event_name = 0; +#define COMMON_ALARM_INIT(prefix, alarm_event_name, duration) #endif struct affinity {