|
Message-ID: <20240805111313.1880ccf5@eclair>
Date: Mon, 5 Aug 2024 11:13:13 +0200
From: Joakim Sindholt <opensource@...sha.com>
To: musl@...ts.openwall.com
Subject: Re: [PATCH v2 1/3] src/signal/sys_signame.c: create hidden
value-name table of signals
On Mon, 5 Aug 2024 08:56:05 +0200
contact@...ktivis.me wrote:
> From: "Haelwenn (lanodan) Monnier" <contact@...ktivis.me>
>
> ---
> src/include/signal.h | 2 ++
> src/signal/sys_signame.c | 41 ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 43 insertions(+)
> create mode 100644 src/signal/sys_signame.c
>
> diff --git a/src/include/signal.h b/src/include/signal.h
> index bb566784..6bbc51d9 100644
> --- a/src/include/signal.h
> +++ b/src/include/signal.h
> @@ -11,4 +11,6 @@ hidden void __restore_sigs(void *);
>
> hidden void __get_handler_set(sigset_t *);
>
> +hidden extern const char __sys_signame[SIGSYS+1][sizeof("STKFLT")];
> +
> #endif
> diff --git a/src/signal/sys_signame.c b/src/signal/sys_signame.c
> new file mode 100644
> index 00000000..e086572c
> --- /dev/null
> +++ b/src/signal/sys_signame.c
> @@ -0,0 +1,41 @@
> +#include <signal.h>
> +
> +#define SIG(s) [SIG##s] = #s
> +const char __sys_signame[SIGSYS+1][sizeof("STKFLT")] = {
> + SIG(HUP),
> + SIG(INT),
> + SIG(QUIT),
> + SIG(ILL),
> + SIG(TRAP),
> + SIG(ABRT),
> + SIG(BUS),
> + SIG(FPE),
> + SIG(KILL),
> + SIG(USR1),
> + SIG(SEGV),
> + SIG(USR2),
> + SIG(PIPE),
> + SIG(ALRM),
> + SIG(TERM),
> +#if defined(SIGSTKFLT)
> + SIG(STKFLT),
> +#endif
> +#if defined(SIGEMT)
> + SIG(EMT),
> +#endif
> + SIG(CHLD),
> + SIG(CONT),
> + SIG(STOP),
> + SIG(TSTP),
> + SIG(TTIN),
> + SIG(TTOU),
> + SIG(URG),
> + SIG(XCPU),
> + SIG(XFSZ),
> + SIG(VTALRM),
> + SIG(PROF),
> + SIG(WINCH),
> + SIG(IO),
> + SIG(PWR),
> + SIG(SYS)
> +};
I know I'm being terribly annoying here but based on Rich's apparent
preference for saving rodata space we could take out SIGSTKFLT, VTALRM,
and WINCH. That leaves only 4-char signals with a handful of 3-char, and
since we need to search through a few aliases and special cases anyway
we could just add those 3 to a second table.
Also I hope there's a nicer way of making that table but this is what I
came up with in a hurry.
View attachment "sig2str.c" of type "text/x-c++src" (2280 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.