about summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-05-24 20:39:46 -0400
committerRich Felker <dalias@aerifal.cx>2014-05-24 20:39:46 -0400
commit44d28e55121f9a7d736df59c09b963e17c8c4cfa (patch)
treeb60d331719601cfeebfcf9e4ad081fe0717dc7c8 /include
parent0b4e0732db5e6ed0cca78d787cbd764248fcbaac (diff)
downloadmusl-44d28e55121f9a7d736df59c09b963e17c8c4cfa.tar.gz
musl-44d28e55121f9a7d736df59c09b963e17c8c4cfa.tar.xz
musl-44d28e55121f9a7d736df59c09b963e17c8c4cfa.zip
overhaul siginfo_t definition in signal.h
the main motivation for this change is that, with the previous
definition, it was arguably illegal, in standard C, to initialize both
si_value and si_pid/si_uid with designated initializers, due to the
rule that only one member of a union can have an initializer. whether
or not this affected real-world application code, it affected some
internal code, and clang was producing warnings (and possibly
generating incorrect code).

the new definition uses a more complex hierarchy of structs and unions
to avoid the need to initialize more than one member of a single union
in usage cases that make sense. further work would be needed to
eliminate even the ones with no practical applications.

at the same time, some fixes are made to the exposed names for
nonstandard fields, to match what software using them expects.
Diffstat (limited to 'include')
-rw-r--r--include/signal.h51
1 files changed, 28 insertions, 23 deletions
diff --git a/include/signal.h b/include/signal.h
index 3fb21b2a..c36e4d59 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -89,19 +89,24 @@ typedef struct {
 	union {
 		char __pad[128 - 2*sizeof(int) - sizeof(long)];
 		struct {
-			pid_t si_pid;
-			uid_t si_uid;
-			union sigval si_sigval;
-		} __rt;
-		struct {
-			unsigned int si_timer1, si_timer2;
-		} __timer;
-		struct {
-			pid_t si_pid;
-			uid_t si_uid;
-			int si_status;
-			clock_t si_utime, si_stime;
-		} __sigchld;
+			union {
+				struct {
+					pid_t si_pid;
+					uid_t si_uid;
+				} __piduid;
+				struct {
+					int si_timerid;
+					int si_overrun;
+				} __timer;
+			} __first;
+			union {
+				union sigval si_value;
+				struct {
+					int si_status;
+					clock_t si_utime, si_stime;
+				} __sigchld;
+			} __second;
+		} __si_common;
 		struct {
 			void *si_addr;
 			short si_addr_lsb;
@@ -117,20 +122,20 @@ typedef struct {
 		} __sigsys;
 	} __si_fields;
 } siginfo_t;
-#define si_pid     __si_fields.__sigchld.si_pid
-#define si_uid     __si_fields.__sigchld.si_uid
-#define si_status  __si_fields.__sigchld.si_status
-#define si_utime   __si_fields.__sigchld.si_utime
-#define si_stime   __si_fields.__sigchld.si_stime
-#define si_value   __si_fields.__rt.si_sigval
+#define si_pid     __si_fields.__si_common.__first.__piduid.si_pid
+#define si_uid     __si_fields.__si_common.__first.__piduid.si_uid
+#define si_status  __si_fields.__si_common.__second.__sigchld.si_status
+#define si_utime   __si_fields.__si_common.__second.__sigchld.si_utime
+#define si_stime   __si_fields.__si_common.__second.__sigchld.si_stime
+#define si_value   __si_fields.__si_common.__second.si_value
 #define si_addr    __si_fields.__sigfault.si_addr
 #define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
 #define si_band    __si_fields.__sigpoll.si_band
 #define si_fd      __si_fields.__sigpoll.si_fd
-#define si_timer1  __si_fields.__timer.si_timer1
-#define si_timer2  __si_fields.__timer.si_timer2
-#define si_ptr     __si_fields.__rt.si_sigval.sival_ptr
-#define si_int     __si_fields.__rt.si_sigval.sival_int
+#define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
+#define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
+#define si_ptr     si_value.sival_ptr
+#define si_int     si_value.sival_int
 #define si_call_addr __si_fields.__sigsys.si_call_addr
 #define si_syscall __si_fields.__sigsys.si_syscall
 #define si_arch    __si_fields.__sigsys.si_arch