[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/10] pthread_sigmask: new module
From: |
Paul Eggert |
Subject: |
[PATCH 03/10] pthread_sigmask: new module |
Date: |
Wed, 06 Jul 2011 00:55:18 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10 |
* 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 <sys/types.h> 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 70b1c51..9cfa56b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2011-07-05 Paul Eggert <address@hidden>
+ 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 <sys/types.h> 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 26c3fa9..c47ef52 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 c9cb841..6e6bf19 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
address@hidden
+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 bcf7935..01987a7 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -30,6 +30,12 @@
#ifndef address@hidden@_SIGNAL_H
+/* Define pid_t, uid_t.
+ Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.
+ On Solaris 10, <signal.h> includes <sys/types.h>, which eventually includes
+ us; so include <sys/types.h> now, before the second inclusion guard. */
+#include <sys/types.h>
+
/* The include_next requires a split double-inclusion guard. */
address@hidden@ @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 <signal.h>, but in <sys/types.h>. */
-#include <sys/types.h>
-
/* 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 address@hidden@
diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4
new file mode 100644
index 0000000..22485bd
--- /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 459ec00..532ef14 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 <signal.h>
- ]], [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 0000000..f1126b6
--- /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:
+<signal.h>
+
+Link:
+$(LIBMULTITHREAD)
+
+License:
+LGPLv2+
+
+Maintainer:
+Paul Eggert, Bruno Haible, Jim Meyering
diff --git a/modules/signal b/modules/signal
index 4e9d5f2..3b793c1 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)' \
--
1.7.4.4
- [PATCH 03/10] pthread_sigmask: new module,
Paul Eggert <=
- [PATCH] pthread_sigmask: always replace when not using pthread, Eric Blake, 2011/07/06
- unit tests for sigprocmask, 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, Paul Eggert, 2011/07/08
- Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/08
- Re: [PATCH 03/10] pthread_sigmask: new module, Paul Eggert, 2011/07/08
- Re: threadlib and emacs, Bruno Haible, 2011/07/08
- Re: threadlib and emacs, Paul Eggert, 2011/07/09
- Re: threadlib and emacs, Bruno Haible, 2011/07/09
- Re: threadlib and emacs, Paul Eggert, 2011/07/09