summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2021-03-01 21:54:27 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2021-03-01 21:54:27 (GMT)
commitd7b277a22aa72f3badcc331e3007df8892e83a80 (patch)
treedf63cc53b0f0aae8ffa8ad58fe31f21aff71c79b
parent051cf5330ba06f113de88de22c201f00677cbdc3 (diff)
downloadhdf5-d7b277a22aa72f3badcc331e3007df8892e83a80.zip
hdf5-d7b277a22aa72f3badcc331e3007df8892e83a80.tar.gz
hdf5-d7b277a22aa72f3badcc331e3007df8892e83a80.tar.bz2
Improves autotools and CMake support for sigtimedwait alternative
-rw-r--r--CMakeLists.txt5
-rw-r--r--config/cmake/H5pubconf.h.in3
-rw-r--r--config/cmake_ext_mod/ConfigureChecks.cmake1
-rw-r--r--configure.ac2
-rw-r--r--test/CMakeLists.txt8
-rw-r--r--test/vfd_swmr_common.c16
6 files changed, 27 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ac291fa..b6e0044 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -816,8 +816,13 @@ if (HDF5_ENABLE_THREADSAFE)
if (Threads_FOUND)
set (H5_HAVE_THREADSAFE 1)
endif ()
+else()
+ # Always check for pthreads for VFD SWMR (for now)
+ set (THREADS_PREFER_PTHREAD_FLAG ON)
+ find_package (Threads REQUIRED)
endif ()
+
#-----------------------------------------------------------------------------
# Option to build the map API
#-----------------------------------------------------------------------------
diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in
index 64b4852..5f34599 100644
--- a/config/cmake/H5pubconf.h.in
+++ b/config/cmake/H5pubconf.h.in
@@ -352,6 +352,9 @@
/* Define to 1 if you have the `sigsetjmp' function. */
#cmakedefine H5_HAVE_SIGSETJMP @H5_HAVE_SIGSETJMP@
+/* Define to 1 if you have the `sigtimedwait' function. */
+#cmakedefine H5_HAVE_SIGTIMEDWAIT @H5_HAVE_SIGTIMEDWAIT@
+
/* Define to 1 if you have the `snprintf' function. */
#cmakedefine H5_HAVE_SNPRINTF @H5_HAVE_SNPRINTF@
diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake
index 0ddb6d0..bfa63ac 100644
--- a/config/cmake_ext_mod/ConfigureChecks.cmake
+++ b/config/cmake_ext_mod/ConfigureChecks.cmake
@@ -518,6 +518,7 @@ CHECK_FUNCTION_EXISTS (setjmp ${HDF_PREFIX}_HAVE_SETJMP)
CHECK_FUNCTION_EXISTS (siglongjmp ${HDF_PREFIX}_HAVE_SIGLONGJMP)
CHECK_FUNCTION_EXISTS (sigsetjmp ${HDF_PREFIX}_HAVE_SIGSETJMP)
CHECK_FUNCTION_EXISTS (sigprocmask ${HDF_PREFIX}_HAVE_SIGPROCMASK)
+CHECK_FUNCTION_EXISTS (sigtimedwait ${HDF_PREFIX}_HAVE_SIGTIMEDWAIT)
CHECK_FUNCTION_EXISTS (snprintf ${HDF_PREFIX}_HAVE_SNPRINTF)
CHECK_FUNCTION_EXISTS (srandom ${HDF_PREFIX}_HAVE_SRANDOM)
diff --git a/configure.ac b/configure.ac
index 2307b4a..a641a45 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1958,7 +1958,7 @@ AC_CHECK_FUNCS([alarm clock_gettime difftime fcntl flock fork frexpf])
AC_CHECK_FUNCS([frexpl gethostname getrusage gettimeofday])
AC_CHECK_FUNCS([lstat rand_r random setsysinfo])
AC_CHECK_FUNCS([signal longjmp setjmp siglongjmp sigsetjmp sigprocmask])
-AC_CHECK_FUNCS([snprintf srandom strdup symlink system])
+AC_CHECK_FUNCS([sigtimedwait snprintf srandom strdup symlink system])
AC_CHECK_FUNCS([strtoll strtoull])
AC_CHECK_FUNCS([tmpfile asprintf vasprintf vsnprintf waitpid])
AC_CHECK_FUNCS([roundf lroundf llroundf round lround llround])
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 023c07e..ad6b258 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -46,6 +46,11 @@ if (NOT ONLY_SHARED_LIBS)
endif ()
H5_SET_LIB_OPTIONS (${HDF5_TEST_LIB_TARGET} ${HDF5_TEST_LIB_NAME} STATIC 0)
set_target_properties (${HDF5_TEST_LIB_TARGET} PROPERTIES FOLDER libraries/test)
+
+ # Always link to pthreads for VFD SWMR tests
+ if (NOT WIN32)
+ target_link_libraries (${HDF5_TEST_LIB_TARGET} PRIVATE Threads::Threads)
+ endif ()
endif ()
if (BUILD_SHARED_LIBS)
@@ -66,6 +71,9 @@ if (BUILD_SHARED_LIBS)
endif ()
H5_SET_LIB_OPTIONS (${HDF5_TEST_LIBSH_TARGET} ${HDF5_TEST_LIB_NAME} SHARED "LIB")
set_target_properties (${HDF5_TEST_LIBSH_TARGET} PROPERTIES FOLDER libraries/test)
+
+ # Always link to pthreads for VFD SWMR tests
+ target_link_libraries (${HDF5_TEST_LIBSH_TARGET} PRIVATE Threads::Threads)
endif ()
#################################################################################
diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c
index d4bb8ef..3f03ce7 100644
--- a/test/vfd_swmr_common.c
+++ b/test/vfd_swmr_common.c
@@ -20,7 +20,9 @@
/***********/
#include <err.h> /* for err(3) */
-#if defined(__APPLE__) && defined(__MACH__)
+
+/* Only need the pthread solution if sigtimedwai(2) isn't available */
+#ifndef H5_HAVE_SIGTIMEDWAIT
#include <pthread.h>
#endif
@@ -181,7 +183,7 @@ strsignal(int signum)
}
#endif
-#if defined(__APPLE__) && defined(__MACH__)
+#ifndef H5_HAVE_SIGTIMEDWAIT
typedef struct timer_params_t {
struct timespec *tick;
@@ -228,7 +230,7 @@ timer_function(void *arg)
return NULL;
}
-#endif
+#endif /* H5_HAVE_SIGTIMEDWAIT */
/* Wait for any signal to occur and then return. Wake periodically
* during the wait to perform API calls: in this way, the
@@ -254,10 +256,10 @@ await_signal(hid_t fid)
dbgf(1, "waiting for signal\n");
-#if defined(__APPLE__) && defined(__MACH__)
+#ifndef H5_HAVE_SIGTIMEDWAIT
{
- /* MacOS does not have sigtimedwait(2), so use an alternative.
- * XXX: Replace with configure macros later.
+ /* Use an alternative scheme for platforms like MacOS that do not have
+ * sigtimedwait(2)
*/
timer_params_t params;
int rc;
@@ -308,7 +310,7 @@ await_signal(hid_t fid)
} else if (rc == -1)
err(EXIT_FAILURE, "%s: sigtimedwait", __func__);
}
-#endif
+#endif /* H5_HAVE_SIGTIMEDWAIT */
}
/* Revised support routines that can be used for all VFD SWMR integration tests