mirror of https://github.com/sheumann/hush.git
Change libbb/signal.names.c to use C89-style constructs for ORCA/C compatibility.
This commit is contained in:
parent
9b98d32e66
commit
4e47bee9d2
|
@ -19,7 +19,11 @@
|
||||||
/* Believe it or not, but some arches have more than 32 SIGs!
|
/* Believe it or not, but some arches have more than 32 SIGs!
|
||||||
* HPPA: SIGSTKFLT == 36. */
|
* HPPA: SIGSTKFLT == 36. */
|
||||||
|
|
||||||
static const char signals[][7] = {
|
static char *signals[NSIG];
|
||||||
|
|
||||||
|
static bool signals_initialized = 0;
|
||||||
|
|
||||||
|
static void initialize_signals(void) {
|
||||||
// SUSv3 says kill must support these, and specifies the numerical values,
|
// SUSv3 says kill must support these, and specifies the numerical values,
|
||||||
// http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html
|
// http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html
|
||||||
// {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"},
|
// {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"},
|
||||||
|
@ -30,111 +34,122 @@ static const char signals[][7] = {
|
||||||
// {SIGCONT, "CONT"}, {SIGSTOP, "STOP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"},
|
// {SIGCONT, "CONT"}, {SIGSTOP, "STOP"}, {SIGTSTP, "TSTP"}, {SIGTTIN, "TTIN"},
|
||||||
// {SIGTTOU, "TTOU"}
|
// {SIGTTOU, "TTOU"}
|
||||||
|
|
||||||
[0] = "EXIT",
|
int i;
|
||||||
|
|
||||||
|
if (signals_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < NSIG; i++) {
|
||||||
|
signals[i] = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
signals[0] = "EXIT";
|
||||||
#ifdef SIGHUP
|
#ifdef SIGHUP
|
||||||
[SIGHUP ] = "HUP",
|
signals[SIGHUP ] = "HUP";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGINT
|
#ifdef SIGINT
|
||||||
[SIGINT ] = "INT",
|
signals[SIGINT ] = "INT";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGQUIT
|
#ifdef SIGQUIT
|
||||||
[SIGQUIT ] = "QUIT",
|
signals[SIGQUIT ] = "QUIT";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGILL
|
#ifdef SIGILL
|
||||||
[SIGILL ] = "ILL",
|
signals[SIGILL ] = "ILL";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGTRAP
|
#ifdef SIGTRAP
|
||||||
[SIGTRAP ] = "TRAP",
|
signals[SIGTRAP ] = "TRAP";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGABRT
|
#ifdef SIGABRT
|
||||||
[SIGABRT ] = "ABRT",
|
signals[SIGABRT ] = "ABRT";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGBUS
|
#ifdef SIGBUS
|
||||||
[SIGBUS ] = "BUS",
|
signals[SIGBUS ] = "BUS";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGFPE
|
#ifdef SIGFPE
|
||||||
[SIGFPE ] = "FPE",
|
signals[SIGFPE ] = "FPE";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGKILL
|
#ifdef SIGKILL
|
||||||
[SIGKILL ] = "KILL",
|
signals[SIGKILL ] = "KILL";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGUSR1
|
#ifdef SIGUSR1
|
||||||
[SIGUSR1 ] = "USR1",
|
signals[SIGUSR1 ] = "USR1";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGSEGV
|
#ifdef SIGSEGV
|
||||||
[SIGSEGV ] = "SEGV",
|
signals[SIGSEGV ] = "SEGV";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGUSR2
|
#ifdef SIGUSR2
|
||||||
[SIGUSR2 ] = "USR2",
|
signals[SIGUSR2 ] = "USR2";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGPIPE
|
#ifdef SIGPIPE
|
||||||
[SIGPIPE ] = "PIPE",
|
signals[SIGPIPE ] = "PIPE";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGALRM
|
#ifdef SIGALRM
|
||||||
[SIGALRM ] = "ALRM",
|
signals[SIGALRM ] = "ALRM";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGTERM
|
#ifdef SIGTERM
|
||||||
[SIGTERM ] = "TERM",
|
signals[SIGTERM ] = "TERM";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGSTKFLT
|
#ifdef SIGSTKFLT
|
||||||
[SIGSTKFLT] = "STKFLT",
|
signals[SIGSTKFLT] = "STKFLT";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGCHLD
|
#ifdef SIGCHLD
|
||||||
[SIGCHLD ] = "CHLD",
|
signals[SIGCHLD ] = "CHLD";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGCONT
|
#ifdef SIGCONT
|
||||||
[SIGCONT ] = "CONT",
|
signals[SIGCONT ] = "CONT";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGSTOP
|
#ifdef SIGSTOP
|
||||||
[SIGSTOP ] = "STOP",
|
signals[SIGSTOP ] = "STOP";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGTSTP
|
#ifdef SIGTSTP
|
||||||
[SIGTSTP ] = "TSTP",
|
signals[SIGTSTP ] = "TSTP";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGTTIN
|
#ifdef SIGTTIN
|
||||||
[SIGTTIN ] = "TTIN",
|
signals[SIGTTIN ] = "TTIN";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGTTOU
|
#ifdef SIGTTOU
|
||||||
[SIGTTOU ] = "TTOU",
|
signals[SIGTTOU ] = "TTOU";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGURG
|
#ifdef SIGURG
|
||||||
[SIGURG ] = "URG",
|
signals[SIGURG ] = "URG";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGXCPU
|
#ifdef SIGXCPU
|
||||||
[SIGXCPU ] = "XCPU",
|
signals[SIGXCPU ] = "XCPU";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGXFSZ
|
#ifdef SIGXFSZ
|
||||||
[SIGXFSZ ] = "XFSZ",
|
signals[SIGXFSZ ] = "XFSZ";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGVTALRM
|
#ifdef SIGVTALRM
|
||||||
[SIGVTALRM] = "VTALRM",
|
signals[SIGVTALRM] = "VTALRM";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGPROF
|
#ifdef SIGPROF
|
||||||
[SIGPROF ] = "PROF",
|
signals[SIGPROF ] = "PROF";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGWINCH
|
#ifdef SIGWINCH
|
||||||
[SIGWINCH ] = "WINCH",
|
signals[SIGWINCH ] = "WINCH";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGPOLL
|
#ifdef SIGPOLL
|
||||||
[SIGPOLL ] = "POLL",
|
signals[SIGPOLL ] = "POLL";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGPWR
|
#ifdef SIGPWR
|
||||||
[SIGPWR ] = "PWR",
|
signals[SIGPWR ] = "PWR";
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGSYS
|
#ifdef SIGSYS
|
||||||
[SIGSYS ] = "SYS",
|
signals[SIGSYS ] = "SYS";
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_RTMINMAX
|
#if ENABLE_FEATURE_RTMINMAX
|
||||||
# ifdef __SIGRTMIN
|
# ifdef __SIGRTMIN
|
||||||
[__SIGRTMIN] = "RTMIN",
|
signals[__SIGRTMIN] = "RTMIN";
|
||||||
# endif
|
# endif
|
||||||
// This makes array about x2 bigger.
|
// This makes array about x2 bigger.
|
||||||
// More compact approach is to special-case SIGRTMAX in print_signames()
|
// More compact approach is to special-case SIGRTMAX in print_signames()
|
||||||
//# ifdef __SIGRTMAX
|
//# ifdef __SIGRTMAX
|
||||||
// [__SIGRTMAX] = "RTMAX",
|
// signals[__SIGRTMAX] = "RTMAX";
|
||||||
//# endif
|
//# endif
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
signals_initialized = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Convert signal name to number.
|
// Convert signal name to number.
|
||||||
|
|
||||||
|
@ -142,6 +157,7 @@ int FAST_FUNC get_signum(const char *name)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
initialize_signals();
|
||||||
i = bb_strtou(name, NULL, 10);
|
i = bb_strtou(name, NULL, 10);
|
||||||
if (!errno)
|
if (!errno)
|
||||||
return i;
|
return i;
|
||||||
|
@ -208,6 +224,7 @@ int FAST_FUNC get_signum(const char *name)
|
||||||
|
|
||||||
const char* FAST_FUNC get_signame(int number)
|
const char* FAST_FUNC get_signame(int number)
|
||||||
{
|
{
|
||||||
|
initialize_signals();
|
||||||
if ((unsigned)number < ARRAY_SIZE(signals)) {
|
if ((unsigned)number < ARRAY_SIZE(signals)) {
|
||||||
if (signals[number][0]) /* if it's not an empty str */
|
if (signals[number][0]) /* if it's not an empty str */
|
||||||
return signals[number];
|
return signals[number];
|
||||||
|
@ -223,6 +240,7 @@ void FAST_FUNC print_signames(void)
|
||||||
{
|
{
|
||||||
unsigned signo;
|
unsigned signo;
|
||||||
|
|
||||||
|
initialize_signals();
|
||||||
for (signo = 1; signo < ARRAY_SIZE(signals); signo++) {
|
for (signo = 1; signo < ARRAY_SIZE(signals); signo++) {
|
||||||
const char *name = signals[signo];
|
const char *name = signals[signo];
|
||||||
if (name[0])
|
if (name[0])
|
||||||
|
|
Loading…
Reference in New Issue