source: mainline/uspace/lib/posix/signal.h@ 1a552fd

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 1a552fd was 1a552fd, checked in by Petr Koupy <petr.koupy@…>, 14 years ago

Some minor improvements/corrections in signal.h to avoid compiler warnings.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 * Copyright (c) 2011 Jiri Zarevucky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libposix
30 * @{
31 */
32/** @file
33 */
34
35#ifndef POSIX_SIGNAL_H_
36#define POSIX_SIGNAL_H_
37
38#include "libc/errno.h"
39#include "sys/types.h"
40
41/* HelenOS doesn't have signals, so calls to functions of this header
42 * are just replaced with their respective failure return value.
43 *
44 * Other macros and constants are here just to satisfy the symbol resolver
45 * and have no practical value whatsoever, until HelenOS implements some
46 * equivalent of signals. Maybe something neat based on IPC will be devised
47 * in the future?
48 */
49
50#undef SIG_DFL
51#define SIG_DFL ((void (*)(int)) 0)
52#undef SIG_ERR
53#define SIG_ERR ((void (*)(int)) 0)
54#undef SIG_HOLD
55#define SIG_HOLD ((void (*)(int)) 0)
56#undef SIG_IGN
57#define SIG_IGN ((void (*)(int)) 0)
58
59#define signal(sig,func) (errno = ENOTSUP, SIG_ERR)
60#define raise(sig) ((int) -1)
61#define kill(pid,sig) (errno = ENOTSUP, (int) -1)
62
63typedef int posix_sig_atomic_t;
64typedef int posix_sigset_t;
65typedef struct posix_mcontext {
66 // FIXME: should not be empty to avoid compiler warnings (-pedantic)
67 int dummy;
68} posix_mcontext_t;
69
70union posix_sigval {
71 int sival_int;
72 void *sival_ptr;
73};
74
75struct posix_sigevent {
76 int sigev_notify; /* Notification type. */
77 int sigev_signo; /* Signal number. */
78 union posix_sigval sigev_value; /* Signal value. */
79 void (*sigev_notify_function)(union posix_sigval); /* Notification function. */
80 posix_thread_attr_t *sigev_notify_attributes; /* Notification attributes. */
81};
82
83typedef struct {
84 int si_signo;
85 int si_code;
86
87 int si_errno;
88
89 pid_t si_pid;
90 uid_t si_uid;
91 void *si_addr;
92 int si_status;
93
94 long si_band;
95
96 union posix_sigval si_value;
97} posix_siginfo_t;
98
99struct posix_sigaction {
100 void (*sa_handler)(int);
101 posix_sigset_t sa_mask;
102 int sa_flags;
103 void (*sa_sigaction)(int, posix_siginfo_t *, void *);
104};
105
106typedef struct {
107 void *ss_sp;
108 size_t ss_size;
109 int ss_flags;
110} posix_stack_t;
111
112typedef struct posix_ucontext {
113 struct posix_ucontext *uc_link;
114 posix_sigset_t uc_sigmask;
115 posix_stack_t uc_stack;
116 posix_mcontext_t uc_mcontext;
117} posix_ucontext_t;
118
119
120/* Values of posix_sigevent::sigev_notify */
121#undef SIGEV_NONE
122#define SIGEV_NONE 0
123#undef SIGEV_SIGNAL
124#define SIGEV_SIGNAL 0
125#undef SIGEV_THREAD
126#define SIGEV_THREAD 0
127
128#undef SIGRT_MIN
129#define SIGRT_MIN 0
130#undef SIGRT_MAX
131#define SIGRT_MAX 0
132
133#undef SIG_BLOCK
134#define SIG_BLOCK 0
135#undef SIG_UNBLOCK
136#define SIG_UNBLOCK 0
137#undef SIG_SETMASK
138#define SIG_SETMASK 0
139
140#undef SA_NOCLDSTOP
141#define SA_NOCLDSTOP 0
142#undef SA_ONSTACK
143#define SA_ONSTACK 0
144#undef SA_RESETHAND
145#define SA_RESETHAND 0
146#undef SA_RESTART
147#define SA_RESTART 0
148#undef SA_SIGINFO
149#define SA_SIGINFO 0
150#undef SA_NOCLDWAIT
151#define SA_NOCLDWAIT 0
152#undef SA_NODEFER
153#define SA_NODEFER 0
154
155#undef SS_ONSTACK
156#define SS_ONSTACK 0
157#undef SS_DISABLE
158#define SS_DISABLE 0
159
160#undef MINSIGSTKSZ
161#define MINSIGSTKSZ 0
162#undef SIGSTKSZ
163#define SIGSTKSZ 0
164
165/* full POSIX set */
166enum {
167 SIGABRT,
168 SIGALRM,
169 SIGBUS,
170 SIGCHLD,
171 SIGCONT,
172 SIGFPE,
173 SIGHUP,
174 SIGILL,
175 SIGINT,
176 SIGKILL,
177 SIGPIPE,
178 SIGQUIT,
179 SIGSEGV,
180 SIGSTOP,
181 SIGTERM,
182 SIGTSTP,
183 SIGTTIN,
184 SIGTTOU,
185 SIGUSR1,
186 SIGUSR2,
187 SIGPOLL,
188 SIGPROF,
189 SIGSYS,
190 SIGTRAP,
191 SIGURG,
192 SIGVTALRM,
193 SIGXCPU,
194 SIGXFSZ
195};
196
197/* Just declared to avoid compiler warnings. */
198extern int posix_sigemptyset(posix_sigset_t *set);
199extern int posix_sigprocmask(int how, const posix_sigset_t *restrict set,
200 posix_sigset_t *restrict oset);
201
202#ifndef LIBPOSIX_INTERNAL
203 #define sig_atomic_t posix_sig_atomic_t
204 #define sigset_t posix_sigset_t
205 #define sigval posix_sigval
206 #define sigevent posix_sigevent
207 #define sigaction posix_sigaction
208 #define mcontext_t posix_mcontext_t
209 #define ucontext_t posix_ucontext_t
210 #define stack_t posix_stack_t
211 #define siginfo_t posix_siginfo_t
212 #define sigemptyset posix_sigemptyset
213 #define sigprocmask posix_sigprocmask
214#endif
215
216#endif /* POSIX_SIGNAL_H_ */
217
218/** @}
219 */
Note: See TracBrowser for help on using the repository browser.