autoconf: update pthread checks 18/13018/4
authorMichael Meffie <mmeffie@sinenomine.net>
Mon, 16 Apr 2018 14:42:49 +0000 (10:42 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Sat, 11 Aug 2018 16:24:30 +0000 (12:24 -0400)
Replace obsolete AC_TRY_COMPILE with AC_COMPILE_IFELSE.  Replace shell
if/then conditionals with AS_IF macros.  Reformat indentation and
quoting.

This change was done manually, since autoupdate copes poorly with the
old, nested AC_TRY_COMPILE macros.

Change-Id: I2c34d1426f154daff65999076821f49ddaa16a24
Reviewed-on: https://gerrit.openafs.org/13018
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>

src/cf/pthread.m4

index 02292c5..0661c74 100644 (file)
@@ -1,76 +1,71 @@
-AC_DEFUN([OPENAFS_PTHREAD_CHECKS],[
-PTHREAD_LIBS=error
-if test "x$MKAFS_OSTYPE" = OBSD; then
-        PTHREAD_LIBS="-pthread"
-fi
-if test "x$MKAFS_OSTYPE" = xDFBSD; then
-        PTHREAD_LIBS="-pthread"
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        AC_CHECK_LIB(pthread, pthread_attr_init,
-                PTHREAD_LIBS="-lpthread")
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        AC_CHECK_LIB(pthreads, pthread_attr_init,
-                PTHREAD_LIBS="-lpthreads")
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        AC_CHECK_LIB(c_r, pthread_attr_init,
-                PTHREAD_LIBS="-lc_r")
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        # pthread_attr_init is a macro under HPUX 11.0 and 11.11
-        AC_CHECK_LIB(pthread, pthread_attr_destroy,
-                PTHREAD_LIBS="-lpthread")
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        AC_MSG_WARN(*** Unable to locate working posix thread library ***)
-fi
-AC_SUBST(PTHREAD_LIBS)
-])
+AC_DEFUN([OPENAFS_PTHREAD_CHECKS],
+[PTHREAD_LIBS=error
+AS_IF([test "x$MKAFS_OSTYPE" = OBSD],
+  [PTHREAD_LIBS="-pthread"])
+AS_IF([test "x$MKAFS_OSTYPE" = xDFBSD],
+  [PTHREAD_LIBS="-pthread"])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [AC_CHECK_LIB([pthread], [pthread_attr_init],
+                [PTHREAD_LIBS="-lpthread"])])
+AS_IF(["x$PTHREAD_LIBS" = xerror],
+  [AC_CHECK_LIB([pthreads], [pthread_attr_init],
+                [PTHREAD_LIBS="-lpthreads"])])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [AC_CHECK_LIB([c_r], [pthread_attr_init],
+                [PTHREAD_LIBS="-lc_r"])])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [AC_CHECK_FUNC([pthread_attr_init], [PTHREAD_LIBS=""])])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [# pthread_attr_init is a macro under HPUX 11.0 and 11.11
+   AC_CHECK_LIB([pthread], [pthread_attr_destroy],
+                [PTHREAD_LIBS="-lpthread"])])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [AC_MSG_WARN([*** Unable to locate working posix thread library ***])])
+AC_SUBST([PTHREAD_LIBS])
+]) # OPENAFS_PTHREADS_CHECKS
 
-AC_DEFUN([OPENAFS_MORE_PTHREAD_CHECKS],[
-dnl Look for "non-portable" pthreads functions.
+AC_DEFUN([OPENAFS_MORE_PTHREAD_CHECKS],
+[dnl Look for "non-portable" pthreads functions.
 save_LIBS="$LIBS"
 LIBS="$LIBS $PTHREAD_LIBS"
 AC_CHECK_FUNCS([ \
-        pthread_set_name_np \
-        pthread_setname_np \
+  pthread_set_name_np \
+  pthread_setname_np \
 ])
-
 dnl Sadly, there are three different versions of pthread_setname_np.
 dnl Try to cater for all of them.
-if test "$ac_cv_func_pthread_setname_np" = "yes" ; then
-    AC_MSG_CHECKING([for signature of pthread_setname_np])
-    AC_TRY_COMPILE([
-#include <pthread.h>
-#ifdef HAVE_PTHREAD_NP_H
-#include <pthread_np.h>
-#endif
-], [pthread_setname_np(pthread_self(), "test", (void *)0)], [
-        AC_MSG_RESULT([three arguments])
-        pthread_setname_np_args=3], [
-        AC_TRY_COMPILE([
-#include <pthread.h>
-#ifdef HAVE_PTHREAD_NP_H
-#include <pthread_np.h>
-#endif
-], [pthread_setname_np(pthread_self(), "test")], [
-            AC_MSG_RESULT([two arguments])
-            pthread_setname_np_args=2], [
-            AC_TRY_COMPILE([
-#include <pthread.h>
-#ifdef HAVE_PTHREAD_NP_H
-#include <pthread_np.h>
-#endif
-], [pthread_setname_np("test")], [
-                AC_MSG_RESULT([one argument])
-                pthread_setname_np_args=1], [pthread_setname_np_args=0])
-])
-])
-AC_DEFINE_UNQUOTED([PTHREAD_SETNAME_NP_ARGS], $pthread_setname_np_args, [Number of arguments required by pthread_setname_np() function])
-fi
-])
+AS_IF([test "$ac_cv_func_pthread_setname_np" = "yes"],
+  [AC_MSG_CHECKING([for signature of pthread_setname_np])
+  AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM(
+      [#include <pthread.h>
+       #ifdef HAVE_PTHREAD_NP_H
+       #include <pthread_np.h>
+       #endif],
+      [pthread_setname_np(pthread_self(), "test", (void *)0)])],
+    [AC_MSG_RESULT([three arguments])
+     pthread_setname_np_args=3],
+    [AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [#include <pthread.h>
+         #ifdef HAVE_PTHREAD_NP_H
+         #include <pthread_np.h>
+         #endif],
+        [pthread_setname_np(pthread_self(), "test")])],
+      [AC_MSG_RESULT([two arguments])
+       pthread_setname_np_args=2],
+      [AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM(
+          [#include <pthread.h>
+           #ifdef HAVE_PTHREAD_NP_H
+           #include <pthread_np.h>
+           #endif],
+          [pthread_setname_np("test")])],
+          [AC_MSG_RESULT([one argument])
+           pthread_setname_np_args=1],
+          [pthread_setname_np_args=0])])])
+  AC_DEFINE_UNQUOTED(
+    [PTHREAD_SETNAME_NP_ARGS],
+    [$pthread_setname_np_args],
+    [Number of arguments required by pthread_setname_np() function])])
+]) # OPENAFS_MORE_PTHREAD_CHECKS