From cf74a3953bedd79cd53057aa00f1c90019c10102 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 5 Jul 2011 23:44:24 -0700 Subject: [PATCH] pthread_sigmask: new module * MODULES.html.sh (Support for systems lacking POSIX:2008): Add it. * doc/posix-functions/pthread_sigmask.texi: Document new module. * lib/signal.in.h (pthread_sigmask): Arrange for replacement. This is done only as a macro; I don't know how well that'll work for C++. Move include before the include_next, to avoid mishap on Solaris. * m4/signal_h.m4 (gl_SIGNAL_H, gl_SIGNAL_H_DEFAULTS): Check for it. * modules/signal (Makefile.am): Substitute the check's results. * modules/pthread_sigmask, m4/pthread_sigmask.m4: New files. --- ChangeLog | 11 +++++++++++ MODULES.html.sh | 1 + doc/posix-functions/pthread_sigmask.texi | 7 +++++-- lib/signal.in.h | 24 ++++++++++++++++++++---- m4/pthread_sigmask.m4 | 24 ++++++++++++++++++++++++ m4/signal_h.m4 | 7 +++++-- modules/pthread_sigmask | 27 +++++++++++++++++++++++++++ modules/signal | 2 ++ 8 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 m4/pthread_sigmask.m4 create mode 100644 modules/pthread_sigmask diff --git a/ChangeLog b/ChangeLog index 70b1c5157..9cfa56b95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-07-05 Paul Eggert + pthread_sigmask: new module + * MODULES.html.sh (Support for systems lacking POSIX:2008): Add it. + * doc/posix-functions/pthread_sigmask.texi: Document new module. + * lib/signal.in.h (pthread_sigmask): Arrange for replacement. + This is done only as a macro; I don't know how well that'll + work for C++. Move include before the include_next, + to avoid mishap on Solaris. + * m4/signal_h.m4 (gl_SIGNAL_H, gl_SIGNAL_H_DEFAULTS): Check for it. + * modules/signal (Makefile.am): Substitute the check's results. + * modules/pthread_sigmask, m4/pthread_sigmask.m4: New files. + test-pselect: new module * modules/pselect-tests, tests/test-pselect.c: New files. * tests/test-select.c, tests/test-sys_select-c++.cc: diff --git a/MODULES.html.sh b/MODULES.html.sh index 26c3fa97c..c47ef52ce 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -2451,6 +2451,7 @@ func_all_modules () func_module times func_module timespec func_module nanosleep + func_module pthread_sigmask func_module regex func_module rename func_module renameat diff --git a/doc/posix-functions/pthread_sigmask.texi b/doc/posix-functions/pthread_sigmask.texi index c9cb8414a..6e6bf1955 100644 --- a/doc/posix-functions/pthread_sigmask.texi +++ b/doc/posix-functions/pthread_sigmask.texi @@ -8,11 +8,14 @@ Gnulib module: --- Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Solaris 2.4, mingw, BeOS. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -Solaris 2.4, mingw, BeOS. +On platforms that do not natively support this function, +it has unspecified behavior in a multi-threaded process. @end itemize diff --git a/lib/signal.in.h b/lib/signal.in.h index bcf793523..01987a7af 100644 --- a/lib/signal.in.h +++ b/lib/signal.in.h @@ -30,6 +30,12 @@ #ifndef _@GUARD_PREFIX@_SIGNAL_H +/* Define pid_t, uid_t. + Also, mingw defines sigset_t not in , but in . + On Solaris 10, includes , which eventually includes + us; so include now, before the second inclusion guard. */ +#include + /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@ @@ -42,10 +48,6 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ -/* Define pid_t, uid_t. - Also, mingw defines sigset_t not in , but in . */ -#include - /* On AIX, sig_atomic_t already includes volatile. C99 requires that 'volatile sig_atomic_t' ignore the extra modifier, but C89 did not. Hence, redefine this to a non-volatile type as needed. */ @@ -100,6 +102,20 @@ typedef void (*sighandler_t) (int); #endif +#if @GNULIB_PTHREAD_SIGMASK@ +# if @REPLACE_PTHREAD_SIGMASK@ +# undef pthread_sigmask +# define pthread_sigmask sigprocmask +# endif +#elif defined GNULIB_POSIXCHECK +# undef pthread_sigmask +# if HAVE_RAW_DECL_PTHREAD_SIGMASK +_GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - " + "use gnulib module pthread_sigmask for portability"); +# endif +#endif + + #if @GNULIB_SIGPROCMASK@ # if !@HAVE_POSIX_SIGNALBLOCKING@ diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4 new file mode 100644 index 000000000..22485bd35 --- /dev/null +++ b/m4/pthread_sigmask.m4 @@ -0,0 +1,24 @@ +# pthread_sigmask.m4 serial 1 +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, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_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" + fi + ], [ + AC_CHECK_FUNCS_ONCE([pthread_sigmask]) + ]) + + if test $ac_cv_func_pthread_sigmask = no; then + REPLACE_PTHREAD_SIGMASK=0 + fi +]) diff --git a/m4/signal_h.m4 b/m4/signal_h.m4 index 459ec007f..532ef14c8 100644 --- a/m4/signal_h.m4 +++ b/m4/signal_h.m4 @@ -1,4 +1,4 @@ -# signal_h.m4 serial 12 +# signal_h.m4 serial 13 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, @@ -27,7 +27,8 @@ AC_DEFUN([gl_SIGNAL_H], dnl Check for declarations of anything we want to poison if the dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[#include - ]], [sigaction sigaddset sigdelset sigemptyset sigfillset sigismember + ]], [pthread_sigmask sigaction + sigaddset sigdelset sigemptyset sigfillset sigismember sigpending sigprocmask]) ]) @@ -42,6 +43,7 @@ AC_DEFUN([gl_SIGNAL_MODULE_INDICATOR], AC_DEFUN([gl_SIGNAL_H_DEFAULTS], [ + GNULIB_PTHREAD_SIGMASK=0; AC_SUBST([GNULIB_PTHREAD_SIGMASK]) GNULIB_SIGNAL_H_SIGPIPE=0; AC_SUBST([GNULIB_SIGNAL_H_SIGPIPE]) GNULIB_SIGPROCMASK=0; AC_SUBST([GNULIB_SIGPROCMASK]) GNULIB_SIGACTION=0; AC_SUBST([GNULIB_SIGACTION]) @@ -55,4 +57,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 new file mode 100644 index 000000000..f1126b6e7 --- /dev/null +++ b/modules/pthread_sigmask @@ -0,0 +1,27 @@ +Description: +POSIX compatible signal blocking for threads. + +Files: +m4/pthread_sigmask.m4 + +Depends-on: +signal +sigprocmask [test $REPLACE_PTHREAD_SIGMASK = 1] + +configure.ac: +gl_PTHREAD_SIGMASK +gl_SYS_SELECT_MODULE_INDICATOR([pthread_sigmask]) + +Makefile.am: + +Include: + + +Link: +$(LIBMULTITHREAD) + +License: +LGPLv2+ + +Maintainer: +Paul Eggert, Bruno Haible, Jim Meyering diff --git a/modules/signal b/modules/signal index 4e9d5f2ed..3b793c175 100644 --- a/modules/signal +++ b/modules/signal @@ -28,6 +28,7 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \ + -e 's|@''GNULIB_PTHREAD_SIGMASK''@|$(GNULIB_PTHREAD_SIGMASK)|g' \ -e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GNULIB_SIGNAL_H_SIGPIPE)/g' \ -e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \ -e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \ @@ -38,6 +39,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