On 06/13/13 12:32, Daniel J Sebald wrote:
derived from the attached files?
That's pretty nice Bruce. Please explain how this will be used
in the build process, just so I understand.
Not all users of gnulib necessarily have code generation tools,
so the generated file needs to get checked into gnulib.
I've attached a full patch this time. So the generated file
("sig2str-def.c") gets built by gnulib maintainers whenever they
need to modify the signal list or change the format of the
resulting sig2str-def.c file.
... If I'm following,
the first stage is that autoconf (?) will look through all
definitions for those beginning with SIG and then create
Nope. The thing gets nailed down at compile time based on
what SIGxxx macros get defined in signal.h. The offsets
to every string are computed by the compiler based on the
text the C pre-processor lets the compiler see. The list
of potential signals needs to be known by gnulib maintainers.
It feels that we are working toward creating a table that
doesn't group according to the signal number (i.e., synonyms),
Correct. It is basically unordered, though it is close to
numerical order. But since it's not 100%, you have to treat
it as unordered. The ordering is actually the order of the
definitions in sig2str.def.
I suppose that is a more initial
expectation for how such a thing would be organized.
It does feel a little unusual.
Cheers - Bruce
>From 93d1de20ca8881c58b276534393f370735c5b5e1 Mon Sep 17 00:00:00 2001
From: Bruce Korb <bk...@gnu.org>
Date: Thu, 13 Jun 2013 13:30:18 -0700
Subject: [PATCH] make strings static const data minimizing fixup
* lib/sig2str.def: list of potential signal names
* lib/sig2str.tpl: conversion instructions from list to sig2str-def.c
* lib/sig2str-def.c: derived from the above two files
* lib/sig2str.c: remove the data generated above
(str2signum): adjust data references
(sig2str): likewise
---
lib/sig2str-def.c | 648 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/sig2str.c | 218 +-----------------
lib/sig2str.def | 21 ++
lib/sig2str.tpl | 36 +++
4 files changed, 710 insertions(+), 213 deletions(-)
create mode 100644 lib/sig2str-def.c
create mode 100644 lib/sig2str.def
create mode 100644 lib/sig2str.tpl
diff --git a/lib/sig2str-def.c b/lib/sig2str-def.c
new file mode 100644
index 0000000..feb45df
--- /dev/null
+++ b/lib/sig2str-def.c
@@ -0,0 +1,648 @@
+
+#define SIG_OFFSET_AFTER_START 0
+
+static char const sig_strings[] =
+#ifdef SIGHUP
+#define SIG_HUP_OFFSET SIG_OFFSET_AFTER_START
+ "HUP\0"
+#define SIG_OFFSET_AFTER_HUP (SIG_OFFSET_AFTER_START + 4)
+#else
+#define SIG_OFFSET_AFTER_HUP SIG_OFFSET_AFTER_START
+#endif
+
+#ifdef SIGINT
+#define SIG_INT_OFFSET SIG_OFFSET_AFTER_HUP
+ "INT\0"
+#define SIG_OFFSET_AFTER_INT (SIG_OFFSET_AFTER_HUP + 4)
+#else
+#define SIG_OFFSET_AFTER_INT SIG_OFFSET_AFTER_HUP
+#endif
+
+#ifdef SIGQUIT
+#define SIG_QUIT_OFFSET SIG_OFFSET_AFTER_INT
+ "QUIT\0"
+#define SIG_OFFSET_AFTER_QUIT (SIG_OFFSET_AFTER_INT + 5)
+#else
+#define SIG_OFFSET_AFTER_QUIT SIG_OFFSET_AFTER_INT
+#endif
+
+#ifdef SIGILL
+#define SIG_ILL_OFFSET SIG_OFFSET_AFTER_QUIT
+ "ILL\0"
+#define SIG_OFFSET_AFTER_ILL (SIG_OFFSET_AFTER_QUIT + 4)
+#else
+#define SIG_OFFSET_AFTER_ILL SIG_OFFSET_AFTER_QUIT
+#endif
+
+#ifdef SIGTRAP
+#define SIG_TRAP_OFFSET SIG_OFFSET_AFTER_ILL
+ "TRAP\0"
+#define SIG_OFFSET_AFTER_TRAP (SIG_OFFSET_AFTER_ILL + 5)
+#else
+#define SIG_OFFSET_AFTER_TRAP SIG_OFFSET_AFTER_ILL
+#endif
+
+#ifdef SIGABRT
+#define SIG_ABRT_OFFSET SIG_OFFSET_AFTER_TRAP
+ "ABRT\0"
+#define SIG_OFFSET_AFTER_ABRT (SIG_OFFSET_AFTER_TRAP + 5)
+#else
+#define SIG_OFFSET_AFTER_ABRT SIG_OFFSET_AFTER_TRAP
+#endif
+
+#ifdef SIGFPE
+#define SIG_FPE_OFFSET SIG_OFFSET_AFTER_ABRT
+ "FPE\0"
+#define SIG_OFFSET_AFTER_FPE (SIG_OFFSET_AFTER_ABRT + 4)
+#else
+#define SIG_OFFSET_AFTER_FPE SIG_OFFSET_AFTER_ABRT
+#endif
+
+#ifdef SIGKILL
+#define SIG_KILL_OFFSET SIG_OFFSET_AFTER_FPE
+ "KILL\0"
+#define SIG_OFFSET_AFTER_KILL (SIG_OFFSET_AFTER_FPE + 5)
+#else
+#define SIG_OFFSET_AFTER_KILL SIG_OFFSET_AFTER_FPE
+#endif
+
+#ifdef SIGSEGV
+#define SIG_SEGV_OFFSET SIG_OFFSET_AFTER_KILL
+ "SEGV\0"
+#define SIG_OFFSET_AFTER_SEGV (SIG_OFFSET_AFTER_KILL + 5)
+#else
+#define SIG_OFFSET_AFTER_SEGV SIG_OFFSET_AFTER_KILL
+#endif
+
+#ifdef SIGBUS
+#define SIG_BUS_OFFSET SIG_OFFSET_AFTER_SEGV
+ "BUS\0"
+#define SIG_OFFSET_AFTER_BUS (SIG_OFFSET_AFTER_SEGV + 4)
+#else
+#define SIG_OFFSET_AFTER_BUS SIG_OFFSET_AFTER_SEGV
+#endif
+
+#ifdef SIGPIPE
+#define SIG_PIPE_OFFSET SIG_OFFSET_AFTER_BUS
+ "PIPE\0"
+#define SIG_OFFSET_AFTER_PIPE (SIG_OFFSET_AFTER_BUS + 5)
+#else
+#define SIG_OFFSET_AFTER_PIPE SIG_OFFSET_AFTER_BUS
+#endif
+
+#ifdef SIGALRM
+#define SIG_ALRM_OFFSET SIG_OFFSET_AFTER_PIPE
+ "ALRM\0"
+#define SIG_OFFSET_AFTER_ALRM (SIG_OFFSET_AFTER_PIPE + 5)
+#else
+#define SIG_OFFSET_AFTER_ALRM SIG_OFFSET_AFTER_PIPE
+#endif
+
+#ifdef SIGTERM
+#define SIG_TERM_OFFSET SIG_OFFSET_AFTER_ALRM
+ "TERM\0"
+#define SIG_OFFSET_AFTER_TERM (SIG_OFFSET_AFTER_ALRM + 5)
+#else
+#define SIG_OFFSET_AFTER_TERM SIG_OFFSET_AFTER_ALRM
+#endif
+
+#ifdef SIGUSR1
+#define SIG_USR1_OFFSET SIG_OFFSET_AFTER_TERM
+ "USR1\0"
+#define SIG_OFFSET_AFTER_USR1 (SIG_OFFSET_AFTER_TERM + 5)
+#else
+#define SIG_OFFSET_AFTER_USR1 SIG_OFFSET_AFTER_TERM
+#endif
+
+#ifdef SIGUSR2
+#define SIG_USR2_OFFSET SIG_OFFSET_AFTER_USR1
+ "USR2\0"
+#define SIG_OFFSET_AFTER_USR2 (SIG_OFFSET_AFTER_USR1 + 5)
+#else
+#define SIG_OFFSET_AFTER_USR2 SIG_OFFSET_AFTER_USR1
+#endif
+
+#ifdef SIGCHLD
+#define SIG_CHLD_OFFSET SIG_OFFSET_AFTER_USR2
+ "CHLD\0"
+#define SIG_OFFSET_AFTER_CHLD (SIG_OFFSET_AFTER_USR2 + 5)
+#else
+#define SIG_OFFSET_AFTER_CHLD SIG_OFFSET_AFTER_USR2
+#endif
+
+#ifdef SIGURG
+#define SIG_URG_OFFSET SIG_OFFSET_AFTER_CHLD
+ "URG\0"
+#define SIG_OFFSET_AFTER_URG (SIG_OFFSET_AFTER_CHLD + 4)
+#else
+#define SIG_OFFSET_AFTER_URG SIG_OFFSET_AFTER_CHLD
+#endif
+
+#ifdef SIGSTOP
+#define SIG_STOP_OFFSET SIG_OFFSET_AFTER_URG
+ "STOP\0"
+#define SIG_OFFSET_AFTER_STOP (SIG_OFFSET_AFTER_URG + 5)
+#else
+#define SIG_OFFSET_AFTER_STOP SIG_OFFSET_AFTER_URG
+#endif
+
+#ifdef SIGTSTP
+#define SIG_TSTP_OFFSET SIG_OFFSET_AFTER_STOP
+ "TSTP\0"
+#define SIG_OFFSET_AFTER_TSTP (SIG_OFFSET_AFTER_STOP + 5)
+#else
+#define SIG_OFFSET_AFTER_TSTP SIG_OFFSET_AFTER_STOP
+#endif
+
+#ifdef SIGCONT
+#define SIG_CONT_OFFSET SIG_OFFSET_AFTER_TSTP
+ "CONT\0"
+#define SIG_OFFSET_AFTER_CONT (SIG_OFFSET_AFTER_TSTP + 5)
+#else
+#define SIG_OFFSET_AFTER_CONT SIG_OFFSET_AFTER_TSTP
+#endif
+
+#ifdef SIGTTIN
+#define SIG_TTIN_OFFSET SIG_OFFSET_AFTER_CONT
+ "TTIN\0"
+#define SIG_OFFSET_AFTER_TTIN (SIG_OFFSET_AFTER_CONT + 5)
+#else
+#define SIG_OFFSET_AFTER_TTIN SIG_OFFSET_AFTER_CONT
+#endif
+
+#ifdef SIGTTOU
+#define SIG_TTOU_OFFSET SIG_OFFSET_AFTER_TTIN
+ "TTOU\0"
+#define SIG_OFFSET_AFTER_TTOU (SIG_OFFSET_AFTER_TTIN + 5)
+#else
+#define SIG_OFFSET_AFTER_TTOU SIG_OFFSET_AFTER_TTIN
+#endif
+
+#ifdef SIGSYS
+#define SIG_SYS_OFFSET SIG_OFFSET_AFTER_TTOU
+ "SYS\0"
+#define SIG_OFFSET_AFTER_SYS (SIG_OFFSET_AFTER_TTOU + 4)
+#else
+#define SIG_OFFSET_AFTER_SYS SIG_OFFSET_AFTER_TTOU
+#endif
+
+#ifdef SIGPOLL
+#define SIG_POLL_OFFSET SIG_OFFSET_AFTER_SYS
+ "POLL\0"
+#define SIG_OFFSET_AFTER_POLL (SIG_OFFSET_AFTER_SYS + 5)
+#else
+#define SIG_OFFSET_AFTER_POLL SIG_OFFSET_AFTER_SYS
+#endif
+
+#ifdef SIGVTALRM
+#define SIG_VTALRM_OFFSET SIG_OFFSET_AFTER_POLL
+ "VTALRM\0"
+#define SIG_OFFSET_AFTER_VTALRM (SIG_OFFSET_AFTER_POLL + 7)
+#else
+#define SIG_OFFSET_AFTER_VTALRM SIG_OFFSET_AFTER_POLL
+#endif
+
+#ifdef SIGPROF
+#define SIG_PROF_OFFSET SIG_OFFSET_AFTER_VTALRM
+ "PROF\0"
+#define SIG_OFFSET_AFTER_PROF (SIG_OFFSET_AFTER_VTALRM + 5)
+#else
+#define SIG_OFFSET_AFTER_PROF SIG_OFFSET_AFTER_VTALRM
+#endif
+
+#ifdef SIGXCPU
+#define SIG_XCPU_OFFSET SIG_OFFSET_AFTER_PROF
+ "XCPU\0"
+#define SIG_OFFSET_AFTER_XCPU (SIG_OFFSET_AFTER_PROF + 5)
+#else
+#define SIG_OFFSET_AFTER_XCPU SIG_OFFSET_AFTER_PROF
+#endif
+
+#ifdef SIGXFSZ
+#define SIG_XFSZ_OFFSET SIG_OFFSET_AFTER_XCPU
+ "XFSZ\0"
+#define SIG_OFFSET_AFTER_XFSZ (SIG_OFFSET_AFTER_XCPU + 5)
+#else
+#define SIG_OFFSET_AFTER_XFSZ SIG_OFFSET_AFTER_XCPU
+#endif
+
+#ifdef SIGIOT
+#define SIG_IOT_OFFSET SIG_OFFSET_AFTER_XFSZ
+ "IOT\0"
+#define SIG_OFFSET_AFTER_IOT (SIG_OFFSET_AFTER_XFSZ + 4)
+#else
+#define SIG_OFFSET_AFTER_IOT SIG_OFFSET_AFTER_XFSZ
+#endif
+
+#ifdef SIGEMT
+#define SIG_EMT_OFFSET SIG_OFFSET_AFTER_IOT
+ "EMT\0"
+#define SIG_OFFSET_AFTER_EMT (SIG_OFFSET_AFTER_IOT + 4)
+#else
+#define SIG_OFFSET_AFTER_EMT SIG_OFFSET_AFTER_IOT
+#endif
+
+#ifdef SIGPHONE
+#define SIG_PHONE_OFFSET SIG_OFFSET_AFTER_EMT
+ "PHONE\0"
+#define SIG_OFFSET_AFTER_PHONE (SIG_OFFSET_AFTER_EMT + 6)
+#else
+#define SIG_OFFSET_AFTER_PHONE SIG_OFFSET_AFTER_EMT
+#endif
+
+#ifdef SIGWIND
+#define SIG_WIND_OFFSET SIG_OFFSET_AFTER_PHONE
+ "WIND\0"
+#define SIG_OFFSET_AFTER_WIND (SIG_OFFSET_AFTER_PHONE + 5)
+#else
+#define SIG_OFFSET_AFTER_WIND SIG_OFFSET_AFTER_PHONE
+#endif
+
+#ifdef SIGCLD
+#define SIG_CLD_OFFSET SIG_OFFSET_AFTER_WIND
+ "CLD\0"
+#define SIG_OFFSET_AFTER_CLD (SIG_OFFSET_AFTER_WIND + 4)
+#else
+#define SIG_OFFSET_AFTER_CLD SIG_OFFSET_AFTER_WIND
+#endif
+
+#ifdef SIGPWR
+#define SIG_PWR_OFFSET SIG_OFFSET_AFTER_CLD
+ "PWR\0"
+#define SIG_OFFSET_AFTER_PWR (SIG_OFFSET_AFTER_CLD + 4)
+#else
+#define SIG_OFFSET_AFTER_PWR SIG_OFFSET_AFTER_CLD
+#endif
+
+#ifdef SIGCANCEL
+#define SIG_CANCEL_OFFSET SIG_OFFSET_AFTER_PWR
+ "CANCEL\0"
+#define SIG_OFFSET_AFTER_CANCEL (SIG_OFFSET_AFTER_PWR + 7)
+#else
+#define SIG_OFFSET_AFTER_CANCEL SIG_OFFSET_AFTER_PWR
+#endif
+
+#ifdef SIGLWP
+#define SIG_LWP_OFFSET SIG_OFFSET_AFTER_CANCEL
+ "LWP\0"
+#define SIG_OFFSET_AFTER_LWP (SIG_OFFSET_AFTER_CANCEL + 4)
+#else
+#define SIG_OFFSET_AFTER_LWP SIG_OFFSET_AFTER_CANCEL
+#endif
+
+#ifdef SIGWAITING
+#define SIG_WAITING_OFFSET SIG_OFFSET_AFTER_LWP
+ "WAITING\0"
+#define SIG_OFFSET_AFTER_WAITING (SIG_OFFSET_AFTER_LWP + 8)
+#else
+#define SIG_OFFSET_AFTER_WAITING SIG_OFFSET_AFTER_LWP
+#endif
+
+#ifdef SIGFREEZE
+#define SIG_FREEZE_OFFSET SIG_OFFSET_AFTER_WAITING
+ "FREEZE\0"
+#define SIG_OFFSET_AFTER_FREEZE (SIG_OFFSET_AFTER_WAITING + 7)
+#else
+#define SIG_OFFSET_AFTER_FREEZE SIG_OFFSET_AFTER_WAITING
+#endif
+
+#ifdef SIGTHAW
+#define SIG_THAW_OFFSET SIG_OFFSET_AFTER_FREEZE
+ "THAW\0"
+#define SIG_OFFSET_AFTER_THAW (SIG_OFFSET_AFTER_FREEZE + 5)
+#else
+#define SIG_OFFSET_AFTER_THAW SIG_OFFSET_AFTER_FREEZE
+#endif
+
+#ifdef SIGLOST
+#define SIG_LOST_OFFSET SIG_OFFSET_AFTER_THAW
+ "LOST\0"
+#define SIG_OFFSET_AFTER_LOST (SIG_OFFSET_AFTER_THAW + 5)
+#else
+#define SIG_OFFSET_AFTER_LOST SIG_OFFSET_AFTER_THAW
+#endif
+
+#ifdef SIGWINCH
+#define SIG_WINCH_OFFSET SIG_OFFSET_AFTER_LOST
+ "WINCH\0"
+#define SIG_OFFSET_AFTER_WINCH (SIG_OFFSET_AFTER_LOST + 6)
+#else
+#define SIG_OFFSET_AFTER_WINCH SIG_OFFSET_AFTER_LOST
+#endif
+
+#ifdef SIGINFO
+#define SIG_INFO_OFFSET SIG_OFFSET_AFTER_WINCH
+ "INFO\0"
+#define SIG_OFFSET_AFTER_INFO (SIG_OFFSET_AFTER_WINCH + 5)
+#else
+#define SIG_OFFSET_AFTER_INFO SIG_OFFSET_AFTER_WINCH
+#endif
+
+#ifdef SIGIO
+#define SIG_IO_OFFSET SIG_OFFSET_AFTER_INFO
+ "IO\0"
+#define SIG_OFFSET_AFTER_IO (SIG_OFFSET_AFTER_INFO + 3)
+#else
+#define SIG_OFFSET_AFTER_IO SIG_OFFSET_AFTER_INFO
+#endif
+
+#ifdef SIGSTKFLT
+#define SIG_STKFLT_OFFSET SIG_OFFSET_AFTER_IO
+ "STKFLT\0"
+#define SIG_OFFSET_AFTER_STKFLT (SIG_OFFSET_AFTER_IO + 7)
+#else
+#define SIG_OFFSET_AFTER_STKFLT SIG_OFFSET_AFTER_IO
+#endif
+
+#ifdef SIGDANGER
+#define SIG_DANGER_OFFSET SIG_OFFSET_AFTER_STKFLT
+ "DANGER\0"
+#define SIG_OFFSET_AFTER_DANGER (SIG_OFFSET_AFTER_STKFLT + 7)
+#else
+#define SIG_OFFSET_AFTER_DANGER SIG_OFFSET_AFTER_STKFLT
+#endif
+
+#ifdef SIGGRANT
+#define SIG_GRANT_OFFSET SIG_OFFSET_AFTER_DANGER
+ "GRANT\0"
+#define SIG_OFFSET_AFTER_GRANT (SIG_OFFSET_AFTER_DANGER + 6)
+#else
+#define SIG_OFFSET_AFTER_GRANT SIG_OFFSET_AFTER_DANGER
+#endif
+
+#ifdef SIGMIGRATE
+#define SIG_MIGRATE_OFFSET SIG_OFFSET_AFTER_GRANT
+ "MIGRATE\0"
+#define SIG_OFFSET_AFTER_MIGRATE (SIG_OFFSET_AFTER_GRANT + 8)
+#else
+#define SIG_OFFSET_AFTER_MIGRATE SIG_OFFSET_AFTER_GRANT
+#endif
+
+#ifdef SIGMSG
+#define SIG_MSG_OFFSET SIG_OFFSET_AFTER_MIGRATE
+ "MSG\0"
+#define SIG_OFFSET_AFTER_MSG (SIG_OFFSET_AFTER_MIGRATE + 4)
+#else
+#define SIG_OFFSET_AFTER_MSG SIG_OFFSET_AFTER_MIGRATE
+#endif
+
+#ifdef SIGPRE
+#define SIG_PRE_OFFSET SIG_OFFSET_AFTER_MSG
+ "PRE\0"
+#define SIG_OFFSET_AFTER_PRE (SIG_OFFSET_AFTER_MSG + 4)
+#else
+#define SIG_OFFSET_AFTER_PRE SIG_OFFSET_AFTER_MSG
+#endif
+
+#ifdef SIGRETRACT
+#define SIG_RETRACT_OFFSET SIG_OFFSET_AFTER_PRE
+ "RETRACT\0"
+#define SIG_OFFSET_AFTER_RETRACT (SIG_OFFSET_AFTER_PRE + 8)
+#else
+#define SIG_OFFSET_AFTER_RETRACT SIG_OFFSET_AFTER_PRE
+#endif
+
+#ifdef SIGSAK
+#define SIG_SAK_OFFSET SIG_OFFSET_AFTER_RETRACT
+ "SAK\0"
+#define SIG_OFFSET_AFTER_SAK (SIG_OFFSET_AFTER_RETRACT + 4)
+#else
+#define SIG_OFFSET_AFTER_SAK SIG_OFFSET_AFTER_RETRACT
+#endif
+
+#ifdef SIGSOUND
+#define SIG_SOUND_OFFSET SIG_OFFSET_AFTER_SAK
+ "SOUND\0"
+#define SIG_OFFSET_AFTER_SOUND (SIG_OFFSET_AFTER_SAK + 6)
+#else
+#define SIG_OFFSET_AFTER_SOUND SIG_OFFSET_AFTER_SAK
+#endif
+
+#ifdef SIGALRM1
+#define SIG_ALRM1_OFFSET SIG_OFFSET_AFTER_SOUND
+ "ALRM1\0"
+#define SIG_OFFSET_AFTER_ALRM1 (SIG_OFFSET_AFTER_SOUND + 6)
+#else
+#define SIG_OFFSET_AFTER_ALRM1 SIG_OFFSET_AFTER_SOUND
+#endif
+
+#ifdef SIGKAP
+#define SIG_KAP_OFFSET SIG_OFFSET_AFTER_ALRM1
+ "KAP\0"
+#define SIG_OFFSET_AFTER_KAP (SIG_OFFSET_AFTER_ALRM1 + 4)
+#else
+#define SIG_OFFSET_AFTER_KAP SIG_OFFSET_AFTER_ALRM1
+#endif
+
+#ifdef SIGVIRT
+#define SIG_VIRT_OFFSET SIG_OFFSET_AFTER_KAP
+ "VIRT\0"
+#define SIG_OFFSET_AFTER_VIRT (SIG_OFFSET_AFTER_KAP + 5)
+#else
+#define SIG_OFFSET_AFTER_VIRT SIG_OFFSET_AFTER_KAP
+#endif
+
+#ifdef SIGWINDOW
+#define SIG_WINDOW_OFFSET SIG_OFFSET_AFTER_VIRT
+ "WINDOW\0"
+#define SIG_OFFSET_AFTER_WINDOW (SIG_OFFSET_AFTER_VIRT + 7)
+#else
+#define SIG_OFFSET_AFTER_WINDOW SIG_OFFSET_AFTER_VIRT
+#endif
+
+#ifdef SIGKILLTHR
+#define SIG_KILLTHR_OFFSET SIG_OFFSET_AFTER_WINDOW
+ "KILLTHR\0"
+#define SIG_OFFSET_AFTER_KILLTHR (SIG_OFFSET_AFTER_WINDOW + 8)
+#else
+#define SIG_OFFSET_AFTER_KILLTHR SIG_OFFSET_AFTER_WINDOW
+#endif
+
+#ifdef SIGDIL
+#define SIG_DIL_OFFSET SIG_OFFSET_AFTER_KILLTHR
+ "DIL\0"
+#endif
+;
+
+static struct num_off {
+ int sig_id;
+ unsigned int sig_nm_off;
+} sig_offsets[59] = {
+#ifdef SIGHUP
+ { SIGHUP, SIG_HUP_OFFSET },
+#endif
+#ifdef SIGINT
+ { SIGINT, SIG_INT_OFFSET },
+#endif
+#ifdef SIGQUIT
+ { SIGQUIT, SIG_QUIT_OFFSET },
+#endif
+#ifdef SIGILL
+ { SIGILL, SIG_ILL_OFFSET },
+#endif
+#ifdef SIGTRAP
+ { SIGTRAP, SIG_TRAP_OFFSET },
+#endif
+#ifdef SIGABRT
+ { SIGABRT, SIG_ABRT_OFFSET },
+#endif
+#ifdef SIGFPE
+ { SIGFPE, SIG_FPE_OFFSET },
+#endif
+#ifdef SIGKILL
+ { SIGKILL, SIG_KILL_OFFSET },
+#endif
+#ifdef SIGSEGV
+ { SIGSEGV, SIG_SEGV_OFFSET },
+#endif
+#ifdef SIGBUS
+ { SIGBUS, SIG_BUS_OFFSET },
+#endif
+#ifdef SIGPIPE
+ { SIGPIPE, SIG_PIPE_OFFSET },
+#endif
+#ifdef SIGALRM
+ { SIGALRM, SIG_ALRM_OFFSET },
+#endif
+#ifdef SIGTERM
+ { SIGTERM, SIG_TERM_OFFSET },
+#endif
+#ifdef SIGUSR1
+ { SIGUSR1, SIG_USR1_OFFSET },
+#endif
+#ifdef SIGUSR2
+ { SIGUSR2, SIG_USR2_OFFSET },
+#endif
+#ifdef SIGCHLD
+ { SIGCHLD, SIG_CHLD_OFFSET },
+#endif
+#ifdef SIGURG
+ { SIGURG, SIG_URG_OFFSET },
+#endif
+#ifdef SIGSTOP
+ { SIGSTOP, SIG_STOP_OFFSET },
+#endif
+#ifdef SIGTSTP
+ { SIGTSTP, SIG_TSTP_OFFSET },
+#endif
+#ifdef SIGCONT
+ { SIGCONT, SIG_CONT_OFFSET },
+#endif
+#ifdef SIGTTIN
+ { SIGTTIN, SIG_TTIN_OFFSET },
+#endif
+#ifdef SIGTTOU
+ { SIGTTOU, SIG_TTOU_OFFSET },
+#endif
+#ifdef SIGSYS
+ { SIGSYS, SIG_SYS_OFFSET },
+#endif
+#ifdef SIGPOLL
+ { SIGPOLL, SIG_POLL_OFFSET },
+#endif
+#ifdef SIGVTALRM
+ { SIGVTALRM, SIG_VTALRM_OFFSET },
+#endif
+#ifdef SIGPROF
+ { SIGPROF, SIG_PROF_OFFSET },
+#endif
+#ifdef SIGXCPU
+ { SIGXCPU, SIG_XCPU_OFFSET },
+#endif
+#ifdef SIGXFSZ
+ { SIGXFSZ, SIG_XFSZ_OFFSET },
+#endif
+#ifdef SIGIOT
+ { SIGIOT, SIG_IOT_OFFSET },
+#endif
+#ifdef SIGEMT
+ { SIGEMT, SIG_EMT_OFFSET },
+#endif
+#ifdef SIGPHONE
+ { SIGPHONE, SIG_PHONE_OFFSET },
+#endif
+#ifdef SIGWIND
+ { SIGWIND, SIG_WIND_OFFSET },
+#endif
+#ifdef SIGCLD
+ { SIGCLD, SIG_CLD_OFFSET },
+#endif
+#ifdef SIGPWR
+ { SIGPWR, SIG_PWR_OFFSET },
+#endif
+#ifdef SIGCANCEL
+ { SIGCANCEL, SIG_CANCEL_OFFSET },
+#endif
+#ifdef SIGLWP
+ { SIGLWP, SIG_LWP_OFFSET },
+#endif
+#ifdef SIGWAITING
+ { SIGWAITING, SIG_WAITING_OFFSET },
+#endif
+#ifdef SIGFREEZE
+ { SIGFREEZE, SIG_FREEZE_OFFSET },
+#endif
+#ifdef SIGTHAW
+ { SIGTHAW, SIG_THAW_OFFSET },
+#endif
+#ifdef SIGLOST
+ { SIGLOST, SIG_LOST_OFFSET },
+#endif
+#ifdef SIGWINCH
+ { SIGWINCH, SIG_WINCH_OFFSET },
+#endif
+#ifdef SIGINFO
+ { SIGINFO, SIG_INFO_OFFSET },
+#endif
+#ifdef SIGIO
+ { SIGIO, SIG_IO_OFFSET },
+#endif
+#ifdef SIGSTKFLT
+ { SIGSTKFLT, SIG_STKFLT_OFFSET },
+#endif
+#ifdef SIGDANGER
+ { SIGDANGER, SIG_DANGER_OFFSET },
+#endif
+#ifdef SIGGRANT
+ { SIGGRANT, SIG_GRANT_OFFSET },
+#endif
+#ifdef SIGMIGRATE
+ { SIGMIGRATE, SIG_MIGRATE_OFFSET },
+#endif
+#ifdef SIGMSG
+ { SIGMSG, SIG_MSG_OFFSET },
+#endif
+#ifdef SIGPRE
+ { SIGPRE, SIG_PRE_OFFSET },
+#endif
+#ifdef SIGRETRACT
+ { SIGRETRACT, SIG_RETRACT_OFFSET },
+#endif
+#ifdef SIGSAK
+ { SIGSAK, SIG_SAK_OFFSET },
+#endif
+#ifdef SIGSOUND
+ { SIGSOUND, SIG_SOUND_OFFSET },
+#endif
+#ifdef SIGALRM1
+ { SIGALRM1, SIG_ALRM1_OFFSET },
+#endif
+#ifdef SIGKAP
+ { SIGKAP, SIG_KAP_OFFSET },
+#endif
+#ifdef SIGVIRT
+ { SIGVIRT, SIG_VIRT_OFFSET },
+#endif
+#ifdef SIGWINDOW
+ { SIGWINDOW, SIG_WINDOW_OFFSET },
+#endif
+#ifdef SIGKILLTHR
+ { SIGKILLTHR, SIG_KILLTHR_OFFSET },
+#endif
+#ifdef SIGDIL
+ { SIGDIL, SIG_DIL_OFFSET },
+#endif
+ /* Korn shell and Bash, of uncertain vintage. */
+ { 0, "EXIT" }
+};
+#define NUMNAME_ENTRIES 59
diff --git a/lib/sig2str.c b/lib/sig2str.c
index 6ead2a7..2efe877 100644
--- a/lib/sig2str.c
+++ b/lib/sig2str.c
@@ -35,215 +35,7 @@
# define SIGRTMAX (SIGRTMIN - 1)
#endif
-#define NUMNAME(name) { SIG##name, #name }
-
-/* Signal names and numbers. Put the preferred name first. */
-static struct numname { int num; char const name[8]; } numname_table[] =
- {
- /* Signals required by POSIX 1003.1-2001 base, listed in
- traditional numeric order where possible. */
-#ifdef SIGHUP
- NUMNAME (HUP),
-#endif
-#ifdef SIGINT
- NUMNAME (INT),
-#endif
-#ifdef SIGQUIT
- NUMNAME (QUIT),
-#endif
-#ifdef SIGILL
- NUMNAME (ILL),
-#endif
-#ifdef SIGTRAP
- NUMNAME (TRAP),
-#endif
-#ifdef SIGABRT
- NUMNAME (ABRT),
-#endif
-#ifdef SIGFPE
- NUMNAME (FPE),
-#endif
-#ifdef SIGKILL
- NUMNAME (KILL),
-#endif
-#ifdef SIGSEGV
- NUMNAME (SEGV),
-#endif
- /* On Haiku, SIGSEGV == SIGBUS, but we prefer SIGSEGV to match
- strsignal.c output, so SIGBUS must be listed second. */
-#ifdef SIGBUS
- NUMNAME (BUS),
-#endif
-#ifdef SIGPIPE
- NUMNAME (PIPE),
-#endif
-#ifdef SIGALRM
- NUMNAME (ALRM),
-#endif
-#ifdef SIGTERM
- NUMNAME (TERM),
-#endif
-#ifdef SIGUSR1
- NUMNAME (USR1),
-#endif
-#ifdef SIGUSR2
- NUMNAME (USR2),
-#endif
-#ifdef SIGCHLD
- NUMNAME (CHLD),
-#endif
-#ifdef SIGURG
- NUMNAME (URG),
-#endif
-#ifdef SIGSTOP
- NUMNAME (STOP),
-#endif
-#ifdef SIGTSTP
- NUMNAME (TSTP),
-#endif
-#ifdef SIGCONT
- NUMNAME (CONT),
-#endif
-#ifdef SIGTTIN
- NUMNAME (TTIN),
-#endif
-#ifdef SIGTTOU
- NUMNAME (TTOU),
-#endif
-
- /* Signals required by POSIX 1003.1-2001 with the XSI extension. */
-#ifdef SIGSYS
- NUMNAME (SYS),
-#endif
-#ifdef SIGPOLL
- NUMNAME (POLL),
-#endif
-#ifdef SIGVTALRM
- NUMNAME (VTALRM),
-#endif
-#ifdef SIGPROF
- NUMNAME (PROF),
-#endif
-#ifdef SIGXCPU
- NUMNAME (XCPU),
-#endif
-#ifdef SIGXFSZ
- NUMNAME (XFSZ),
-#endif
-
- /* Unix Version 7. */
-#ifdef SIGIOT
- NUMNAME (IOT), /* Older name for ABRT. */
-#endif
-#ifdef SIGEMT
- NUMNAME (EMT),
-#endif
-
- /* USG Unix. */
-#ifdef SIGPHONE
- NUMNAME (PHONE),
-#endif
-#ifdef SIGWIND
- NUMNAME (WIND),
-#endif
-
- /* Unix System V. */
-#ifdef SIGCLD
- NUMNAME (CLD),
-#endif
-#ifdef SIGPWR
- NUMNAME (PWR),
-#endif
-
- /* GNU/Linux 2.2 and Solaris 8. */
-#ifdef SIGCANCEL
- NUMNAME (CANCEL),
-#endif
-#ifdef SIGLWP
- NUMNAME (LWP),
-#endif
-#ifdef SIGWAITING
- NUMNAME (WAITING),
-#endif
-#ifdef SIGFREEZE
- NUMNAME (FREEZE),
-#endif
-#ifdef SIGTHAW
- NUMNAME (THAW),
-#endif
-#ifdef SIGLOST
- NUMNAME (LOST),
-#endif
-#ifdef SIGWINCH
- NUMNAME (WINCH),
-#endif
-
- /* GNU/Linux 2.2. */
-#ifdef SIGINFO
- NUMNAME (INFO),
-#endif
-#ifdef SIGIO
- NUMNAME (IO),
-#endif
-#ifdef SIGSTKFLT
- NUMNAME (STKFLT),
-#endif
-
- /* AIX 5L. */
-#ifdef SIGDANGER
- NUMNAME (DANGER),
-#endif
-#ifdef SIGGRANT
- NUMNAME (GRANT),
-#endif
-#ifdef SIGMIGRATE
- NUMNAME (MIGRATE),
-#endif
-#ifdef SIGMSG
- NUMNAME (MSG),
-#endif
-#ifdef SIGPRE
- NUMNAME (PRE),
-#endif
-#ifdef SIGRETRACT
- NUMNAME (RETRACT),
-#endif
-#ifdef SIGSAK
- NUMNAME (SAK),
-#endif
-#ifdef SIGSOUND
- NUMNAME (SOUND),
-#endif
-
- /* Older AIX versions. */
-#ifdef SIGALRM1
- NUMNAME (ALRM1), /* unknown; taken from Bash 2.05 */
-#endif
-#ifdef SIGKAP
- NUMNAME (KAP), /* Older name for SIGGRANT. */
-#endif
-#ifdef SIGVIRT
- NUMNAME (VIRT), /* unknown; taken from Bash 2.05 */
-#endif
-#ifdef SIGWINDOW
- NUMNAME (WINDOW), /* Older name for SIGWINCH. */
-#endif
-
- /* BeOS */
-#ifdef SIGKILLTHR
- NUMNAME (KILLTHR),
-#endif
-
- /* Older HP-UX versions. */
-#ifdef SIGDIL
- NUMNAME (DIL),
-#endif
-
- /* Korn shell and Bash, of uncertain vintage. */
- { 0, "EXIT" }
- };
-
-#define NUMNAME_ENTRIES (sizeof numname_table / sizeof numname_table[0])
+#include "sig2str-def.c"
/* ISDIGIT differs from isdigit, as follows:
- Its arg may be any int or unsigned int; it need not be an unsigned char
@@ -271,8 +63,8 @@ str2signum (char const *signame)
{
unsigned int i;
for (i = 0; i < NUMNAME_ENTRIES; i++)
- if (strcmp (numname_table[i].name, signame) == 0)
- return numname_table[i].num;
+ if (strcmp (sig_strings + numname_table[i].sig_nm_off, signame) == 0)
+ return numname_table[i].sig_id;
{
char *endp;
@@ -316,9 +108,9 @@ sig2str (int signum, char *signame)
{
unsigned int i;
for (i = 0; i < NUMNAME_ENTRIES; i++)
- if (numname_table[i].num == signum)
+ if (numname_table[i].sig_id == signum)
{
- strcpy (signame, numname_table[i].name);
+ strcpy (signame, sig_strings + numname_table[i].sig_nm_off);
return 0;
}
diff --git a/lib/sig2str.def b/lib/sig2str.def
new file mode 100644
index 0000000..f6dfb9c
--- /dev/null
+++ b/lib/sig2str.def
@@ -0,0 +1,21 @@
+
+AutoGen Definitions sig2str;
+
+sig =
+ /* Signals required by POSIX 1003.1-2001 base, listed in
+ traditional numeric order where possible. */
+ HUP, INT, QUIT, ILL, TRAP, ABRT, FPE,
+ KILL, SEGV,
+ /* On Haiku, SIGSEGV == SIGBUS, but we prefer SIGSEGV to match
+ strsignal.c output, so SIGBUS must be listed second. */
+ BUS, PIPE, ALRM, TERM, USR1, USR2, CHLD,
+ URG, STOP, TSTP, CONT, TTIN, TTOU,
+ /* Signals required by POSIX 1003.1-2001 with the XSI extension. */
+ SYS, POLL, VTALRM, PROF, XCPU, XFSZ,
+ IOT, /* Older name for ABRT. */
+ EMT, PHONE, WIND, CLD, PWR,
+ /* GNU/Linux 2.2 and Solaris 8. */
+ CANCEL, LWP, WAITING, FREEZE, THAW, LOST, WINCH,
+ INFO, IO, STKFLT, DANGER, GRANT, MIGRATE, MSG,
+ PRE, RETRACT, SAK, SOUND, ALRM1, KAP, VIRT,
+ WINDOW, KILLTHR, DIL;
diff --git a/lib/sig2str.tpl b/lib/sig2str.tpl
new file mode 100644
index 0000000..5923947
--- /dev/null
+++ b/lib/sig2str.tpl
@@ -0,0 +1,36 @@
+[= AutoGen5 Template c=%s-def.c =]
+
+#define SIG_OFFSET_AFTER_START 0
+
+static char const sig_strings[] =[=
+
+(define last-signal "START") =][=
+
+FOR sig =]
+#ifdef SIG[= sig =]
+#define SIG_[= sig =]_OFFSET SIG_OFFSET_AFTER_[=(. last-signal)=]
+ "[= sig =]\0"[=
+ IF (not (last-for?)) =]
+#define SIG_OFFSET_AFTER_[= sig =] (SIG_OFFSET_AFTER_[=(. last-signal)
+ =] + [= (+ 1 (string-length (get "sig"))) =])
+#else
+#define SIG_OFFSET_AFTER_[= sig =] SIG_OFFSET_AFTER_[=(emit last-signal)
+ (set! last-signal (get "sig"))=][=
+ ENDIF =]
+#endif
+[= ENDFOR =];
+
+static struct num_off {
+ int sig_id;
+ unsigned int sig_nm_off;
+} sig_offsets[[=(+ 1 (count "sig"))=]] = {[=
+
+FOR sig =]
+#ifdef SIG[= sig =]
+ { SIG[= sig =], SIG_[= sig =]_OFFSET },
+#endif[=
+ENDFOR =]
+ /* Korn shell and Bash, of uncertain vintage. */
+ { 0, "EXIT" }
+};
+#define NUMNAME_ENTRIES [=(+ 1 (count "sig"))=]
--
1.8.1.4