| 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 |
|
|---|
| 63 | typedef int posix_sig_atomic_t;
|
|---|
| 64 | typedef int posix_sigset_t;
|
|---|
| 65 | typedef struct posix_mcontext {
|
|---|
| 66 | } posix_mcontext_t;
|
|---|
| 67 |
|
|---|
| 68 | union posix_sigval {
|
|---|
| 69 | int sival_int;
|
|---|
| 70 | void *sival_ptr;
|
|---|
| 71 | };
|
|---|
| 72 |
|
|---|
| 73 | struct posix_sigevent {
|
|---|
| 74 | int sigev_notify; /* Notification type. */
|
|---|
| 75 | int sigev_signo; /* Signal number. */
|
|---|
| 76 | union posix_sigval sigev_value; /* Signal value. */
|
|---|
| 77 | void (*sigev_notify_function)(union sigval); /* Notification function. */
|
|---|
| 78 | posix_thread_attr_t *sigev_notify_attributes; /* Notification attributes. */
|
|---|
| 79 | };
|
|---|
| 80 |
|
|---|
| 81 | typedef struct {
|
|---|
| 82 | int si_signo;
|
|---|
| 83 | int si_code;
|
|---|
| 84 |
|
|---|
| 85 | int si_errno;
|
|---|
| 86 |
|
|---|
| 87 | pid_t si_pid;
|
|---|
| 88 | uid_t si_uid;
|
|---|
| 89 | void *si_addr;
|
|---|
| 90 | int si_status;
|
|---|
| 91 |
|
|---|
| 92 | long si_band;
|
|---|
| 93 |
|
|---|
| 94 | union posix_sigval si_value;
|
|---|
| 95 | } posix_siginfo_t;
|
|---|
| 96 |
|
|---|
| 97 | struct posix_sigaction {
|
|---|
| 98 | void (*sa_handler)(int);
|
|---|
| 99 | posix_sigset_t sa_mask;
|
|---|
| 100 | int sa_flags;
|
|---|
| 101 | void (*sa_sigaction)(int, posix_siginfo_t *, void *);
|
|---|
| 102 | };
|
|---|
| 103 |
|
|---|
| 104 | typedef struct {
|
|---|
| 105 | void *ss_sp;
|
|---|
| 106 | size_t ss_size;
|
|---|
| 107 | int ss_flags;
|
|---|
| 108 | } posix_stack_t;
|
|---|
| 109 |
|
|---|
| 110 | typedef struct posix_ucontext {
|
|---|
| 111 | struct posix_ucontext *uc_link;
|
|---|
| 112 | posix_sigset_t uc_sigmask;
|
|---|
| 113 | posix_stack_t uc_stack;
|
|---|
| 114 | posix_mcontext_t uc_mcontext;
|
|---|
| 115 | } posix_ucontext_t;
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 | /* Values of posix_sigevent::sigev_notify */
|
|---|
| 119 | #undef SIGEV_NONE
|
|---|
| 120 | #define SIGEV_NONE 0
|
|---|
| 121 | #undef SIGEV_SIGNAL
|
|---|
| 122 | #define SIGEV_SIGNAL 0
|
|---|
| 123 | #undef SIGEV_THREAD
|
|---|
| 124 | #define SIGEV_THREAD 0
|
|---|
| 125 |
|
|---|
| 126 | #undef SIGRT_MIN
|
|---|
| 127 | #define SIGRT_MIN 0
|
|---|
| 128 | #undef SIGRT_MAX
|
|---|
| 129 | #define SIGRT_MAX 0
|
|---|
| 130 |
|
|---|
| 131 | #undef SIG_BLOCK
|
|---|
| 132 | #define SIG_BLOCK 0
|
|---|
| 133 | #undef SIG_UNBLOCK
|
|---|
| 134 | #define SIG_UNBLOCK 0
|
|---|
| 135 | #undef SIG_SETMASK
|
|---|
| 136 | #define SIG_SETMASK 0
|
|---|
| 137 |
|
|---|
| 138 | #undef SA_NOCLDSTOP
|
|---|
| 139 | #define SA_NOCLDSTOP 0
|
|---|
| 140 | #undef SA_ONSTACK
|
|---|
| 141 | #define SA_ONSTACK 0
|
|---|
| 142 | #undef SA_RESETHAND
|
|---|
| 143 | #define SA_RESETHAND 0
|
|---|
| 144 | #undef SA_RESTART
|
|---|
| 145 | #define SA_RESTART 0
|
|---|
| 146 | #undef SA_SIGINFO
|
|---|
| 147 | #define SA_SIGINFO 0
|
|---|
| 148 | #undef SA_NOCLDWAIT
|
|---|
| 149 | #define SA_NOCLDWAIT 0
|
|---|
| 150 | #undef SA_NODEFER
|
|---|
| 151 | #define SA_NODEFER 0
|
|---|
| 152 |
|
|---|
| 153 | #undef SS_ONSTACK
|
|---|
| 154 | #define SS_ONSTACK 0
|
|---|
| 155 | #undef SS_DISABLE
|
|---|
| 156 | #define SS_DISABLE 0
|
|---|
| 157 |
|
|---|
| 158 | #undef MINSIGSTKSZ
|
|---|
| 159 | #define MINSIGSTKSZ 0
|
|---|
| 160 | #undef SIGSTKSZ
|
|---|
| 161 | #define SIGSTKSZ 0
|
|---|
| 162 |
|
|---|
| 163 | /* full POSIX set */
|
|---|
| 164 | enum {
|
|---|
| 165 | SIGABRT,
|
|---|
| 166 | SIGALRM,
|
|---|
| 167 | SIGBUS,
|
|---|
| 168 | SIGCHLD,
|
|---|
| 169 | SIGCONT,
|
|---|
| 170 | SIGFPE,
|
|---|
| 171 | SIGHUP,
|
|---|
| 172 | SIGILL,
|
|---|
| 173 | SIGINT,
|
|---|
| 174 | SIGKILL,
|
|---|
| 175 | SIGPIPE,
|
|---|
| 176 | SIGQUIT,
|
|---|
| 177 | SIGSEGV,
|
|---|
| 178 | SIGSTOP,
|
|---|
| 179 | SIGTERM,
|
|---|
| 180 | SIGTSTP,
|
|---|
| 181 | SIGTTIN,
|
|---|
| 182 | SIGTTOU,
|
|---|
| 183 | SIGUSR1,
|
|---|
| 184 | SIGUSR2,
|
|---|
| 185 | SIGPOLL,
|
|---|
| 186 | SIGPROF,
|
|---|
| 187 | SIGSYS,
|
|---|
| 188 | SIGTRAP,
|
|---|
| 189 | SIGURG,
|
|---|
| 190 | SIGVTALRM,
|
|---|
| 191 | SIGXCPU,
|
|---|
| 192 | SIGXFSZ
|
|---|
| 193 | };
|
|---|
| 194 |
|
|---|
| 195 | #ifndef LIBPOSIX_INTERNAL
|
|---|
| 196 | #define sig_atomic_t posix_sig_atomic_t
|
|---|
| 197 | #define sigset_t posix_sigset_t
|
|---|
| 198 | #define sigval posix_sigval
|
|---|
| 199 | #define sigevent posix_sigevent
|
|---|
| 200 | #define sigaction posix_sigaction
|
|---|
| 201 | #define mcontext_t posix_mcontext_t
|
|---|
| 202 | #define ucontext_t posix_ucontext_t
|
|---|
| 203 | #define stack_t posix_stack_t
|
|---|
| 204 | #define siginfo_t posix_siginfo_t
|
|---|
| 205 | #endif
|
|---|
| 206 |
|
|---|
| 207 | #endif /* POSIX_SIGNAL_H_ */
|
|---|
| 208 |
|
|---|
| 209 | /** @}
|
|---|
| 210 | */
|
|---|