OSDN Git Service

* include/cygwin/config.h (_GLIBC_EXTENSION): Define.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / include / cygwin / signal.h
1 /* signal.h
2
3   Copyright 2004, 2005, 2006, 2011 Red Hat, Inc.
4
5   This file is part of Cygwin.
6
7   This software is a copyrighted work licensed under the terms of the
8   Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9   details. */
10
11 #ifndef _CYGWIN_SIGNAL_H
12 #define _CYGWIN_SIGNAL_H
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 struct _fpstate
18 {
19   unsigned long cw;
20   unsigned long sw;
21   unsigned long tag;
22   unsigned long ipoff;
23   unsigned long cssel;
24   unsigned long dataoff;
25   unsigned long datasel;
26   unsigned char _st[80];
27   unsigned long nxst;
28 };
29
30 struct ucontext
31 {
32   unsigned long cr2;
33   unsigned long dr0;
34   unsigned long dr1;
35   unsigned long dr2;
36   unsigned long dr3;
37   unsigned long dr6;
38   unsigned long dr7;
39   struct _fpstate fpstate;
40   unsigned long gs;
41   unsigned long fs;
42   unsigned long es;
43   unsigned long ds;
44   unsigned long edi;
45   unsigned long esi;
46   unsigned long ebx;
47   unsigned long edx;
48   unsigned long ecx;
49   unsigned long eax;
50   unsigned long ebp;
51   unsigned long eip;
52   unsigned long cs;
53   unsigned long eflags;
54   unsigned long esp;
55   unsigned long ss;
56   unsigned char _internal;
57   unsigned long oldmask;
58 };
59
60 #define __COPY_CONTEXT_SIZE ((unsigned) &((struct ucontext *) 0)->_internal)
61
62 typedef union sigval
63 {
64   int sival_int;                        /* integer signal value */
65   void  *sival_ptr;                     /* pointer signal value */
66 } sigval_t;
67
68 typedef struct sigevent
69 {
70   sigval_t sigev_value;                 /* signal value */
71   int sigev_signo;                      /* signal number */
72   int sigev_notify;                     /* notification type */
73   void (*sigev_notify_function) (sigval_t); /* notification function */
74   pthread_attr_t *sigev_notify_attributes; /* notification attributes */
75 } sigevent_t;
76
77 #pragma pack(push,4)
78 struct _sigcommune
79 {
80   __uint32_t _si_code;
81   void *_si_read_handle;
82   void *_si_write_handle;
83   void *_si_process_handle;
84   __extension__ union
85   {
86     int _si_fd;
87     void *_si_pipe_fhandler;
88     char *_si_str;
89   };
90 };
91
92 typedef struct
93 {
94   int si_signo;                         /* signal number */
95   int si_code;                          /* signal code */
96   pid_t si_pid;                         /* sender's pid */
97   uid_t si_uid;                         /* sender's uid */
98   int si_errno;                         /* errno associated with signal */
99
100   __extension__ union
101   {
102     __uint32_t __pad[32];               /* plan for future growth */
103     struct _sigcommune _si_commune;     /* cygwin ipc */
104     __extension__ union
105     {
106       /* timers */
107       struct
108       {
109         union
110         {
111           struct
112           {
113             timer_t si_tid;             /* timer id */
114             unsigned int si_overrun;    /* overrun count */
115           };
116           sigval_t si_sigval;           /* signal value */
117           sigval_t si_value;            /* signal value */
118         };
119       };
120     };
121
122     /* SIGCHLD */
123     __extension__ struct
124     {
125       int si_status;                    /* exit code */
126       clock_t si_utime;                 /* user time */
127       clock_t si_stime;                 /* system time */
128     };
129
130     /* core dumping signals */
131     void *si_addr;                      /* faulting address */
132   };
133 } siginfo_t;
134 #pragma pack(pop)
135
136 enum
137 {
138   SI_USER = 0,                          /* sent by kill, raise, pthread_kill */
139   SI_ASYNCIO = 2,                       /* sent by AIO completion (currently
140                                            unimplemented) */
141   SI_MESGQ,                             /* sent by real time mesq state change
142                                            (currently unimplemented) */
143   SI_TIMER,                             /* sent by timer expiration */
144   SI_QUEUE,                             /* sent by sigqueue (currently
145                                            unimplemented) */
146   SI_KERNEL,                            /* sent by system */
147
148   ILL_ILLOPC,                           /* illegal opcode */
149   ILL_ILLOPN,                           /* illegal operand */
150   ILL_ILLADR,                           /* illegal addressing mode */
151   ILL_ILLTRP,                           /* illegal trap*/
152   ILL_PRVOPC,                           /* privileged opcode */
153   ILL_PRVREG,                           /* privileged register */
154   ILL_COPROC,                           /* coprocessor error */
155   ILL_BADSTK,                           /* internal stack error */
156
157   FPE_INTDIV,                           /* integer divide by zero */
158   FPE_INTOVF,                           /* integer overflow */
159   FPE_FLTDIV,                           /* floating point divide by zero */
160   FPE_FLTOVF,                           /* floating point overflow */
161   FPE_FLTUND,                           /* floating point underflow */
162   FPE_FLTRES,                           /* floating point inexact result */
163   FPE_FLTINV,                           /* floating point invalid operation */
164   FPE_FLTSUB,                           /* subscript out of range */
165
166   SEGV_MAPERR,                          /* address not mapped to object */
167   SEGV_ACCERR,                          /* invalid permissions for mapped object */
168
169   BUS_ADRALN,                           /* invalid address alignment.  */
170   BUS_ADRERR,                           /* non-existant physical address.  */
171   BUS_OBJERR,                           /* object specific hardware error.  */
172
173   CLD_EXITED,                           /* child has exited */
174   CLD_KILLED,                           /* child was killed */
175   CLD_DUMPED,                           /* child terminated abnormally */
176   CLD_TRAPPED,                          /* traced child has trapped */
177   CLD_STOPPED,                          /* child has stopped */
178   CLD_CONTINUED                         /* stopped child has continued */
179 };
180
181 enum
182 {
183   SIGEV_SIGNAL = 0,                     /* a queued signal, with an application
184                                            defined value, is generated when the
185                                            event of interest occurs */
186   SIGEV_NONE,                           /* no asynchronous notification is
187                                            delivered when the event of interest
188                                            occurs */
189   SIGEV_THREAD                          /* a notification function is called to
190                                            perform notification */
191 };
192
193 typedef void (*_sig_func_ptr)(int);
194
195 struct sigaction
196 {
197   __extension__ union
198   {
199     _sig_func_ptr sa_handler;           /* SIG_DFL, SIG_IGN, or pointer to a function */
200     void  (*sa_sigaction) ( int, siginfo_t *, void * );
201   };
202   sigset_t sa_mask;
203   int sa_flags;
204 };
205
206 #define SA_NOCLDSTOP 1                  /* Do not generate SIGCHLD when children
207                                            stop */
208 #define SA_SIGINFO   2                  /* Invoke the signal catching function
209                                            with three arguments instead of one
210                                          */
211 #define SA_RESTART   0x10000000         /* Restart syscall on signal return */
212 #define SA_NODEFER   0x40000000         /* Don't automatically block the signal
213                                            when its handler is being executed  */
214 #define SA_RESETHAND 0x80000000         /* Reset to SIG_DFL on entry to handler */
215 #define SA_ONESHOT   SA_RESETHAND       /* Historical linux name */
216 #define SA_NOMASK    SA_NODEFER         /* Historical linux name */
217
218 /* Used internally by cygwin.  Included here to group everything in one place.
219    Do not use.  */
220 #define _SA_INTERNAL_MASK 0xf000        /* bits in this range are internal */
221
222 #define SIGHUP  1       /* hangup */
223 #define SIGINT  2       /* interrupt */
224 #define SIGQUIT 3       /* quit */
225 #define SIGILL  4       /* illegal instruction (not reset when caught) */
226 #define SIGTRAP 5       /* trace trap (not reset when caught) */
227 #define SIGABRT 6       /* used by abort */
228 #define SIGEMT  7       /* EMT instruction */
229 #define SIGFPE  8       /* floating point exception */
230 #define SIGKILL 9       /* kill (cannot be caught or ignored) */
231 #define SIGBUS  10      /* bus error */
232 #define SIGSEGV 11      /* segmentation violation */
233 #define SIGSYS  12      /* bad argument to system call */
234 #define SIGPIPE 13      /* write on a pipe with no one to read it */
235 #define SIGALRM 14      /* alarm clock */
236 #define SIGTERM 15      /* software termination signal from kill */
237 #define SIGURG  16      /* urgent condition on IO channel */
238 #define SIGSTOP 17      /* sendable stop signal not from tty */
239 #define SIGTSTP 18      /* stop signal from tty */
240 #define SIGCONT 19      /* continue a stopped process */
241 #define SIGCHLD 20      /* to parent on child stop or exit */
242 #define SIGCLD  20      /* System V name for SIGCHLD */
243 #define SIGTTIN 21      /* to readers pgrp upon background tty read */
244 #define SIGTTOU 22      /* like TTIN for output if (tp->t_local&LTOSTOP) */
245 #define SIGIO   23      /* input/output possible signal */
246 #define SIGPOLL SIGIO   /* System V name for SIGIO */
247 #define SIGXCPU 24      /* exceeded CPU time limit */
248 #define SIGXFSZ 25      /* exceeded file size limit */
249 #define SIGVTALRM 26    /* virtual time alarm */
250 #define SIGPROF 27      /* profiling time alarm */
251 #define SIGWINCH 28     /* window changed */
252 #define SIGLOST 29      /* resource lost (eg, record-lock lost) */
253 #define SIGPWR  SIGLOST /* power failure */
254 #define SIGUSR1 30      /* user defined signal 1 */
255 #define SIGUSR2 31      /* user defined signal 2 */
256
257 /* Real-Time signals per SUSv3.  RT_SIGMAX is defined as 8 in limits.h */
258 #define SIGRTMIN 32
259 #define SIGRTMAX ((SIGRTMIN) + 0)
260 #define NSIG    33      /* signal 0 implied */
261
262 #define SIG_HOLD ((_sig_func_ptr)2)     /* Signal in signal mask */
263
264 void psiginfo (const siginfo_t *, const char *);
265 int sigwait (const sigset_t *, int *);
266 int sigwaitinfo (const sigset_t *, siginfo_t *);
267 int sighold (int);
268 int sigignore (int);
269 int sigrelse (int);
270 _sig_func_ptr sigset (int, _sig_func_ptr);
271
272 int sigqueue(pid_t, int, const union sigval);
273 int siginterrupt (int, int);
274 #ifdef __INSIDE_CYGWIN__
275 extern const char *sys_sigabbrev[];
276 extern const char *sys_siglist[];
277 #else
278 extern const char __declspec(dllimport) *sys_sigabbrev[];
279 extern const char __declspec(dllimport) *sys_siglist[];
280 #endif
281
282 #ifdef __cplusplus
283 }
284 #endif
285 #endif /*_CYGWIN_SIGNAL_H*/