[098eeba3] | 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 |
|
---|
[4f4b4e7] | 29 | /** @addtogroup libposix
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[098eeba3] | 35 | #ifndef POSIX_SIGNAL_H_
|
---|
| 36 | #define POSIX_SIGNAL_H_
|
---|
| 37 |
|
---|
[4f4b4e7] | 38 | #include "libc/errno.h"
|
---|
[fa9815d9] | 39 | #include "sys/types.h"
|
---|
[098eeba3] | 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 |
|
---|
[4f4b4e7] | 50 | #undef SIG_DFL
|
---|
[098eeba3] | 51 | #define SIG_DFL ((void (*)(int)) 0)
|
---|
[4f4b4e7] | 52 | #undef SIG_ERR
|
---|
[098eeba3] | 53 | #define SIG_ERR ((void (*)(int)) 0)
|
---|
[fa9815d9] | 54 | #undef SIG_HOLD
|
---|
| 55 | #define SIG_HOLD ((void (*)(int)) 0)
|
---|
[4f4b4e7] | 56 | #undef SIG_IGN
|
---|
[098eeba3] | 57 | #define SIG_IGN ((void (*)(int)) 0)
|
---|
| 58 |
|
---|
[4f4b4e7] | 59 | typedef int posix_sig_atomic_t;
|
---|
[fa9815d9] | 60 | typedef int posix_sigset_t;
|
---|
| 61 | typedef struct posix_mcontext {
|
---|
[1a552fd] | 62 | // FIXME: should not be empty to avoid compiler warnings (-pedantic)
|
---|
| 63 | int dummy;
|
---|
[fa9815d9] | 64 | } posix_mcontext_t;
|
---|
| 65 |
|
---|
| 66 | union posix_sigval {
|
---|
| 67 | int sival_int;
|
---|
| 68 | void *sival_ptr;
|
---|
| 69 | };
|
---|
| 70 |
|
---|
| 71 | struct posix_sigevent {
|
---|
| 72 | int sigev_notify; /* Notification type. */
|
---|
| 73 | int sigev_signo; /* Signal number. */
|
---|
| 74 | union posix_sigval sigev_value; /* Signal value. */
|
---|
[1a552fd] | 75 | void (*sigev_notify_function)(union posix_sigval); /* Notification function. */
|
---|
[fa9815d9] | 76 | posix_thread_attr_t *sigev_notify_attributes; /* Notification attributes. */
|
---|
| 77 | };
|
---|
| 78 |
|
---|
| 79 | typedef struct {
|
---|
| 80 | int si_signo;
|
---|
| 81 | int si_code;
|
---|
| 82 |
|
---|
| 83 | int si_errno;
|
---|
| 84 |
|
---|
[7530a00] | 85 | posix_pid_t si_pid;
|
---|
| 86 | posix_uid_t si_uid;
|
---|
[fa9815d9] | 87 | void *si_addr;
|
---|
| 88 | int si_status;
|
---|
| 89 |
|
---|
| 90 | long si_band;
|
---|
| 91 |
|
---|
| 92 | union posix_sigval si_value;
|
---|
| 93 | } posix_siginfo_t;
|
---|
| 94 |
|
---|
| 95 | struct posix_sigaction {
|
---|
| 96 | void (*sa_handler)(int);
|
---|
| 97 | posix_sigset_t sa_mask;
|
---|
| 98 | int sa_flags;
|
---|
| 99 | void (*sa_sigaction)(int, posix_siginfo_t *, void *);
|
---|
| 100 | };
|
---|
| 101 |
|
---|
| 102 | typedef struct {
|
---|
| 103 | void *ss_sp;
|
---|
| 104 | size_t ss_size;
|
---|
| 105 | int ss_flags;
|
---|
| 106 | } posix_stack_t;
|
---|
| 107 |
|
---|
| 108 | typedef struct posix_ucontext {
|
---|
| 109 | struct posix_ucontext *uc_link;
|
---|
| 110 | posix_sigset_t uc_sigmask;
|
---|
| 111 | posix_stack_t uc_stack;
|
---|
| 112 | posix_mcontext_t uc_mcontext;
|
---|
| 113 | } posix_ucontext_t;
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | /* Values of posix_sigevent::sigev_notify */
|
---|
| 117 | #undef SIGEV_NONE
|
---|
| 118 | #define SIGEV_NONE 0
|
---|
| 119 | #undef SIGEV_SIGNAL
|
---|
| 120 | #define SIGEV_SIGNAL 0
|
---|
| 121 | #undef SIGEV_THREAD
|
---|
| 122 | #define SIGEV_THREAD 0
|
---|
| 123 |
|
---|
| 124 | #undef SIGRT_MIN
|
---|
| 125 | #define SIGRT_MIN 0
|
---|
| 126 | #undef SIGRT_MAX
|
---|
| 127 | #define SIGRT_MAX 0
|
---|
| 128 |
|
---|
| 129 | #undef SIG_BLOCK
|
---|
| 130 | #define SIG_BLOCK 0
|
---|
| 131 | #undef SIG_UNBLOCK
|
---|
| 132 | #define SIG_UNBLOCK 0
|
---|
| 133 | #undef SIG_SETMASK
|
---|
| 134 | #define SIG_SETMASK 0
|
---|
| 135 |
|
---|
| 136 | #undef SA_NOCLDSTOP
|
---|
| 137 | #define SA_NOCLDSTOP 0
|
---|
| 138 | #undef SA_ONSTACK
|
---|
| 139 | #define SA_ONSTACK 0
|
---|
| 140 | #undef SA_RESETHAND
|
---|
| 141 | #define SA_RESETHAND 0
|
---|
| 142 | #undef SA_RESTART
|
---|
| 143 | #define SA_RESTART 0
|
---|
| 144 | #undef SA_SIGINFO
|
---|
| 145 | #define SA_SIGINFO 0
|
---|
| 146 | #undef SA_NOCLDWAIT
|
---|
| 147 | #define SA_NOCLDWAIT 0
|
---|
| 148 | #undef SA_NODEFER
|
---|
| 149 | #define SA_NODEFER 0
|
---|
| 150 |
|
---|
| 151 | #undef SS_ONSTACK
|
---|
| 152 | #define SS_ONSTACK 0
|
---|
| 153 | #undef SS_DISABLE
|
---|
| 154 | #define SS_DISABLE 0
|
---|
| 155 |
|
---|
| 156 | #undef MINSIGSTKSZ
|
---|
| 157 | #define MINSIGSTKSZ 0
|
---|
| 158 | #undef SIGSTKSZ
|
---|
| 159 | #define SIGSTKSZ 0
|
---|
[098eeba3] | 160 |
|
---|
| 161 | /* full POSIX set */
|
---|
| 162 | enum {
|
---|
| 163 | SIGABRT,
|
---|
| 164 | SIGALRM,
|
---|
| 165 | SIGBUS,
|
---|
| 166 | SIGCHLD,
|
---|
| 167 | SIGCONT,
|
---|
| 168 | SIGFPE,
|
---|
| 169 | SIGHUP,
|
---|
| 170 | SIGILL,
|
---|
| 171 | SIGINT,
|
---|
| 172 | SIGKILL,
|
---|
| 173 | SIGPIPE,
|
---|
| 174 | SIGQUIT,
|
---|
| 175 | SIGSEGV,
|
---|
| 176 | SIGSTOP,
|
---|
| 177 | SIGTERM,
|
---|
| 178 | SIGTSTP,
|
---|
| 179 | SIGTTIN,
|
---|
| 180 | SIGTTOU,
|
---|
| 181 | SIGUSR1,
|
---|
| 182 | SIGUSR2,
|
---|
| 183 | SIGPOLL,
|
---|
| 184 | SIGPROF,
|
---|
| 185 | SIGSYS,
|
---|
| 186 | SIGTRAP,
|
---|
| 187 | SIGURG,
|
---|
| 188 | SIGVTALRM,
|
---|
| 189 | SIGXCPU,
|
---|
| 190 | SIGXFSZ
|
---|
| 191 | };
|
---|
| 192 |
|
---|
[7530a00] | 193 | extern void (*posix_signal(int sig, void (*func)(int)))(int);
|
---|
| 194 | extern int posix_raise(int sig);
|
---|
| 195 | extern int posix_kill(posix_pid_t pid, int sig);
|
---|
| 196 |
|
---|
[244d6fd] | 197 | extern int posix_sigaddset(posix_sigset_t *set, int signo);
|
---|
[1a552fd] | 198 | extern int posix_sigemptyset(posix_sigset_t *set);
|
---|
| 199 | extern int posix_sigprocmask(int how, const posix_sigset_t *restrict set,
|
---|
| 200 | posix_sigset_t *restrict oset);
|
---|
| 201 |
|
---|
[491e1ee] | 202 | #ifndef LIBPOSIX_INTERNAL
|
---|
[4f4b4e7] | 203 | #define sig_atomic_t posix_sig_atomic_t
|
---|
[fa9815d9] | 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
|
---|
[7530a00] | 212 |
|
---|
| 213 | #define signal posix_signal
|
---|
| 214 | #define raise posix_raise
|
---|
| 215 | #define kill posix_kill
|
---|
[244d6fd] | 216 | #define sigaddset posix_sigaddset
|
---|
[1a552fd] | 217 | #define sigemptyset posix_sigemptyset
|
---|
| 218 | #define sigprocmask posix_sigprocmask
|
---|
[4f4b4e7] | 219 | #endif
|
---|
| 220 |
|
---|
[098eeba3] | 221 | #endif /* POSIX_SIGNAL_H_ */
|
---|
| 222 |
|
---|
[4f4b4e7] | 223 | /** @}
|
---|
| 224 | */
|
---|