diff --git a/CMakeLists.txt b/CMakeLists.txt index 19ab868e4..dce790c54 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -268,6 +268,7 @@ endif() if(UNIX OR CYGWIN) check_include_files(sys/eventfd.h HAVE_EVENTFD_H) + check_include_files(sys/timerfd.h HAVE_TIMERFD_H) set(X11_FEATURE_TYPE "RECOMMENDED") else() set(X11_FEATURE_TYPE "DISABLED") diff --git a/config.h.in b/config.h.in index 63de66d8d..83b0abecb 100755 --- a/config.h.in +++ b/config.h.in @@ -30,6 +30,7 @@ #cmakedefine HAVE_SYS_SELECT_H #cmakedefine HAVE_SYS_STRTIO_H #cmakedefine HAVE_EVENTFD_H +#cmakedefine HAVE_TIMERFD_H #cmakedefine HAVE_TM_GMTOFF diff --git a/winpr/libwinpr/synch/synch.h b/winpr/libwinpr/synch/synch.h index 0e46d69f5..f3593c536 100644 --- a/winpr/libwinpr/synch/synch.h +++ b/winpr/libwinpr/synch/synch.h @@ -20,6 +20,10 @@ #ifndef WINPR_SYNCH_PRIVATE_H #define WINPR_SYNCH_PRIVATE_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include @@ -70,7 +74,7 @@ struct winpr_event }; typedef struct winpr_event WINPR_EVENT; -#ifdef __linux__ +#ifdef HAVE_TIMERFD_H #include #include #include @@ -87,7 +91,7 @@ struct winpr_timer PTIMERAPCROUTINE pfnCompletionRoutine; LPVOID lpArgToCompletionRoutine; -#ifdef __linux__ +#ifdef HAVE_TIMERFD_H struct itimerspec timeout; #endif }; diff --git a/winpr/libwinpr/synch/timer.c b/winpr/libwinpr/synch/timer.c index 10ecc19d2..bc32ffcdb 100644 --- a/winpr/libwinpr/synch/timer.c +++ b/winpr/libwinpr/synch/timer.c @@ -51,7 +51,7 @@ HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManua timer->pfnCompletionRoutine = NULL; timer->lpArgToCompletionRoutine = NULL; -#ifdef __linux__ +#ifdef HAVE_TIMERFD_H timer->fd = timerfd_create(CLOCK_MONOTONIC, 0); if (timer->fd <= 0) @@ -114,7 +114,7 @@ BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPerio timer->pfnCompletionRoutine = pfnCompletionRoutine; timer->lpArgToCompletionRoutine = lpArgToCompletionRoutine; -#ifdef __linux__ +#ifdef HAVE_TIMERFD_H ZeroMemory(&(timer->timeout), sizeof(struct itimerspec)); if (lpDueTime->QuadPart < 0)