* proposed siginfo changes
@ 2014-04-20 4:59 Rich Felker
0 siblings, 0 replies; only message in thread
From: Rich Felker @ 2014-04-20 4:59 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 759 bytes --]
I've realized that our siginfo_t structure (and also the kernel and
glibc versions of it) have a bug: due to the way the union is laid
out, it's illegal to initialize both si_pid and si_value. This is
because __sigchld and __rt are both members of the same union and at
most one member of a union can be initialized.
The attached patch is a proposal for fixing this, with a more complex
setup of unions and structs. I'm going to hold off on applying it
immediately in case anyone has better ideas for how to do this. One
possible improvement would be to set things up so we could #define
away all of the __-prefixed names on GNUC or C11 compilers and thereby
use anonymous structs and unions instead of the hideous preprocessor
mess to access members.
Rich
[-- Attachment #2: siginfo.diff --]
[-- Type: text/plain, Size: 2534 bytes --]
diff --git a/include/signal.h b/include/signal.h
index 3fb21b2..b6e1e98 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_tid;
+ int si_overrun;
+ } __timer;
+ } __first;
+ union {
+ union sigval si_sigval;
+ 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_commin.__second.__sigchld.si_status
+#define si_utime __si_fields.__si_commin.__second.__sigchld.si_utime
+#define si_stime __si_fields.__si_commin.__second.__sigchld.si_stime
+#define si_value __si_fields.__si_commin.__second.si_sigval
#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_tid __si_fields.__si_common.__first.__timer.si_tid
+#define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
+#define si_ptr __si_fields.__si_commin.__second.si_sigval.sival_ptr
+#define si_int __si_fields.__si_commin.__second.si_sigval.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-04-20 4:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-20 4:59 proposed siginfo changes Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).