annotate lib/strsignal.c @ 17476:6057744acd2c default tip master

autoupdate
author Karl Berry <karl@freefriends.org>
date Fri, 16 Aug 2013 06:32:22 -0700
parents e542fd46ad6f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
1 /* Copyright (C) 1991, 1994-2002, 2005, 2008-2013 Free Software Foundation,
12518
b5e42ef33b49 update nearly all FSF copyright year lists to include 2009
Jim Meyering <meyering@redhat.com>
parents: 12421
diff changeset
2 Inc.
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
3 This file is part of the GNU C Library.
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
4
12002
f295924fa612 Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents: 10318
diff changeset
5 This program is free software: you can redistribute it and/or modify
f295924fa612 Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents: 10318
diff changeset
6 it under the terms of the GNU General Public License as published by
f295924fa612 Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents: 10318
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
f295924fa612 Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents: 10318
diff changeset
8 (at your option) any later version.
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
9
12002
f295924fa612 Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents: 10318
diff changeset
10 This program is distributed in the hope that it will be useful,
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12002
f295924fa612 Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents: 10318
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f295924fa612 Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents: 10318
diff changeset
13 GNU General Public License for more details.
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
14
12002
f295924fa612 Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents: 10318
diff changeset
15 You should have received a copy of the GNU General Public License
f295924fa612 Use the standard header with GPL copyright.
Bruno Haible <bruno@clisp.org>
parents: 10318
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
17
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
18 #ifndef _LIBC
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
19 # include <config.h>
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
20 #endif
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
21
15816
db340f34e324 glthread/*, strsignal: Support for MSVC.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
22 /* Specification. */
db340f34e324 glthread/*, strsignal: Support for MSVC.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
23 #include <string.h>
db340f34e324 glthread/*, strsignal: Support for MSVC.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
24
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
25 #include <signal.h>
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
26 #include <stdio.h>
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
27 #include <stdlib.h>
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
28
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
29 #ifdef _LIBC
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
30 # include <libintl.h>
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
31 #else /* !_LIBC */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
32 # include "gettext.h"
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
33 # define _(msgid) gettext (msgid)
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
34 # define N_(msgid) gettext_noop (msgid)
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
35 #endif /* _LIBC */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
36
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
37 #ifdef _LIBC
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
38 # include <bits/libc-lock.h>
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
39 #else /* !_LIBC */
10318
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents: 9893
diff changeset
40 # include "glthread/lock.h"
8a3539888308 Move the lock and tls source files into a subdirectory.
Bruno Haible <bruno@clisp.org>
parents: 9893
diff changeset
41 # include "glthread/tls.h"
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
42 # define __libc_once_define(CLASS, NAME) gl_once_define (CLASS, NAME)
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
43 # define __libc_once(NAME, INIT) gl_once ((NAME), (INIT))
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
44 # define __libc_key_t gl_tls_key_t
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
45 # define __libc_getspecific(NAME) gl_tls_get ((NAME))
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
46 # define __libc_setspecific(NAME, POINTER) gl_tls_set ((NAME), (POINTER))
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
47 # define __snprintf snprintf
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
48 #endif /* _LIBC */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
49
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
50 #ifdef _LIBC
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
51
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
52 /* Defined in siglist.c. */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
53 extern const char *const _sys_siglist[];
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
54 extern const char *const _sys_siglist_internal[] attribute_hidden;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
55
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
56 #else /* !_LIBC */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
57
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
58 /* NetBSD declares sys_siglist in unistd.h. */
15816
db340f34e324 glthread/*, strsignal: Support for MSVC.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
59 # if HAVE_UNISTD_H
db340f34e324 glthread/*, strsignal: Support for MSVC.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
60 # include <unistd.h>
db340f34e324 glthread/*, strsignal: Support for MSVC.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
61 # endif
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
62
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
63 # define INTUSE(x) (x)
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
64
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
65 # if HAVE_DECL_SYS_SIGLIST
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
66 # undef _sys_siglist
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
67 # define _sys_siglist sys_siglist
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
68 # else /* !HAVE_DECL_SYS_SIGLIST */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
69 # ifndef NSIG
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
70 # define NSIG 32
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
71 # endif /* NSIG */
9893
ec6e90aaf2d7 Fix two compilation errors.
Bruno Haible <bruno@clisp.org>
parents: 9616
diff changeset
72 # if !HAVE_DECL__SYS_SIGLIST
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
73 static const char *_sys_siglist[NSIG];
9893
ec6e90aaf2d7 Fix two compilation errors.
Bruno Haible <bruno@clisp.org>
parents: 9616
diff changeset
74 # endif
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
75 # endif /* !HAVE_DECL_SYS_SIGLIST */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
76
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
77 #endif /* _LIBC */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
78
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
79 static __libc_key_t key;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
80
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
81 /* If nonzero the key allocation failed and we should better use a
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
82 static buffer than fail. */
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
83 #define BUFFERSIZ 100
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
84 static char local_buf[BUFFERSIZ];
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
85 static char *static_buf;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
86
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
87 /* Destructor for the thread-specific data. */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
88 static void init (void);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
89 static void free_key_mem (void *mem);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
90 static char *getbuffer (void);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
91
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
92
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
93 /* Return a string describing the meaning of the signal number SIGNUM. */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
94 char *
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
95 strsignal (int signum)
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
96 {
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
97 const char *desc;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
98 __libc_once_define (static, once);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
99
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
100 /* If we have not yet initialized the buffer do it now. */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
101 __libc_once (once, init);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
102
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
103 if (
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
104 #ifdef SIGRTMIN
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
105 (signum >= SIGRTMIN && signum <= SIGRTMAX) ||
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
106 #endif
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
107 signum < 0 || signum >= NSIG
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
108 || (desc = INTUSE(_sys_siglist)[signum]) == NULL)
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
109 {
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
110 char *buffer = getbuffer ();
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
111 int len;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
112 #ifdef SIGRTMIN
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
113 if (signum >= SIGRTMIN && signum <= SIGRTMAX)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
114 len = __snprintf (buffer, BUFFERSIZ - 1, _("Real-time signal %d"),
13957
4efda5bffbf3 signal: Document problem with type of SIGRTMIN, SIGRTMAX on OSF/1 5.1.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
115 signum - (int) SIGRTMIN);
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
116 else
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
117 #endif
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
118 len = __snprintf (buffer, BUFFERSIZ - 1, _("Unknown signal %d"),
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
119 signum);
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
120 if (len >= BUFFERSIZ)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
121 buffer = NULL;
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
122 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
123 buffer[len] = '\0';
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
124
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
125 return buffer;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
126 }
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
127
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
128 return (char *) _(desc);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
129 }
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
130
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
131
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
132 /* Initialize buffer. */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
133 static void
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
134 init (void)
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
135 {
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
136 #ifdef _LIBC
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
137 if (__libc_key_create (&key, free_key_mem))
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
138 /* Creating the key failed. This means something really went
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
139 wrong. In any case use a static buffer which is better than
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
140 nothing. */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
141 static_buf = local_buf;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
142 #else /* !_LIBC */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
143 gl_tls_key_init (key, free_key_mem);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
144
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
145 # if !HAVE_DECL_SYS_SIGLIST
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
146 memset (_sys_siglist, 0, NSIG * sizeof *_sys_siglist);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
147
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
148 /* No need to use a do {} while (0) here since init_sig(...) must expand
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
149 to a complete statement. (We cannot use the ISO C99 designated array
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
150 initializer syntax since it is not supported by ANSI C compilers and
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
151 since some signal numbers might exceed NSIG.) */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
152 # define init_sig(sig, abbrev, desc) \
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
153 if (sig >= 0 && sig < NSIG) \
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
154 _sys_siglist[sig] = desc;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
155
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
156 # include "siglist.h"
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
157
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
158 # undef init_sig
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
159
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
160 # endif /* !HAVE_DECL_SYS_SIGLIST */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
161 #endif /* !_LIBC */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
162 }
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
163
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
164
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
165 /* Free the thread specific data, this is done if a thread terminates. */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
166 static void
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
167 free_key_mem (void *mem)
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
168 {
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
169 free (mem);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
170 __libc_setspecific (key, NULL);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
171 }
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
172
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
173
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
174 /* Return the buffer to be used. */
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
175 static char *
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
176 getbuffer (void)
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
177 {
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
178 char *result;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
179
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
180 if (static_buf != NULL)
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
181 result = static_buf;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
182 else
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
183 {
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
184 /* We don't use the static buffer and so we have a key. Use it
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
185 to get the thread-specific buffer. */
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
186 result = __libc_getspecific (key);
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
187 if (result == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
188 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
189 /* No buffer allocated so far. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
190 result = malloc (BUFFERSIZ);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
191 if (result == NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
192 /* No more memory available. We use the static buffer. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
193 result = local_buf;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
194 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
195 __libc_setspecific (key, result);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12002
diff changeset
196 }
9616
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
197 }
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
198
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
199 return result;
878f41b0e41e New module 'strsignal'.
Colin Watson <cjwatson@debian.org>
parents:
diff changeset
200 }