Skip to content

Commit ebdb0ab

Browse files
committed
cmake: Add confiure checks for pthread members
1 parent 60e2722 commit ebdb0ab

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ConfigureChecks.cmake

+22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include(CheckCSourceCompiles)
22
include(TestBigEndian)
33
include(CheckIncludeFile)
44
include(CheckSymbolExists)
5+
include(CheckStructHasMember)
56

67
check_include_file(cpuid.h HAVE_CPUID_H)
78

@@ -40,6 +41,27 @@ set(CMAKE_REQUIRED_LIBRARIES)
4041
set(CMAKE_REQUIRED_INCLUDES)
4142
endif()
4243

44+
#
45+
# Check for pthread struct members
46+
#
47+
set(CMAKE_REQUIRED_FLAGS ${THREADS_PREFER_PTHREAD_FLAG})
48+
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
49+
50+
check_struct_has_member("struct __pthread_rwlock_arch_t"
51+
"__readers"
52+
"pthread.h"
53+
HAVE_THREAD_RWLOCK_ARCH_T_READERS
54+
LANGUAGE C)
55+
56+
check_struct_has_member("struct __pthread_rwlock_arch_t"
57+
"__nr_readers"
58+
"pthread.h"
59+
HAVE_THREAD_RWLOCK_ARCH_T_NR_READERS
60+
LANGUAGE C)
61+
62+
unset(CMAKE_REQUIRED_FLAGS)
63+
unset(CMAKE_REQUIRED_LIBRARIES)
64+
4365
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR})
4466

4567
check_c_source_compiles("#include <stdio.h>

src/config.cmake.h

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ static const char *dt_supported_extensions[] __attribute__((unused)) = {"@DT_SUP
7171

7272
#cmakedefine HAVE_OMP_FIRSTPRIVATE_WITH_CONST 1
7373

74+
#cmakedefine HAVE_THREAD_RWLOCK_ARCH_T_READERS 1
75+
76+
#cmakedefine HAVE_THREAD_RWLOCK_ARCH_T_NR_READERS 1
77+
7478
/******************************************************************************
7579
* OpenCL target settings
7680
*****************************************************************************/

0 commit comments

Comments
 (0)