Fixed check for _GNU_SOURCE pthread extensions.

This commit is contained in:
Armin Novak 2013-08-16 11:49:35 +02:00 committed by Bernhard Miklautz
parent ebff396e90
commit 313250d99b
2 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -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,6 +105,7 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
mutex = (WINPR_MUTEX*) Object;
#if HAVE_PTHREAD_GNU_EXT
if (dwMilliseconds != INFINITE)
{
struct timespec timeout;
@ -115,6 +116,7 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
pthread_mutex_timedlock(&mutex->mutex, &timeout);
}
else
#endif
pthread_mutex_lock(&mutex->mutex);
}
else if (Type == HANDLE_TYPE_EVENT)