--- /home/cjwatson/src/gnu/libc/string/strsignal.c 2005-11-06 02:05:17.000000000 +0000 +++ lib/strsignal.c 2008-01-08 22:36:10.000000000 +0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1994-2002, 2005 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994-2002, 2005, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,17 +16,61 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#ifndef _LIBC +# include +#endif + #include #include #include #include -#include -#include +#ifdef _LIBC +# include +#else /* !_LIBC */ +# include "gettext.h" +# define _(msgid) gettext (msgid) +# define N_(msgid) gettext_noop (msgid) +#endif /* _LIBC */ + +#ifdef _LIBC +# include +#else /* !_LIBC */ +# include "lock.h" +# include "tls.h" +# define __libc_once_define(CLASS, NAME) gl_once_define (CLASS, NAME); +# define __libc_once(NAME, INIT) gl_once ((NAME), (INIT)) +# define __libc_key_t gl_tls_key_t +# define __libc_getspecific(NAME) gl_tls_get ((NAME)) +# define __libc_setspecific(NAME, POINTER) gl_tls_set ((NAME), (POINTER)) +# define __snprintf snprintf +#endif /* _LIBC */ + +#ifdef _LIBC /* Defined in siglist.c. */ extern const char *const _sys_siglist[]; extern const char *const _sys_siglist_internal[] attribute_hidden; + +#else /* !_LIBC */ + +/* NetBSD declares sys_siglist in unistd.h. */ +# include + +# define INTUSE(x) (x) + +# if HAVE_DECL_SYS_SIGLIST +# undef _sys_siglist +# define _sys_siglist sys_siglist +# else /* !HAVE_DECL_SYS_SIGLIST */ +# ifndef NSIG +# define NSIG 32 +# endif /* NSIG */ +static const char *_sys_siglist[NSIG]; +# endif /* !HAVE_DECL_SYS_SIGLIST */ + +#endif /* _LIBC */ + static __libc_key_t key; /* If nonzero the key allocation failed and we should better use a @@ -84,11 +128,32 @@ static void init (void) { +#ifdef _LIBC 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; +#else /* !_LIBC */ + gl_tls_key_init (key, free_key_mem); + +# 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 */ +#endif /* !_LIBC */ }