@@ -51,6 +51,7 @@ extern int __ffs (int __i) __attribute__ ((const));
extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen);
/* Called as part of the thread shutdown sequence. */
+void __strsignal_thread_freeres (void) attribute_hidden;
void __strerror_thread_freeres (void) attribute_hidden;
/* Get _STRING_ARCH_unaligned. */
@@ -32,6 +32,7 @@ __libc_thread_freeres (void)
call_function_static_weak (__rpc_thread_destroy);
call_function_static_weak (__res_thread_freeres);
call_function_static_weak (__strerror_thread_freeres);
+ call_function_static_weak (__strsignal_thread_freeres);
/* This should come last because it shuts down malloc for this
thread and the other shutdown functions might well call free. */
@@ -44,7 +44,7 @@ routines := strcat strchr strcmp strcoll strcpy strcspn \
addsep replace) \
envz basename \
strcoll_l strxfrm_l string-inlines memrchr \
- xpg-strerror strerror_l explicit_bzero
+ xpg-strerror strerror_l explicit_bzero strsignal_l
strop-tests := memchr memcmp memcpy memmove mempcpy memset memccpy \
stpcpy stpncpy strcat strchr strcmp strcpy strcspn \
@@ -85,4 +85,7 @@ libc {
GLIBC_2.25 {
explicit_bzero;
}
+ GLIBC_2.32 {
+ strsignal_l;
+ }
}
@@ -454,6 +454,11 @@ extern char *strsep (char **__restrict __stringp,
/* Return a string describing the meaning of the signal number in SIG. */
extern char *strsignal (int __sig) __THROW;
+# ifdef __USE_GNU
+/* Translate the meaning of the signal in SIG according to the locale L. */
+extern char *strsignal_l (int __sig, locale_t __l) __THROW;
+# endif
+
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
__THROW __nonnull ((1, 2));
new file mode 100644
@@ -0,0 +1,68 @@
+/* Return the translated string describing signal.
+ Copyright (C) 2020 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.
+
+ The GNU C Library 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.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <string.h>
+#include <stdio.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <locale.h>
+#include <libintl.h>
+#include <array_length.h>
+#include <tls_internal.h>
+
+static const char *
+translate (const char *str, locale_t loc)
+{
+ locale_t oldloc = __uselocale (loc);
+ const char *res = _(str);
+ __uselocale (oldloc);
+ return res;
+}
+
+char *
+strsignal_l (int signum, locale_t loc)
+{
+ const char *desc = NULL;
+
+ if (signum >= 0 && signum <= NSIG
+ && signum < array_length (__sys_siglist_internal))
+ desc = __sys_siglist_internal[signum];
+
+ if (desc != NULL)
+ return (char *) translate (desc, loc);
+
+ const char* prefix = "Unknown signal ";
+#ifdef SIGRTMIN
+ if (signum >= SIGRTMIN && signum <= SIGRTMAX)
+ prefix = "Real-time signal ";
+#endif
+
+ struct tls_internal_t *tls_internal = __glibc_tls_internal ();
+ free (tls_internal->strsignal_l_buf);
+ if (__asprintf (&tls_internal->strsignal_l_buf, "%s%d",
+ translate (prefix, loc), signum) == -1)
+ tls_internal->strsignal_l_buf = NULL;
+ return tls_internal->strsignal_l_buf;
+}
+
+void
+__strsignal_thread_freeres (void)
+{
+ free (__glibc_tls_internal()->strsignal_l_buf);
+}
+text_set_element (__libc_subfreeres, __strsignal_thread_freeres);
@@ -27,6 +27,7 @@ struct tls_internal_t
{
/* Used on strsignal.c. */
char strsignal_buf[strsignal_str_len + INT_STRLEN_BOUND (int) + 1];
+ char *strsignal_l_buf;
};
#endif
@@ -2147,3 +2147,4 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
@@ -2227,6 +2227,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
@@ -134,6 +134,7 @@ GLIBC_2.31 msgctl F
GLIBC_2.31 semctl F
GLIBC_2.31 shmctl F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
@@ -131,6 +131,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
GLIBC_2.4 _IO_2_1_stdin_ D 0xa0
@@ -2091,3 +2091,4 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
@@ -2048,6 +2048,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2214,6 +2214,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2080,6 +2080,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -135,6 +135,7 @@ GLIBC_2.31 msgctl F
GLIBC_2.31 semctl F
GLIBC_2.31 shmctl F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0x98
GLIBC_2.4 _IO_2_1_stdin_ D 0x98
@@ -2160,6 +2160,7 @@ GLIBC_2.31 msgctl F
GLIBC_2.31 semctl F
GLIBC_2.31 shmctl F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2142,3 +2142,4 @@ GLIBC_2.31 msgctl F
GLIBC_2.31 semctl F
GLIBC_2.31 shmctl F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
@@ -2139,3 +2139,4 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
@@ -2131,6 +2131,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2129,6 +2129,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2137,6 +2137,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2131,6 +2131,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2180,3 +2180,4 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
@@ -2187,6 +2187,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
@@ -2220,6 +2220,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
@@ -2050,6 +2050,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
@@ -2342,3 +2342,4 @@ GLIBC_2.32 __wprintf_chkieee128 F
GLIBC_2.32 __wprintfieee128 F
GLIBC_2.32 __wscanfieee128 F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
@@ -2109,3 +2109,4 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
@@ -2185,6 +2185,7 @@ GLIBC_2.31 msgctl F
GLIBC_2.31 semctl F
GLIBC_2.31 shmctl F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
@@ -2086,6 +2086,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
@@ -2055,6 +2055,7 @@ GLIBC_2.31 msgctl F
GLIBC_2.31 semctl F
GLIBC_2.31 shmctl F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2052,6 +2052,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2176,6 +2176,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F
@@ -2103,6 +2103,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2061,6 +2061,7 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F
GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F
@@ -2160,3 +2160,4 @@ GLIBC_2.30 gettid F
GLIBC_2.30 tgkill F
GLIBC_2.30 twalk_r F
GLIBC_2.32 pthread_sigmask F
+GLIBC_2.32 strsignal_l F