Skip to content

Commit

Permalink
Revert changes for detecting C11 threads
Browse files Browse the repository at this point in the history
Signed-off-by: Quincey Koziol <[email protected]>
  • Loading branch information
qkoziol committed Nov 20, 2024
1 parent 51d1f5a commit 883cbbe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
52 changes: 22 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -794,43 +794,35 @@ endif ()

# Determine if a threading package is available on this system
option (HDF5_ENABLE_THREADS "Enable thread support" ON)
if (HDF5_ENABLE_THREADS)
# When C11 threads are available, those are the top choice
CHECK_INCLUDE_FILE("threads.h" HAVE_THREADS_H)
if (HAVE_THREADS_H)
set (H5_HAVE_C11_THREADS 1)
else()
# Determine which threading package to use
set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads)

if (Threads_FOUND)
# When Win32 is available, we use those threads
if (WIN32)
set (H5_HAVE_WIN_THREADS 1)
else()
if (CMAKE_USE_PTHREADS_INIT)
set (H5_HAVE_PTHREAD_H 1)
else()
message (FATAL_ERROR " **** thread support requires C11 threads, Win32 threads or Pthreads **** ")
endif()
endif()

set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
else()
message (FATAL_ERROR " **** thread support requires C11 threads, Win32 threads or Pthreads **** ")
endif()
endif()

# Threads are available
set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads)
if (Threads_FOUND)
set (H5_HAVE_THREADS 1)
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})

# Determine which threading package to use
# Comment out check for C11 threads for now, since it conflicts with the
# current --std=c99 compile flags at configuration time. When we switch to
# --std=c11, this can be uncommented.
#CHECK_INCLUDE_FILE("threads.h" HAVE_THREADS_H)
if (WIN32)
# When Win32 is available, we use those threads
set (H5_HAVE_WIN_THREADS 1)
elseif (HAVE_THREADS_H)
# When C11 threads are available, those are the top choice
set (H5_HAVE_C11_THREADS 1)
elseif (CMAKE_USE_PTHREADS_INIT)
set (H5_HAVE_PTHREAD_H 1)
else ()
message (FATAL_ERROR " **** thread support requires C11 threads, Win32 threads or Pthreads **** ")
endif ()

# Check for compiler support for atomic variables
CHECK_INCLUDE_FILE("stdatomic.h" HAVE_STDATOMIC_H)
if (HAVE_STDATOMIC_H)
set (H5_HAVE_STDATOMIC_H 1)
endif()
endif()
endif ()

# Determine whether to build the HDF5 Subfiling VFD
set (H5FD_SUBFILING_DIR ${HDF5_SRC_DIR}/H5FDsubfiling)
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,7 @@ if test "X$THREADS" = "Xyes"; then
# Comment out check for C11 threads for now, since it conflicts with the
# current --std=c99 compile flags at configuration time. When we switch to
# --std=c11, this can be uncommented.
AC_CHECK_HEADERS([threads.h],[HAVE_THREADS_H="yes"],[HAVE_THREADS_H="no"])
#AC_CHECK_HEADERS([threads.h],[HAVE_THREADS_H="yes"],[HAVE_THREADS_H="no"])
if test "x$HAVE_THREADS_H" = "xyes"; then
# Default or no --> C11 threads
if test "$withval" = "default" -o "$withval" = "no" ; then
Expand Down
5 changes: 3 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ set (H5TS_SOURCES
${HDF5_SRC_DIR}/H5TSbarrier.c
${HDF5_SRC_DIR}/H5TSc11.c
${HDF5_SRC_DIR}/H5TScond.c
${HDF5_SRC_DIR}/H5TSdlftt_mutex.c
${HDF5_SRC_DIR}/H5TSint.c
${HDF5_SRC_DIR}/H5TSkey.c
${HDF5_SRC_DIR}/H5TSmutex.c
Expand Down Expand Up @@ -1113,7 +1114,7 @@ if (BUILD_STATIC_LIBS)
)
if (NOT WIN32)
target_link_libraries (${HDF5_LIB_TARGET}
PRIVATE "$<$<OR:$<BOOL:${HDF5_ENABLE_THREADS}>,$<BOOL:${HDF5_ENABLE_SUBFILING_VFD}>>:${CMAKE_THREAD_LIBS_INIT}>"
PRIVATE "$<$<OR:$<BOOL:${HDF5_ENABLE_THREADS}>,$<BOOL:${HDF5_ENABLE_SUBFILING_VFD}>>:Threads::Threads>"
)
endif ()
set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET})
Expand Down Expand Up @@ -1145,7 +1146,7 @@ if (BUILD_SHARED_LIBS)
TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED)
target_link_libraries (${HDF5_LIBSH_TARGET}
PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS}
PUBLIC "$<$<PLATFORM_ID:Windows>:${LINK_PUB_LIBS}>" "$<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}>" "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPI::MPI_C>" "$<$<OR:$<BOOL:${HDF5_ENABLE_THREADS}>,$<BOOL:${HDF5_ENABLE_SUBFILING_VFD}>>:${CMAKE_THREAD_LIBS_INIT}>"
PUBLIC "$<$<PLATFORM_ID:Windows>:${LINK_PUB_LIBS}>" "$<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}>" "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPI::MPI_C>" "$<$<OR:$<BOOL:${HDF5_ENABLE_THREADS}>,$<BOOL:${HDF5_ENABLE_SUBFILING_VFD}>>:Threads::Threads>"
)
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}")
H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED "LIB")
Expand Down

0 comments on commit 883cbbe

Please sign in to comment.