]> granicus.if.org Git - gc/commitdiff
Avoid duplication of code handling pthreads case in configure
authorIvan Maidanski <ivmai@mail.ru>
Tue, 6 Mar 2018 08:34:17 +0000 (11:34 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 6 Mar 2018 21:32:30 +0000 (00:32 +0300)
(code refactoring)

* configure.ac [$THREADS=pthreads] (default_threadlibs): New variable.
* configure.ac [$THREADS=pthreads && ($host in *-*-aix* | *-*-cygwin*
| *-*-darwin* | *-*-dragonfly* | *-*-freebsd* | *-*-haiku*
| *-*-hpux11* | *-*-irix* | *-*-kfreebsd*-gnu | *-*-gnu* | *-*-*linux*
| *-*-nacl* | *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris*)]
(default_threadlibs): Set to true.
* configure.ac [$THREADS=pthreads && !($host in
*-*-hpux11* | *-*-openbsd* | *-*-freebsd* | *-*-gnu* | *-*-netbsd*
| *-*-solaris* | *-*-cygwin* | *-*-mingw* | *-*-darwin* | *-*-osf*)]:
Do AC_MSG_ERROR() only if default_threadlibs is false.

configure.ac

index f08ef5aa576c5d8ca5684d615db99692fe894e08..354ce1b6b3a5e1f24c38006ada12068fd42b0af5 100644 (file)
@@ -182,6 +182,7 @@ case "$THREADS" in
     ;;
  posix | pthreads)
     THREADS=posix
+    default_threadlibs=false
     # Common defines for most POSIX platforms.
     case "$host" in
       *-*-aix* | *-*-cygwin* | *-*-darwin* | *-*-dragonfly* | \
@@ -197,15 +198,12 @@ case "$THREADS" in
         if test "${enable_thread_local_alloc}" != no; then
           AC_DEFINE(THREAD_LOCAL_ALLOC)
         fi
+        default_threadlibs=true
         AC_MSG_WARN("Explicit GC_INIT() calls may be required.")
         ;;
     esac
     AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
     case "$host" in
-      *-*-aix* | *-*-dragonfly* | *-*-haiku* | *-*-irix* | *-*-*linux* | \
-      *-*-nacl*)
-        # The default THREADDLLIBS.
-        ;;
       *-*-hpux11*)
         AC_MSG_WARN("Only HP/UX 11 POSIX threads are supported.")
         AC_DEFINE(_POSIX_C_SOURCE,199506L)
@@ -224,7 +222,7 @@ case "$THREADS" in
         AC_DEFINE(USE_COMPILER_TLS)
         THREADDLLIBS=-pthread
         ;;
-      *-*-gnu*) # Excluding kfreebsd.
+      *-*-gnu*) # E.g. linux but excluding kfreebsd.
         # The default THREADDLLIBS.
         ;;
       *-*-netbsd*)
@@ -261,7 +259,10 @@ case "$THREADS" in
         THREADDLLIBS="-lpthread -lrt"
         ;;
       *)
-        AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
+        AS_IF([test x$default_threadlibs != xtrue],
+              [ AC_MSG_ERROR(
+                    [Pthreads not supported by the GC on this platform]) ])
+        # The default THREADDLLIBS.
         ;;
     esac
     case "$host" in