| 1 | /* Extended support for using signal values.
|
|---|
| 2 | Written by Fred Fish. [email protected]
|
|---|
| 3 | This file is in the public domain. */
|
|---|
| 4 |
|
|---|
| 5 | #include "ansidecl.h"
|
|---|
| 6 | #include "libiberty.h"
|
|---|
| 7 |
|
|---|
| 8 | #include "config.h"
|
|---|
| 9 |
|
|---|
| 10 | /* We need to declare sys_siglist, because even if the system provides
|
|---|
| 11 | it we can't assume that it is declared in <signal.h> (for example,
|
|---|
| 12 | SunOS provides sys_siglist, but it does not declare it in any
|
|---|
| 13 | header file). fHowever, we can't declare sys_siglist portably,
|
|---|
| 14 | because on some systems it is declared with const and on some
|
|---|
| 15 | systems it is declared without const. If we were using autoconf,
|
|---|
| 16 | we could work out the right declaration. Until, then we just
|
|---|
| 17 | ignore any declaration in the system header files, and always
|
|---|
| 18 | declare it ourselves. With luck, this will always work. */
|
|---|
| 19 | #define sys_siglist no_such_symbol
|
|---|
| 20 | #define sys_nsig sys_nsig__no_such_symbol
|
|---|
| 21 |
|
|---|
| 22 | #include <stdio.h>
|
|---|
| 23 | #include <signal.h>
|
|---|
| 24 |
|
|---|
| 25 | /* Routines imported from standard C runtime libraries. */
|
|---|
| 26 |
|
|---|
| 27 | #ifdef HAVE_STDLIB_H
|
|---|
| 28 | #include <stdlib.h>
|
|---|
| 29 | #else
|
|---|
| 30 | extern PTR malloc ();
|
|---|
| 31 | #endif
|
|---|
| 32 |
|
|---|
| 33 | #ifdef HAVE_STRING_H
|
|---|
| 34 | #include <string.h>
|
|---|
| 35 | #else
|
|---|
| 36 | extern PTR memset ();
|
|---|
| 37 | #endif
|
|---|
| 38 |
|
|---|
| 39 | /* Undefine the macro we used to hide the definition of sys_siglist
|
|---|
| 40 | found in the system header files. */
|
|---|
| 41 | #undef sys_siglist
|
|---|
| 42 | #undef sys_nsig
|
|---|
| 43 |
|
|---|
| 44 | #ifndef NULL
|
|---|
| 45 | # ifdef __STDC__
|
|---|
| 46 | # define NULL (void *) 0
|
|---|
| 47 | # else
|
|---|
| 48 | # define NULL 0
|
|---|
| 49 | # endif
|
|---|
| 50 | #endif
|
|---|
| 51 |
|
|---|
| 52 | #ifndef MAX
|
|---|
| 53 | # define MAX(a,b) ((a) > (b) ? (a) : (b))
|
|---|
| 54 | #endif
|
|---|
| 55 |
|
|---|
| 56 | static void init_signal_tables PARAMS ((void));
|
|---|
| 57 |
|
|---|
| 58 | /* Translation table for signal values.
|
|---|
| 59 |
|
|---|
| 60 | Note that this table is generally only accessed when it is used at runtime
|
|---|
| 61 | to initialize signal name and message tables that are indexed by signal
|
|---|
| 62 | value.
|
|---|
| 63 |
|
|---|
| 64 | Not all of these signals will exist on all systems. This table is the only
|
|---|
| 65 | thing that should have to be updated as new signal numbers are introduced.
|
|---|
| 66 | It's sort of ugly, but at least its portable. */
|
|---|
| 67 |
|
|---|
| 68 | struct signal_info
|
|---|
| 69 | {
|
|---|
| 70 | const int value; /* The numeric value from <signal.h> */
|
|---|
| 71 | const char *const name; /* The equivalent symbolic value */
|
|---|
| 72 | #ifndef HAVE_SYS_SIGLIST
|
|---|
| 73 | const char *const msg; /* Short message about this value */
|
|---|
| 74 | #endif
|
|---|
| 75 | };
|
|---|
| 76 |
|
|---|
| 77 | #ifndef HAVE_SYS_SIGLIST
|
|---|
| 78 | # define ENTRY(value, name, msg) {value, name, msg}
|
|---|
| 79 | #else
|
|---|
| 80 | # define ENTRY(value, name, msg) {value, name}
|
|---|
| 81 | #endif
|
|---|
| 82 |
|
|---|
| 83 | static const struct signal_info signal_table[] =
|
|---|
|
|---|