--- /home/cjwatson/src/gnu/libc/string/strsignal.c 2005-11-06 02:05:17.000000000 +0000 +++ lib/strsignal.c 2008-01-06 09:31:27.000000000 +0000 @@ -16,18 +16,31 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include + #include #include #include #include -#include -#include +/* NetBSD declares sys_siglist in unistd.h. */ +#include + +#include "gettext.h" +#define _(msgid) gettext (msgid) +#define N_(msgid) gettext_noop (msgid) +#include "lock.h" +#include "tls.h" + + +#if !HAVE_DECL_SYS_SIGLIST +# ifndef NSIG +# define NSIG 32 +# endif /* NSIG */ +static const char *sys_siglist[NSIG]; +#endif /* !HAVE_DECL_SYS_SIGLIST */ -/* Defined in siglist.c. */ -extern const char *const _sys_siglist[]; -extern const char *const _sys_siglist_internal[] attribute_hidden; -static __libc_key_t key; +static gl_tls_key_t key; /* If nonzero the key allocation failed and we should better use a static buffer than fail. */ @@ -45,29 +58,29 @@ char * strsignal (int signum) { - __libc_once_define (static, once); + gl_once_define (static, once); const char *desc; /* If we have not yet initialized the buffer do it now. */ - __libc_once (once, init); + gl_once (once, init); if ( #ifdef SIGRTMIN (signum >= SIGRTMIN && signum <= SIGRTMAX) || #endif signum < 0 || signum >= NSIG - || (desc = INTUSE(_sys_siglist)[signum]) == NULL) + || (desc = sys_siglist[signum]) == NULL) { char *buffer = getbuffer (); int len; #ifdef SIGRTMIN if (signum >= SIGRTMIN && signum <= SIGRTMAX) - len = __snprintf (buffer, BUFFERSIZ - 1, _("Real-time signal %d"), - signum - SIGRTMIN); + len = snprintf (buffer, BUFFERSIZ - 1, _("Real-time signal %d"), + signum - SIGRTMIN); else #endif - len = __snprintf (buffer, BUFFERSIZ - 1, _("Unknown signal %d"), - signum); + len = snprintf (buffer, BUFFERSIZ - 1, _("Unknown signal %d"), + signum); if (len >= BUFFERSIZ) buffer = NULL; else @@ -84,11 +97,24 @@ static void init (void) { - if (__libc_key_create (&key, free_key_mem)) - /* Creating the key failed. This means something really went - wrong. In any case use a static buffer which is better than - nothing. */ - static_buf = local_buf; +#if !HAVE_DECL_SYS_SIGLIST + memset (sys_siglist, 0, NSIG * sizeof *sys_siglist); + + /* The trailing semicolon is because siglist.h is really designed for + array initializers, but we don't want that here because the signal + numbers might exceed NSIG. */ +# define init_sig(sig, abbrev, desc) do { \ + if (sig >= 0 && sig < NSIG) \ + sys_siglist[sig] = desc; \ +} while (0); + +# include "siglist.h" + +# undef init_sig + +#endif /* !HAVE_DECL_SYS_SIGLIST */ + + gl_tls_key_init (key, free_key_mem); } @@ -97,7 +123,7 @@ free_key_mem (void *mem) { free (mem); - __libc_setspecific (key, NULL); + gl_tls_set (key, NULL); } @@ -113,7 +139,7 @@ { /* We don't use the static buffer and so we have a key. Use it to get the thread-specific buffer. */ - result = __libc_getspecific (key); + result = gl_tls_get (key); if (result == NULL) { /* No buffer allocated so far. */ @@ -122,7 +148,7 @@ /* No more memory available. We use the static buffer. */ result = local_buf; else - __libc_setspecific (key, result); + gl_tls_set (key, result); } } --- /home/cjwatson/src/gnu/libc/sysdeps/generic/siglist.h 2001-07-06 05:55:50.000000000 +0100 +++ lib/siglist.h 2008-01-06 00:14:26.000000000 +0000 @@ -26,34 +26,90 @@ /* This file is included multiple times. */ /* Standard signals */ +#ifdef SIGHUP init_sig (SIGHUP, "HUP", N_("Hangup")) +#endif +#ifdef SIGINT init_sig (SIGINT, "INT", N_("Interrupt")) +#endif +#ifdef SIGQUIT init_sig (SIGQUIT, "QUIT", N_("Quit")) +#endif +#ifdef SIGILL init_sig (SIGILL, "ILL", N_("Illegal instruction")) +#endif +#ifdef SIGTRAP init_sig (SIGTRAP, "TRAP", N_("Trace/breakpoint trap")) +#endif +#ifdef SIGABRT init_sig (SIGABRT, "ABRT", N_("Aborted")) +#endif +#ifdef SIGFPE init_sig (SIGFPE, "FPE", N_("Floating point exception")) +#endif +#ifdef SIGKILL init_sig (SIGKILL, "KILL", N_("Killed")) +#endif +#ifdef SIGBUS init_sig (SIGBUS, "BUS", N_("Bus error")) +#endif +#ifdef SIGSEGV init_sig (SIGSEGV, "SEGV", N_("Segmentation fault")) +#endif +#ifdef SIGPIPE init_sig (SIGPIPE, "PIPE", N_("Broken pipe")) +#endif +#ifdef SIGALRM init_sig (SIGALRM, "ALRM", N_("Alarm clock")) +#endif +#ifdef SIGTERM init_sig (SIGTERM, "TERM", N_("Terminated")) +#endif +#ifdef SIGURG init_sig (SIGURG, "URG", N_("Urgent I/O condition")) +#endif +#ifdef SIGSTOP init_sig (SIGSTOP, "STOP", N_("Stopped (signal)")) +#endif +#ifdef SIGTSTP init_sig (SIGTSTP, "TSTP", N_("Stopped")) +#endif +#ifdef SIGCONT init_sig (SIGCONT, "CONT", N_("Continued")) +#endif +#ifdef SIGCHLD init_sig (SIGCHLD, "CHLD", N_("Child exited")) +#endif +#ifdef SIGTTIN init_sig (SIGTTIN, "TTIN", N_("Stopped (tty input)")) +#endif +#ifdef SIGTTOU init_sig (SIGTTOU, "TTOU", N_("Stopped (tty output)")) +#endif +#ifdef SIGIO init_sig (SIGIO, "IO", N_("I/O possible")) +#endif +#ifdef SIGXCPU init_sig (SIGXCPU, "XCPU", N_("CPU time limit exceeded")) +#endif +#ifdef SIGXFSZ init_sig (SIGXFSZ, "XFSZ", N_("File size limit exceeded")) +#endif +#ifdef SIGVTALRM init_sig (SIGVTALRM, "VTALRM", N_("Virtual timer expired")) +#endif +#ifdef SIGPROF init_sig (SIGPROF, "PROF", N_("Profiling timer expired")) +#endif +#ifdef SIGWINCH init_sig (SIGWINCH, "WINCH", N_("Window changed")) +#endif +#ifdef SIGUSR1 init_sig (SIGUSR1, "USR1", N_("User defined signal 1")) +#endif +#ifdef SIGUSR2 init_sig (SIGUSR2, "USR2", N_("User defined signal 2")) +#endif /* Variations */ #ifdef SIGEMT