Back to index

glibc  2.9
siginfo.h
Go to the documentation of this file.
00001 /* siginfo_t, sigevent and constants.  Linux/MIPS version.
00002    Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008
00003        Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #if !defined _SIGNAL_H && !defined __need_siginfo_t \
00022     && !defined __need_sigevent_t
00023 # error "Never include this file directly.  Use <signal.h> instead"
00024 #endif
00025 
00026 #include <bits/wordsize.h>
00027 
00028 #if (!defined __have_sigval_t \
00029      && (defined _SIGNAL_H || defined __need_siginfo_t \
00030         || defined __need_sigevent_t))
00031 # define __have_sigval_t    1
00032 
00033 /* Type for data associated with a signal.  */
00034 typedef union sigval
00035   {
00036     int sival_int;
00037     void *sival_ptr;
00038   } sigval_t;
00039 #endif
00040 
00041 #if (!defined __have_siginfo_t \
00042      && (defined _SIGNAL_H || defined __need_siginfo_t))
00043 # define __have_siginfo_t   1
00044 
00045 # define __SI_MAX_SIZE             128
00046 # if __WORDSIZE == 64
00047 #  define __SI_PAD_SIZE            ((__SI_MAX_SIZE / sizeof (int)) - 4)
00048 # else
00049 #  define __SI_PAD_SIZE            ((__SI_MAX_SIZE / sizeof (int)) - 3)
00050 # endif
00051 
00052 
00053 typedef struct siginfo
00054   {
00055     int si_signo;           /* Signal number.  */
00056     int si_code;            /* Signal code.  */
00057     int si_errno;           /* If non-zero, an errno value associated with
00058                                this signal, as defined in <errno.h>.  */
00059     int __pad0[__SI_MAX_SIZE / sizeof (int) - __SI_PAD_SIZE - 3];
00060                             /* Explicit padding.  */
00061 
00062     union
00063       {
00064        int _pad[__SI_PAD_SIZE];
00065 
00066         /* kill().  */
00067        struct
00068          {
00069            __pid_t si_pid;  /* Sending process ID.  */
00070            __uid_t si_uid;  /* Real user ID of sending process.  */
00071          } _kill;
00072 
00073        /* POSIX.1b timers.  */
00074        struct
00075          {
00076            int si_tid;             /* Timer ID.  */
00077            int si_overrun;  /* Overrun count.  */
00078            sigval_t si_sigval;     /* Signal value.  */
00079          } _timer;
00080 
00081        /* POSIX.1b signals.  */
00082        struct
00083          {
00084            __pid_t si_pid;  /* Sending process ID.  */
00085            __uid_t si_uid;  /* Real user ID of sending process.  */
00086            sigval_t si_sigval;     /* Signal value.  */
00087          } _rt;
00088 
00089        /* SIGCHLD.  */
00090        struct
00091          {
00092            __pid_t si_pid;  /* Which child.  */
00093            __uid_t si_uid;  /* Real user ID of sending process.  */
00094            int si_status;   /* Exit value or signal.  */
00095            __clock_t si_utime;
00096            __clock_t si_stime;
00097          } _sigchld;
00098 
00099        /* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */
00100        struct
00101          {
00102            void *si_addr;   /* Faulting insn/memory ref.  */
00103          } _sigfault;
00104 
00105        /* SIGPOLL.  */
00106        struct
00107          {
00108            long int si_band;       /* Band event for SIGPOLL.  */
00109            int si_fd;
00110          } _sigpoll;
00111       } _sifields;
00112   } siginfo_t;
00113 
00114 
00115 /* X/Open requires some more fields with fixed names.  */
00116 # define si_pid             _sifields._kill.si_pid
00117 # define si_uid             _sifields._kill.si_uid
00118 # define si_timerid  _sifields._timer.si_tid
00119 # define si_overrun  _sifields._timer.si_overrun
00120 # define si_status   _sifields._sigchld.si_status
00121 # define si_utime    _sifields._sigchld.si_utime
00122 # define si_stime    _sifields._sigchld.si_stime
00123 # define si_value    _sifields._rt.si_sigval
00124 # define si_int             _sifields._rt.si_sigval.sival_int
00125 # define si_ptr             _sifields._rt.si_sigval.sival_ptr
00126 # define si_addr     _sifields._sigfault.si_addr
00127 # define si_band     _sifields._sigpoll.si_band
00128 # define si_fd              _sifields._sigpoll.si_fd
00129 
00130 
00131 /* Values for `si_code'.  Positive values are reserved for kernel-generated
00132    signals.  */
00133 enum
00134 {
00135   SI_ASYNCNL = -60,         /* Sent by asynch name lookup completion.  */
00136 # define SI_ASYNCNL  SI_ASYNCNL
00137   SI_TKILL = -6,            /* Sent by tkill.  */
00138 # define SI_TKILL    SI_TKILL
00139   SI_SIGIO,                 /* Sent by queued SIGIO.  */
00140 # define SI_SIGIO    SI_SIGIO
00141   SI_MESGQ,                 /* Sent by real time mesq state change.  */
00142 # define SI_MESGQ    SI_MESGQ
00143   SI_TIMER,                 /* Sent by real time mesq state change.  */
00144 # define SI_TIMER    SI_TIMER
00145   SI_ASYNCIO,               /* Sent by AIO completion.  */
00146 # define SI_ASYNCIO  SI_ASYNCIO
00147   SI_QUEUE,                 /* Sent by sigqueue.  */
00148 # define SI_QUEUE    SI_QUEUE
00149   SI_USER,                  /* Sent by kill, sigsend, raise.  */
00150 # define SI_USER     SI_USER
00151   SI_KERNEL = 0x80          /* Send by kernel.  */
00152 #define SI_KERNEL    SI_KERNEL
00153 };
00154 
00155 
00156 /* `si_code' values for SIGILL signal.  */
00157 enum
00158 {
00159   ILL_ILLOPC = 1,           /* Illegal opcode.  */
00160 # define ILL_ILLOPC  ILL_ILLOPC
00161   ILL_ILLOPN,               /* Illegal operand.  */
00162 # define ILL_ILLOPN  ILL_ILLOPN
00163   ILL_ILLADR,               /* Illegal addressing mode.  */
00164 # define ILL_ILLADR  ILL_ILLADR
00165   ILL_ILLTRP,               /* Illegal trap.  */
00166 # define ILL_ILLTRP  ILL_ILLTRP
00167   ILL_PRVOPC,               /* Privileged opcode.  */
00168 # define ILL_PRVOPC  ILL_PRVOPC
00169   ILL_PRVREG,               /* Privileged register.  */
00170 # define ILL_PRVREG  ILL_PRVREG
00171   ILL_COPROC,               /* Coprocessor error.  */
00172 # define ILL_COPROC  ILL_COPROC
00173   ILL_BADSTK                /* Internal stack error.  */
00174 # define ILL_BADSTK  ILL_BADSTK
00175 };
00176 
00177 /* `si_code' values for SIGFPE signal.  */
00178 enum
00179 {
00180   FPE_INTDIV = 1,           /* Integer divide by zero.  */
00181 # define FPE_INTDIV  FPE_INTDIV
00182   FPE_INTOVF,               /* Integer overflow.  */
00183 # define FPE_INTOVF  FPE_INTOVF
00184   FPE_FLTDIV,               /* Floating point divide by zero.  */
00185 # define FPE_FLTDIV  FPE_FLTDIV
00186   FPE_FLTOVF,               /* Floating point overflow.  */
00187 # define FPE_FLTOVF  FPE_FLTOVF
00188   FPE_FLTUND,               /* Floating point underflow.  */
00189 # define FPE_FLTUND  FPE_FLTUND
00190   FPE_FLTRES,               /* Floating point inexact result.  */
00191 # define FPE_FLTRES  FPE_FLTRES
00192   FPE_FLTINV,               /* Floating point invalid operation.  */
00193 # define FPE_FLTINV  FPE_FLTINV
00194   FPE_FLTSUB                /* Subscript out of range.  */
00195 # define FPE_FLTSUB  FPE_FLTSUB
00196 };
00197 
00198 /* `si_code' values for SIGSEGV signal.  */
00199 enum
00200 {
00201   SEGV_MAPERR = 1,          /* Address not mapped to object.  */
00202 # define SEGV_MAPERR SEGV_MAPERR
00203   SEGV_ACCERR               /* Invalid permissions for mapped object.  */
00204 # define SEGV_ACCERR SEGV_ACCERR
00205 };
00206 
00207 /* `si_code' values for SIGBUS signal.  */
00208 enum
00209 {
00210   BUS_ADRALN = 1,           /* Invalid address alignment.  */
00211 # define BUS_ADRALN  BUS_ADRALN
00212   BUS_ADRERR,               /* Non-existant physical address.  */
00213 # define BUS_ADRERR  BUS_ADRERR
00214   BUS_OBJERR                /* Object specific hardware error.  */
00215 # define BUS_OBJERR  BUS_OBJERR
00216 };
00217 
00218 /* `si_code' values for SIGTRAP signal.  */
00219 enum
00220 {
00221   TRAP_BRKPT = 1,           /* Process breakpoint.  */
00222 # define TRAP_BRKPT  TRAP_BRKPT
00223   TRAP_TRACE                /* Process trace trap.  */
00224 # define TRAP_TRACE  TRAP_TRACE
00225 };
00226 
00227 /* `si_code' values for SIGCHLD signal.  */
00228 enum
00229 {
00230   CLD_EXITED = 1,           /* Child has exited.  */
00231 # define CLD_EXITED  CLD_EXITED
00232   CLD_KILLED,               /* Child was killed.  */
00233 # define CLD_KILLED  CLD_KILLED
00234   CLD_DUMPED,               /* Child terminated abnormally.  */
00235 # define CLD_DUMPED  CLD_DUMPED
00236   CLD_TRAPPED,                     /* Traced child has trapped.  */
00237 # define CLD_TRAPPED CLD_TRAPPED
00238   CLD_STOPPED,                     /* Child has stopped.  */
00239 # define CLD_STOPPED CLD_STOPPED
00240   CLD_CONTINUED                    /* Stopped child has continued.  */
00241 # define CLD_CONTINUED      CLD_CONTINUED
00242 };
00243 
00244 /* `si_code' values for SIGPOLL signal.  */
00245 enum
00246 {
00247   POLL_IN = 1,                     /* Data input available.  */
00248 # define POLL_IN     POLL_IN
00249   POLL_OUT,                 /* Output buffers available.  */
00250 # define POLL_OUT    POLL_OUT
00251   POLL_MSG,                 /* Input message available.   */
00252 # define POLL_MSG    POLL_MSG
00253   POLL_ERR,                 /* I/O error.  */
00254 # define POLL_ERR    POLL_ERR
00255   POLL_PRI,                 /* High priority input available.  */
00256 # define POLL_PRI    POLL_PRI
00257   POLL_HUP                  /* Device disconnected.  */
00258 # define POLL_HUP    POLL_HUP
00259 };
00260 
00261 # undef __need_siginfo_t
00262 #endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t).  */
00263 
00264 
00265 #if (defined _SIGNAL_H || defined __need_sigevent_t) \
00266     && !defined __have_sigevent_t
00267 # define __have_sigevent_t  1
00268 
00269 /* Structure to transport application-defined values with signals.  */
00270 # define __SIGEV_MAX_SIZE   64
00271 # if __WORDSIZE == 64
00272 #  define __SIGEV_PAD_SIZE  ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
00273 # else
00274 #  define __SIGEV_PAD_SIZE  ((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
00275 # endif
00276 
00277 typedef struct sigevent
00278   {
00279     sigval_t sigev_value;
00280     int sigev_signo;
00281     int sigev_notify;
00282 
00283     union
00284       {
00285        int _pad[__SIGEV_PAD_SIZE];
00286 
00287        /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the
00288           thread to receive the signal.  */
00289        __pid_t _tid;
00290 
00291        struct
00292          {
00293            void (*_function) (sigval_t);  /* Function to start.  */
00294            void *_attribute;                     /* Really pthread_attr_t.  */
00295          } _sigev_thread;
00296       } _sigev_un;
00297   } sigevent_t;
00298 
00299 /* POSIX names to access some of the members.  */
00300 # define sigev_notify_function   _sigev_un._sigev_thread._function
00301 # define sigev_notify_attributes _sigev_un._sigev_thread._attribute
00302 
00303 /* `sigev_notify' values.  */
00304 enum
00305 {
00306   SIGEV_SIGNAL = 0,         /* Notify via signal.  */
00307 # define SIGEV_SIGNAL       SIGEV_SIGNAL
00308   SIGEV_NONE,               /* Other notification: meaningless.  */
00309 # define SIGEV_NONE  SIGEV_NONE
00310   SIGEV_THREAD,                    /* Deliver via thread creation.  */
00311 # define SIGEV_THREAD       SIGEV_THREAD
00312 
00313   SIGEV_THREAD_ID = 4              /* Send signal to specific thread.  */
00314 #define SIGEV_THREAD_ID     SIGEV_THREAD_ID
00315 };
00316 
00317 #endif /* have _SIGNAL_H.  */