[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/10] pthread_sigmask: new module
From: |
Bruno Haible |
Subject: |
Re: [PATCH 03/10] pthread_sigmask: new module |
Date: |
Fri, 8 Jul 2011 02:09:05 +0200 |
User-agent: |
KMail/1.9.9 |
Paul Eggert wrote:
> +#if @GNULIB_PTHREAD_SIGMASK@
> +# if @REPLACE_PTHREAD_SIGMASK@
> +# undef pthread_sigmask
> +# define pthread_sigmask sigprocmask
> +# endif
> +#elif defined GNULIB_POSIXCHECK
When I add a signature check to the unit test
*** tests/test-signal-c++.cc.orig Thu Jul 7 21:33:01 2011
--- tests/test-signal-c++.cc Thu Jul 7 17:34:43 2011
***************
*** 24,29 ****
--- 24,34 ----
#include "signature.h"
+ #if GNULIB_TEST_PTHREAD_SIGMASK
+ SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_sigmask, int,
+ (int, const sigset_t *, sigset_t *));
+ #endif
+
#if GNULIB_TEST_SIGPROCMASK
SIGNATURE_CHECK (GNULIB_NAMESPACE::sigismember, int, (const sigset_t *, int));
SIGNATURE_CHECK (GNULIB_NAMESPACE::sigemptyset, int, (sigset_t *));
I get a compilation error like this, already on a glibc system:
test-signal-c++.cc:28:1: error: 'pthread_sigmask' is not a member of 'gnulib'
test-signal-c++.cc:28:1: note: suggested alternative:
/usr/include/bits/sigthread.h:31:12: note: 'pthread_sigmask'
and with GCC 4.3 a different one:
In file included from /usr/include/sys/ucontext.h:23:0,
from /usr/include/signal.h:353,
from ../gllib/signal.h:41,
from test-signal-c++.cc:22:
../gllib/signal.h:422:1: error: '::pthread_sigmask' has not been declared
../gllib/signal.h:422:1: note: suggested alternative:
../gllib/signal.h:422:1: note: 'gnulib::pthread_sigmask'
../gllib/signal.h:424:1: error: 'pthread_sigmask' was not declared in this scope
../gllib/signal.h:424:1: note: suggested alternative:
../gllib/signal.h:422:1: note: 'gnulib::pthread_sigmask'
../gllib/signal.h:424:35: error: invalid type in declaration before ';' token
In file included from /usr/include/signal.h:389:0,
from ../gllib/signal.h:41,
from test-signal-c++.cc:22:
/usr/include/bits/sigthread.h:33:41: error: 'int pthread_sigmask(int, const
__sigset_t*, __sigset_t*)' redeclared as different kind of symbol
../gllib/signal.h:424:1: error: previous declaration of 'int pthread_sigmask'
The reason is that the code does not use one of the known idioms for C++ safe
declaration of replacement functions. These idioms are listed in
build-aux/c++defs.h. The first idiom (for a function without known bugs, but
missing on some platforms) does it already.
There is some complication due to circular includes among glibc header files;
this can be fixed like for <stdio.h>. Here's the fix:
2011-07-07 Bruno Haible <address@hidden>
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.
--- lib/signal.in.h.orig Fri Jul 8 02:02:44 2011
+++ lib/signal.in.h Fri Jul 8 02:02:38 2011
@@ -20,8 +20,17 @@
#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 address@hidden@_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. */
address@hidden@ @NEXT_SIGNAL_H@
+#undef _GL_ALREADY_INCLUDING_SIGNAL_H
+
#ifndef address@hidden@_SIGNAL_H
#define address@hidden@_SIGNAL_H
@@ -103,10 +116,13 @@
#if @GNULIB_PTHREAD_SIGMASK@
-# if @REPLACE_PTHREAD_SIGMASK@
+# if address@hidden@
_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
--- m4/pthread_sigmask.m4.orig Fri Jul 8 02:02:44 2011
+++ m4/pthread_sigmask.m4 Fri Jul 8 01:54:04 2011
@@ -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 @@
])
if test $ac_cv_func_pthread_sigmask = no; then
- REPLACE_PTHREAD_SIGMASK=1
+ HAVE_PTHREAD_SIGMASK=0
fi
])
--- m4/signal_h.m4.orig Fri Jul 8 02:02:44 2011
+++ m4/signal_h.m4 Fri Jul 8 01:54:04 2011
@@ -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 @@
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 @@
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])
])
--- modules/pthread_sigmask.orig Fri Jul 8 02:02:44 2011
+++ modules/pthread_sigmask Fri Jul 8 01:54:25 2011
@@ -7,11 +7,11 @@
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])
--- modules/signal.orig Fri Jul 8 02:02:44 2011
+++ modules/signal Fri Jul 8 01:54:04 2011
@@ -33,13 +33,13 @@
-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)' \
--
In memoriam Georges Mandel <http://en.wikipedia.org/wiki/Georges_Mandel>
- Re: threadlib and emacs, (continued)
- git, merging patches, Bruno Haible, 2011/07/18
- Re: git, merging patches, Paul Eggert, 2011/07/19
- Re: git, merging patches, Paul Eggert, 2011/07/19
- Re: git, merging patches, Bruno Haible, 2011/07/19
- Re: threadlib and emacs, Bruno Haible, 2011/07/18
- Re: trouble with aclocal, Bruno Haible, 2011/07/18
Re: [PATCH 03/10] pthread_sigmask: new module,
Bruno Haible <=
Re: [PATCH 03/10] pthread_sigmask: new module, 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, 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, Bruno Haible, 2011/07/07
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/08
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/08
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/08
Re: [PATCH 03/10] pthread_sigmask: new module, Bruno Haible, 2011/07/08