[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/10] pthread_sigmask: new module
From: |
Bruno Haible |
Subject: |
Re: [PATCH 03/10] pthread_sigmask: new module |
Date: |
Fri, 8 Jul 2011 04:07:12 +0200 |
User-agent: |
KMail/1.9.9 |
Paul Eggert wrote:
> + m4_ifdef([gl_THREADLIB], [
> + AC_REQUIRE([gl_THREADLIB])
> + if test "$gl_threads_api" = posix; then
> + gl_save_LIBS="$LIBS"
> + LIBS="$LIBS $LIBMULTITHREAD"
> + AC_CHECK_FUNCS([pthread_sigmask])
> + LIBS="$gl_save_LIBS"
> + fi
> + ], [
> + AC_CHECK_FUNCS_ONCE([pthread_sigmask])
> + ])
It is a bit dangerous to use the variable ac_cv_func_pthread_sigmask for
two different purposes: once for the availability of pthread_sigmask()
in libc, and once for its presence in -lpthread.
> +Link:
> +$(LIBMULTITHREAD)
This does not work when "$gl_threads_api" != posix.
1) On OSF/1 5.1, we turn off multithreading by default, see m4/threadlib.m4:
case "$host_os" in
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().
As a consequence, LIBMULTITHREAD becomes empty. Hence a link error occurs
in unit tests:
cc -O -o test-pthread_sigmask1 test-pthread_sigmask1.o libtests.a
../gllib/libgnu.a libtests.a
ld:
Unresolved:
pthread_sigmask
*** Exit 1
2) Similarly, when the user explicitly configures with --disable-threads.
3) Similarly, when the user explicitly configures with --enable-threads=pth.
Then it would be wrong to use pthread_sigmask from libc; instead we need
to use pth_sigmask or, equivalently, sigprocmask. And in this case
LIBMULTITHREAD contains "-lpth", whereas for linking lib/pthread_sigmask.o
no external library is necessary.
This fixes it:
2011-07-07 Bruno Haible <address@hidden>
pthread_sigmask: Fix link requirements on OSF/1 5.1 and with pth.
* lib/signal.in.h (pthread_sigmask): Override if
REPLACE_PTHREAD_SIGMASK is 1.
* m4/signal_h.m4 (gl_SIGNAL_H_DEFAULTS): Initialize
REPLACE_PTHREAD_SIGMASK.
* m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): Set also
REPLACE_PTHREAD_SIGMASK. Set and substitute LIB_PTHREAD_SIGMASK.
* modules/signal (Makefile.am): Substitute REPLACE_PTHREAD_SIGMASK.
* modules/pthread_sigmask (Depends-on, configure.ac): Update condition.
(Link): Set to $(LIB_PTHREAD_SIGMASK), not $(LIBMULTITHREAD).
--- lib/signal.in.h.orig Fri Jul 8 03:53:40 2011
+++ lib/signal.in.h Fri Jul 8 03:39:24 2011
@@ -125,12 +125,23 @@
#if @GNULIB_PTHREAD_SIGMASK@
-# if address@hidden@
+# if @REPLACE_PTHREAD_SIGMASK@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef pthread_sigmask
+# define pthread_sigmask rpl_pthread_sigmask
+# endif
+_GL_FUNCDECL_RPL (pthread_sigmask, int,
+ (int how, const sigset_t *new_mask, sigset_t *old_mask));
+_GL_CXXALIAS_RPL (pthread_sigmask, int,
+ (int how, const sigset_t *new_mask, sigset_t *old_mask));
+# else
+# if address@hidden@
_GL_FUNCDECL_SYS (pthread_sigmask, int,
(int how, const sigset_t *new_mask, sigset_t *old_mask));
-# endif
+# endif
_GL_CXXALIAS_SYS (pthread_sigmask, int,
(int how, const sigset_t *new_mask, sigset_t *old_mask));
+# endif
_GL_CXXALIASWARN (pthread_sigmask);
#elif defined GNULIB_POSIXCHECK
# undef pthread_sigmask
--- m4/pthread_sigmask.m4.orig Fri Jul 8 03:53:40 2011
+++ m4/pthread_sigmask.m4 Fri Jul 8 03:53:31 2011
@@ -1,4 +1,4 @@
-# pthread_sigmask.m4 serial 4
+# pthread_sigmask.m4 serial 5
dnl Copyright (C) 2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -6,21 +6,67 @@
AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK],
[
+ AC_CHECK_FUNCS_ONCE([pthread_sigmask])
+ LIB_PTHREAD_SIGMASK=
m4_ifdef([gl_THREADLIB], [
AC_REQUIRE([gl_THREADLIB])
if test "$gl_threads_api" = posix; then
- gl_save_LIBS="$LIBS"
- LIBS="$LIBS $LIBMULTITHREAD"
- AC_CHECK_FUNCS([pthread_sigmask])
- LIBS="$gl_save_LIBS"
+ if test $ac_cv_func_pthread_sigmask = yes; then
+ dnl pthread_sigmask is available without -lpthread.
+ :
+ else
+ if test -n "$LIBMULTITHREAD"; then
+ AC_CACHE_CHECK([for pthread_sigmask in $LIBMULTITHREAD],
+ [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD],
+ [gl_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBMULTITHREAD"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <pthread.h>
+ #include <signal.h>
+ ]],
+ [[return pthread_sigmask (0, (sigset_t *) 0, (sigset_t *)
0);]])
+ ],
+ [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=yes],
+ [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=no])
+ LIBS="$gl_save_LIBS"
+ ])
+ if test $gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD = yes; then
+ dnl pthread_sigmask is available with -lpthread.
+ LIB_PTHREAD_SIGMASK="$LIBMULTITHREAD"
+ else
+ dnl pthread_sigmask is not available at all.
+ HAVE_PTHREAD_SIGMASK=0
+ fi
+ else
+ dnl pthread_sigmask is not available at all.
+ HAVE_PTHREAD_SIGMASK=0
+ fi
+ fi
else
- ac_cv_func_pthread_sigmask=no
+ dnl pthread_sigmask may exist but does not interoperate with the chosen
+ dnl multithreading facility.
+ dnl If "$gl_threads_api" = pth, we could use the function pth_sigmask,
+ dnl but it is equivalent to sigprocmask, so we choose to emulate
+ dnl pthread_sigmask with sigprocmask also in this case. This yields fewer
+ dnl link dependencies.
+ if test $ac_cv_func_pthread_sigmask = yes; then
+ REPLACE_PTHREAD_SIGMASK=1
+ else
+ HAVE_PTHREAD_SIGMASK=0
+ fi
+ fi
+ ] ,[
+ dnl If module 'threadlib' is not in use, assume all programs will be
+ dnl single-threaded.
+ if test $ac_cv_func_pthread_sigmask = yes; then
+ REPLACE_PTHREAD_SIGMASK=1
+ else
+ HAVE_PTHREAD_SIGMASK=0
fi
- ], [
- AC_CHECK_FUNCS_ONCE([pthread_sigmask])
])
-
- if test $ac_cv_func_pthread_sigmask = no; then
- HAVE_PTHREAD_SIGMASK=0
- fi
+ AC_SUBST([LIB_PTHREAD_SIGMASK])
+ dnl We don't need a variable LTLIB_PTHREAD_SIGMASK, because when
+ dnl "$gl_threads_api" = posix, $LTLIBMULTITHREAD and $LIBMULTITHREAD are the
+ dnl same: either both empty or both "-lpthread".
])
--- m4/signal_h.m4.orig Fri Jul 8 03:53:40 2011
+++ m4/signal_h.m4 Fri Jul 8 03:39:24 2011
@@ -1,4 +1,4 @@
-# signal_h.m4 serial 15
+# signal_h.m4 serial 16
dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -73,4 +73,5 @@
HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1;
AC_SUBST([HAVE_TYPE_VOLATILE_SIG_ATOMIC_T])
HAVE_SIGHANDLER_T=1; AC_SUBST([HAVE_SIGHANDLER_T])
+ REPLACE_PTHREAD_SIGMASK=0; AC_SUBST([REPLACE_PTHREAD_SIGMASK])
])
--- modules/pthread_sigmask.orig Fri Jul 8 03:53:40 2011
+++ modules/pthread_sigmask Fri Jul 8 03:46:57 2011
@@ -7,11 +7,11 @@
Depends-on:
signal
-sigprocmask [test $HAVE_PTHREAD_SIGMASK = 0]
+sigprocmask [test $HAVE_PTHREAD_SIGMASK = 0 || test
$REPLACE_PTHREAD_SIGMASK = 1]
configure.ac:
gl_FUNC_PTHREAD_SIGMASK
-if test $HAVE_PTHREAD_SIGMASK = 0; then
+if test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1; then
AC_LIBOBJ([pthread_sigmask])
fi
gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask])
@@ -22,7 +22,7 @@
<signal.h>
Link:
-$(LIBMULTITHREAD)
+$(LIB_PTHREAD_SIGMASK)
License:
LGPLv2+
--- modules/signal.orig Fri Jul 8 03:53:40 2011
+++ modules/signal Fri Jul 8 03:39:24 2011
@@ -40,6 +40,7 @@
-e
's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g'
\
-e
's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \
-e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \
+ -e 's|@''REPLACE_PTHREAD_SIGMASK''@|$(REPLACE_PTHREAD_SIGMASK)|g'
\
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
--
In memoriam Georges Mandel <http://en.wikipedia.org/wiki/Georges_Mandel>
- git, merging patches, (continued)
- git, merging patches, Bruno Haible, 2011/07/18
- Re: git, merging patches, Paul Eggert, 2011/07/19
- Re: git, merging patches, Paul Eggert, 2011/07/19
- Re: git, merging patches, Bruno Haible, 2011/07/19
- Re: threadlib and emacs, Bruno Haible, 2011/07/18
- Re: trouble with aclocal, Bruno Haible, 2011/07/18
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/07
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/07
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/07
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/07
Re: [PATCH 03/10] pthread_sigmask: new module,
Bruno Haible <=
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/07
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/08
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/08
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/08
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/08