|
|
@ -37,7 +37,6 @@
|
|
|
|
#elif defined(__MACH__)
|
|
|
|
#elif defined(__MACH__)
|
|
|
|
#include <mach/mach.h>
|
|
|
|
#include <mach/mach.h>
|
|
|
|
#include <mach/thread_policy.h>
|
|
|
|
#include <mach/thread_policy.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#if defined(_WIN32)
|
|
|
@ -150,13 +149,13 @@ common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration)
|
|
|
|
#ifndef SECOND_TIMER
|
|
|
|
#ifndef SECOND_TIMER
|
|
|
|
#define SECOND_TIMER 10000000
|
|
|
|
#define SECOND_TIMER 10000000
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name) \
|
|
|
|
#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) \
|
|
|
|
static HANDLE common_win_alarm_timer; \
|
|
|
|
static HANDLE prefix##_common_win_alarm_timer; \
|
|
|
|
static HANDLE alarm_event_name; \
|
|
|
|
static HANDLE prefix##_alarm_event_name; \
|
|
|
|
static LARGE_INTEGER common_alarm_timer_length; \
|
|
|
|
static LARGE_INTEGER prefix##_common_alarm_timer_length; \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
static void CALLBACK \
|
|
|
|
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)arg; \
|
|
|
|
(void)timer_low_value; \
|
|
|
|
(void)timer_low_value; \
|
|
|
@ -166,7 +165,7 @@ common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_val
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
static void * \
|
|
|
|
static void * \
|
|
|
|
common_win_alarm(void *unused) \
|
|
|
|
prefix##_common_win_alarm(void *unused) \
|
|
|
|
{ \
|
|
|
|
{ \
|
|
|
|
(void)unused; \
|
|
|
|
(void)unused; \
|
|
|
|
bool timer_success = false; \
|
|
|
|
bool timer_success = false; \
|
|
|
@ -183,28 +182,28 @@ common_win_alarm(void *unused) \
|
|
|
|
return NULL; \
|
|
|
|
return NULL; \
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name, local_name) \
|
|
|
|
#define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \
|
|
|
|
int64_t common_alarm_tl_#local_name; \
|
|
|
|
int64_t prefix##_common_alarm_tl; \
|
|
|
|
pthread_t common_win_alarm_thread_#local_name;
|
|
|
|
pthread_t prefix##_common_win_alarm_thread;
|
|
|
|
|
|
|
|
|
|
|
|
#define COMMON_ALARM_INIT(alarm_event_name, duration, local_name) \
|
|
|
|
#define COMMON_ALARM_INIT(prefix, alarm_event_name, duration) \
|
|
|
|
common_alarm_tl_#local_name = -1 * (duration) * SECOND_TIMER; \
|
|
|
|
prefix##_common_alarm_tl = -1 * (duration) * SECOND_TIMER; \
|
|
|
|
common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \
|
|
|
|
prefix##_common_alarm_timer_length.LowPart = (DWORD) (tl & 0xFFFFFFFF); \
|
|
|
|
common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \
|
|
|
|
prefix##_common_alarm_timer_length.HighPart = (LONG) (tl >> 32); \
|
|
|
|
alarm_event_name = CreateEvent(NULL, false, false, NULL); \
|
|
|
|
prefix##_alarm_event_name = CreateEvent(NULL, false, false, NULL); \
|
|
|
|
assert(alarm_event_name != NULL); \
|
|
|
|
assert(prefix##_alarm_event_name != NULL); \
|
|
|
|
common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \
|
|
|
|
prefix##_common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \
|
|
|
|
assert(common_win_alarm_timer != NULL); \
|
|
|
|
assert(prefix##_common_win_alarm_timer != NULL); \
|
|
|
|
if (pthread_create(&common_win_alarm_thread_#local_name, \
|
|
|
|
if (pthread_create(&prefix##_common_win_alarm_thread, \
|
|
|
|
NULL, \
|
|
|
|
NULL, \
|
|
|
|
common_win_alarm, \
|
|
|
|
prefix##_common_win_alarm, \
|
|
|
|
NULL) != 0) \
|
|
|
|
NULL) != 0) \
|
|
|
|
ck_error("ERROR: Failed to create common_win_alarm thread.\n");
|
|
|
|
ck_error("ERROR: Failed to create common_win_alarm thread.\n");
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#define COMMON_ALARM_DECLARE_GLOBAL(alarm_event_name, flag_name)
|
|
|
|
#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name)
|
|
|
|
#define COMMON_ALARM_DECLARE_LOCAL(alarm_event_name, local_name) \
|
|
|
|
#define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \
|
|
|
|
int alarm_event_name = 0;
|
|
|
|
int prefix##_alarm_event_name = 0;
|
|
|
|
#define COMMON_ALARM_INIT(alarm_event_name, duration)
|
|
|
|
#define COMMON_ALARM_INIT(prefix, alarm_event_name, duration)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
struct affinity {
|
|
|
|
struct affinity {
|
|
|
|