pthread_sigmask: Make declaration C++ safe.
authorBruno Haible <bruno@clisp.org>
Fri, 8 Jul 2011 00:08:15 +0000 (02:08 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 8 Jul 2011 00:08:15 +0000 (02:08 +0200)
* lib/signal.in.h: In two special conditions, just do an #include_next.
(pthread_sigmask): Test HAVE_PTHREAD_SIGMASK, not REPLACE_PTHREAD_MASK.
Invoke _GL_CXXALIAS_SYS and _GL_CXXALIASWARN.
* m4/signal_h.m4 (gl_SIGNAL_H_DEFAULTS): Initialize
HAVE_PTHREAD_SIGMASK, not REPLACE_PTHREAD_MASK.
* m4/pthread_sigmask.m4 (gl_PTHREAD_SIGMASK): Set HAVE_PTHREAD_SIGMASK,
not REPLACE_PTHREAD_MASK.
* modules/signal (Makefile.am): Substitute HAVE_PTHREAD_SIGMASK,
not REPLACE_PTHREAD_MASK.
* modules/pthread_sigmask (Depends-on, configure.ac): Update condition.

ChangeLog
lib/signal.in.h
m4/pthread_sigmask.m4
m4/signal_h.m4
modules/pthread_sigmask
modules/signal

index 2f03121..b3fa05e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2011-07-07  Bruno Haible  <bruno@clisp.org>
 
+       pthread_sigmask: Make declaration C++ safe.
+       * lib/signal.in.h: In two special conditions, just do an #include_next.
+       (pthread_sigmask): Test HAVE_PTHREAD_SIGMASK, not REPLACE_PTHREAD_MASK.
+       Invoke _GL_CXXALIAS_SYS and _GL_CXXALIASWARN.
+       * m4/signal_h.m4 (gl_SIGNAL_H_DEFAULTS): Initialize
+       HAVE_PTHREAD_SIGMASK, not REPLACE_PTHREAD_MASK.
+       * m4/pthread_sigmask.m4 (gl_PTHREAD_SIGMASK): Set HAVE_PTHREAD_SIGMASK,
+       not REPLACE_PTHREAD_MASK.
+       * modules/signal (Makefile.am): Substitute HAVE_PTHREAD_SIGMASK,
+       not REPLACE_PTHREAD_MASK.
+       * modules/pthread_sigmask (Depends-on, configure.ac): Update condition.
+
+2011-07-07  Bruno Haible  <bruno@clisp.org>
+
        pthread_sigmask: Fix return value.
        * lib/signal.in.h (pthread_sigmask): Declare. Don't define as a macro.
        * lib/pthread_sigmask.c: New file.
index 5049b1d..6d1be8f 100644 (file)
 #endif
 @PRAGMA_COLUMNS@
 
-#if defined __need_sig_atomic_t || defined __need_sigset_t
-/* Special invocation convention inside glibc header files.  */
+#if defined __need_sig_atomic_t || defined __need_sigset_t || defined _GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T)
+/* Special invocation convention:
+   - Inside glibc header files.
+   - On glibc systems we have a sequence of nested includes
+     <signal.h> -> <ucontext.h> -> <signal.h>.
+     In this situation, the functions are not yet declared, therefore we cannot
+     provide the C++ aliases.
+   - On glibc systems with GCC 4.3 we have a sequence of nested includes
+     <csignal> -> </usr/include/signal.h> -> <sys/ucontext.h> -> <signal.h>.
+     In this situation, some of the functions are not yet declared, therefore
+     we cannot provide the C++ aliases.  */
 
 # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
 
@@ -30,6 +39,8 @@
 
 #ifndef _@GUARD_PREFIX@_SIGNAL_H
 
+#define _GL_ALREADY_INCLUDING_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
@@ -39,6 +50,8 @@
 /* The include_next requires a split double-inclusion guard.  */
 #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@
 
+#undef _GL_ALREADY_INCLUDING_SIGNAL_H
+
 #ifndef _@GUARD_PREFIX@_SIGNAL_H
 #define _@GUARD_PREFIX@_SIGNAL_H
 
@@ -103,10 +116,13 @@ typedef void (*sighandler_t) (int);
 
 
 #if @GNULIB_PTHREAD_SIGMASK@
-# if @REPLACE_PTHREAD_SIGMASK@
+# if !@HAVE_PTHREAD_SIGMASK@
 _GL_FUNCDECL_SYS (pthread_sigmask, int,
                   (int how, const sigset_t *new_mask, sigset_t *old_mask));
 # endif
+_GL_CXXALIAS_SYS (pthread_sigmask, int,
+                  (int how, const sigset_t *new_mask, sigset_t *old_mask));
+_GL_CXXALIASWARN (pthread_sigmask);
 #elif defined GNULIB_POSIXCHECK
 # undef pthread_sigmask
 # if HAVE_RAW_DECL_PTHREAD_SIGMASK
index d25e2cc..aa2904a 100644 (file)
@@ -1,4 +1,4 @@
-# pthread_sigmask.m4 serial 2
+# pthread_sigmask.m4 serial 3
 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,
@@ -21,6 +21,6 @@ AC_DEFUN([gl_PTHREAD_SIGMASK],
   ])
 
   if test $ac_cv_func_pthread_sigmask = no; then
-    REPLACE_PTHREAD_SIGMASK=1
+    HAVE_PTHREAD_SIGMASK=0
   fi
 ])
index 53972fb..96270a9 100644 (file)
@@ -1,4 +1,4 @@
-# signal_h.m4 serial 14
+# signal_h.m4 serial 15
 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,
@@ -64,6 +64,7 @@ AC_DEFUN([gl_SIGNAL_H_DEFAULTS],
   GNULIB_SIGACTION=0;          AC_SUBST([GNULIB_SIGACTION])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING])
+  HAVE_PTHREAD_SIGMASK=1;      AC_SUBST([HAVE_PTHREAD_SIGMASK])
   HAVE_SIGSET_T=1;             AC_SUBST([HAVE_SIGSET_T])
   HAVE_SIGINFO_T=1;            AC_SUBST([HAVE_SIGINFO_T])
   HAVE_SIGACTION=1;            AC_SUBST([HAVE_SIGACTION])
@@ -72,5 +73,4 @@ 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])
 ])
index 59cce93..f2a77a0 100644 (file)
@@ -7,11 +7,11 @@ m4/pthread_sigmask.m4
 
 Depends-on:
 signal
-sigprocmask     [test $REPLACE_PTHREAD_SIGMASK = 1]
+sigprocmask     [test $HAVE_PTHREAD_SIGMASK = 0]
 
 configure.ac:
 gl_PTHREAD_SIGMASK
-if test $REPLACE_PTHREAD_SIGMASK = 1; then
+if test $HAVE_PTHREAD_SIGMASK = 0; then
   AC_LIBOBJ([pthread_sigmask])
 fi
 gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask])
index 3b793c1..d84105b 100644 (file)
@@ -33,13 +33,13 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \
              -e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \
              -e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \
+             -e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \
              -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \
              -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \
              -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \
              -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)' \