Subversion Repositories Kolibri OS

Rev

Rev 1693 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1693 serge 1
/* sys/signal.h */
2
 
3
#ifndef _SYS_SIGNAL_H
4
#define _SYS_SIGNAL_H
5
#ifdef __cplusplus
6
extern "C" {
7
#endif
8
 
9
#include "_ansi.h"
10
#include 
11
#include 
12
 
13
/* #ifndef __STRICT_ANSI__*/
14
 
15
typedef unsigned long sigset_t;
16
 
17
#if defined(__rtems__)
18
 
19
#if defined(_POSIX_REALTIME_SIGNALS)
20
 
21
/* sigev_notify values
22
   NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD.  */
23
 
24
#define SIGEV_NONE   1  /* No asynchronous notification shall be delivered */
25
                        /*   when the event of interest occurs. */
26
#define SIGEV_SIGNAL 2  /* A queued signal, with an application defined */
27
                        /*  value, shall be delivered when the event of */
28
                        /*  interest occurs. */
29
#define SIGEV_THREAD 3  /* A notification function shall be called to */
30
                        /*   perform notification. */
31
 
32
/*  Signal Generation and Delivery, P1003.1b-1993, p. 63
33
    NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
34
          sigev_notify_attributes to the sigevent structure.  */
35
 
36
union sigval {
37
  int    sival_int;    /* Integer signal value */
38
  void  *sival_ptr;    /* Pointer signal value */
39
};
40
 
41
struct sigevent {
42
  int              sigev_notify;               /* Notification type */
43
  int              sigev_signo;                /* Signal number */
44
  union sigval     sigev_value;                /* Signal value */
45
 
46
#if defined(_POSIX_THREADS)
47
  void           (*sigev_notify_function)( union sigval );
48
                                               /* Notification function */
49
  pthread_attr_t  *sigev_notify_attributes;    /* Notification Attributes */
50
#endif
51
};
52
 
53
/* Signal Actions, P1003.1b-1993, p. 64 */
54
/* si_code values, p. 66 */
55
 
56
#define SI_USER    1    /* Sent by a user. kill(), abort(), etc */
57
#define SI_QUEUE   2    /* Sent by sigqueue() */
58
#define SI_TIMER   3    /* Sent by expiration of a timer_settime() timer */
59
#define SI_ASYNCIO 4    /* Indicates completion of asycnhronous IO */
60
#define SI_MESGQ   5    /* Indicates arrival of a message at an empty queue */
61
 
62
typedef struct {
63
  int          si_signo;    /* Signal number */
64
  int          si_code;     /* Cause of the signal */
65
  union sigval si_value;    /* Signal value */
66
} siginfo_t;
67
#endif
68
 
69
/*  3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
70
 
71
#define SA_NOCLDSTOP 1   /* Do not generate SIGCHLD when children stop */
72
#define SA_SIGINFO   2   /* Invoke the signal catching function with */
73
                         /*   three arguments instead of one. */
74
 
75
/* struct sigaction notes from POSIX:
76
 *
77
 *  (1) Routines stored in sa_handler should take a single int as
78
 *      their argument although the POSIX standard does not require this.
3065 serge 79
 *      This is not longer true since at least POSIX.1-2008
1693 serge 80
 *  (2) The fields sa_handler and sa_sigaction may overlap, and a conforming
81
 *      application should not use both simultaneously.
82
 */
83
 
3065 serge 84
typedef void (*_sig_func_ptr)(int);
1693 serge 85
 
86
struct sigaction {
87
  int         sa_flags;       /* Special flags to affect behavior of signal */
88
  sigset_t    sa_mask;        /* Additional set of signals to be blocked */
89
                              /*   during execution of signal-catching */
90
                              /*   function. */
91
  union {
92
    _sig_func_ptr _handler;  /* SIG_DFL, SIG_IGN, or pointer to a function */
93
#if defined(_POSIX_REALTIME_SIGNALS)
94
    void      (*_sigaction)( int, siginfo_t *, void * );
95
#endif
96
  } _signal_handlers;
97
};
98
 
99
#define sa_handler    _signal_handlers._handler
100
#if defined(_POSIX_REALTIME_SIGNALS)
101
#define sa_sigaction  _signal_handlers._sigaction
102
#endif
103
 
104
#elif defined(__CYGWIN__)
105
#include 
106
#else
107
#define SA_NOCLDSTOP 1  /* only value supported now for sa_flags */
108
 
109
typedef void (*_sig_func_ptr)(int);
110
 
111
struct sigaction
112
{
113
	_sig_func_ptr sa_handler;
114
	sigset_t sa_mask;
115
	int sa_flags;
116
};
117
#endif /* defined(__rtems__) */
118
 
119
#define SIG_SETMASK 0	/* set mask with sigprocmask() */
120
#define SIG_BLOCK 1	/* set of signals to block */
121
#define SIG_UNBLOCK 2	/* set of signals to, well, unblock */
122
 
123
/* These depend upon the type of sigset_t, which right now
124
   is always a long.. They're in the POSIX namespace, but
125
   are not ANSI. */
126
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
127
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
128
#define sigemptyset(what)   (*(what) = 0, 0)
129
#define sigfillset(what)    (*(what) = ~(0), 0)
130
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
131
 
132
int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset));
133
 
134
#if defined(_POSIX_THREADS)
135
int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
136
#endif
137
 
138
/* protos for functions found in winsup sources for CYGWIN */
139
#if defined(__CYGWIN__) || defined(__rtems__)
140
#undef sigaddset
141
#undef sigdelset
142
#undef sigemptyset
143
#undef sigfillset
144
#undef sigismember
145
 
146
int _EXFUN(kill, (pid_t, int));
147
int _EXFUN(killpg, (pid_t, int));
148
int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
149
int _EXFUN(sigaddset, (sigset_t *, const int));
150
int _EXFUN(sigdelset, (sigset_t *, const int));
151
int _EXFUN(sigismember, (const sigset_t *, int));
152
int _EXFUN(sigfillset, (sigset_t *));
153
int _EXFUN(sigemptyset, (sigset_t *));
154
int _EXFUN(sigpending, (sigset_t *));
155
int _EXFUN(sigsuspend, (const sigset_t *));
156
int _EXFUN(sigpause, (int));
157
 
158
#if defined(_POSIX_THREADS)
159
#ifdef __CYGWIN__
160
#  ifndef _CYGWIN_TYPES_H
161
#    error You need the winsup sources or a cygwin installation to compile the cygwin version of newlib.
162
#  endif
163
#endif
164
int _EXFUN(pthread_kill, (pthread_t thread, int sig));
165
#endif
166
 
167
#if defined(_POSIX_REALTIME_SIGNALS)
168
 
169
/*  3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
170
    NOTE: P1003.1c/D10, p. 39 adds sigwait().  */
171
 
172
int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info));
173
int _EXFUN(sigtimedwait,
174
  (const sigset_t *set, siginfo_t *info, const struct timespec  *timeout)
175
);
176
int _EXFUN(sigwait, (const sigset_t *set, int *sig));
177
 
178
/*  3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */
179
int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
180
 
181
#endif /* defined(_POSIX_REALTIME_SIGNALS) */
182
 
183
#endif /* defined(__CYGWIN__) || defined(__rtems__) */
184
 
185
/* #endif __STRICT_ANSI__ */
186
 
187
#if defined(___AM29K__)
188
/* These all need to be defined for ANSI C, but I don't think they are
189
   meaningful.  */
190
#define SIGABRT 1
191
#define SIGFPE 1
192
#define SIGILL 1
193
#define SIGINT 1
194
#define SIGSEGV 1
195
#define SIGTERM 1
196
/* These need to be defined for POSIX, and some others do too.  */
197
#define SIGHUP 1
198
#define SIGQUIT 1
199
#define NSIG 2
200
#elif defined(__GO32__)
201
#define SIGINT  1
202
#define SIGKILL 2
203
#define SIGPIPE 3
204
#define SIGFPE  4
205
#define SIGHUP  5
206
#define SIGTERM 6
207
#define SIGSEGV 7
208
#define SIGTSTP 8
209
#define SIGQUIT 9
210
#define SIGTRAP 10
211
#define SIGILL  11
212
#define SIGEMT  12
213
#define SIGALRM 13
214
#define SIGBUS  14
215
#define SIGLOST 15
216
#define SIGSTOP 16
217
#define SIGABRT 17
218
#define SIGUSR1	18
219
#define SIGUSR2	19
220
#define NSIG    20
221
#elif !defined(SIGTRAP)
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	SIGIOT	6	/* IOT instruction */
228
#define	SIGABRT 6	/* used by abort, replace SIGIOT in the future */
229
#define	SIGEMT	7	/* EMT instruction */
230
#define	SIGFPE	8	/* floating point exception */
231
#define	SIGKILL	9	/* kill (cannot be caught or ignored) */
232
#define	SIGBUS	10	/* bus error */
233
#define	SIGSEGV	11	/* segmentation violation */
234
#define	SIGSYS	12	/* bad argument to system call */
235
#define	SIGPIPE	13	/* write on a pipe with no one to read it */
236
#define	SIGALRM	14	/* alarm clock */
237
#define	SIGTERM	15	/* software termination signal from kill */
238
 
239
#if defined(__rtems__)
240
#define	SIGURG	16	/* urgent condition on IO channel */
241
#define	SIGSTOP	17	/* sendable stop signal not from tty */
242
#define	SIGTSTP	18	/* stop signal from tty */
243
#define	SIGCONT	19	/* continue a stopped process */
244
#define	SIGCHLD	20	/* to parent on child stop or exit */
245
#define	SIGCLD	20	/* System V name for SIGCHLD */
246
#define	SIGTTIN	21	/* to readers pgrp upon background tty read */
247
#define	SIGTTOU	22	/* like TTIN for output if (tp->t_local<OSTOP) */
248
#define	SIGIO	23	/* input/output possible signal */
249
#define	SIGPOLL	SIGIO	/* System V name for SIGIO */
250
#define	SIGWINCH 24	/* window changed */
251
#define	SIGUSR1 25	/* user defined signal 1 */
252
#define	SIGUSR2 26	/* user defined signal 2 */
253
 
254
/* Real-Time Signals Range, P1003.1b-1993, p. 61
255
   NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX
256
         (which is a minimum of 8) signals.
257
 */
258
#define SIGRTMIN 27
259
#define SIGRTMAX 31
260
#define __SIGFIRSTNOTRT SIGHUP
261
#define __SIGLASTNOTRT  SIGUSR2
262
 
263
#define NSIG	32      /* signal 0 implied */
264
 
265
#elif defined(__svr4__)
266
/* svr4 specifics. different signals above 15, and sigaction. */
267
#define	SIGUSR1	16
268
#define SIGUSR2	17
269
#define SIGCLD	18
270
#define	SIGPWR	19
271
#define SIGWINCH 20
272
#define	SIGPOLL	22	/* 20 for x.out binaries!!!! */
273
#define	SIGSTOP	23	/* sendable stop signal not from tty */
274
#define	SIGTSTP	24	/* stop signal from tty */
275
#define	SIGCONT	25	/* continue a stopped process */
276
#define	SIGTTIN	26	/* to readers pgrp upon background tty read */
277
#define	SIGTTOU	27	/* like TTIN for output if (tp->t_local<OSTOP) */
278
#define NSIG	28
279
#else
280
#define	SIGURG	16	/* urgent condition on IO channel */
281
#define	SIGSTOP	17	/* sendable stop signal not from tty */
282
#define	SIGTSTP	18	/* stop signal from tty */
283
#define	SIGCONT	19	/* continue a stopped process */
284
#define	SIGCHLD	20	/* to parent on child stop or exit */
285
#define	SIGCLD	20	/* System V name for SIGCHLD */
286
#define	SIGTTIN	21	/* to readers pgrp upon background tty read */
287
#define	SIGTTOU	22	/* like TTIN for output if (tp->t_local<OSTOP) */
288
#define	SIGIO	23	/* input/output possible signal */
289
#define	SIGPOLL	SIGIO	/* System V name for SIGIO */
290
#define	SIGXCPU	24	/* exceeded CPU time limit */
291
#define	SIGXFSZ	25	/* exceeded file size limit */
292
#define	SIGVTALRM 26	/* virtual time alarm */
293
#define	SIGPROF	27	/* profiling time alarm */
294
#define	SIGWINCH 28	/* window changed */
295
#define	SIGLOST 29	/* resource lost (eg, record-lock lost) */
296
#define	SIGUSR1 30	/* user defined signal 1 */
297
#define	SIGUSR2 31	/* user defined signal 2 */
298
#define NSIG	32      /* signal 0 implied */
299
#endif
300
#endif
301
 
302
#ifdef __cplusplus
303
}
304
#endif
305
 
306
#ifndef _SIGNAL_H_
307
/* Some applications take advantage of the fact that 
308
 * and  are equivalent in glibc.  Allow for that here.  */
309
#include 
310
#endif
311
#endif /* _SYS_SIGNAL_H */