From adc1845b485b1917049a10a285ce91b3aad21261 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 29 Jan 2015 18:48:20 -0500 Subject: [svn-r26081] Moved the check for pthread_attr_setscope() into the thread-safe checks section. Documented its necessity and added a cross-compiling option and helpful comment. Also removed a check for BSDgettimeofday from configure.ac, which was for Irix 5.3 support. Part of HDFFV-9087 Tested on: jam with threadsafe --- configure | 123 +++++++++++++++++++++++++++++------------------------- configure.ac | 73 ++++++++++++++++++-------------- src/H5config.h.in | 3 -- 3 files changed, 106 insertions(+), 93 deletions(-) diff --git a/configure b/configure index 420a90d..73f89f6 100755 --- a/configure +++ b/configure @@ -26033,7 +26033,7 @@ $as_echo "#define HAVE_THREADSAFE 1" >>confdefs.h ## ---------------------------------------------------------------------- - ## Is the pthreads library present? It has a header file `pthread.h' and + ## Is the Pthreads library present? It has a header file `pthread.h' and ## a library `-lpthread' and their locations might be specified with the ## `--with-pthread' command-line switch. The value is an include path ## and/or a library path. If the library path is specified then it must @@ -26313,6 +26313,69 @@ fi fi ;; esac + + ## ---------------------------------------------------------------------- + ## Check if pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM) + ## is supported on this system + ## + ## Unfortunately, this probably needs to be an AC_TRY_RUN since + ## it's impossible to determine if PTHREAD_SCOPE_SYSTEM is + ## supported a priori. POSIX.1-2001 requires that a conformant + ## system need only support one of SYSTEM or PROCESS scopes. + ## + ## For cross-compiling, we've added a pessimistic 'no'. You can + ## hand-hack the config file if you know otherwise. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Pthreads supports system scope" >&5 +$as_echo_n "checking Pthreads supports system scope... " >&6; } + if ${hdf5_cv_system_scope_threads+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + hdf5_cv_system_scope_threads=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #if STDC_HEADERS + #include + #include + #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 +if ac_fn_c_try_run "$LINENO"; then : + hdf5_cv_system_scope_threads=yes +else + hdf5_cv_system_scope_threads=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + + + if test ${hdf5_cv_system_scope_threads} = "yes"; then + +$as_echo "#define SYSTEM_SCOPE_THREADS 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: Always 'no' if cross-compiling. Edit the config file if your platform supports pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM)." >&5 +$as_echo "$as_me: Always 'no' if cross-compiling. Edit the config file if your platform supports pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM)." >&6;} + fi fi ## ---------------------------------------------------------------------- @@ -26634,7 +26697,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ## ---------------------------------------------------------------------- ## Check for functions. ## -for ac_func in alarm BSDgettimeofday fork frexpf frexpl +for ac_func in alarm fork frexpf frexpl do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -27149,62 +27212,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF -## ---------------------------------------------------------------------- -## Check if pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM) -## is supported on this system -## -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Threads support system scope" >&5 -$as_echo_n "checking Threads support system scope... " >&6; } -if ${hdf5_cv_system_scope_threads+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #if STDC_HEADERS - #include - #include - #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 -if ac_fn_c_try_run "$LINENO"; then : - hdf5_cv_system_scope_threads=yes -else - hdf5_cv_system_scope_threads=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi - - -if test ${hdf5_cv_system_scope_threads} = "yes"; then - -$as_echo "#define SYSTEM_SCOPE_THREADS 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi ## ---------------------------------------------------------------------- ## Turn on debugging by setting compiler flags diff --git a/configure.ac b/configure.ac index 72b0ab0..3d2a5c2 100644 --- a/configure.ac +++ b/configure.ac @@ -1694,7 +1694,7 @@ if test "X$THREADSAFE" = "Xyes"; then AC_DEFINE([HAVE_THREADSAFE], [1], [Define if we have thread safe support]) ## ---------------------------------------------------------------------- - ## Is the pthreads library present? It has a header file `pthread.h' and + ## Is the Pthreads library present? It has a header file `pthread.h' and ## a library `-lpthread' and their locations might be specified with the ## `--with-pthread' command-line switch. The value is an include path ## and/or a library path. If the library path is specified then it must @@ -1768,6 +1768,45 @@ if test "X$THREADSAFE" = "Xyes"; then fi ;; esac + + ## ---------------------------------------------------------------------- + ## Check if pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM) + ## is supported on this system + ## + ## Unfortunately, this probably needs to be an AC_TRY_RUN since + ## it's impossible to determine if PTHREAD_SCOPE_SYSTEM is + ## supported a priori. POSIX.1-2001 requires that a conformant + ## system need only support one of SYSTEM or PROCESS scopes. + ## + ## For cross-compiling, we've added a pessimistic 'no'. You can + ## hand-hack the config file if you know otherwise. + AC_MSG_CHECKING([Pthreads supports system scope]) + AC_CACHE_VAL([hdf5_cv_system_scope_threads], + [AC_TRY_RUN([ + #if STDC_HEADERS + #include + #include + #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], [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]) + AC_MSG_NOTICE([Always 'no' if cross-compiling. Edit the config file if your platform supports pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM).]) + fi fi ## ---------------------------------------------------------------------- @@ -1866,7 +1905,7 @@ AC_TRY_COMPILE([#include ],[int w=TIOCGETD;], ## ---------------------------------------------------------------------- ## Check for functions. ## -AC_CHECK_FUNCS([alarm BSDgettimeofday fork frexpf frexpl]) +AC_CHECK_FUNCS([alarm fork frexpf frexpl]) AC_CHECK_FUNCS([gethostname getpwuid getrusage lstat]) AC_CHECK_FUNCS([rand_r random setsysinfo]) AC_CHECK_FUNCS([signal longjmp setjmp siglongjmp sigsetjmp sigprocmask]) @@ -2019,36 +2058,6 @@ AC_MSG_RESULT([%${hdf5_cv_printf_ll}d and %${hdf5_cv_printf_ll}u]) AC_DEFINE_UNQUOTED([PRINTF_LL_WIDTH], ["$hdf5_cv_printf_ll"], [Width for printf() for type `long long' or `__int64', use `ll']) -## ---------------------------------------------------------------------- -## Check if pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM) -## is supported on this system -## -AC_MSG_CHECKING([Threads support system scope]) -AC_CACHE_VAL([hdf5_cv_system_scope_threads], - [AC_TRY_RUN([ - #if STDC_HEADERS - #include - #include - #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 ## ---------------------------------------------------------------------- ## Turn on debugging by setting compiler flags diff --git a/src/H5config.h.in b/src/H5config.h.in index 119763f..5a3159e 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -58,9 +58,6 @@ /* Define if the __attribute__(()) extension is present */ #undef HAVE_ATTRIBUTE -/* Define to 1 if you have the `BSDgettimeofday' function. */ -#undef HAVE_BSDGETTIMEOFDAY - /* Define if the compiler understands C99 designated initialization of structs and unions */ #undef HAVE_C99_DESIGNATED_INITIALIZER -- cgit v0.12