bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sig2str and str2sig use in C++


From: Daniel J Sebald
Subject: Re: sig2str and str2sig use in C++
Date: Thu, 13 Jun 2013 14:32:35 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

On 06/13/2013 09:37 AM, Bruce Korb wrote:
On 06/10/13 22:41, Paul Eggert wrote:
Maybe someone else can come up with something even better.

This:

#define SIG_OFFSET_AFTER_START 0

static char const sig_strings[] =
#ifdef SIGHUP
#define SIG_HUP_OFFSET SIG_OFFSET_AFTER_START
#define SIG_OFFSET_AFTER_HUP (SIG_OFFSET_AFTER_START + 4)
"HUP\0"
#else
#define SIG_OFFSET_AFTER_HUP SIG_OFFSET_AFTER_START
#endif

#ifdef SIGINT
#define SIG_INT_OFFSET SIG_OFFSET_AFTER_HUP
#define SIG_OFFSET_AFTER_INT (SIG_OFFSET_AFTER_HUP + 4)
"INT\0"
#else
#define SIG_OFFSET_AFTER_INT SIG_OFFSET_AFTER_HUP
#endif
[...]
static unsigned int sig_offsets[] = {
#ifdef SIGHUP
[SIGHUP] = SIG_HUP_OFFSET,
#endif
#ifdef SIGINT
[SIGINT] = SIG_INT_OFFSET,
#endif

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. It's probably obvious to someone who uses AC tools a lot. If I'm following, the first stage is that autoconf (?) will look through all definitions for those beginning with SIG and then create further definitions similar to the above which can be compiled. The definition "sig = HUP, INT, QUIT, ..." can then be included in something like:

static char const sig_strings[] = {
  sig
};

?

It feels that we are working toward creating a table that doesn't group according to the signal number (i.e., synonyms), but instead just lists all SIG defines (and from there the user can figure things out using the already existing functions). I'm alright with that. I suppose that is a more initial expectation for how such a thing would be organized.

Dan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]