summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-02-10 15:38:52 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-02-10 15:38:52 (GMT)
commit738661ab9f409b8d961ba1402d6c4dd5f99ecb43 (patch)
tree01f97a9d10bc3bbe519366197b475efdae2cc8d5
parent168d67dbd20923feef30fb76c6b569ef2e5add4a (diff)
downloadhdf5-738661ab9f409b8d961ba1402d6c4dd5f99ecb43.zip
hdf5-738661ab9f409b8d961ba1402d6c4dd5f99ecb43.tar.gz
hdf5-738661ab9f409b8d961ba1402d6c4dd5f99ecb43.tar.bz2
[svn-r6386] Purpose:
Bug fix Description: The "system scope" for threads isn't supported on all platforms. Solution: Add detection of this feature to the configure script and check for "H5_HAVE_SYSTEM_SCOPE_THREADS" in the appropriate places. Platforms tested: modi4 w/threadsafe
-rwxr-xr-xconfigure67
-rw-r--r--configure.in31
-rw-r--r--src/H5config.h.in4
-rw-r--r--test/ttsafe_cancel.c2
-rw-r--r--test/ttsafe_dcreate.c7
-rw-r--r--test/ttsafe_error.c2
6 files changed, 108 insertions, 5 deletions
diff --git a/configure b/configure
index c0a7674..7a1ebdf 100755
--- a/configure
+++ b/configure
@@ -29493,6 +29493,73 @@ else
echo "${ECHO_T}no" >&6
fi
+echo "$as_me:$LINENO: checking Threads support system scope" >&5
+echo $ECHO_N "checking Threads support system scope... $ECHO_C" >&6
+if test "${hdf5_cv_system_scope_threads+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling" >&5
+echo "$as_me: error: cannot run test program while cross compiling" >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <pthread.h>
+#endif
+
+int main(void)
+{
+ pthread_attr_t attribute;
+ int ret;
+
+ pthread_attr_init(&attribute);
+ ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
+ exit(ret==0 ? 0 : 1);
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ hdf5_cv_system_scope_threads=yes
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+( exit $ac_status )
+hdf5_cv_system_scope_threads=no
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+
+
+if test ${hdf5_cv_system_scope_threads} = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define SYSTEM_SCOPE_THREADS 1
+_ACEOF
+
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
for ac_header in gpfs.h
do
diff --git a/configure.in b/configure.in
index 8d689e0..7d487e7 100644
--- a/configure.in
+++ b/configure.in
@@ -1483,6 +1483,37 @@ else
fi
dnl ----------------------------------------------------------------------
+dnl Check if pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM)
+dnl is supported on this system
+dnl
+AC_MSG_CHECKING([Threads support system scope])
+AC_CACHE_VAL(hdf5_cv_system_scope_threads,
+AC_TRY_RUN([
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <pthread.h>
+#endif
+
+int main(void)
+{
+ pthread_attr_t attribute;
+ int ret;
+
+ pthread_attr_init(&attribute);
+ ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
+ exit(ret==0 ? 0 : 1);
+}
+], hdf5_cv_system_scope_threads=yes, hdf5_cv_system_scope_threads=no,))
+
+if test ${hdf5_cv_system_scope_threads} = "yes"; then
+ AC_DEFINE(SYSTEM_SCOPE_THREADS, 1,
+ [Define if your system supports pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM) call.])
+ AC_MSG_RESULT(yes)
+else
+ AC_MSG_RESULT(no)
+fi
+
+dnl ----------------------------------------------------------------------
dnl Checking to see if GPFS is available on this filesystem
dnl
AC_CHECK_HEADERS([gpfs.h],
diff --git a/src/H5config.h.in b/src/H5config.h.in
index 06928ff..4ac1519 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -460,6 +460,10 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* Define if your system supports pthread_attr_setscope(&attribute,
+ PTHREAD_SCOPE_SYSTEM) call. */
+#undef SYSTEM_SCOPE_THREADS
+
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
diff --git a/test/ttsafe_cancel.c b/test/ttsafe_cancel.c
index 8e47d09..93b3f24 100644
--- a/test/ttsafe_cancel.c
+++ b/test/ttsafe_cancel.c
@@ -62,7 +62,9 @@ void tts_cancel(void)
/* make thread scheduling global */
pthread_attr_init(&attribute);
+#ifdef H5_HAVE_SYSTEM_SCOPE_THREADS
pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
+#endif /* H5_HAVE_SYSTEM_SCOPE_THREADS */
/*
* Create a hdf5 file using H5F_ACC_TRUNC access, default file
diff --git a/test/ttsafe_dcreate.c b/test/ttsafe_dcreate.c
index d85dbe7..9a66609 100644
--- a/test/ttsafe_dcreate.c
+++ b/test/ttsafe_dcreate.c
@@ -87,13 +87,10 @@ void tts_dcreate(void)
/* set pthread attribute to perform global scheduling */
ret=pthread_attr_init(&attribute);
assert(ret==0);
+#ifdef H5_HAVE_SYSTEM_SCOPE_THREADS
ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
-/* Don't check return value on FreeBSD, since PTHREAD_SCOPE_SYSTEM is not
- * currently supported in v4.7
- */
-#ifndef __FreeBSD__
assert(ret==0);
-#endif /* __FreeBSD__ */
+#endif /* H5_HAVE_SYSTEM_SCOPE_THREADS */
/*
* Create a hdf5 file using H5F_ACC_TRUNC access, default file
diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c
index e911863..284a6e4 100644
--- a/test/ttsafe_error.c
+++ b/test/ttsafe_error.c
@@ -90,7 +90,9 @@ void tts_error(void)
/* make thread scheduling global */
pthread_attr_init(&attribute);
+#ifdef H5_HAVE_SYSTEM_SCOPE_THREADS
pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
+#endif /* H5_HAVE_SYSTEM_SCOPE_THREADS */
/*
* Create a hdf5 file using H5F_ACC_TRUNC access, default file