From 035159ed54cf2e1abc0439fbb6e628c9223f8e5d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 29 May 2014 08:05:06 -0700 Subject: [PATCH] Don't substitute sigprocmask for pthread_sigmask. sigprocmask isn't portable in a multithreaded process. * configure.ac (gl_THREADLIB): Remove dummy. Merge from gnulib, incorporating: 2014-05-28 pthread_sigmask, timer-time: use gl_THREADLIB only if needed * m4/pthread_sigmask.m4, m4/timer_time.m4: Update from gnulib. * src/Makefile.in (LIB_PTHREAD_SIGMASK): Remove; all uses removed. Fixes: debbugs:17561 --- ChangeLog | 9 +++++ configure.ac | 2 - m4/pthread_sigmask.m4 | 85 +++++++++++++++++++++++-------------------- m4/timer_time.m4 | 39 +++++++++++--------- src/ChangeLog | 5 +++ src/Makefile.in | 6 +-- 6 files changed, 83 insertions(+), 63 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26f841e8eb0..921d211ac4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-05-29 Paul Eggert + + Don't substitute sigprocmask for pthread_sigmask (Bug#17561). + sigprocmask isn't portable in a multithreaded process. + * configure.ac (gl_THREADLIB): Remove dummy. + Merge from gnulib, incorporating: + 2014-05-28 pthread_sigmask, timer-time: use gl_THREADLIB only if needed + * m4/pthread_sigmask.m4, m4/timer_time.m4: Update from gnulib. + 2014-05-29 Glenn Morris * configure.ac: Explicitly drop some ancient Solaris versions. diff --git a/configure.ac b/configure.ac index e70c0fc6312..00bba75a76c 100644 --- a/configure.ac +++ b/configure.ac @@ -704,8 +704,6 @@ AC_DEFUN([gl_CRYPTO_CHECK]) # Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW, # as we don't use them. AC_DEFUN([gl_FCNTL_O_FLAGS]) -# Avoid gnulib's threadlib module, as we do threads our own way. -AC_DEFUN([gl_THREADLIB]) # Initialize gnulib right after choosing the compiler. dnl Amongst other things, this sets AR and ARFLAGS. diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4 index 4ba073231f9..2b3347f992d 100644 --- a/m4/pthread_sigmask.m4 +++ b/m4/pthread_sigmask.m4 @@ -1,4 +1,4 @@ -# pthread_sigmask.m4 serial 13 +# pthread_sigmask.m4 serial 14 dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -97,39 +97,43 @@ AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK], dnl with -lpthread, the pthread_sigmask() function always returns 0 and has dnl no effect. if test -z "$LIB_PTHREAD_SIGMASK"; then - AC_CACHE_CHECK([whether pthread_sigmask works without -lpthread], - [gl_cv_func_pthread_sigmask_in_libc_works], - [ - AC_RUN_IFELSE( - [AC_LANG_SOURCE([[ -#include -#include -#include -int main () -{ - sigset_t set; - sigemptyset (&set); - return pthread_sigmask (1729, &set, NULL) != 0; -}]])], - [gl_cv_func_pthread_sigmask_in_libc_works=no], - [gl_cv_func_pthread_sigmask_in_libc_works=yes], - [ -changequote(,)dnl - case "$host_os" in - freebsd* | hpux* | solaris | solaris2.[2-9]*) - gl_cv_func_pthread_sigmask_in_libc_works="guessing no";; - *) - gl_cv_func_pthread_sigmask_in_libc_works="guessing yes";; - esac -changequote([,])dnl - ]) - ]) - case "$gl_cv_func_pthread_sigmask_in_libc_works" in - *no) - REPLACE_PTHREAD_SIGMASK=1 - AC_DEFINE([PTHREAD_SIGMASK_INEFFECTIVE], [1], - [Define to 1 if pthread_sigmask() may returns 0 and have no effect.]) - ;; + case " $LIBS " in + *' -lpthread '*) ;; + *) + AC_CACHE_CHECK([whether pthread_sigmask works without -lpthread], + [gl_cv_func_pthread_sigmask_in_libc_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ + #include + #include + #include + int main () + { + sigset_t set; + sigemptyset (&set); + return pthread_sigmask (1729, &set, NULL) != 0; + }]])], + [gl_cv_func_pthread_sigmask_in_libc_works=no], + [gl_cv_func_pthread_sigmask_in_libc_works=yes], + [ + changequote(,)dnl + case "$host_os" in + freebsd* | hpux* | solaris | solaris2.[2-9]*) + gl_cv_func_pthread_sigmask_in_libc_works="guessing no";; + *) + gl_cv_func_pthread_sigmask_in_libc_works="guessing yes";; + esac + changequote([,])dnl + ]) + ]) + case "$gl_cv_func_pthread_sigmask_in_libc_works" in + *no) + REPLACE_PTHREAD_SIGMASK=1 + AC_DEFINE([PTHREAD_SIGMASK_INEFFECTIVE], [1], + [Define to 1 if pthread_sigmask may return 0 and have no effect.]) + ;; + esac;; esac fi @@ -184,11 +188,12 @@ int main () *) gl_cv_func_pthread_sigmask_unblock_works="guessing yes";; esac - dnl Here we link against $LIBMULTITHREAD, not only $LIB_PTHREAD_SIGMASK, - dnl otherwise we get a false positive on those platforms where - dnl $gl_cv_func_pthread_sigmask_in_libc_works is "no". - gl_save_LIBS="$LIBS" - LIBS="$LIBS $LIBMULTITHREAD" + m4_ifdef([gl_][THREADLIB], + [dnl Link against $LIBMULTITHREAD, not only $LIB_PTHREAD_SIGMASK. + dnl Otherwise we get a false positive on those platforms where + dnl $gl_cv_func_pthread_sigmask_in_libc_works is "no". + gl_save_LIBS=$LIBS + LIBS="$LIBS $LIBMULTITHREAD"]) AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include @@ -227,7 +232,7 @@ int main () [:], [gl_cv_func_pthread_sigmask_unblock_works=no], [:]) - LIBS="$gl_save_LIBS" + m4_ifdef([gl_][THREADLIB], [LIBS=$gl_save_LIBS]) ]) case "$gl_cv_func_pthread_sigmask_unblock_works" in *no) diff --git a/m4/timer_time.m4 b/m4/timer_time.m4 index 8e2c921cbef..578ebe0809a 100644 --- a/m4/timer_time.m4 +++ b/m4/timer_time.m4 @@ -1,4 +1,4 @@ -# timer_time.m4 serial 2 +# timer_time.m4 serial 3 dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,7 +11,12 @@ AC_DEFUN([gl_TIMER_TIME], dnl Based on clock_time.m4. See details there. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_THREADLIB]) + + dnl Test whether the gnulib module 'threadlib' is in use. + dnl Some packages like Emacs use --avoid=threadlib. + dnl Write the symbol in such a way that it does not cause 'aclocal' to pick + dnl the threadlib.m4 file that is installed in $PREFIX/share/aclocal/. + m4_ifdef([gl_][THREADLIB], [AC_REQUIRE([gl_][THREADLIB])]) LIB_TIMER_TIME= AC_SUBST([LIB_TIMER_TIME]) @@ -19,21 +24,21 @@ AC_DEFUN([gl_TIMER_TIME], AC_SEARCH_LIBS([timer_settime], [rt posix4], [test "$ac_cv_search_timer_settime" = "none required" || LIB_TIMER_TIME=$ac_cv_search_timer_settime]) - dnl GLIBC uses threads to emulate posix timers when kernel support - dnl is not available (like Linux < 2.6 or when used with kFreeBSD) - dnl Now the pthread lib is linked automatically in the normal case, - dnl but when linking statically, it needs to be explicitly specified. - AC_EGREP_CPP([Thread], - [ -#include -#ifdef __GNU_LIBRARY__ - #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)) \ - && !(__UCLIBC__ && __HAS_NO_THREADS__) - Thread emulation available - #endif -#endif - ], - [LIB_TIMER_TIME="$LIB_TIMER_TIME $LIBMULTITHREAD"]) + m4_ifdef([gl_][THREADLIB], + [dnl GLIBC uses threads to emulate posix timers when kernel support + dnl is not available (like Linux < 2.6 or when used with kFreeBSD) + dnl Now the pthread lib is linked automatically in the normal case, + dnl but when linking statically, it needs to be explicitly specified. + AC_EGREP_CPP([Thread], + [#include + #ifdef __GNU_LIBRARY__ + #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)) \ + && !(__UCLIBC__ && __HAS_NO_THREADS__) + Thread emulation available + #endif + #endif + ], + [LIB_TIMER_TIME="$LIB_TIMER_TIME $LIBMULTITHREAD"])]) AC_CHECK_FUNCS([timer_settime]) LIBS=$gl_saved_libs ]) diff --git a/src/ChangeLog b/src/ChangeLog index 33b8257cc1c..5189712d490 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-05-29 Paul Eggert + + Don't substitute sigprocmask for pthread_sigmask (Bug#17561). + * Makefile.in (LIB_PTHREAD_SIGMASK): Remove; all uses removed. + 2014-05-29 Eli Zaretskii * buffer.c (init_buffer): Accept an argument 'initialized'. diff --git a/src/Makefile.in b/src/Makefile.in index 0f4130b4dac..d90e9e0eef3 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -125,7 +125,7 @@ LIBS_SYSTEM=@LIBS_SYSTEM@ ## -lm, or empty. LIB_MATH=@LIB_MATH@ -## -lpthreads, or empty. +## -lpthread, or empty. LIB_PTHREAD=@LIB_PTHREAD@ LIBIMAGE=@LIBTIFF@ @LIBJPEG@ @LIBPNG@ @LIBGIF@ @LIBXPM@ @@ -293,8 +293,6 @@ LIBSELINUX_LIBS = @LIBSELINUX_LIBS@ LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ -LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ - INTERVALS_H = dispextern.h intervals.h composite.h GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ @@ -413,7 +411,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ - $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \ + $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) \ $(GFILENOTIFY_LIBS) $(LIB_MATH) $(LIBZ) all: emacs$(EXEEXT) $(OTHER_FILES) -- 2.39.5