]> Savannah Git Hosting - gnulib.git/commitdiff
threadlib: Provide an easy way to avoid mingw's winpthreads library.
authorBruno Haible <bruno@clisp.org>
Sat, 18 May 2019 16:22:45 +0000 (18:22 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 18 May 2019 16:22:45 +0000 (18:22 +0200)
* m4/threadlib.m4 (gl_AVOID_WINPTHREAD): New macro.
(gl_THREADLIB_EARLY_BODY): Recognize when it was invoked, and set
gl_use_threads accordingly.

ChangeLog
m4/threadlib.m4

index abdaa99ce123eee184e371a68305e897987d606a..3ec5ac58f1b69249b14f211d88d93fb5a6f65d20 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-05-18  Bruno Haible  <bruno@clisp.org>
+
+       threadlib: Provide an easy way to avoid mingw's winpthreads library.
+       * m4/threadlib.m4 (gl_AVOID_WINPTHREAD): New macro.
+       (gl_THREADLIB_EARLY_BODY): Recognize when it was invoked, and set
+       gl_use_threads accordingly.
+
 2019-05-18  Bruno Haible  <bruno@clisp.org>
 
        pthread_sigmask: Fix compilation error with --enable-threads=windows.
index bfc3bac853693c22836877f911a1400210d37159..b4401f8665f7f90d8f9c034a9f61fdd98cd6c03e 100644 (file)
@@ -1,4 +1,4 @@
-# threadlib.m4 serial 16
+# threadlib.m4 serial 17
 dnl Copyright (C) 2005-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -50,6 +50,7 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
   m4_ifdef([gl_THREADLIB_DEFAULT_NO],
     [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
     [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
+  m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=])
   AC_ARG_ENABLE([threads],
 AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
 AC_HELP_STRING([--disable-threads], [build without multithread safety])]),
@@ -62,16 +63,24 @@ changequote(,)dnl
          dnl Disable multithreading by default on OSF/1, because it interferes
          dnl with fork()/exec(): When msgexec is linked with -lpthread, its
          dnl child process gets an endless segmentation fault inside execvp().
+         osf*) gl_use_threads=no ;;
          dnl Disable multithreading by default on Cygwin 1.5.x, because it has
          dnl bugs that lead to endless loops or crashes. See
          dnl <https://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
-         osf*) gl_use_threads=no ;;
          cygwin*)
                case `uname -r` in
                  1.[0-5].*) gl_use_threads=no ;;
                  *)         gl_use_threads=yes ;;
                esac
                ;;
+         dnl Obey gl_AVOID_WINPTHREAD on mingw.
+         mingw*)
+               case "$gl_use_winpthreads_default" in
+                 yes) gl_use_threads=posix ;;
+                 no)  gl_use_threads=windows ;;
+                 *)   gl_use_threads=yes ;;
+               esac
+               ;;
          *)    gl_use_threads=yes ;;
        esac
 changequote([,])dnl
@@ -337,6 +346,18 @@ AC_DEFUN([gl_DISABLE_THREADS], [
 ])
 
 
+dnl gl_AVOID_WINPTHREAD
+dnl -------------------
+dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the
+dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided.
+dnl The user can still override it at installation time, by using the
+dnl configure option '--enable-threads'.
+
+AC_DEFUN([gl_AVOID_WINPTHREAD], [
+  m4_divert_text([INIT_PREPARE], [gl_use_winpthreads_default=no])
+])
+
+
 dnl Survey of platforms:
 dnl
 dnl Platform           Available  Compiler    Supports   test-lock