diff mbox

[06/29] Allow some fields of siginfo to be different from the generic one

Message ID 1414396793-9005-7-git-send-email-apinski@cavium.com
State New
Headers show

Commit Message

Andrew Pinski Oct. 27, 2014, 7:59 a.m. UTC
In AARCH64:ILP32, we want to use the layout for siginfo as AARCH64:LP64,
so we need to add a few hooks into siginfo.h to support this.

* sysdeps/unix/sysv/linux/bits/siginfo.h (__SIGINFO_VOIDPTR): New define.
(__SIGINFO_BAND): New define.
(union sigval): Use __SIGINFO_VOIDPTR for the pointer.
(__SI_PAD_SIZE): Don't define if it is already defined.
(struct siginfo): Use __SIGINFO_VOIDPTR for the pointer types.
Use __SIGINFO_BAND for the si_band field.
(struct sigevent): Add a comment on why the remaining fields
don't need special handling.
---
 sysdeps/unix/sysv/linux/bits/siginfo.h |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

Comments

Will Newton Nov. 18, 2014, 11:31 a.m. UTC | #1
On 27 October 2014 07:59, Andrew Pinski <apinski@cavium.com> wrote:
> In AARCH64:ILP32, we want to use the layout for siginfo as AARCH64:LP64,
> so we need to add a few hooks into siginfo.h to support this.
>
> * sysdeps/unix/sysv/linux/bits/siginfo.h (__SIGINFO_VOIDPTR): New define.
> (__SIGINFO_BAND): New define.
> (union sigval): Use __SIGINFO_VOIDPTR for the pointer.
> (__SI_PAD_SIZE): Don't define if it is already defined.
> (struct siginfo): Use __SIGINFO_VOIDPTR for the pointer types.
> Use __SIGINFO_BAND for the si_band field.
> (struct sigevent): Add a comment on why the remaining fields
> don't need special handling.
> ---
>  sysdeps/unix/sysv/linux/bits/siginfo.h |   26 +++++++++++++++++++-------
>  1 files changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/bits/siginfo.h b/sysdeps/unix/sysv/linux/bits/siginfo.h
> index ae603e8..f319d44 100644
> --- a/sysdeps/unix/sysv/linux/bits/siginfo.h
> +++ b/sysdeps/unix/sysv/linux/bits/siginfo.h
> @@ -23,6 +23,14 @@
>
>  #include <bits/wordsize.h>
>
> +#ifndef __SIGINFO_VOIDPTR
> +#define __SIGINFO_VOIDPTR(field) void *field
> +#endif
> +
> +#ifndef __SIGINFO_BAND
> +#define __SIGINFO_BAND(field) long field
> +#endif
> +

These #defines need indenting.

>  #if (!defined __have_sigval_t \
>       && (defined _SIGNAL_H || defined __need_siginfo_t \
>          || defined __need_sigevent_t))
> @@ -32,7 +40,7 @@
>  typedef union sigval
>    {
>      int sival_int;
> -    void *sival_ptr;
> +    __SIGINFO_VOIDPTR (sival_ptr);
>    } sigval_t;
>  #endif
>
> @@ -41,10 +49,13 @@ typedef union sigval
>  # define __have_siginfo_t      1
>
>  # define __SI_MAX_SIZE     128
> -# if __WORDSIZE == 64
> -#  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
> +
> +# ifndef __SI_PAD_SIZE
> +#  if __WORDSIZE == 64
> +#   define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
>  # else

This #else needs indenting further too.

Otherwise this looks ok to me.

> -#  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)
> +#   define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)
> +#  endif
>  # endif
>
>  typedef struct
> @@ -94,21 +105,21 @@ typedef struct
>         /* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */
>         struct
>           {
> -           void *si_addr;      /* Faulting insn/memory ref.  */
> +           __SIGINFO_VOIDPTR (si_addr);        /* Faulting insn/memory ref.  */
>             short int si_addr_lsb;      /* Valid LSB of the reported address.  */
>           } _sigfault;
>
>         /* SIGPOLL.  */
>         struct
>           {
> -           long int si_band;   /* Band event for SIGPOLL.  */
> +           __SIGINFO_BAND (si_band);   /* Band event for SIGPOLL.  */
>             int si_fd;
>           } _sigpoll;
>
>         /* SIGSYS.  */
>         struct
>           {
> -           void *_call_addr;   /* Calling user insn.  */
> +           __SIGINFO_VOIDPTR (_call_addr);     /* Calling user insn.  */
>             int _syscall;       /* Triggering system call number.  */
>             unsigned int _arch; /* AUDIT_ARCH_* of syscall.  */
>           } _sigsys;
> @@ -312,6 +323,7 @@ typedef struct sigevent
>            thread to receive the signal.  */
>         __pid_t _tid;
>
> +       /* Note these two are handled only in userspace. */
>         struct
>           {
>             void (*_function) (sigval_t);       /* Function to start.  */
> --
> 1.7.2.5
>
diff mbox

Patch

diff --git a/sysdeps/unix/sysv/linux/bits/siginfo.h b/sysdeps/unix/sysv/linux/bits/siginfo.h
index ae603e8..f319d44 100644
--- a/sysdeps/unix/sysv/linux/bits/siginfo.h
+++ b/sysdeps/unix/sysv/linux/bits/siginfo.h
@@ -23,6 +23,14 @@ 
 
 #include <bits/wordsize.h>
 
+#ifndef __SIGINFO_VOIDPTR
+#define __SIGINFO_VOIDPTR(field) void *field
+#endif
+
+#ifndef __SIGINFO_BAND
+#define __SIGINFO_BAND(field) long field
+#endif
+
 #if (!defined __have_sigval_t \
      && (defined _SIGNAL_H || defined __need_siginfo_t \
 	 || defined __need_sigevent_t))
@@ -32,7 +40,7 @@ 
 typedef union sigval
   {
     int sival_int;
-    void *sival_ptr;
+    __SIGINFO_VOIDPTR (sival_ptr);
   } sigval_t;
 #endif
 
@@ -41,10 +49,13 @@  typedef union sigval
 # define __have_siginfo_t	1
 
 # define __SI_MAX_SIZE     128
-# if __WORDSIZE == 64
-#  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
+
+# ifndef __SI_PAD_SIZE
+#  if __WORDSIZE == 64
+#   define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
 # else
-#  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)
+#   define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)
+#  endif
 # endif
 
 typedef struct
@@ -94,21 +105,21 @@  typedef struct
 	/* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */
 	struct
 	  {
-	    void *si_addr;	/* Faulting insn/memory ref.  */
+	    __SIGINFO_VOIDPTR (si_addr);	/* Faulting insn/memory ref.  */
 	    short int si_addr_lsb;	/* Valid LSB of the reported address.  */
 	  } _sigfault;
 
 	/* SIGPOLL.  */
 	struct
 	  {
-	    long int si_band;	/* Band event for SIGPOLL.  */
+	    __SIGINFO_BAND (si_band);	/* Band event for SIGPOLL.  */
 	    int si_fd;
 	  } _sigpoll;
 
 	/* SIGSYS.  */
 	struct
 	  {
-	    void *_call_addr;	/* Calling user insn.  */
+	    __SIGINFO_VOIDPTR (_call_addr);	/* Calling user insn.  */
 	    int _syscall;	/* Triggering system call number.  */
 	    unsigned int _arch; /* AUDIT_ARCH_* of syscall.  */
 	  } _sigsys;
@@ -312,6 +323,7 @@  typedef struct sigevent
 	   thread to receive the signal.  */
 	__pid_t _tid;
 
+	/* Note these two are handled only in userspace. */
 	struct
 	  {
 	    void (*_function) (sigval_t);	/* Function to start.  */