Changeset 1574 for trunk/src/emx/include/sys/signal.h
- Timestamp:
- Oct 10, 2004, 1:07:40 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/sys/signal.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1573 r1574 1 #ifdef __NEW_SIGNALS__ 2 /* $Id: $ */ 3 /** @file 4 * 5 * BSD compatible. 6 * 7 * 8 * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net> 9 * 10 * 11 * This file is part of InnoTek LIBC. 12 * 13 * InnoTek LIBC is free software; you can redistribute it and/or modify 14 * it under the terms of the GNU Lesser General Public License as published 15 * by the Free Software Foundation; either version 2 of the License, or 16 * (at your option) any later version. 17 * 18 * InnoTek LIBC is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU Lesser General Public License for more details. 22 * 23 * You should have received a copy of the GNU Lesser General Public License 24 * along with InnoTek LIBC; if not, write to the Free Software 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 * 27 */ 28 29 30 #ifndef _SYS_SIGNAL_H_ 31 #define _SYS_SIGNAL_H_ 32 33 /******************************************************************************* 34 * Header Files * 35 *******************************************************************************/ 36 #include <sys/cdefs.h> 37 #include <sys/_types.h> 38 #include <machine/signal.h> 39 40 41 /******************************************************************************* 42 * Defined Constants And Macros * 43 *******************************************************************************/ 44 /** @defgroup sys_signal_h_signo Signal numbers. 45 * @{ 46 */ 47 #if __XSI_VISIBLE || __POSIX_VISIBLE 48 #define SIGHUP 1 /** POSIX: Hangup */ 49 #endif 50 #define SIGINT 2 /** ANSI: Interrupt (Ctrl-C) */ 51 #if __XSI_VISIBLE || __POSIX_VISIBLE 52 #define SIGQUIT 3 /** POSIX: Quit */ 53 #endif 54 #define SIGILL 4 /** ANSI: Illegal instruction */ 55 #if __XSI_VISIBLE 56 #define SIGTRAP 5 /** POSIX: Single step (debugging) */ 57 #endif 58 #define SIGABRT 6 /** ANSI: abort () */ 59 #if __BSD_VISIBLE 60 #define SIGIOT SIGABRT /** BSD 4.2 */ 61 #define SIGEMT 7 /** BSD: EMT instruction */ 62 #endif 63 #define SIGFPE 8 /** ANSI: Floating point */ 64 #if __XSI_VISIBLE || __POSIX_VISIBLE 65 #define SIGKILL 9 /** POSIX: Kill process */ 66 #endif 67 #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 68 #define SIGBUS 10 /** BSD 4.2: Bus error */ 69 #endif 70 #define SIGSEGV 11 /** ANSI: Segmentation fault */ 71 #if __BSD_VISIBLE 72 #define SIGSYS 12 /** Invalid argument to system call */ 73 #endif 74 #if __XSI_VISIBLE || __POSIX_VISIBLE 75 #define SIGPIPE 13 /** POSIX: Broken pipe. */ 76 #define SIGALRM 14 /** POSIX: Alarm. */ 77 #endif 78 #define SIGTERM 15 /** ANSI: Termination, process killed */ 79 #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 80 #define SIGURG 16 /** POSIX/BSD: urgent condition on IO channel */ 81 #endif 82 #if __XSI_VISIBLE || __POSIX_VISIBLE 83 #define SIGSTOP 17 /** POSIX: Sendable stop signal not from tty. unblockable. */ 84 #define SIGTSTP 18 /** POSIX: Stop signal from tty. */ 85 #define SIGCONT 19 /** POSIX: Continue a stopped process. */ 86 #define SIGCHLD 20 /** POSIX: Death or stop of a child process. (EMX: 18) */ 87 #define SIGCLD SIGCHLD /** System V */ 88 #define SIGTTIN 21 /** POSIX: To readers pgrp upon background tty read. */ 89 #define SIGTTOU 22 /** POSIX: To readers pgrp upon background tty write. */ 90 #endif 91 #if __BSD_VISIBLE 92 #define SIGIO 23 /** BSD: Input/output possible signal. */ 93 #endif 94 #if __XSI_VISIBLE 95 #define SIGXCPU 24 /** BSD 4.2: Exceeded CPU time limit. */ 96 #define SIGXFSZ 25 /** BSD 4.2: Exceeded file size limit. */ 97 #define SIGVTALRM 26 /** BSD 4.2: Virtual time alarm. */ 98 #define SIGPROF 27 /** BSD 4.2: Profiling time alarm. */ 99 #endif 100 #if __BSD_VISIBLE 101 #define SIGWINCH 28 /** BSD 4.3: Window size change (not implemented). */ 102 #define SIGINFO 29 /** BSD 4.3: Information request. */ 103 #endif 104 #if __XSI_VISIBLE || __POSIX_VISIBLE 105 #define SIGUSR1 30 /** POSIX: User-defined signal #1 */ 106 #define SIGUSR2 31 /** POSIX: User-defined signal #2 */ 107 #endif 108 #define SIGBREAK 32 /** OS/2: Break (Ctrl-Break). (EMX: 21) */ 109 #if __BSD_VISIBLE 110 #define NSIG 33 /** Number of old style signals (counting zero). */ 111 #endif 112 113 #define SIGRTMIN 33 /** First real time signal. */ 114 #define SIGRTMAX 63 /** Last real time signal (inclusive) */ 115 /** @} */ 116 117 118 /** @defgroup sys_signal_h_sighnd Fake Signal Functions 119 * @{ 120 */ 121 #define SIG_ERR ((void (*)(int))-1) /** Failure. */ 122 #define SIG_DFL ((void (*)(int))0) /** Default action. */ 123 #define SIG_IGN ((void (*)(int))1) /** Ignore signal. */ 124 /* 2 is reserved for BSD internal use */ 125 #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 /** @todo check specs on SIG_HOLD. */ 126 #define SIG_HOLD ((void (*)(int))3) 127 #endif 128 #ifdef __BSD_VISIBLE 129 #define SIG_ACK ((void (*)(int))4) /** OS/2: Acknowledge a signal. */ 130 #endif 131 /** @} */ 132 133 134 /** @defgroup sys_signal_h_sigev Signal Event Notification Types. 135 * See struct sigevent. 136 * @{ 137 */ 138 #define SIGEV_NONE 0 /* No async notification */ 139 #define SIGEV_SIGNAL 1 /* Generate a queued signal */ 140 #define SIGEV_THREAD 2 /* Deliver via thread creation. */ 141 /** @} */ 142 143 144 /** @defgroup sys_signal_h_sigaction_flags Signal Action Flags. 145 * @{ 146 */ 147 #if __XSI_VISIBLE 148 /** Take signal on a registerd stack_t. */ 149 #define SA_ONSTACK 0x00000001 150 /** Restart system call on signal return. Not implemented on OS/2. */ 151 #define SA_RESTART 0x00000002 152 /** Reset signal handler to SIG_DFL when deliving the signal. */ 153 #define SA_RESETHAND 0x00000004 154 /** Don't mask the signal which is being delivered. */ 155 #define SA_NODEFER 0x00000010 156 /** Don't keep zombies around for wait*(). Not implmented on OS/2. */ 157 #define SA_NOCLDWAIT 0x00000020 158 /** Signal the handler with the full set of arguments. */ 159 #define SA_SIGINFO 0x00000040 160 #endif 161 #if __XSI_VISIBLE || __POSIX_VISIBLE 162 /** Do not generate SIGCHLD on child stop. */ 163 #define SA_NOCLDSTOP 0x00000008 164 #endif 165 /** Block the signal (OS/2 legacy mode). */ 166 #define SA_ACK 0x10000000 167 /** EMX compatibility. */ 168 #define SA_SYSV SA_RESETHAND 169 /** @} */ 170 171 172 #if __BSD_VISIBLE 173 /** #defgroup sys_signal_h_sigval_flags Signal Value Flags. 174 * BSD 4.3 compatibility. 175 * @{ 176 */ 177 #define SV_ONSTACK SA_ONSTACK 178 /** opposite sense. */ 179 #define SV_INTERRUPT SA_RESTART 180 #define SV_RESETHAND SA_RESETHAND 181 #define SV_NODEFER SA_NODEFER 182 #define SV_NOCLDSTOP SA_NOCLDSTOP 183 #define SV_SIGINFO SA_SIGINFO 184 /** @} */ 185 #endif 186 187 188 /** @defgroup sys_signal_h_stack_t_flags Signal Stack Flags. (ss_flags) 189 * @{ 190 */ 191 /** Deliver signal on alternate stack. */ 192 #define SS_ONSTACK 0x00000001 193 /** Do not take signal on alternate stack. */ 194 #define SS_DISABLE 0x00000004 195 /** @} */ 196 /** Recommended size for an alternate signal stack. (See stack_t) */ 197 #define SIGSTKSZ (0x10000) 198 199 200 201 #if __BSD_VISIBLE || __POSIX_VISIBLE > 0 && __POSIX_VISIBLE <= 200112 202 /** Convert signo to a signal mask for use with sigblock(). */ 203 #define sigmask(signo) (1 << ((signo) - 1)) 204 #endif 205 206 #if __BSD_VISIBLE 207 #define BADSIG SIG_ERR 208 #endif 209 210 #if __POSIX_VISIBLE || __XSI_VISIBLE 211 /* 212 * Flags for sigprocmask: 213 */ 214 /** @defgroup sys_signal_h_sigprocmask_flags Flags for sigprocmask(). 215 * @{ 216 */ 217 /** Block specified signal set. */ 218 #define SIG_BLOCK 1 219 /** Unblock specified signal set. */ 220 #define SIG_UNBLOCK 2 221 /** Set specified signal set. */ 222 #define SIG_SETMASK 3 223 #endif 224 225 226 227 /** @defgroup sys_signal_h_si_code siginfo_t.si_code values. 228 * @{ 229 */ 230 231 /** @defgroup sys_signal_h_si_code_sigill siginfo_t.si_code values - SIGILL 232 * @{ */ 233 /** Illegal opcode. */ 234 #define ILL_ILLOPC 0x80001001 235 /** Illegal operand. */ 236 #define ILL_ILLOPN 0x80001002 237 /** Illegal addressing mode. */ 238 #define ILL_ILLADR 0x80001003 239 /** Illegal trap. */ 240 #define ILL_ILLTRP 0x80001004 241 /** Privileged opcode. */ 242 #define ILL_PRVOPC 0x80001005 243 /** Privileged register. */ 244 #define ILL_PRVREG 0x80001006 245 /** Coprocessor error. */ 246 #define ILL_COPROC 0x80001007 247 /** Internal stack error. */ 248 #define ILL_BADSTK 0x80001008 249 /** @} */ 250 251 252 /** @defgroup sys_signal_h_si_code_sigfpe siginfo_t.si_code values - SIGILL 253 * @{ */ 254 /** see machine/trap.h. */ 255 /** @} */ 256 257 258 /** @defgroup sys_signal_h_si_code_sigsegv siginfo_t.si_code values - SIGSEGV 259 * @{ */ 260 /** Address not mapped to object. */ 261 #define SEGV_MAPERR 0x80003001 262 /** Invalid permissions for mapped object. */ 263 #define SEGV_ACCERR 0x80003002 264 /** @} */ 265 266 267 /** @defgroup sys_signal_h_si_code_sigbus siginfo_t.si_code values - SIGBUS 268 * @{ */ 269 /** Invalid address alignment. */ 270 #define BUS_ADRALN 0x80004001 271 /** Nonexistent physical address. */ 272 #define BUS_ADRERR 0x80004002 273 /** Object-specific hardware error. */ 274 #define BUS_OBJERR 0x80004003 275 /** @} */ 276 277 278 /** @defgroup sys_signal_h_si_code_sigtrap siginfo_t.si_code values - SIGTRAP 279 * @{ */ 280 /** Process breakpoint. */ 281 #define TRAP_BRKPT 0x80005001 282 /** Process trace trap. */ 283 #define TRAP_TRACE 0x80005002 284 /** @} */ 285 286 287 /** @defgroup sys_signal_h_si_code_sigchild siginfo_t.si_code values - SIGCHLD 288 * @{ */ 289 /** Child has exited. */ 290 #define CLD_EXITED 0x80006001 291 /** Child has terminated abnormally and did not create a core file. */ 292 #define CLD_KILLED 0x80006002 293 /** Child has terminated abnormally and created a core file. */ 294 #define CLD_DUMPED 0x80006003 295 /** Traced child has trapped. */ 296 #define CLD_TRAPPED 0x80006004 297 /** Child has stopped. */ 298 #define CLD_STOPPED 0x80006005 299 /** Stopped child has continued. */ 300 #define CLD_CONTINUED 0x80006006 301 /** @} */ 302 303 304 /** @defgroup sys_signal_h_si_code_sigpoll siginfo_t.si_code values - SIGPOLL 305 * @{ */ 306 /** Data input available. */ 307 #define POLL_IN 0x80007001 308 /** Output buffers available. */ 309 #define POLL_OUT 0x80007002 310 /** Input message available. */ 311 #define POLL_MSG 0x80007003 312 /** I/O error. */ 313 #define POLL_ERR 0x80007004 314 /** High priority input available. */ 315 #define POLL_PRI 0x80007005 316 /** Device disconnected. */ 317 #define POLL_HUP 0x80007006 318 /** @} */ 319 320 321 /** @defgroup sys_signal_h_siginfo_codes Signal Info Codes (si_code). 322 * @{ */ 323 #if __POSIX_VISIBLE || __XSI_VISIBLE 324 /** Sent by kill() or raise(). */ 325 #define SI_USER 0x00010001 326 /** Sent by sigqueue(). */ 327 #define SI_QUEUE 0x00010002 328 /** Sent cause a timer expired. */ 329 #define SI_TIMER 0x00010003 330 /** Sent upon AIO completion. */ 331 #define SI_ASYNCIO 0x00010004 332 /** Sent upon real time mesq state change. */ 333 #define SI_MESGQ 0x00010005 334 #endif 335 #if __BSD_VISIBLE 336 /** No idea. */ 337 #define SI_UNDEFINED 0x00000000 338 #endif 339 /** @} */ 340 341 /** @} */ 342 343 344 /******************************************************************************* 345 * Structures and Typedefs * 346 *******************************************************************************/ 347 #if __POSIX_VISIBLE || __XSI_VISIBLE 348 #ifndef _SIGSET_T_DECLARED 349 #define _SIGSET_T_DECLARED 350 /** Signal set. */ 351 typedef __sigset_t sigset_t; 352 #endif 353 #endif 354 355 356 #if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >= 500 357 /** Type for a value associated with a signal. */ 358 typedef union sigval 359 { 360 int sigval_int; 361 void *sigval_ptr; 362 } sigval_t; 363 #endif 364 365 366 #if __POSIX_VISIBLE >= 199309 367 /** Signal event. */ 368 typedef struct sigevent 369 { 370 /** Notification type. */ 371 int sigev_notify; 372 /** Signal number. */ 373 int sigev_signo; 374 /** Signal value. */ 375 union sigval sigev_value; 376 /** Thread Function. */ 377 void (*sigev_notify_function)(sigval_t); 378 /** Thread Attributes. */ 379 void *sigev_notify_attributes; 380 } sigevent_t; 381 #endif 382 383 384 #if __XSI_VISIBLE || __POSIX_VISIBLE >= 199309 385 /** 386 * Signal info. 387 */ 388 typedef struct __siginfo 389 { 390 /** Signal number. */ 391 int si_signo; 392 /** Associated errno. */ 393 int si_errno; 394 /** Signal code. (See SI_* and FPE_* macros.) */ 395 int si_code; 396 /** Timestamp when the signal was generated - LIBC extension. */ 397 unsigned si_timestamp; 398 /** Process sending the signal. */ 399 __pid_t si_pid; 400 /** Thread sending the signal - LIBC extension. */ 401 unsigned si_tid; 402 /** User sending the signal (ruid). (Usually 0 for OS/2) */ 403 __uid_t si_uid; 404 /** Exit value. (SIGCHLD) */ 405 int si_status; 406 /** Pointer to the faulting instruction or memory reference. (SIGSEGV, SIGILL, SIGFPE, SIGBUS) */ 407 void *si_addr; 408 /** Signal value. */ 409 union sigval si_value; 410 /** Band event for SIGPOLL. */ 411 long si_band; 412 /** Filehandle for SIGPOLL. */ 413 int si_fd; 414 /** Reserve a little bit for future usage. */ 415 unsigned auReserved[4]; 416 } siginfo_t; 417 #endif 418 419 420 #if __POSIX_VISIBLE || __XSI_VISIBLE 421 struct __siginfo; 422 423 /** Signal action structure for sigaction(). */ 424 struct sigaction 425 { 426 /** Two handler prototypes, __sa_handler is the exposed one, 427 * while __sa_sigaction is the one used internally. The two extra 428 * arguments will not cause any trouble because of the nature of 429 * __cdecl on i386. 430 */ 431 union 432 { 433 /** New style handler. First arg is signal number, second is signal 434 * info, third is signal specific (I think). */ 435 void (*__sa_sigaction)(int, struct __siginfo *, void *); 436 /** Old style handler. First arg is signal number. */ 437 void (*__sa_handler)(int); 438 } __sigaction_u; 439 /** Signal mask to apply when executing the action. */ 440 sigset_t sa_mask; 441 /** Signal action flags. (See SA_* macros.) */ 442 int sa_flags; 443 }; 444 #define sa_handler __sigaction_u.__sa_handler 445 #endif 446 447 448 #if __BSD_VISIBLE 449 /** BSD 4.3 compatibility. 450 * This structure is identical to sigaction. 451 */ 452 struct sigvec 453 { 454 /** See sa_sigaction in struct sigaction. */ 455 void (*sv_handler)(int, struct __siginfo *, void *); 456 /** See sa_mask in struct sigaction. */ 457 int sv_mask; 458 /** See sa_flags in struct sigaction. */ 459 int sv_flags; 460 }; 461 #define sv_onstack sv_flags 462 #endif 463 464 465 #if __XSI_VISIBLE 466 /* 467 * Structure used in sigaltstack call. 468 */ 469 #if __BSD_VISIBLE 470 typedef struct sigaltstack 471 #else 472 typedef struct 473 #endif 474 { 475 /** Stack base pointer. */ 476 void *ss_sp; 477 /** Stack size. */ 478 __size_t ss_size; 479 /** Flags. (SS_DISABLE and/or SS_ONSTACK) */ 480 int ss_flags; 481 } stack_t; 482 #endif 483 484 485 #if __XSI_VISIBLE 486 /** Structure for sigstack(). obsolete. */ 487 struct sigstack 488 { 489 /** Pointer to stack base. */ 490 void *ss_sp; 491 /** On stack indicator. Non zero if executing on this stack. */ 492 int ss_onstack; 493 }; 494 #endif 495 496 497 /******************************************************************************* 498 * Functions * 499 *******************************************************************************/ 500 501 __BEGIN_DECLS 502 void (*signal(int, void (*)(int)))(int); 503 504 void (*bsd_signal(int, void (*)(int)))(int); 505 void (*_signal_sysv(int, void (*)(int)))(int); 506 void (*_signal_os2(int, void (*)(int)))(int); 507 508 /** @define __LIBC_SIGNAL_SYSV 509 * #define __LIBC_SIGNAL_SYSV to use System V style signal. */ 510 #ifdef __LIBC_SIGNAL_SYSV 511 static inline void (*signal (int iSignalNo, void (*pfnHandler)(int)))(int) 512 { return _signal_sysv(iSignalNo, pfnHandler); } 513 #endif 514 515 /** @define __LIBC_SIGNAL_OS2 516 * #define __LIBC_SIGNAL_OS2 to use System V style signal. */ 517 #ifdef __LIBC_SIGNAL_OS2 518 static inline void (*signal (int iSignalNo, void (*pfnHandler)(int)))(int) 519 { return _signal_os2(iSignalNo, pfnHandler); } 520 #endif 521 522 __END_DECLS 523 524 525 #if 0 /** @todo various emx stuff. */ 526 #define SIGPTRACENOTIFY 128 /* Notification from ptrace() */ 527 #define SIGTY void 528 #endif 529 530 #endif /* not _SYS_SIGNAL_H */ 531 532 533 #else /* !__NEW_SIGNALS__ */ 534 535 1 536 /* sys/signal.h (emx+gcc) */ 2 537 … … 121 656 122 657 #endif /* not _SYS_SIGNAL_H */ 658 659 660 #endif /* !__NEW_SIGNALS__ */ -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.