|
|
|
@ -149,37 +149,37 @@ 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(prefix, alarm_event_name, flag_name) \
|
|
|
|
|
static HANDLE prefix##_common_win_alarm_timer; \
|
|
|
|
|
static HANDLE alarm_event_name; \
|
|
|
|
|
static LARGE_INTEGER prefix##_common_alarm_timer_length; \
|
|
|
|
|
\
|
|
|
|
|
static void CALLBACK \
|
|
|
|
|
prefix##_common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \
|
|
|
|
|
{ \
|
|
|
|
|
(void)arg; \
|
|
|
|
|
(void)timer_low_value; \
|
|
|
|
|
(void)timer_high_value; \
|
|
|
|
|
flag_name = true; \
|
|
|
|
|
return; \
|
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
static void * \
|
|
|
|
|
prefix##_common_win_alarm(void *unused) \
|
|
|
|
|
{ \
|
|
|
|
|
(void)unused; \
|
|
|
|
|
bool timer_success = false; \
|
|
|
|
|
for (;;) { \
|
|
|
|
|
WaitForSingleObjectEx(alarm_event_name, INFINITE, true); \
|
|
|
|
|
timer_success = SetWaitableTimer(common_win_alarm_timer, \
|
|
|
|
|
&common_alarm_timer_length, \
|
|
|
|
|
0, \
|
|
|
|
|
common_win_alarm_handler, NULL, false); \
|
|
|
|
|
assert(timer_success != false); \
|
|
|
|
|
WaitForSingleObjectEx(common_win_alarm_timer, INFINITE, true); \
|
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
return NULL; \
|
|
|
|
|
#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) \
|
|
|
|
|
static HANDLE prefix##_common_win_alarm_timer; \
|
|
|
|
|
static HANDLE alarm_event_name; \
|
|
|
|
|
static LARGE_INTEGER prefix##_common_alarm_timer_length; \
|
|
|
|
|
\
|
|
|
|
|
static void CALLBACK \
|
|
|
|
|
prefix##_common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \
|
|
|
|
|
{ \
|
|
|
|
|
(void)arg; \
|
|
|
|
|
(void)timer_low_value; \
|
|
|
|
|
(void)timer_high_value; \
|
|
|
|
|
flag_name = true; \
|
|
|
|
|
return; \
|
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
static void * \
|
|
|
|
|
prefix##_common_win_alarm(void *unused) \
|
|
|
|
|
{ \
|
|
|
|
|
(void)unused; \
|
|
|
|
|
bool timer_success = false; \
|
|
|
|
|
for (;;) { \
|
|
|
|
|
WaitForSingleObjectEx(alarm_event_name, INFINITE, true); \
|
|
|
|
|
timer_success = SetWaitableTimer(prefix##_common_win_alarm_timer, \
|
|
|
|
|
&prefix##_common_alarm_timer_length, \
|
|
|
|
|
0, \
|
|
|
|
|
prefix##_common_win_alarm_handler, NULL, false); \
|
|
|
|
|
assert(timer_success != false); \
|
|
|
|
|
WaitForSingleObjectEx(prefix##_common_win_alarm_timer, INFINITE, true); \
|
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
return NULL; \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \
|
|
|
|
|