blob: dc803dc1505a9cfc7dea36d81e94bbeb28b196c3 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* siginfo_t, sigevent and constants. Stub version.
2 Copyright (C) 1997-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#if (!defined __have_sigval_t \
25 && (defined _SIGNAL_H || defined __need_siginfo_t \
26 || defined __need_sigevent_t))
27# define __have_sigval_t 1
28
29/* Type for data associated with a signal. */
30typedef union sigval
31 {
32 int sival_int;
33 void *sival_ptr;
34 } sigval_t;
35#endif
36
37#if (!defined __have_siginfo_t \
38 && (defined _SIGNAL_H || defined __need_siginfo_t))
39# define __have_siginfo_t 1
40
41typedef struct siginfo
42 {
43 int si_signo; /* Signal number. */
44 int si_errno; /* If non-zero, an errno value associated with
45 this signal, as defined in <errno.h>. */
46 int si_code; /* Signal code. */
47 __pid_t si_pid; /* Sending process ID. */
48 __uid_t si_uid; /* Real user ID of sending process. */
49 void *si_addr; /* Address of faulting instruction. */
50 int si_status; /* Exit value or signal. */
51 long int si_band; /* Band event for SIGPOLL. */
52 union sigval si_value; /* Signal value. */
53 } siginfo_t;
54
55
56/* Values for `si_code'. Positive values are reserved for kernel-generated
57 signals. */
58enum
59{
60 SI_ASYNCIO = -4, /* Sent by AIO completion. */
61# define SI_ASYNCIO SI_ASYNCIO
62 SI_MESGQ, /* Sent by real time mesq state change. */
63# define SI_MESGQ SI_MESGQ
64 SI_TIMER, /* Sent by timer expiration. */
65# define SI_TIMER SI_TIMER
66 SI_QUEUE, /* Sent by sigqueue. */
67# define SI_QUEUE SI_QUEUE
68 SI_USER /* Sent by kill, sigsend, raise. */
69# define SI_USER SI_USER
70};
71
72
73# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
74/* `si_code' values for SIGILL signal. */
75enum
76{
77 ILL_ILLOPC = 1, /* Illegal opcode. */
78# define ILL_ILLOPC ILL_ILLOPC
79 ILL_ILLOPN, /* Illegal operand. */
80# define ILL_ILLOPN ILL_ILLOPN
81 ILL_ILLADR, /* Illegal addressing mode. */
82# define ILL_ILLADR ILL_ILLADR
83 ILL_ILLTRP, /* Illegal trap. */
84# define ILL_ILLTRP ILL_ILLTRP
85 ILL_PRVOPC, /* Privileged opcode. */
86# define ILL_PRVOPC ILL_PRVOPC
87 ILL_PRVREG, /* Privileged register. */
88# define ILL_PRVREG ILL_PRVREG
89 ILL_COPROC, /* Coprocessor error. */
90# define ILL_COPROC ILL_COPROC
91 ILL_BADSTK /* Internal stack error. */
92# define ILL_BADSTK ILL_BADSTK
93};
94
95/* `si_code' values for SIGFPE signal. */
96enum
97{
98 FPE_INTDIV = 1, /* Integer divide by zero. */
99# define FPE_INTDIV FPE_INTDIV
100 FPE_INTOVF, /* Integer overflow. */
101# define FPE_INTOVF FPE_INTOVF
102 FPE_FLTDIV, /* Floating point divide by zero. */
103# define FPE_FLTDIV FPE_FLTDIV
104 FPE_FLTOVF, /* Floating point overflow. */
105# define FPE_FLTOVF FPE_FLTOVF
106 FPE_FLTUND, /* Floating point underflow. */
107# define FPE_FLTUND FPE_FLTUND
108 FPE_FLTRES, /* Floating point inexact result. */
109# define FPE_FLTRES FPE_FLTRES
110 FPE_FLTINV, /* Floating point invalid operation. */
111# define FPE_FLTINV FPE_FLTINV
112 FPE_FLTSUB /* Subscript out of range. */
113# define FPE_FLTSUB FPE_FLTSUB
114};
115
116/* `si_code' values for SIGSEGV signal. */
117enum
118{
119 SEGV_MAPERR = 1, /* Address not mapped to object. */
120# define SEGV_MAPERR SEGV_MAPERR
121 SEGV_ACCERR /* Invalid permissions for mapped object. */
122# define SEGV_ACCERR SEGV_ACCERR
123};
124
125/* `si_code' values for SIGBUS signal. */
126enum
127{
128 BUS_ADRALN = 1, /* Invalid address alignment. */
129# define BUS_ADRALN BUS_ADRALN
130 BUS_ADRERR, /* Non-existant physical address. */
131# define BUS_ADRERR BUS_ADRERR
132 BUS_OBJERR /* Object specific hardware error. */
133# define BUS_OBJERR BUS_OBJERR
134};
135# endif
136
137# ifdef __USE_XOPEN_EXTENDED
138/* `si_code' values for SIGTRAP signal. */
139enum
140{
141 TRAP_BRKPT = 1, /* Process breakpoint. */
142# define TRAP_BRKPT TRAP_BRKPT
143 TRAP_TRACE /* Process trace trap. */
144# define TRAP_TRACE TRAP_TRACE
145};
146# endif
147
148# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
149/* `si_code' values for SIGCHLD signal. */
150enum
151{
152 CLD_EXITED = 1, /* Child has exited. */
153# define CLD_EXITED CLD_EXITED
154 CLD_KILLED, /* Child was killed. */
155# define CLD_KILLED CLD_KILLED
156 CLD_DUMPED, /* Child terminated abnormally. */
157# define CLD_DUMPED CLD_DUMPED
158 CLD_TRAPPED, /* Traced child has trapped. */
159# define CLD_TRAPPED CLD_TRAPPED
160 CLD_STOPPED, /* Child has stopped. */
161# define CLD_STOPPED CLD_STOPPED
162 CLD_CONTINUED /* Stopped child has continued. */
163# define CLD_CONTINUED CLD_CONTINUED
164};
165
166/* `si_code' values for SIGPOLL signal. */
167enum
168{
169 POLL_IN = 1, /* Data input available. */
170# define POLL_IN POLL_IN
171 POLL_OUT, /* Output buffers available. */
172# define POLL_OUT POLL_OUT
173 POLL_MSG, /* Input message available. */
174# define POLL_MSG POLL_MSG
175 POLL_ERR, /* I/O error. */
176# define POLL_ERR POLL_ERR
177 POLL_PRI, /* High priority input available. */
178# define POLL_PRI POLL_PRI
179 POLL_HUP /* Device disconnected. */
180# define POLL_HUP POLL_HUP
181};
182# endif
183
184# undef __need_siginfo_t
185#endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t). */
186
187
188#if (defined _SIGNAL_H || defined __need_sigevent_t) \
189 && !defined __have_sigevent_t
190# define __have_sigevent_t 1
191
192/* Structure to transport application-defined values with signals. */
193# define SIGEV_MAX_SIZE 64
194# define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE / sizeof (int)) - 3)
195
196typedef struct sigevent
197 {
198 sigval_t sigev_value;
199 int sigev_signo;
200 int sigev_notify;
201 void (*sigev_notify_function) (sigval_t); /* Function to start. */
202 void *sigev_notify_attributes; /* Really pthread_attr_t.*/
203 } sigevent_t;
204
205/* `sigev_notify' values. */
206enum
207{
208 SIGEV_SIGNAL = 0, /* Notify via signal. */
209# define SIGEV_SIGNAL SIGEV_SIGNAL
210 SIGEV_NONE, /* Other notification: meaningless. */
211# define SIGEV_NONE SIGEV_NONE
212 SIGEV_THREAD /* Deliver via thread creation. */
213# define SIGEV_THREAD SIGEV_THREAD
214};
215
216#endif /* have _SIGNAL_H. */