Back to index

glibc  2.9
siginfo.h
Go to the documentation of this file.
00001 /* siginfo_t, sigevent and constants.  Linux/ia64 version.
00002    Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
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 #if (!defined __have_sigval_t \
00027      && (defined _SIGNAL_H || defined __need_siginfo_t \
00028         || defined __need_sigevent_t))
00029 # define __have_sigval_t    1
00030 
00031 /* Type for data associated with a signal.  */
00032 typedef union sigval
00033   {
00034     int sival_int;
00035     void *sival_ptr;
00036   } sigval_t;
00037 #endif
00038 
00039 #if (!defined __have_siginfo_t \
00040      && (defined _SIGNAL_H || defined __need_siginfo_t))
00041 # define __have_siginfo_t   1
00042 
00043 # define __SI_MAX_SIZE     128
00044 # define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
00045 
00046 typedef struct siginfo
00047   {
00048     int si_signo;           /* Signal number.  */
00049     int si_errno;           /* If non-zero, an errno value associated with
00050                                this signal, as defined in <errno.h>.  */
00051     int si_code;            /* Signal code.  */
00052     int __pad0;                    /* Explicit padding.  */
00053 
00054     union
00055       {
00056        int _pad[__SI_PAD_SIZE];
00057 
00058         /* kill().  */
00059        struct
00060          {
00061            __pid_t si_pid;  /* Sending process ID.  */
00062            __uid_t si_uid;  /* Real user ID of sending process.  */
00063          } _kill;
00064 
00065        /* POSIX.1b timers.  */
00066        struct
00067          {
00068            int si_tid;             /* Timer ID.  */
00069            int si_overrun;  /* Overrun count.  */
00070            sigval_t si_sigval;     /* Signal value.  */
00071          } _timer;
00072 
00073        /* POSIX.1b signals.  */
00074        struct
00075          {
00076            __pid_t si_pid;  /* Sending process ID.  */
00077            __uid_t si_uid;  /* Real user ID of sending process.  */
00078            sigval_t si_sigval;     /* Signal value.  */
00079          } _rt;
00080 
00081        /* SIGCHLD.  */
00082        struct
00083          {
00084            __pid_t si_pid;  /* Which child.  */
00085            __uid_t si_uid;  /* Real user ID of sending process.  */
00086            int si_status;   /* Exit value or signal.  */
00087            __clock_t si_utime;
00088            __clock_t si_stime;
00089          } _sigchld;
00090 
00091        /* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */
00092        struct
00093          {
00094            void *si_addr;   /* Faulting insn/memory ref.  */
00095            int _si_imm;
00096            unsigned int _si_flags;
00097            unsigned long int _si_isr;
00098          } _sigfault;
00099 
00100        /* SIGPOLL.  */
00101        struct
00102          {
00103            long int si_band;       /* Band event for SIGPOLL.  */
00104            int si_fd;
00105          } _sigpoll;
00106       } _sifields;
00107   } siginfo_t;
00108 
00109 
00110 /* X/Open requires some more fields with fixed names.  */
00111 # define si_pid             _sifields._kill.si_pid
00112 # define si_uid             _sifields._kill.si_uid
00113 # define si_timerid  _sifields._timer.si_tid
00114 # define si_overrun  _sifields._timer.si_overrun
00115 # define si_status   _sifields._sigchld.si_status
00116 # define si_utime    _sifields._sigchld.si_utime
00117 # define si_stime    _sifields._sigchld.si_stime
00118 # define si_value    _sifields._rt.si_sigval
00119 # define si_int             _sifields._rt.si_sigval.sival_int
00120 # define si_ptr             _sifields._rt.si_sigval.sival_ptr
00121 # define si_addr     _sifields._sigfault.si_addr
00122 # define si_band     _sifields._sigpoll.si_band
00123 # define si_fd              _sifields._sigpoll.si_fd
00124 
00125 # ifdef __USE_GNU
00126 #  define si_imm     _sifields._sigfault._si_imm
00127 #  define si_segvflags      _sifields._sigfault._si_flags
00128 #  define si_isr     _sifields._sigfault._si_isr
00129 # endif
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_ASYNCIO,               /* Sent by AIO completion.  */
00142 # define SI_ASYNCIO  SI_ASYNCIO
00143   SI_MESGQ,                 /* Sent by real time mesq state change.  */
00144 # define SI_MESGQ    SI_MESGQ
00145   SI_TIMER,                 /* Sent by timer expiration.  */
00146 # define SI_TIMER    SI_TIMER
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   ILL_BADIADDR                     /* Unimplemented instruction address. */
00176 # define ILL_BADIADDR       ILL_BADIADDR
00177 
00178 # ifdef __USE_GNU
00179    , ILL_BREAK
00180 #  define ILL_BREAK  ILL_BREAK
00181 # endif
00182 };
00183 
00184 /* `si_code' values for SIGFPE signal.  */
00185 enum
00186 {
00187   FPE_INTDIV = 1,           /* Integer divide by zero.  */
00188 # define FPE_INTDIV  FPE_INTDIV
00189   FPE_INTOVF,               /* Integer overflow.  */
00190 # define FPE_INTOVF  FPE_INTOVF
00191   FPE_FLTDIV,               /* Floating point divide by zero.  */
00192 # define FPE_FLTDIV  FPE_FLTDIV
00193   FPE_FLTOVF,               /* Floating point overflow.  */
00194 # define FPE_FLTOVF  FPE_FLTOVF
00195   FPE_FLTUND,               /* Floating point underflow.  */
00196 # define FPE_FLTUND  FPE_FLTUND
00197   FPE_FLTRES,               /* Floating point inexact result.  */
00198 # define FPE_FLTRES  FPE_FLTRES
00199   FPE_FLTINV,               /* Floating point invalid operation.  */
00200 # define FPE_FLTINV  FPE_FLTINV
00201   FPE_FLTSUB                /* Subscript out of range.  */
00202 # define FPE_FLTSUB  FPE_FLTSUB
00203 # ifdef __USE_GNU
00204    , FPE_DECOVF
00205 #  define FPE_DECOVF FPE_DECOVF
00206    , FPE_DECDIV
00207 #  define FPE_DECDIV FPE_DECDIV
00208    , FPE_DECERR
00209 #  define FPE_DECERR FPE_DECERR
00210    , FPE_INVASC
00211 #  define FPE_INVASC FPE_INVASC
00212    , FPE_INVDEC
00213 #  define FPE_INVDEC FPE_INVDEC
00214 # endif
00215 };
00216 
00217 /* `si_code' values for SIGSEGV signal.  */
00218 enum
00219 {
00220   SEGV_MAPERR = 1,          /* Address not mapped to object.  */
00221 # define SEGV_MAPERR SEGV_MAPERR
00222   SEGV_ACCERR               /* Invalid permissions for mapped object.  */
00223 # define SEGV_ACCERR SEGV_ACCERR
00224 # ifdef __USE_GNU
00225   , SEGV_PSTKOVF            /* Paragraph stack overflow. */
00226 # define SEGV_PSTKOVF       SEGV_PSTKOVF
00227 # endif
00228 };
00229 
00230 /* `si_code' values for SIGBUS signal.  */
00231 enum
00232 {
00233   BUS_ADRALN = 1,           /* Invalid address alignment.  */
00234 # define BUS_ADRALN  BUS_ADRALN
00235   BUS_ADRERR,               /* Non-existant physical address.  */
00236 # define BUS_ADRERR  BUS_ADRERR
00237   BUS_OBJERR                /* Object specific hardware error.  */
00238 # define BUS_OBJERR  BUS_OBJERR
00239 };
00240 
00241 /* `si_code' values for SIGTRAP signal.  */
00242 enum
00243 {
00244   TRAP_BRKPT = 1,           /* Process breakpoint.  */
00245 # define TRAP_BRKPT  TRAP_BRKPT
00246   TRAP_TRACE                /* Process trace trap.  */
00247 # define TRAP_TRACE  TRAP_TRACE
00248 
00249 # ifdef __USE_GNU
00250   , TRAP_BRANCH
00251 # define TRAP_BRANCH TRAP_BRANCH
00252   , TRAP_HWBKPT
00253 # define TRAP_HWBKPT TRAP_HWBKPT
00254 # endif
00255 };
00256 
00257 /* `si_code' values for SIGCHLD signal.  */
00258 enum
00259 {
00260   CLD_EXITED = 1,           /* Child has exited.  */
00261 # define CLD_EXITED  CLD_EXITED
00262   CLD_KILLED,               /* Child was killed.  */
00263 # define CLD_KILLED  CLD_KILLED
00264   CLD_DUMPED,               /* Child terminated abnormally.  */
00265 # define CLD_DUMPED  CLD_DUMPED
00266   CLD_TRAPPED,                     /* Traced child has trapped.  */
00267 # define CLD_TRAPPED CLD_TRAPPED
00268   CLD_STOPPED,                     /* Child has stopped.  */
00269 # define CLD_STOPPED CLD_STOPPED
00270   CLD_CONTINUED                    /* Stopped child has continued.  */
00271 # define CLD_CONTINUED      CLD_CONTINUED
00272 };
00273 
00274 /* `si_code' values for SIGPOLL signal.  */
00275 enum
00276 {
00277   POLL_IN = 1,                     /* Data input available.  */
00278 # define POLL_IN     POLL_IN
00279   POLL_OUT,                 /* Output buffers available.  */
00280 # define POLL_OUT    POLL_OUT
00281   POLL_MSG,                 /* Input message available.   */
00282 # define POLL_MSG    POLL_MSG
00283   POLL_ERR,                 /* I/O error.  */
00284 # define POLL_ERR    POLL_ERR
00285   POLL_PRI,                 /* High priority input available.  */
00286 # define POLL_PRI    POLL_PRI
00287   POLL_HUP                  /* Device disconnected.  */
00288 # define POLL_HUP    POLL_HUP
00289 };
00290 
00291 # undef __need_siginfo_t
00292 #endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t).  */
00293 
00294 
00295 #if (defined _SIGNAL_H || defined __need_sigevent_t) \
00296     && !defined __have_sigevent_t
00297 # define __have_sigevent_t  1
00298 
00299 /* Structure to transport application-defined values with signals.  */
00300 # define __SIGEV_MAX_SIZE   64
00301 # define __SIGEV_PAD_SIZE   ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
00302 
00303 typedef struct sigevent
00304   {
00305     sigval_t sigev_value;
00306     int sigev_signo;
00307     int sigev_notify;
00308 
00309     union
00310       {
00311        int _pad[__SIGEV_PAD_SIZE];
00312 
00313        struct
00314          {
00315            void (*_function) (sigval_t);  /* Function to start.  */
00316            void *_attribute;                     /* Really pthread_attr_t.  */
00317          } _sigev_thread;
00318       } _sigev_un;
00319   } sigevent_t;
00320 
00321 /* POSIX names to access some of the members.  */
00322 # define sigev_notify_function   _sigev_un._sigev_thread._function
00323 # define sigev_notify_attributes _sigev_un._sigev_thread._attribute
00324 
00325 /* `sigev_notify' values.  */
00326 enum
00327 {
00328   SIGEV_SIGNAL = 0,         /* Notify via signal.  */
00329 # define SIGEV_SIGNAL       SIGEV_SIGNAL
00330   SIGEV_NONE,               /* Other notification: meaningless.  */
00331 # define SIGEV_NONE  SIGEV_NONE
00332   SIGEV_THREAD,                    /* Deliver via thread creation.  */
00333 # define SIGEV_THREAD       SIGEV_THREAD
00334 
00335   SIGEV_THREAD_ID = 4              /* Send signal to specific thread.  */
00336 #define SIGEV_THREAD_ID     SIGEV_THREAD_ID
00337 };
00338 
00339 #endif /* have _SIGNAL_H.  */