signal.h (4405B)
1 /* -*-comment-start: "//";comment-end:""-*- 2 * GNU Mes --- Maxwell Equations of Software 3 * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> 4 * 5 * This file is part of GNU Mes. 6 * 7 * GNU Mes is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or (at 10 * your option) any later version. 11 * 12 * GNU Mes is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #ifndef __MES_SIGNAL_H 21 #define __MES_SIGNAL_H 1 22 23 #if SYSTEM_LIBC 24 #undef __MES_SIGNAL_H 25 #include_next <signal.h> 26 #else //! SYSTEM_LIBC 27 28 #define _NSIG 64 29 30 #define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long))) 31 32 #if !__M2__ 33 typedef struct 34 { 35 unsigned long items[_SIGSET_NITEMS]; 36 } sigset_t; 37 #endif 38 typedef long stack_t; 39 40 #include <sys/types.h> 41 42 // *INDENT-OFF* 43 #define NSIG 30 44 #define SIGHUP 1 45 #define SIGINT 2 46 #define SIGQUIT 3 47 #define SIGILL 4 48 #define SIGTRAP 5 49 #define SIGABRT 6 50 #define SIGIOT 6 51 #define SIGBUS 7 52 #define SIGFPE 8 53 #define SIGKILL 9 54 #define SIGUSR1 10 55 #define SIGSEGV 11 56 #define SIGUSR2 12 57 #define SIGPIPE 13 58 #define SIGALRM 14 59 #define SIGTERM 15 60 #define SIGSTKFLT 16 61 #define SIGCHLD 17 62 #define SIGCONT 18 63 #define SIGSTOP 19 64 #define SIGTSTP 20 65 #define SIGTTIN 21 66 #define SIGTTOU 22 67 #define SIGURG 23 68 #define SIGXCPU 24 69 #define SIGXFSZ 25 70 #define SIGVTALRM 26 71 #define SIGPROF 27 72 #define SIGWINCH 28 73 #define SIGIO 29 74 #define SIGPOLL SIGIO 75 76 #define FPE_INTDIV 1 77 #define FPE_INTOVF 2 78 #define FPE_FLTDIV 3 79 #define FPE_FLTOVF 4 80 #define FPE_FLTUND 5 81 #define FPE_FLTRES 6 82 #define FPE_FLTINV 7 83 #define FPE_FLTSUB 8 84 85 #define SA_NOCLDSTOP 0x00000001 86 #define SA_NOCLDWAIT 0x00000002 87 #define SA_SIGINFO 0x00000004 88 #define SA_RESTORER 0x04000000 89 #define SA_ONSTACK 0x08000000 90 #define SA_RESTART 0x10000000 91 #define SA_NODEFER 0x40000000 92 #define SA_RESETHAND 0x80000000 93 94 #define SA_NOMASK SA_NODEFER 95 #define SA_ONESHOT SA_RESETHAND 96 97 #if !__M2__ // lacks short, casts 98 typedef struct siginfo_t 99 { 100 int si_signo; 101 int si_errno; 102 int si_code; 103 int si_trapno; 104 pid_t si_pid; 105 uid_t si_uid; 106 int si_status; 107 clock_t si_utime; 108 clock_t si_stime; 109 sigval_t si_value; 110 int si_int; 111 void *si_ptr; 112 int si_overrun; 113 int si_timerid; 114 void *si_addr; 115 long si_band; 116 int si_fd; 117 short si_addr_lsb; 118 void *si_lower; 119 void *si_upper; 120 int si_pkey; 121 void *si_call_addr; 122 int si_syscall; 123 unsigned int si_arch; 124 } siginfo_t; 125 // *INDENT-ON* 126 127 #if __M2__ || __MESC__ 128 typedef long sighandler_t; 129 #else 130 typedef void (*sighandler_t) (int); 131 #endif 132 133 #if __i386__ || __x86_64__ 134 struct sigaction 135 { 136 union 137 { 138 sighandler_t sa_handler; 139 void (*sa_sigaction) (int signum, siginfo_t *, void *); 140 }; 141 unsigned long sa_flags; 142 #if __x86_64__ 143 long _foo0; 144 #endif 145 sigset_t sa_mask; 146 #if __x86_64__ 147 long _foo1[15]; 148 #endif 149 //unsigned long sa_flags; // x86? 150 void (*sa_restorer) (void); 151 }; 152 #else /* uapi */ 153 struct sigaction 154 { 155 union 156 { 157 sighandler_t sa_handler; 158 void (*sa_sigaction) (int signum, siginfo_t *, void *); 159 }; 160 unsigned long sa_flags; 161 void (*sa_restorer) (void); 162 sigset_t sa_mask; 163 }; 164 #endif 165 166 #define SIG_DFL ((sighandler_t)0) 167 #define SIG_IGN ((sighandler_t)1) 168 #define SIG_ERR ((sighandler_t)-1) 169 170 #include <arch/signal.h> 171 172 int kill (pid_t pid, int signum); 173 int raise (int); 174 int sigaction (int signum, struct sigaction const *act, struct sigaction *oldact); 175 int sigaddset (sigset_t * set, int signum); 176 #if __MESC__ 177 void *signal (int signum, void *action); 178 #else 179 sighandler_t signal (int signum, sighandler_t action); 180 #endif 181 int sigemptyset (sigset_t * set); 182 #ifndef SIG_BLOCK 183 #define SIG_BLOCK 0 184 #define SIG_UNBLOCK 1 185 #define SIG_SETMASK 2 186 #endif 187 int sigprocmask (int how, sigset_t const *set, sigset_t * oldset); 188 189 #endif // !__M2__ 190 191 #endif //! SYSTEM_LIBC 192 193 #endif // __MES_SIGNAL_H