Back to index

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