modernc.org/cc@v1.0.1/v2/headers/linux_amd64/usr/include/bits/siginfo.h (about)

     1  /* siginfo_t, sigevent and constants.  Linux x86-64 version.
     2     Copyright (C) 2012-2015 Free Software Foundation, Inc.
     3     This file is part of the GNU C Library.
     4  
     5     The GNU C Library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9  
    10     The GNU C Library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14  
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with the GNU C Library; if not, see
    17     <http://www.gnu.org/licenses/>.  */
    18  
    19  #if !defined _SIGNAL_H && !defined __need_siginfo_t \
    20      && !defined __need_sigevent_t
    21  # error "Never include this file directly.  Use <signal.h> instead"
    22  #endif
    23  
    24  #include <bits/wordsize.h>
    25  
    26  #if (!defined __have_sigval_t \
    27       && (defined _SIGNAL_H || defined __need_siginfo_t \
    28  	 || defined __need_sigevent_t))
    29  # define __have_sigval_t	1
    30  
    31  /* Type for data associated with a signal.  */
    32  typedef union sigval {
    33  	int sival_int;
    34  	void *sival_ptr;
    35  } sigval_t;
    36  #endif
    37  
    38  #if (!defined __have_siginfo_t \
    39       && (defined _SIGNAL_H || defined __need_siginfo_t))
    40  # define __have_siginfo_t	1
    41  
    42  # define __SI_MAX_SIZE     128
    43  # if __WORDSIZE == 64
    44  #  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
    45  # else
    46  #  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)
    47  # endif
    48  
    49  # if defined __x86_64__ && __WORDSIZE == 32
    50  /* si_utime and si_stime must be 4 byte aligned for x32 to match the
    51     kernel.  We align siginfo_t to 8 bytes so that si_utime and si_stime
    52     are actually aligned to 8 bytes since their offsets are multiple of
    53     8 bytes.  */
    54  typedef __clock_t __attribute__ ((__aligned__(4))) __sigchld_clock_t;
    55  #  define __SI_ALIGNMENT __attribute__ ((__aligned__ (8)))
    56  # else
    57  typedef __clock_t __sigchld_clock_t;
    58  #  define __SI_ALIGNMENT
    59  # endif
    60  
    61  typedef struct {
    62  	int si_signo;		/* Signal number.  */
    63  	int si_errno;		/* If non-zero, an errno value associated with
    64  				   this signal, as defined in <errno.h>.  */
    65  	int si_code;		/* Signal code.  */
    66  
    67  	union {
    68  		int _pad[__SI_PAD_SIZE];
    69  
    70  		/* kill().  */
    71  		struct {
    72  			__pid_t si_pid;	/* Sending process ID.  */
    73  			__uid_t si_uid;	/* Real user ID of sending process.  */
    74  		} _kill;
    75  
    76  		/* POSIX.1b timers.  */
    77  		struct {
    78  			int si_tid;	/* Timer ID.  */
    79  			int si_overrun;	/* Overrun count.  */
    80  			sigval_t si_sigval;	/* Signal value.  */
    81  		} _timer;
    82  
    83  		/* POSIX.1b signals.  */
    84  		struct {
    85  			__pid_t si_pid;	/* Sending process ID.  */
    86  			__uid_t si_uid;	/* Real user ID of sending process.  */
    87  			sigval_t si_sigval;	/* Signal value.  */
    88  		} _rt;
    89  
    90  		/* SIGCHLD.  */
    91  		struct {
    92  			__pid_t si_pid;	/* Which child.  */
    93  			__uid_t si_uid;	/* Real user ID of sending process.  */
    94  			int si_status;	/* Exit value or signal.  */
    95  			__sigchld_clock_t si_utime;
    96  			__sigchld_clock_t si_stime;
    97  		} _sigchld;
    98  
    99  		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */
   100  		struct {
   101  			void *si_addr;	/* Faulting insn/memory ref.  */
   102  			short int si_addr_lsb;	/* Valid LSB of the reported address.  */
   103  			struct {
   104  				void *_lower;
   105  				void *_upper;
   106  			} si_addr_bnd;
   107  		} _sigfault;
   108  
   109  		/* SIGPOLL.  */
   110  		struct {
   111  			long int si_band;	/* Band event for SIGPOLL.  */
   112  			int si_fd;
   113  		} _sigpoll;
   114  
   115  		/* SIGSYS.  */
   116  		struct {
   117  			void *_call_addr;	/* Calling user insn.  */
   118  			int _syscall;	/* Triggering system call number.  */
   119  			unsigned int _arch;	/* AUDIT_ARCH_* of syscall.  */
   120  		} _sigsys;
   121  	} _sifields;
   122  } siginfo_t __SI_ALIGNMENT;
   123  
   124  /* X/Open requires some more fields with fixed names.  */
   125  # define si_pid		_sifields._kill.si_pid
   126  # define si_uid		_sifields._kill.si_uid
   127  # define si_timerid	_sifields._timer.si_tid
   128  # define si_overrun	_sifields._timer.si_overrun
   129  # define si_status	_sifields._sigchld.si_status
   130  # define si_utime	_sifields._sigchld.si_utime
   131  # define si_stime	_sifields._sigchld.si_stime
   132  # define si_value	_sifields._rt.si_sigval
   133  # define si_int		_sifields._rt.si_sigval.sival_int
   134  # define si_ptr		_sifields._rt.si_sigval.sival_ptr
   135  # define si_addr	_sifields._sigfault.si_addr
   136  # define si_addr_lsb	_sifields._sigfault.si_addr_lsb
   137  # define si_lower	_sifields._sigfault.si_addr_bnd._lower
   138  # define si_upper	_sifields._sigfault.si_addr_bnd._upper
   139  # define si_band	_sifields._sigpoll.si_band
   140  # define si_fd		_sifields._sigpoll.si_fd
   141  # define si_call_addr 	_sifields._sigsys._call_addr
   142  # define si_syscall	_sifields._sigsys._syscall
   143  # define si_arch	_sifields._sigsys._arch
   144  
   145  /* Values for `si_code'.  Positive values are reserved for kernel-generated
   146     signals.  */
   147  enum {
   148  	SI_ASYNCNL = -60,	/* Sent by asynch name lookup completion.  */
   149  # define SI_ASYNCNL	SI_ASYNCNL
   150  	SI_TKILL = -6,		/* Sent by tkill.  */
   151  # define SI_TKILL	SI_TKILL
   152  	SI_SIGIO,		/* Sent by queued SIGIO. */
   153  # define SI_SIGIO	SI_SIGIO
   154  	SI_ASYNCIO,		/* Sent by AIO completion.  */
   155  # define SI_ASYNCIO	SI_ASYNCIO
   156  	SI_MESGQ,		/* Sent by real time mesq state change.  */
   157  # define SI_MESGQ	SI_MESGQ
   158  	SI_TIMER,		/* Sent by timer expiration.  */
   159  # define SI_TIMER	SI_TIMER
   160  	SI_QUEUE,		/* Sent by sigqueue.  */
   161  # define SI_QUEUE	SI_QUEUE
   162  	SI_USER,		/* Sent by kill, sigsend.  */
   163  # define SI_USER	SI_USER
   164  	SI_KERNEL = 0x80	/* Send by kernel.  */
   165  #define SI_KERNEL	SI_KERNEL
   166  };
   167  
   168  # if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
   169  /* `si_code' values for SIGILL signal.  */
   170  enum {
   171  	ILL_ILLOPC = 1,		/* Illegal opcode.  */
   172  #  define ILL_ILLOPC	ILL_ILLOPC
   173  	ILL_ILLOPN,		/* Illegal operand.  */
   174  #  define ILL_ILLOPN	ILL_ILLOPN
   175  	ILL_ILLADR,		/* Illegal addressing mode.  */
   176  #  define ILL_ILLADR	ILL_ILLADR
   177  	ILL_ILLTRP,		/* Illegal trap. */
   178  #  define ILL_ILLTRP	ILL_ILLTRP
   179  	ILL_PRVOPC,		/* Privileged opcode.  */
   180  #  define ILL_PRVOPC	ILL_PRVOPC
   181  	ILL_PRVREG,		/* Privileged register.  */
   182  #  define ILL_PRVREG	ILL_PRVREG
   183  	ILL_COPROC,		/* Coprocessor error.  */
   184  #  define ILL_COPROC	ILL_COPROC
   185  	ILL_BADSTK		/* Internal stack error.  */
   186  #  define ILL_BADSTK	ILL_BADSTK
   187  };
   188  
   189  /* `si_code' values for SIGFPE signal.  */
   190  enum {
   191  	FPE_INTDIV = 1,		/* Integer divide by zero.  */
   192  #  define FPE_INTDIV	FPE_INTDIV
   193  	FPE_INTOVF,		/* Integer overflow.  */
   194  #  define FPE_INTOVF	FPE_INTOVF
   195  	FPE_FLTDIV,		/* Floating point divide by zero.  */
   196  #  define FPE_FLTDIV	FPE_FLTDIV
   197  	FPE_FLTOVF,		/* Floating point overflow.  */
   198  #  define FPE_FLTOVF	FPE_FLTOVF
   199  	FPE_FLTUND,		/* Floating point underflow.  */
   200  #  define FPE_FLTUND	FPE_FLTUND
   201  	FPE_FLTRES,		/* Floating point inexact result.  */
   202  #  define FPE_FLTRES	FPE_FLTRES
   203  	FPE_FLTINV,		/* Floating point invalid operation.  */
   204  #  define FPE_FLTINV	FPE_FLTINV
   205  	FPE_FLTSUB		/* Subscript out of range.  */
   206  #  define FPE_FLTSUB	FPE_FLTSUB
   207  };
   208  
   209  /* `si_code' values for SIGSEGV signal.  */
   210  enum {
   211  	SEGV_MAPERR = 1,	/* Address not mapped to object.  */
   212  #  define SEGV_MAPERR	SEGV_MAPERR
   213  	SEGV_ACCERR		/* Invalid permissions for mapped object.  */
   214  #  define SEGV_ACCERR	SEGV_ACCERR
   215  };
   216  
   217  /* `si_code' values for SIGBUS signal.  */
   218  enum {
   219  	BUS_ADRALN = 1,		/* Invalid address alignment.  */
   220  #  define BUS_ADRALN	BUS_ADRALN
   221  	BUS_ADRERR,		/* Non-existant physical address.  */
   222  #  define BUS_ADRERR	BUS_ADRERR
   223  	BUS_OBJERR,		/* Object specific hardware error.  */
   224  #  define BUS_OBJERR	BUS_OBJERR
   225  	BUS_MCEERR_AR,		/* Hardware memory error: action required.  */
   226  #  define BUS_MCEERR_AR	BUS_MCEERR_AR
   227  	BUS_MCEERR_AO		/* Hardware memory error: action optional.  */
   228  #  define BUS_MCEERR_AO	BUS_MCEERR_AO
   229  };
   230  # endif
   231  
   232  # ifdef __USE_XOPEN_EXTENDED
   233  /* `si_code' values for SIGTRAP signal.  */
   234  enum {
   235  	TRAP_BRKPT = 1,		/* Process breakpoint.  */
   236  #  define TRAP_BRKPT	TRAP_BRKPT
   237  	TRAP_TRACE		/* Process trace trap.  */
   238  #  define TRAP_TRACE	TRAP_TRACE
   239  };
   240  # endif
   241  
   242  # if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
   243  /* `si_code' values for SIGCHLD signal.  */
   244  enum {
   245  	CLD_EXITED = 1,		/* Child has exited.  */
   246  #  define CLD_EXITED	CLD_EXITED
   247  	CLD_KILLED,		/* Child was killed.  */
   248  #  define CLD_KILLED	CLD_KILLED
   249  	CLD_DUMPED,		/* Child terminated abnormally.  */
   250  #  define CLD_DUMPED	CLD_DUMPED
   251  	CLD_TRAPPED,		/* Traced child has trapped.  */
   252  #  define CLD_TRAPPED	CLD_TRAPPED
   253  	CLD_STOPPED,		/* Child has stopped.  */
   254  #  define CLD_STOPPED	CLD_STOPPED
   255  	CLD_CONTINUED		/* Stopped child has continued.  */
   256  #  define CLD_CONTINUED	CLD_CONTINUED
   257  };
   258  
   259  /* `si_code' values for SIGPOLL signal.  */
   260  enum {
   261  	POLL_IN = 1,		/* Data input available.  */
   262  #  define POLL_IN	POLL_IN
   263  	POLL_OUT,		/* Output buffers available.  */
   264  #  define POLL_OUT	POLL_OUT
   265  	POLL_MSG,		/* Input message available.   */
   266  #  define POLL_MSG	POLL_MSG
   267  	POLL_ERR,		/* I/O error.  */
   268  #  define POLL_ERR	POLL_ERR
   269  	POLL_PRI,		/* High priority input available.  */
   270  #  define POLL_PRI	POLL_PRI
   271  	POLL_HUP		/* Device disconnected.  */
   272  #  define POLL_HUP	POLL_HUP
   273  };
   274  # endif
   275  
   276  # undef __need_siginfo_t
   277  #endif				/* !have siginfo_t && (have _SIGNAL_H || need siginfo_t).  */
   278  
   279  #if (defined _SIGNAL_H || defined __need_sigevent_t) \
   280      && !defined __have_sigevent_t
   281  # define __have_sigevent_t	1
   282  
   283  /* Structure to transport application-defined values with signals.  */
   284  # define __SIGEV_MAX_SIZE	64
   285  # if __WORDSIZE == 64
   286  #  define __SIGEV_PAD_SIZE	((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
   287  # else
   288  #  define __SIGEV_PAD_SIZE	((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
   289  # endif
   290  
   291  /* Forward declaration.  */
   292  # ifndef __have_pthread_attr_t
   293  typedef union pthread_attr_t pthread_attr_t;
   294  #  define __have_pthread_attr_t	1
   295  # endif
   296  
   297  typedef struct sigevent {
   298  	sigval_t sigev_value;
   299  	int sigev_signo;
   300  	int sigev_notify;
   301  
   302  	union {
   303  		int _pad[__SIGEV_PAD_SIZE];
   304  
   305  		/* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the
   306  		   thread to receive the signal.  */
   307  		__pid_t _tid;
   308  
   309  		struct {
   310  			void (*_function) (sigval_t);	/* Function to start.  */
   311  			pthread_attr_t *_attribute;	/* Thread attributes.  */
   312  		} _sigev_thread;
   313  	} _sigev_un;
   314  } sigevent_t;
   315  
   316  /* POSIX names to access some of the members.  */
   317  # define sigev_notify_function   _sigev_un._sigev_thread._function
   318  # define sigev_notify_attributes _sigev_un._sigev_thread._attribute
   319  
   320  /* `sigev_notify' values.  */
   321  enum {
   322  	SIGEV_SIGNAL = 0,	/* Notify via signal.  */
   323  # define SIGEV_SIGNAL	SIGEV_SIGNAL
   324  	SIGEV_NONE,		/* Other notification: meaningless.  */
   325  # define SIGEV_NONE	SIGEV_NONE
   326  	SIGEV_THREAD,		/* Deliver via thread creation.  */
   327  # define SIGEV_THREAD	SIGEV_THREAD
   328  
   329  	SIGEV_THREAD_ID = 4	/* Send signal to specific thread.  */
   330  #define SIGEV_THREAD_ID	SIGEV_THREAD_ID
   331  };
   332  
   333  #endif				/* have _SIGNAL_H.  */