From 7ded27a6c89101fce7f00203b3439f8d40f281b4 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 18 May 2019 18:22:45 +0200 Subject: 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. --- ChangeLog | 7 +++++++ m4/threadlib.m4 | 25 +++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index abdaa99ce1..3ec5ac58f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-05-18 Bruno Haible + + 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 pthread_sigmask: Fix compilation error with --enable-threads=windows. diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 index bfc3bac853..b4401f8665 100644 --- a/m4/threadlib.m4 +++ b/m4/threadlib.m4 @@ -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 . - 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 -- cgit v1.2.1