about summary refs log tree commit diff
path: root/sysdeps/unix
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-08-16 20:33:59 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-08-16 20:33:59 +0000
commit67f0aff0c63e5deaade7f6cc7758f5cb63344fb8 (patch)
tree6cd8f38178b1ba6c4c73bf2f61d4e24df1e975dc /sysdeps/unix
parent87e7bf4d36af0a4622dc2687730f26d7d53003fe (diff)
downloadglibc-67f0aff0c63e5deaade7f6cc7758f5cb63344fb8.tar.gz
glibc-67f0aff0c63e5deaade7f6cc7758f5cb63344fb8.tar.xz
glibc-67f0aff0c63e5deaade7f6cc7758f5cb63344fb8.zip
Fix sigval namespace (bug 21944).
XPG4.2 defines the siginfo_t type, but not union sigval or its
contents (which were added in the 1993 edition of POSIX.1), resulting
in namespace violations for sigval, sival_int and sival_ptr for
signal.h and sys/wait.h for that standard because those headers
incorrectly expose those names in that case.

This patch fixes this problem.  The public type in this case is union
sigval, but various places in the headers use the sigval_t name for
it; direct uses of union sigval are already properly guarded or in
headers not in XPG4.2.  Now, sigval_t, although not a standard name,
does seem to be widely used outside glibc.  The approach taken by this
patch is to make installed headers use the name __sigval_t instead.
__sigval_t is then defined to either union sigval or union __sigval
(where union __sigval has __-prefixed member names as well), depending
on whether there are any namespace issues with the union sigval name
and its members.  In the case where union __sigval is used, sigval_t
is not defined at all, to avoid the problem of sigval_t having a C++
mangled name that depends on feature test macros.  sigval_t is still
defined by signal.h if __USE_MISC (reflecting the nonstandard nature
of that name).

Tested for x86_64.

	[BZ #21944]
	* signal/bits/types/__sigval_t.h: New file.
	* signal/Makefile (headers): Add bits/types/__sigval_t.h.
	* signal/bits/types/sigval_t.h: Include <bits/types/__sigval_t.h>
	and define sigval_t using __sigval_t.
	* include/bits/types/__sigval_t.h: New file.
	* bits/types/sigevent_t.h: Include <bits/types/__sigval_t.h>
	instead of <bits/types/__sigval_t.h>.
	(struct sigevent): Use __sigval_t instead of sigval_t.
	* bits/types/siginfo_t.h: Include <bits/types/__sigval_t.h>
	instead of <bits/types/__sigval_t.h>.
	(siginfo_t): Use __sigval_t instead of sigval_t.
	* sysdeps/unix/sysv/linux/bits/types/sigevent_t.h: Include
	<bits/types/__sigval_t.h> instead of <bits/types/__sigval_t.h>.
	(struct sigevent): Use __sigval_t instead of sigval_t.
	* sysdeps/unix/sysv/linux/bits/types/siginfo_t.h: Include
	<bits/types/__sigval_t.h> instead of <bits/types/__sigval_t.h>.
	(siginfo_t): Use __sigval_t instead of sigval_t.
	* signal/signal.h [__USE_MISC]: Include <bits/types/sigval_t.h>.
Diffstat (limited to 'sysdeps/unix')
-rw-r--r--sysdeps/unix/sysv/linux/bits/types/sigevent_t.h6
-rw-r--r--sysdeps/unix/sysv/linux/bits/types/siginfo_t.h6
2 files changed, 6 insertions, 6 deletions
diff --git a/sysdeps/unix/sysv/linux/bits/types/sigevent_t.h b/sysdeps/unix/sysv/linux/bits/types/sigevent_t.h
index 0d4857b16e..e8b28de7e3 100644
--- a/sysdeps/unix/sysv/linux/bits/types/sigevent_t.h
+++ b/sysdeps/unix/sysv/linux/bits/types/sigevent_t.h
@@ -3,7 +3,7 @@
 
 #include <bits/wordsize.h>
 #include <bits/types.h>
-#include <bits/types/sigval_t.h>
+#include <bits/types/__sigval_t.h>
 
 #define __SIGEV_MAX_SIZE	64
 #if __WORDSIZE == 64
@@ -21,7 +21,7 @@ typedef union pthread_attr_t pthread_attr_t;
 /* Structure to transport application-defined values with signals.  */
 typedef struct sigevent
   {
-    sigval_t sigev_value;
+    __sigval_t sigev_value;
     int sigev_signo;
     int sigev_notify;
 
@@ -35,7 +35,7 @@ typedef struct sigevent
 
 	struct
 	  {
-	    void (*_function) (sigval_t);	/* Function to start.  */
+	    void (*_function) (__sigval_t);	/* Function to start.  */
 	    pthread_attr_t *_attribute;		/* Thread attributes.  */
 	  } _sigev_thread;
       } _sigev_un;
diff --git a/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h b/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
index bed69148f9..33766d1813 100644
--- a/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
+++ b/sysdeps/unix/sysv/linux/bits/types/siginfo_t.h
@@ -3,7 +3,7 @@
 
 #include <bits/wordsize.h>
 #include <bits/types.h>
-#include <bits/types/sigval_t.h>
+#include <bits/types/__sigval_t.h>
 
 #define __SI_MAX_SIZE	128
 #if __WORDSIZE == 64
@@ -64,7 +64,7 @@ typedef struct
 	  {
 	    int si_tid;		/* Timer ID.  */
 	    int si_overrun;	/* Overrun count.  */
-	    sigval_t si_sigval;	/* Signal value.  */
+	    __sigval_t si_sigval;	/* Signal value.  */
 	  } _timer;
 
 	/* POSIX.1b signals.  */
@@ -72,7 +72,7 @@ typedef struct
 	  {
 	    __pid_t si_pid;	/* Sending process ID.  */
 	    __uid_t si_uid;	/* Real user ID of sending process.  */
-	    sigval_t si_sigval;	/* Signal value.  */
+	    __sigval_t si_sigval;	/* Signal value.  */
 	  } _rt;
 
 	/* SIGCHLD.  */