Update.
[jlayton/glibc.git] / sysdeps / unix / sysv / linux / bits / siginfo.h
1 /* siginfo_t, sigevent and constants.  Linux version.
2    Copyright (C) 1997 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 Library General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    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    Library General Public License for more details.
14
15    You should have received a copy of the GNU Library General Public
16    License along with the GNU C Library; see the file COPYING.LIB.  If not,
17    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18    Boston, MA 02111-1307, USA.  */
19
20 #ifndef _SIGNAL_H
21 # error "Never include this file directly.  Use <signal.h> instead"
22 #endif
23
24 #define SI_MAX_SIZE     128
25 #define SI_PAD_SIZE     ((SI_MAX_SIZE / sizeof (int)) - 3)
26
27 typedef struct siginfo
28   {
29     int si_signo;               /* Signal number.  */
30     int si_errno;               /* If non-zero, an errno value associated with
31                                    this signal, as defined in <errno.h>.  */
32     int si_code;                /* Signal code.  */
33
34     union
35       {
36         int _pad[SI_PAD_SIZE];
37
38          /* kill().  */
39         struct
40           {
41             __pid_t si_pid;     /* Sending process ID.  */
42             __uid_t si_uid;     /* Real user ID of sending process.  */
43           } _kill;
44
45         /* POSIX.1b timers.  */
46         struct
47           {
48             unsigned int _timer1;
49             unsigned int _timer2;
50           } _timer;
51
52         /* POSIX.1b signals.  */
53         struct
54           {
55             __pid_t si_pid;     /* Sending process ID.  */
56             __uid_t si_uid;     /* Real user ID of sending process.  */
57             sigval_t si_sigval; /* Signal value.  */
58           } _rt;
59
60         /* SIGCHLD.  */
61         struct
62           {
63             __pid_t si_pid;     /* Which child.  */
64             int si_status;      /* Exit value or signal.  */
65             __clock_t si_utime;
66             __clock_t si_stime;
67           } _sigchld;
68
69         /* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */
70         struct
71           {
72             void *si_addr;      /* Faulting insn/memory ref.  */
73           } _sigfault;
74
75         /* SIGPOLL.  */
76         struct
77           {
78             int si_band;        /* Band event for SIGPOLL.  */
79             int si_fd;
80           } _sigpoll;
81       } _sifields;
82   } siginfo_t;
83
84
85 /* X/Open requires some more fields with fixed names.  */
86 #define si_pid          _sifields._kill.si_pid
87 #define si_uid          _sifields._kill.si_uid
88 #define si_status       _sifields._sigchld.si_status
89 #define si_utime        _sifields._sigchld.si_utime
90 #define si_stime        _sifields._sigchld.si_stime
91 #define si_value        _sifields._rt.si_sigval
92 #define si_int          _sifields._rt.si_sigval.sival_int
93 #define si_ptr          _sifields._rt.si_sigval.sival_ptr
94 #define si_addr         _sifields._sigfault.si_addr
95 #define si_band         _sifields._sigpoll.si_band
96 #define si_fd           _sifields._sigpoll.si_fd
97
98
99 /* Values for `si_code'.  Positive values are reserved for kernel-generated
100    signals.  */
101 enum
102 {
103   SI_ASYNCIO = -4,              /* Sent by AIO completion.  */
104 #define SI_ASYNCIO      SI_ASYNCIO
105   SI_MESGQ,                     /* Sent by real time mesq state change.  */
106 #define SI_MESGQ        SI_MESGQ
107   SI_TIMER,                     /* Sent by timer expiration.  */
108 #define SI_TIMER        SI_TIMER
109   SI_QUEUE,                     /* Sent by sigqueue.  */
110 #define SI_QUEUE        SI_QUEUE
111   SI_USER                       /* Sent by kill, sigsend, raise.  */
112 #define SI_USER         SI_USER
113 };
114
115
116 /* `si_code' values for SIGILL signal.  */
117 enum
118 {
119   ILL_ILLOPC = 1,               /* Illegal opcode.  */
120 #define ILL_ILLOPC      ILL_ILLOPC
121   ILL_ILL_OPN,                  /* Illegal operand.  */
122 #define ILL_ILLOPN      ILL_ILLOPN
123   ILL_ILLADR,                   /* Illegal addressing mode.  */
124 #define ILL_ILLADR      ILL_ILLADR
125   ILL_ILLTRP,                   /* Illegal trap. */
126 #define ILL_ILLTRP      ILL_ILLTRP
127   ILL_PRVOPC,                   /* Privileged opcode.  */
128 #define ILL_PRVOPC      ILL_PRVOPC
129   ILL_PRVREG,                   /* Privileged register.  */
130 #define ILL_PRVREG      ILL_PRVREG
131   ILL_COPROC,                   /* Coprocessor error.  */
132 #define ILL_COPROC      ILL_COPROC
133   ILL_BADSTK                    /* Internal stack error.  */
134 #define ILL_BADSTK      ILL_BADSTK
135 };
136
137 /* `si_code' values for SIGFPE signal.  */
138 enum
139 {
140   FPE_INTDIV = 1,               /* Integer divide by zero.  */
141 #define FPE_INTDIV      FPE_INTDIV
142   FPE_INTOVF,                   /* Integer overflow.  */
143 #define FPE_INTOVF      FPE_INTOVF
144   FPE_FLTDIV,                   /* Floating point divide by zero.  */
145 #define FPE_FLTDIV      FPE_FLTDIV
146   FPE_FLTOVF,                   /* Floating point overflow.  */
147 #define FPE_FLTOVF      FPE_FLTOVF
148   FPE_FLTUND,                   /* Floating point underflow.  */
149 #define FPE_FLTUND      FPE_FLTUND
150   FPE_FLTRES,                   /* Floating point inexact result.  */
151 #define FPE_FLTRES      FPE_FLTRES
152   FPE_FLTINV,                   /* Floating point invalid operation.  */
153 #define FPE_FLTINV      FPE_FLTINV
154   FPE_FLTSUB                    /* Subscript out of range.  */
155 #define FPE_FLTSUB      FPE_FLTSUB
156 };
157
158 /* `si_code' values for SIGSEGV signal.  */
159 enum
160 {
161   SEGV_MAPERR = 1,              /* Address not mapped to object.  */
162 #define SEGV_MAPERR     SEGV_MAPERR
163   SEGV_ACCERR                   /* Invalid permissions for mapped object.  */
164 #define SEGV_ACCERR     SEGV_ACCERR
165 };
166
167 /* `si_code' values for SIGBUS signal.  */
168 enum
169 {
170   BUS_ADRALN = 1,               /* Invalid address alignment.  */
171 #define BUS_ADRALN      BUS_ADRALN
172   BUS_ADRERR,                   /* Non-existant physical address.  */
173 #define BUS_ADRERR      BUS_ADRERR
174   BUS_OBJERR                    /* Object specific hardware error.  */
175 #define BUS_OBJERR      BUS_OBJERR
176 };
177
178 /* `si_code' values for SIGTRAP signal.  */
179 enum
180 {
181   TRAP_BRKPT = 1,               /* Process breakpoint.  */
182 #define TRAP_BRKPT      TRAP_BRKPT
183   TRAP_TRACE                    /* Process trace trap.  */
184 #define TRAP_TRACE      TRAP_TRACE
185 };
186
187 /* `si_code' values for SIGCHLD signal.  */
188 enum
189 {
190   CLD_EXITED = 1,               /* Child has exited.  */
191 #define CLD_EXITED      CLD_EXITED
192   CLD_KILLED,                   /* Child was killed.  */
193 #define CLD_KILLED      CLD_KILLED
194   CLD_DUMPED,                   /* Child terminated abnormally.  */
195 #define CLD_DUMPED      CLD_DUMPED
196   CLD_TRAPPED,                  /* Traced child has trapped.  */
197 #define CLD_TRAPPED     CLD_TRAPPED
198   CLD_STOPPED,                  /* Child has stopped.  */
199 #define CLD_STOPPED     CLD_STOPPED
200   CLD_CONTINUED                 /* Stopped child has continued.  */
201 #define CLD_CONTINUED   CLD_CONTINUED
202 };
203
204 /* `si_code' values for SIGPOLL signal.  */
205 enum
206 {
207   POLL_IN = 1,                  /* Data input available.  */
208 #define POLL_IN         POLL_IN
209   POLL_OUT,                     /* Output buffers available.  */
210 #define POLL_OUT        POLL_OUT
211   POLL_MSG,                     /* Input message available.   */
212 #define POLL_MSG        POLL_MSG
213   POLL_ERR,                     /* I/O error.  */
214 #define POLL_ERR        POLL_ERR
215   POLL_PRI,                     /* High priority input available.  */
216 #define POLL_PRI        POLL_PRI
217   POLL_HUP                      /* Device disconnected.  */
218 #define POLL_HUP        POLL_HUP
219 };
220
221
222 /* Structure to transport application-defined values with signals.  */
223 #define SIGEV_MAX_SIZE  64
224 #define SIGEV_PAD_SIZE  ((SIGEV_MAX_SIZE / sizeof (int)) - 3)
225
226 typedef struct sigevent
227   {
228     sigval_t sigev_value;
229     int sigev_signo;
230     int sigev_notify;
231
232     union
233       {
234         int _pad[SIGEV_PAD_SIZE];
235
236         struct
237           {
238             void (*_function) __P ((sigval_t)); /* Function to start.  */
239             void *_attribute;                   /* Really pthread_attr_t.  */
240           } _sigev_thread;
241       } _sigev_un;
242   } sigevent_t;
243
244 /* POSIX names to access some of the members.  */
245 #define sigev_notify_function   _sigev_un._sigev_thread._function
246 #define sigev_notify_attributes _sigev_un._sigev_thread._attribute
247
248 /* `sigev_notify' values.  */
249 enum
250 {
251   SIGEV_SIGNAL = 0,             /* Notify via signal.  */
252 #define SIGEV_SIGNAL    SIGEV_SIGNAL
253   SIGEV_NONE,                   /* Other notification: meaningless.  */
254 #define SIGEV_NONE      SIGEV_NONE
255   SIGEV_THREAD                  /* Deliver via thread creation.  */
256 #define SIGEV_THREAD    SIGEV_THREAD
257 };