Mercurial > hg > octave-lojdl > gnulib-hg
changeset 15370:54bbcd9bb255
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).
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 08 Jul 2011 04:05:45 +0200 |
parents | ff0056fd6295 |
children | 90ac6874ff8e |
files | ChangeLog lib/signal.in.h m4/pthread_sigmask.m4 m4/signal_h.m4 modules/pthread_sigmask modules/signal |
diffstat | 6 files changed, 90 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-07-07 Bruno Haible <bruno@clisp.org> + + 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 <bruno@clisp.org> pthread_sigmask: Ensure declaration in <signal.h>.
--- a/lib/signal.in.h +++ b/lib/signal.in.h @@ -125,12 +125,23 @@ #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
--- 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 @@ 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 - ], [ - AC_CHECK_FUNCS_ONCE([pthread_sigmask]) + ] ,[ + 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 ]) - - 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". ])
--- 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 @@ 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]) ])
--- a/modules/pthread_sigmask +++ b/modules/pthread_sigmask @@ -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+
--- a/modules/signal +++ b/modules/signal @@ -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)' \