diff options
author | Bruno Haible <bruno@clisp.org> | 2020-08-21 00:54:18 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-08-21 01:18:07 +0200 |
commit | f57bc6d11afae19deb915709bb9a2de66bcdeeac (patch) | |
tree | b3cd68268d231a655e8bd9f06a0984dbed2c1850 /lib/sigabbrev_np.c | |
parent | bb2e34896a96a94ca7f29798a9020f630ef6ad70 (diff) | |
download | gnulib-f57bc6d11afae19deb915709bb9a2de66bcdeeac.tar.gz |
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.
Diffstat (limited to 'lib/sigabbrev_np.c')
-rw-r--r-- | lib/sigabbrev_np.c | 265 |
1 files changed, 265 insertions, 0 deletions
diff --git a/lib/sigabbrev_np.c b/lib/sigabbrev_np.c new file mode 100644 index 0000000000..f1c45aa806 --- /dev/null +++ b/lib/sigabbrev_np.c @@ -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; + } +} |