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