Skip to content

Commit 84be284

Browse files
committed
SQUASHME pthreads/configure.m4: bunches of minor updates
- Use OPAL_VAR_SCOPE_PUSH|POP to make shell variable scopes safe - Use the "-eq" and "-ne" test operands for numeric comparisons - Use proper C prototypes in the Fortran link test to prevent spurious compiler warnings Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
1 parent 9719cfd commit 84be284

File tree

1 file changed

+37
-23
lines changed

1 file changed

+37
-23
lines changed

opal/mca/threads/pthreads/configure.m4

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# University of Stuttgart. All rights reserved.
1111
# Copyright (c) 2004-2005 The Regents of the University of California.
1212
# All rights reserved.
13-
# Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
13+
# Copyright (c) 2008-2020 Cisco Systems, Inc. All rights reserved.
1414
# Copyright (c) 2015 Research Organization for Information Science
1515
# and Technology (RIST). All rights reserved.
1616
# Copyright (c) 2019 Sandia National Laboratories. All rights reserved.
@@ -122,7 +122,8 @@ AS_IF([test "$OPAL_THREADS_HAVE_DIFFERENT_PIDS" = "1"],
122122
# if pthreads is not available, then the system does not have an insane threads
123123
# model
124124
#
125-
OPAL_VAR_SCOPE_POP])dnl
125+
OPAL_VAR_SCOPE_POP
126+
])dnl
126127
127128
AC_DEFUN([OPAL_INTL_PTHREAD_TRY_LINK], [
128129
# BEGIN: OPAL_INTL_PTHREAD_TRY_LINK
@@ -171,6 +172,8 @@ AC_DEFUN([OPAL_INTL_PTHREAD_TRY_LINK_FORTRAN], [
171172
# Make sure that we can run a small application in Fortran, with
172173
# pthreads living in a C object file
173174
175+
OPAL_VAR_SCOPE_PUSH([HAPPY opal_conftest_h])
176+
174177
# Fortran module
175178
cat > conftestf.f <<EOF
176179
program fpthread
@@ -198,7 +201,12 @@ pthread_t me, newthread;
198201
199202
void cleanup_routine(void *foo);
200203
void *thread_main(void *foo);
204+
201205
void pthreadtest_f(void);
206+
void pthreadtest(void);
207+
void pthreadtest_(void);
208+
void pthreadtest__(void);
209+
void PTHREADTEST(void);
202210
203211
void cleanup_routine(void *foo) { i = 4; }
204212
void *thread_main(void *foo) { i = 2; return (void*) &i; }
@@ -256,8 +264,9 @@ else
256264
$2
257265
fi
258266
259-
unset HAPPY opal_conftest_h
260267
rm -rf conftest*
268+
269+
OPAL_VAR_SCOPE_POP
261270
# END: OPAL_INTL_PTHREAD_TRY_LINK_FORTRAN
262271
])dnl
263272
@@ -457,6 +466,7 @@ AC_DEFUN([OPAL_INTL_POSIX_THREADS_SPECIAL_FLAGS],[
457466
# Put -mt before -mthreads because HP-UX aCC will properly compile
458467
# with -mthreads (reading as -mt), but emit a warning about unknown
459468
# flags hreads. Stupid compilers.
469+
OPAL_VAR_SCOPE_PUSH([pflags])
460470
461471
case "${host_cpu}-${host_os}" in
462472
*solaris*)
@@ -480,6 +490,7 @@ AC_PROVIDE_IFELSE([AC_PROG_FC],
480490
[OPAL_INTL_POSIX_THREADS_SPECIAL_FLAGS_FC],
481491
[opal_pthread_fortran_success=1])
482492
493+
OPAL_VAR_SCOPE_POP
483494
# End: OPAL_INTL_POSIX_THREADS_SPECIAL_FLAGS
484495
])dnl
485496
@@ -604,10 +615,10 @@ AC_DEFUN([OPAL_INTL_POSIX_THREADS_LIBS_FC],[
604615
#
605616
# Fortran compiler
606617
#
607-
if test "$opal_pthread_fortran_success" = "0" && \
618+
if test $opal_pthread_fortran_success -eq 0 && \
608619
test "$OMPI_TRY_FORTRAN_BINDINGS" -gt "$OMPI_FORTRAN_NO_BINDINGS" && \
609620
test $ompi_fortran_happy -eq 1; then
610-
if test ! "$opal_pthread_c_success" = "0" && test ! "$TPKG_LIBS" = "" ; then
621+
if test $opal_pthread_c_success -ne 0 && test ! "$TPKG_LIBS" = "" ; then
611622
AC_MSG_CHECKING([if Fortran compiler and POSIX threads work with $TPKG_LIBS])
612623
LIBS="$orig_LIBS $TPKG_LIBS"
613624
AC_LANG_PUSH(C)
@@ -654,6 +665,7 @@ AC_DEFUN([OPAL_INTL_POSIX_THREADS_LIBS],[
654665
# libpthreads: AIX - must check before libpthread
655666
# liblthread: LinuxThreads on FreeBSD
656667
# libpthread: The usual place (like we can define usual!)
668+
OPAL_VAR_SCOPE_PUSH([plibs])
657669
plibs="-lpthreads -llthread -lpthread"
658670
659671
# Only run C++ and Fortran if those compilers already configured
@@ -669,6 +681,7 @@ AC_PROVIDE_IFELSE([AC_PROG_FC],
669681
[OPAL_INTL_POSIX_THREADS_LIBS_FC],
670682
[opal_pthread_fortran_success=1])
671683
684+
OPAL_VAR_SCOPE_POP
672685
# End: OPAL_INTL_POSIX_THREADS_LIBS]
673686
)dnl
674687
@@ -679,6 +692,7 @@ AC_PROVIDE_IFELSE([AC_PROG_FC],
679692
#
680693
#********************************************************************
681694
AC_DEFUN([OPAL_CONFIG_POSIX_THREADS],[
695+
OPAL_VAR_SCOPE_PUSH([opal_pthreads_result defval opal_pthread_c_success opal_pthread_fortran_success opal_pthread_cxx_success orig_CFLAGS orig_FCFLAGS orig_CXXFLAGS orig_CPPFLAGS orig_CXXCPPFLAGS orig_LDFLAGS orig_LIBS])
682696
AC_REQUIRE([AC_PROG_GREP])
683697
684698
opal_pthread_c_success=0
@@ -725,8 +739,8 @@ AC_LINK_IFELSE(
725739
[AC_LANG_PROGRAM(
726740
[[#include <pthread.h>]],
727741
[[pthread_mutexattr_settype(NULL, PTHREAD_MUTEX_ERRORCHECK_NP);]])],
728-
[result="yes" defval=1], [result="no" defval=0])
729-
AC_MSG_RESULT([$result])
742+
[opal_pthreads_result="yes" defval=1], [opal_pthreads_result="no" defval=0])
743+
AC_MSG_RESULT([$opal_pthreads_result])
730744
AC_DEFINE_UNQUOTED([OPAL_HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], [$defval],
731745
[If PTHREADS implementation supports PTHREAD_MUTEX_ERRORCHECK_NP])
732746
@@ -736,8 +750,8 @@ AC_LINK_IFELSE(
736750
[AC_LANG_PROGRAM(
737751
[[#include <pthread.h>]],
738752
[[pthread_mutexattr_settype(NULL, PTHREAD_MUTEX_ERRORCHECK);]])],
739-
[result="yes" defval=1], [result="no" defval=0])
740-
AC_MSG_RESULT([$result])
753+
[opal_pthreads_result="yes" defval=1], [opal_pthreads_result="no" defval=0])
754+
AC_MSG_RESULT([$opal_pthreads_result])
741755
AC_DEFINE_UNQUOTED([OPAL_HAVE_PTHREAD_MUTEX_ERRORCHECK], [$defval],
742756
[If PTHREADS implementation supports PTHREAD_MUTEX_ERRORCHECK])
743757
@@ -761,23 +775,21 @@ OPAL_CHECK_PTHREAD_PIDS
761775
762776
if test "$OMPI_TRY_FORTRAN_BINDINGS" = "$OMPI_FORTRAN_NO_BINDINGS" || \
763777
test $ompi_fortran_happy -ne 1; then
764-
opal_pthread_fortran_success=1
778+
opal_pthread_fortran_success=1
765779
fi
766780
767-
if test "$opal_pthread_c_success" = "1" && \
768-
test "$opal_pthread_cxx_success" = "1" && \
769-
test "$opal_pthread_fortran_success" = "1"; then
770-
internal_useless=1
771-
AC_MSG_RESULT("looks like posix threads work")
772-
$1
781+
AC_MSG_CHECKING([if POSIX threads work])
782+
if test $opal_pthread_c_success -eq 1 && \
783+
test $opal_pthread_cxx_success -eq 1 && \
784+
test $opal_pthread_fortran_success -eq 1; then
785+
AC_MSG_RESULT([yes])
786+
$1
773787
else
774-
internal_useless=1
775-
AC_MSG_RESULT("looks like posix threads don't work")
776-
$2
788+
AC_MSG_RESULT([no])
789+
$2
777790
fi
778791
779-
unset opal_pthread_c_success opal_pthread_fortran_success opal_pthread_cxx_success
780-
unset internal_useless
792+
OPAL_VAR_SCOPE_POP
781793
])dnl
782794
783795
AC_DEFUN([MCA_opal_threads_pthreads_PRIORITY], [30])
@@ -826,14 +838,16 @@ AC_DEFUN([MCA_opal_threads_pthreads_POST_CONFIG],[
826838
# ------------------------------------------------
827839
AC_DEFUN([MCA_opal_threads_pthreads_CONFIG],[
828840
AC_CONFIG_FILES([opal/mca/threads/pthreads/Makefile])
841+
OPAL_VAR_SCOPE_PUSH([posix_thread_works])
829842
830843
AS_IF([test -z "$with_threads" || test "$with_threads" = "pthreads" || test "$with_threads" = "yes"],
831844
[OPAL_CONFIG_POSIX_THREADS([posix_threads_works=1],[posix_threads_works=0])],
832845
[posix_threads_works=0])
833846
834-
AS_IF([test "$posix_threads_works" = "1"],
847+
AS_IF([test $posix_threads_works -eq 1],
835848
[$1],
836849
[$2])
837-
AC_MSG_RESULT("posix_threads_works = $posix_threads_works")
850+
851+
OPAL_VAR_SCOPE_POP
838852
])
839853

0 commit comments

Comments
 (0)