1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-08 17:22:05 +03:00

sigabbrev_np: New module.

* lib/string.in.h (sigabbrev_np): New declaration.
* lib/sigabbrev_np.c: New file.
* m4/sigabbrev_np.m4: New file.
* m4/string_h.m4 (gl_HEADER_STRING_H_BODY): Test whether sigabbrev_np is
declared.
(gl_HEADER_STRING_H_DEFAULTS): Initialize GNULIB_SIGABBREV_NP,
HAVE_SIGABBREV_NP.
* modules/string (Makefile.am): Substitute GNULIB_SIGABBREV_NP,
HAVE_SIGABBREV_NP.
* modules/sigabbrev_np: New file.
* tests/test-string-c++.cc: Verify the signature of sigabbrev_np.
* doc/glibc-functions/sigabbrev_np.texi: Mention the new module.
This commit is contained in:
Bruno Haible
2020-08-21 00:54:18 +02:00
parent bb2e34896a
commit f57bc6d11a
9 changed files with 356 additions and 7 deletions

View File

@@ -1,3 +1,19 @@
2020-08-20 Bruno Haible <bruno@clisp.org>
sigabbrev_np: New module.
* lib/string.in.h (sigabbrev_np): New declaration.
* lib/sigabbrev_np.c: New file.
* m4/sigabbrev_np.m4: New file.
* m4/string_h.m4 (gl_HEADER_STRING_H_BODY): Test whether sigabbrev_np is
declared.
(gl_HEADER_STRING_H_DEFAULTS): Initialize GNULIB_SIGABBREV_NP,
HAVE_SIGABBREV_NP.
* modules/string (Makefile.am): Substitute GNULIB_SIGABBREV_NP,
HAVE_SIGABBREV_NP.
* modules/sigabbrev_np: New file.
* tests/test-string-c++.cc: Verify the signature of sigabbrev_np.
* doc/glibc-functions/sigabbrev_np.texi: Mention the new module.
2020-08-20 Bruno Haible <bruno@clisp.org>
stdalign tests: Skip test with AIX xlclang.

View File

@@ -10,15 +10,15 @@ Documentation:@*
@url{https://www.gnu.org/software/libc/manual/html_node/Signal-Messages.html}.
@end ifnotinfo
Gnulib module: ---
Gnulib module: sigabbrev_np
Portability problems fixed by Gnulib:
@itemize
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
This function is missing on all non-glibc platforms:
glibc 2.31, Mac OS X 10.13, FreeBSD 6.4, NetBSD 9.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Cygwin 2.9, mingw, MSVC 14, Android 9.0.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@end itemize

265
lib/sigabbrev_np.c Normal file
View File

@@ -0,0 +1,265 @@
/* Abbreviated name of signals.
Copyright (C) 2020 Free Software Foundation, Inc.
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.
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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2020. */
#include <config.h>
/* Specification. */
#include <string.h>
#include <signal.h>
const char *
sigabbrev_np (int sig)
{
switch (sig)
{
/* Signals specified by ISO C. */
case SIGABRT: return "ABRT";
case SIGFPE: return "FPE";
case SIGILL: return "ILL";
case SIGINT: return "INT";
case SIGSEGV: return "SEGV";
case SIGTERM: return "TERM";
/* Signals specified by POSIX.
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html> */
#if defined SIGALRM
case SIGALRM: return "ALRM";
#endif
#if defined SIGBUS
case SIGBUS: return "BUS";
#endif
#if defined SIGCHLD
case SIGCHLD: return "CHLD";
#endif
#if defined SIGCONT
case SIGCONT: return "CONT";
#endif
#if defined SIGHUP
case SIGHUP: return "HUP";
#endif
#if defined SIGKILL
case SIGKILL: return "KILL";
#endif
#if defined SIGPIPE
case SIGPIPE: return "PIPE";
#endif
#if defined SIGQUIT
case SIGQUIT: return "QUIT";
#endif
#if defined SIGSTOP
case SIGSTOP: return "STOP";
#endif
#if defined SIGTSTP
case SIGTSTP: return "TSTP";
#endif
#if defined SIGTTIN
case SIGTTIN: return "TTIN";
#endif
#if defined SIGTTOU
case SIGTTOU: return "TTOU";
#endif
#if defined SIGUSR1
case SIGUSR1: return "USR1";
#endif
#if defined SIGUSR2
case SIGUSR2: return "USR2";
#endif
#if defined SIGPOLL
case SIGPOLL: return "POLL";
#endif
#if defined SIGPROF
case SIGPROF: return "PROF";
#endif
#if defined SIGSYS
case SIGSYS: return "SYS";
#endif
#if defined SIGTRAP
case SIGTRAP: return "TRAP";
#endif
#if defined SIGURG
case SIGURG: return "URG";
#endif
#if defined SIGVTALRM
case SIGVTALRM: return "VTALRM";
#endif
#if defined SIGXCPU
case SIGXCPU: return "XCPU";
#endif
#if defined SIGXFSZ
case SIGXFSZ: return "XFSZ";
#endif
/* Other signals on other systems. */
/* native Windows */
#if defined SIGBREAK
case SIGBREAK: return "BREAK";
#endif
/* IRIX */
#if defined SIGCKPT
case SIGCKPT: return "CKPT";
#endif
/* Linux, IRIX, Cygwin */
#if defined SIGCLD && SIGCLD != SIGCHLD
case SIGCLD: return "CLD";
#endif
/* AIX */
#if defined SIGCPUFAIL
case SIGCPUFAIL: return "CPUFAIL";
#endif
/* AIX */
#if defined SIGDANGER
case SIGDANGER: return "DANGER";
#endif
/* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, mingw */
#if defined SIGEMT
case SIGEMT: return "EMT";
#endif
/* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix */
#if defined SIGINFO
case SIGINFO: return "INFO";
#endif
/* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin */
#if defined SIGIO && SIGIO != SIGPOLL
case SIGIO: return "IO";
#endif
/* Linux, IRIX, Cygwin, mingw */
#if defined SIGIOT && SIGIOT != SIGABRT
case SIGIOT: return "IOT";
#endif
/* AIX */
#if defined SIGKAP
case SIGKAP: return "KAP";
#endif
/* Haiku */
#if defined SIGKILLTHR
case SIGKILLTHR: return "KILLTHR";
#endif
/* Minix */
#if defined SIGKMEM
case SIGKMEM: return "KMEM";
#endif
/* Minix */
#if defined SIGKMESS
case SIGKMESS: return "KMESS";
#endif
/* Minix */
#if defined SIGKSIG
case SIGKSIG: return "KSIG";
#endif
/* Minix */
#if defined SIGKSIGSM
case SIGKSIGSM: return "KSIGSM";
#endif
/* FreeBSD */
#if defined SIGLIBRT
case SIGLIBRT: return "LIBRT";
#endif
/* Cygwin */
#if defined SIGLOST && SIGLOST != SIGABRT && SIGLOST != SIGPWR
case SIGLOST: return "LOST";
#endif
/* AIX */
#if defined SIGMIGRATE
case SIGMIGRATE: return "MIGRATE";
#endif
/* AIX */
#if defined SIGMSG
case SIGMSG: return "MSG";
#endif
/* AIX */
#if defined SIGPRE
case SIGPRE: return "PRE";
#endif
/* IRIX */
#if defined SIGPTINTR
case SIGPTINTR: return "PTINTR";
#endif
/* IRIX */
#if defined SIGPTRESCHED
case SIGPTRESCHED:return "PTRESCHED";
#endif
/* Linux, NetBSD, Minix, AIX, IRIX, Cygwin */
#if defined SIGPWR
case SIGPWR: return "PWR";
#endif
/* AIX */
#if defined SIGRECONFIG
case SIGRECONFIG: return "RECONFIG";
#endif
/* AIX */
#if defined SIGRECOVERY
case SIGRECOVERY: return "RECOVERY";
#endif
/* IRIX */
#if defined SIGRESTART
case SIGRESTART: return "RESTART";
#endif
/* AIX */
#if defined SIGRETRACT
case SIGRETRACT: return "RETRACT";
#endif
/* AIX */
#if defined SIGSAK
case SIGSAK: return "SAK";
#endif
/* Minix */
#if defined SIGSNDELAY
case SIGSNDELAY: return "SNDELAY";
#endif
/* AIX */
#if defined SIGSOUND
case SIGSOUND: return "SOUND";
#endif
/* Linux */
#if defined SIGSTKFLT
case SIGSTKFLT: return "STKFLT";
#endif
/* AIX */
#if defined SIGSYSERROR
case SIGSYSERROR: return "SYSERROR";
#endif
/* AIX */
#if defined SIGTALRM
case SIGTALRM: return "TALRM";
#endif
/* FreeBSD, OpenBSD */
#if defined SIGTHR
case SIGTHR: return "THR";
#endif
/* IRIX */
#if defined SIGUME
case SIGUME: return "UME";
#endif
/* AIX */
#if defined SIGVIRT
case SIGVIRT: return "VIRT";
#endif
/* AIX */
#if defined SIGWAITING
case SIGWAITING: return "WAITING";
#endif
/* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, Haiku */
#if defined SIGWINCH
case SIGWINCH: return "WINCH";
#endif
default:
return NULL;
}
}

View File

@@ -1045,6 +1045,21 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
# endif
#endif
/* Return an abbreviation string for the signal number SIG. */
#if @GNULIB_SIGABBREV_NP@
# if ! @HAVE_SIGABBREV_NP@
_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig));
# endif
_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig));
_GL_CXXALIASWARN (sigabbrev_np);
#elif defined GNULIB_POSIXCHECK
# undef sigabbrev_np
# if HAVE_RAW_DECL_SIGABBREV_NP
_GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - "
"use gnulib module sigabbrev_np for portability");
# endif
#endif
#if @GNULIB_STRSIGNAL@
# if @REPLACE_STRSIGNAL@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)

17
m4/sigabbrev_np.m4 Normal file
View File

@@ -0,0 +1,17 @@
# sigabbrev_np.m4 serial 1
dnl Copyright (C) 2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_SIGABBREV_NP],
[
dnl Persuade glibc <string.h> to declare sigabbrev_np().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
AC_CHECK_FUNCS([sigabbrev_np])
if test $ac_cv_func_sigabbrev_np = no; then
HAVE_SIGABBREV_NP=0
fi
])

View File

@@ -5,7 +5,7 @@
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 24
# serial 25
# Written by Paul Eggert.
@@ -28,7 +28,7 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
]],
[ffsl ffsll memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul
strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r
strerror_r strsignal strverscmp])
strerror_r sigabbrev_np strsignal strverscmp])
AC_REQUIRE([AC_C_RESTRICT])
])
@@ -80,6 +80,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R])
GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR])
GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R])
GNULIB_SIGABBREV_NP=0;AC_SUBST([GNULIB_SIGABBREV_NP])
GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
@@ -102,6 +103,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R])
HAVE_SIGABBREV_NP=1; AC_SUBST([HAVE_SIGABBREV_NP])
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])

28
modules/sigabbrev_np Normal file
View File

@@ -0,0 +1,28 @@
Description:
sigabbrev_np() function: abbreviated name of signals.
Files:
lib/sigabbrev_np.c
m4/sigabbrev_np.m4
Depends-on:
extensions
string
configure.ac:
gl_FUNC_SIGABBREV_NP
if test $HAVE_SIGABBREV_NP = 0; then
AC_LIBOBJ([sigabbrev_np])
fi
gl_STRING_MODULE_INDICATOR([sigabbrev_np])
Makefile.am:
Include:
<string.h>
License:
LGPLv2+
Maintainer:
all

View File

@@ -66,6 +66,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \
-e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \
-e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \
-e 's/@''GNULIB_SIGABBREV_NP''@/$(GNULIB_SIGABBREV_NP)/g' \
-e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
-e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \
< $(srcdir)/string.in.h | \
@@ -88,6 +89,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
-e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
-e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
-e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \
-e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
-e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
-e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \

View File

@@ -138,6 +138,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::strerror, char *, (int));
SIGNATURE_CHECK (GNULIB_NAMESPACE::strerror_r, int, (int, char *, size_t));
#endif
#if GNULIB_TEST_SIGABBREV_NP
SIGNATURE_CHECK (GNULIB_NAMESPACE::sigabbrev_np, const char *, (int));
#endif
#if GNULIB_TEST_STRSIGNAL
SIGNATURE_CHECK (GNULIB_NAMESPACE::strsignal, char *, (int));
#endif