I had already written this patch, and was in the process of testing it,
before cgf voted it down.  I'm still posting it for the record, as it
would allow us to be source-compatible with Linux while we wait for the
gcc bug to be fixed.

For that matter, even if this patch is not applied, we might still want to
consider simplifying things in siginfo_t - an anonymous union containing a
single anonymous struct containing a single anonymous union seems
wasteful, and we can prune two of those scopes whether or not we also name
the outer union.

2010-04-27  Eric Blake  <[email protected]>

        * include/cygwin/signal.h (siginfo_t, sigaction): Work around gcc
        bug with member initialization of anonymous union members.

-- 
Eric Blake   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org
---
 winsup/cygwin/ChangeLog               |    5 +++
 winsup/cygwin/include/cygwin/signal.h |   62 ++++++++++++++++++--------------
 2 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/winsup/cygwin/include/cygwin/signal.h 
b/winsup/cygwin/include/cygwin/signal.h
index 25d501d..4fcfd33 100644
--- a/winsup/cygwin/include/cygwin/signal.h
+++ b/winsup/cygwin/include/cygwin/signal.h
@@ -1,6 +1,6 @@
 /* signal.h

-  Copyright 2004, 2005, 2006 Red Hat, Inc.
+  Copyright 2004, 2005, 2006, 2010 Red Hat, Inc.

   This file is part of Cygwin.

@@ -97,40 +97,46 @@ typedef struct
   uid_t si_uid;                                /* sender's uid */
   int si_errno;                                /* errno associated with signal 
*/

-  __extension__ union
+  /* GCC bug 10676: we must use macros instead of anonymous unions,
+     to allow member initialization syntax to work.  */
+  union
   {
     __uint32_t __pad[32];              /* plan for future growth */
-    struct _sigcommune _si_commune;    /* cygwin ipc */
-    __extension__ union
+    struct _sigcommune __si_commune;   /* cygwin ipc */
+    union
     {
       /* timers */
       struct
       {
-       union
-       {
-         struct
-         {
-           timer_t si_tid;             /* timer id */
-           unsigned int si_overrun;    /* overrun count */
-         };
-         sigval_t si_sigval;           /* signal value */
-         sigval_t si_value;            /* signal value */
-       };
-      };
-    };
+       timer_t __si_tid;               /* timer id */
+       unsigned int __si_overrun;      /* overrun count */
+      } __timer;
+      sigval_t __si_sigval;            /* signal value */
+      sigval_t __si_value;             /* signal value */
+    } __value;

     /* SIGCHLD */
-    __extension__ struct
+    struct
     {
-      int si_status;                   /* exit code */
-      clock_t si_utime;                        /* user time */
-      clock_t si_stime;                        /* system time */
-    };
+      int __si_status;                 /* exit code */
+      clock_t __si_utime;              /* user time */
+      clock_t __si_stime;              /* system time */
+    } __child;

     /* core dumping signals */
-    void *si_addr;                     /* faulting address */
-  };
+    void *__si_addr;                   /* faulting address */
+  } __si;
 } siginfo_t;
+#define _si_commune    __si.__si_commune
+#define si_tid         __si.__value.__timer.__si_tid
+#define si_overrun     __si.__value.__timer.__si_overrun
+#define si_sigval      __si.__value.__si_sigval
+#define si_value       __si.__value.__si_value
+#define si_status      __si.__child.__si_status
+#define si_utime       __si.__child.__si_utime
+#define si_stime       __si.__child.__si_stime
+#define si_addr                __si.__si_addr
+
 #pragma pack(pop)

 enum
@@ -194,14 +200,16 @@ typedef void (*_sig_func_ptr)(int);

 struct sigaction
 {
-  __extension__ union
+  union
   {
-    _sig_func_ptr sa_handler;                  /* SIG_DFL, SIG_IGN, or pointer 
to a function */
-    void  (*sa_sigaction) ( int, siginfo_t *, void * );
-  };
+    _sig_func_ptr __sa_handler;                /* SIG_DFL, SIG_IGN, or pointer 
to a function */
+    void  (*__sa_sigaction) ( int, siginfo_t *, void * );
+  } __sa;
   sigset_t sa_mask;
   int sa_flags;
 };
+#define sa_handler     __sa.__sa_handler
+#define sa_sigaction   __sa.__sa_sigaction

 #define SA_NOCLDSTOP 1                 /* Do not generate SIGCHLD when children
                                           stop */
-- 
1.7.0.4

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to