From fb3f754067034f95a9ed385284d4e42a1ec74449 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 8 Jul 2011 04:05:45 +0200 Subject: [PATCH] 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). --- ChangeLog | 13 +++++++++ lib/signal.in.h | 15 +++++++++-- m4/pthread_sigmask.m4 | 70 ++++++++++++++++++++++++++++++++++++++++--------- m4/signal_h.m4 | 3 ++- modules/pthread_sigmask | 6 ++--- modules/signal | 1 + 6 files changed, 90 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 581b066e8..00165e2d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2011-07-07 Bruno Haible + 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). + +2011-07-07 Bruno Haible + pthread_sigmask: Ensure declaration in . * lib/signal.in.h: On MacOS X, FreeBSD, OpenBSD, OSF/1, Solaris 2.6, include . diff --git a/lib/signal.in.h b/lib/signal.in.h index 475727944..93787f753 100644 --- a/lib/signal.in.h +++ b/lib/signal.in.h @@ -125,12 +125,23 @@ typedef void (*sighandler_t) (int); #if @GNULIB_PTHREAD_SIGMASK@ -# if !@HAVE_PTHREAD_SIGMASK@ +# 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 !@HAVE_PTHREAD_SIGMASK@ _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 diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4 index 2147c08fc..984f69d5c 100644 --- a/m4/pthread_sigmask.m4 +++ b/m4/pthread_sigmask.m4 @@ -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 @@ dnl with or without modifications, as long as this notice is preserved. 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 + #include + ]], + [[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". ]) diff --git a/m4/signal_h.m4 b/m4/signal_h.m4 index 96270a911..b9536fb0e 100644 --- a/m4/signal_h.m4 +++ b/m4/signal_h.m4 @@ -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 @@ AC_DEFUN([gl_SIGNAL_H_DEFAULTS], 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]) ]) diff --git a/modules/pthread_sigmask b/modules/pthread_sigmask index 8f1a0a0c3..087c1589b 100644 --- a/modules/pthread_sigmask +++ b/modules/pthread_sigmask @@ -7,11 +7,11 @@ m4/pthread_sigmask.m4 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 @@ Include: Link: -$(LIBMULTITHREAD) +$(LIB_PTHREAD_SIGMASK) License: LGPLv2+ diff --git a/modules/signal b/modules/signal index d84105bff..785da7892 100644 --- a/modules/signal +++ b/modules/signal @@ -40,6 +40,7 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -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)' \ -- 2.11.0