X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrsignal.c;h=7caab1d45c6c3fa5e98151f0dc4f610edda6166d;hb=21492d6c3ca00ff0827528640804732f2ed66470;hp=2496e2ca445c404b86377483ae233479aa4f5f74;hpb=bd642010ddd06b7ced7e5a26a75c68fd828ac2bf;p=gnulib.git diff --git a/lib/strsignal.c b/lib/strsignal.c index 2496e2ca4..7caab1d45 100644 --- a/lib/strsignal.c +++ b/lib/strsignal.c @@ -1,29 +1,30 @@ -/* Copyright (C) 1991, 1994-2002, 2005, 2008 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994-2002, 2005, 2008-2011 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 - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. - The GNU C Library is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ #ifndef _LIBC # include #endif +/* Specification. */ +#include + #include #include #include -#include #ifdef _LIBC # include @@ -36,8 +37,8 @@ #ifdef _LIBC # include #else /* !_LIBC */ -# include "lock.h" -# include "tls.h" +# include "glthread/lock.h" +# include "glthread/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 @@ -55,7 +56,9 @@ extern const char *const _sys_siglist_internal[] attribute_hidden; #else /* !_LIBC */ /* NetBSD declares sys_siglist in unistd.h. */ -# include +# if HAVE_UNISTD_H +# include +# endif # define INTUSE(x) (x) @@ -66,7 +69,9 @@ extern const char *const _sys_siglist_internal[] attribute_hidden; # ifndef NSIG # define NSIG 32 # endif /* NSIG */ +# if !HAVE_DECL__SYS_SIGLIST static const char *_sys_siglist[NSIG]; +# endif # endif /* !HAVE_DECL_SYS_SIGLIST */ #endif /* _LIBC */ @@ -75,7 +80,7 @@ static __libc_key_t key; /* If nonzero the key allocation failed and we should better use a static buffer than fail. */ -#define BUFFERSIZ 100 +#define BUFFERSIZ 100 static char local_buf[BUFFERSIZ]; static char *static_buf; @@ -106,16 +111,16 @@ strsignal (int signum) 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 - (int) 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; + buffer = NULL; else - buffer[len] = '\0'; + buffer[len] = '\0'; return buffer; } @@ -147,7 +152,6 @@ init (void) # define init_sig(sig, abbrev, desc) \ if (sig >= 0 && sig < NSIG) \ _sys_siglist[sig] = desc; -} while (0); # include "siglist.h" @@ -178,18 +182,18 @@ getbuffer (void) else { /* We don't use the static buffer and so we have a key. Use it - to get the thread-specific buffer. */ + to get the thread-specific buffer. */ result = __libc_getspecific (key); if (result == NULL) - { - /* No buffer allocated so far. */ - result = malloc (BUFFERSIZ); - if (result == NULL) - /* No more memory available. We use the static buffer. */ - result = local_buf; - else - __libc_setspecific (key, result); - } + { + /* No buffer allocated so far. */ + result = malloc (BUFFERSIZ); + if (result == NULL) + /* No more memory available. We use the static buffer. */ + result = local_buf; + else + __libc_setspecific (key, result); + } } return result;