diff --git a/winpr/libwinpr/synch/CMakeLists.txt b/winpr/libwinpr/synch/CMakeLists.txt index cd93e84f8..fbc607292 100644 --- a/winpr/libwinpr/synch/CMakeLists.txt +++ b/winpr/libwinpr/synch/CMakeLists.txt @@ -18,6 +18,15 @@ set(MODULE_NAME "winpr-synch") set(MODULE_PREFIX "WINPR_SYNCH") +INCLUDE (CheckLibraryExists) +list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) +check_library_exists(pthread pthread_tryjoin_np "" HAVE_PTHREAD_GNU_EXT) +list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) + +if(HAVE_PTHREAD_GNU_EXT) + add_definitions(-D_GNU_SOURCE -DHAVE_PTHREAD_GNU_EXT) +endif(HAVE_PTHREAD_GNU_EXT) + include_directories(../thread) set(${MODULE_PREFIX}_SRCS diff --git a/winpr/libwinpr/synch/wait.c b/winpr/libwinpr/synch/wait.c index dccb071ae..9a8eba120 100644 --- a/winpr/libwinpr/synch/wait.c +++ b/winpr/libwinpr/synch/wait.c @@ -77,7 +77,7 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) { if (dwMilliseconds != INFINITE) { -#if _GNU_SOURCE +#if HAVE_PTHREAD_GNU_EXT struct timespec timeout; clock_gettime(CLOCK_REALTIME, &timeout); @@ -105,7 +105,7 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) mutex = (WINPR_MUTEX*) Object; -#if _GNU_SOURCE +#if HAVE_PTHREAD_GNU_EXT if (dwMilliseconds != INFINITE) { struct timespec timeout;