sigabbrev_np is a new function in glibc 2.32. It is probably useful for
implementations of shells; maybe also for guile.

Here's a module which adds support for it to gnulib, so that it may be
used in GNU code without portability worries.


2020-08-20  Bruno Haible  <br...@clisp.org>

        sigabbrev_np: Add tests.
        * tests/test-sigabbrev_np.c: New file.
        * modules/sigabbrev_np-tests: New file.

        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.

>From f57bc6d11afae19deb915709bb9a2de66bcdeeac Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 21 Aug 2020 00:54:18 +0200
Subject: [PATCH 1/2] 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.
---
 ChangeLog                             |  16 ++
 doc/glibc-functions/sigabbrev_np.texi |   8 +-
 lib/sigabbrev_np.c                    | 265 ++++++++++++++++++++++++++++++++++
 lib/string.in.h                       |  15 ++
 m4/sigabbrev_np.m4                    |  17 +++
 m4/string_h.m4                        |   6 +-
 modules/sigabbrev_np                  |  28 ++++
 modules/string                        |   2 +
 tests/test-string-c++.cc              |   4 +
 9 files changed, 355 insertions(+), 6 deletions(-)
 create mode 100644 lib/sigabbrev_np.c
 create mode 100644 m4/sigabbrev_np.m4
 create mode 100644 modules/sigabbrev_np

diff --git a/ChangeLog b/ChangeLog
index 82ee489..8e071bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2020-08-20  Bruno Haible  <br...@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  <br...@clisp.org>
+
 	stdalign tests: Skip test with AIX xlclang.
 	* tests/test-stdalign.c (main): Skip alignas tests with AIX xlclang.
 
diff --git a/doc/glibc-functions/sigabbrev_np.texi b/doc/glibc-functions/sigabbrev_np.texi
index 2376dac..90a4c06 100644
--- a/doc/glibc-functions/sigabbrev_np.texi
+++ b/doc/glibc-functions/sigabbrev_np.texi
@@ -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
+@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
-@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
diff --git a/lib/sigabbrev_np.c b/lib/sigabbrev_np.c
new file mode 100644
index 0000000..f1c45aa
--- /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 <br...@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;
+    }
+}
diff --git a/lib/string.in.h b/lib/string.in.h
index 4c88a37..20da813 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -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)
diff --git a/m4/sigabbrev_np.m4 b/m4/sigabbrev_np.m4
new file mode 100644
index 0000000..1aa6b3e
--- /dev/null
+++ b/m4/sigabbrev_np.m4
@@ -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
+])
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index 516b346..d519bea 100644
--- a/m4/string_h.m4
+++ b/m4/string_h.m4
@@ -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])
diff --git a/modules/sigabbrev_np b/modules/sigabbrev_np
new file mode 100644
index 0000000..9f2edfd
--- /dev/null
+++ b/modules/sigabbrev_np
@@ -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
diff --git a/modules/string b/modules/string
index bc87bc8..48e5186 100644
--- a/modules/string
+++ b/modules/string
@@ -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' \
diff --git a/tests/test-string-c++.cc b/tests/test-string-c++.cc
index 330e697..c6dbd1a 100644
--- a/tests/test-string-c++.cc
+++ b/tests/test-string-c++.cc
@@ -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
-- 
2.7.4

>From 00bd2a9222207390542b5163ff2f04b5acdce9df Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Fri, 21 Aug 2020 00:55:43 +0200
Subject: [PATCH 2/2] sigabbrev_np: Add tests.

* tests/test-sigabbrev_np.c: New file.
* modules/sigabbrev_np-tests: New file.
---
 ChangeLog                  |   4 +
 modules/sigabbrev_np-tests |  12 +++
 tests/test-sigabbrev_np.c  | 251 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 267 insertions(+)
 create mode 100644 modules/sigabbrev_np-tests
 create mode 100644 tests/test-sigabbrev_np.c

diff --git a/ChangeLog b/ChangeLog
index 8e071bf..00ab2f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2020-08-20  Bruno Haible  <br...@clisp.org>
 
+	sigabbrev_np: Add tests.
+	* tests/test-sigabbrev_np.c: New file.
+	* modules/sigabbrev_np-tests: New file.
+
 	sigabbrev_np: New module.
 	* lib/string.in.h (sigabbrev_np): New declaration.
 	* lib/sigabbrev_np.c: New file.
diff --git a/modules/sigabbrev_np-tests b/modules/sigabbrev_np-tests
new file mode 100644
index 0000000..04fbb68
--- /dev/null
+++ b/modules/sigabbrev_np-tests
@@ -0,0 +1,12 @@
+Files:
+tests/test-sigabbrev_np.c
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-sigabbrev_np
+check_PROGRAMS += test-sigabbrev_np
diff --git a/tests/test-sigabbrev_np.c b/tests/test-sigabbrev_np.c
new file mode 100644
index 0000000..ca38813
--- /dev/null
+++ b/tests/test-sigabbrev_np.c
@@ -0,0 +1,251 @@
+/* Test of sigabbrev_np() function.
+
+   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, 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/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <string.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (sigabbrev_np, const char *, (int));
+
+#include <signal.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  /* Signals specified by ISO C.  */
+  ASSERT (strcmp (sigabbrev_np (SIGABRT), "ABRT") == 0);
+  ASSERT (strcmp (sigabbrev_np (SIGFPE), "FPE") == 0);
+  ASSERT (strcmp (sigabbrev_np (SIGILL), "ILL") == 0);
+  ASSERT (strcmp (sigabbrev_np (SIGINT), "INT") == 0);
+  ASSERT (strcmp (sigabbrev_np (SIGSEGV), "SEGV") == 0);
+  ASSERT (strcmp (sigabbrev_np (SIGTERM), "TERM") == 0);
+
+  /* Signals specified by POSIX.
+     <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html>  */
+  #ifdef SIGALRM
+  ASSERT (strcmp (sigabbrev_np (SIGALRM), "ALRM") == 0);
+  #endif
+  #ifdef SIGBUS
+  ASSERT (strcmp (sigabbrev_np (SIGBUS), "BUS") == 0);
+  #endif
+  #ifdef SIGCHLD
+  ASSERT (strcmp (sigabbrev_np (SIGCHLD), "CHLD") == 0);
+  #endif
+  #ifdef SIGCONT
+  ASSERT (strcmp (sigabbrev_np (SIGCONT), "CONT") == 0);
+  #endif
+  #ifdef SIGHUP
+  ASSERT (strcmp (sigabbrev_np (SIGHUP), "HUP") == 0);
+  #endif
+  #ifdef SIGKILL
+  ASSERT (strcmp (sigabbrev_np (SIGKILL), "KILL") == 0);
+  #endif
+  #ifdef SIGPIPE
+  ASSERT (strcmp (sigabbrev_np (SIGPIPE), "PIPE") == 0);
+  #endif
+  #ifdef SIGQUIT
+  ASSERT (strcmp (sigabbrev_np (SIGQUIT), "QUIT") == 0);
+  #endif
+  #ifdef SIGSTOP
+  ASSERT (strcmp (sigabbrev_np (SIGSTOP), "STOP") == 0);
+  #endif
+  #ifdef SIGTSTP
+  ASSERT (strcmp (sigabbrev_np (SIGTSTP), "TSTP") == 0);
+  #endif
+  #ifdef SIGTTIN
+  ASSERT (strcmp (sigabbrev_np (SIGTTIN), "TTIN") == 0);
+  #endif
+  #ifdef SIGTTOU
+  ASSERT (strcmp (sigabbrev_np (SIGTTOU), "TTOU") == 0);
+  #endif
+  #ifdef SIGUSR1
+  ASSERT (strcmp (sigabbrev_np (SIGUSR1), "USR1") == 0);
+  #endif
+  #ifdef SIGUSR2
+  ASSERT (strcmp (sigabbrev_np (SIGUSR2), "USR2") == 0);
+  #endif
+  #ifdef SIGPOLL
+  ASSERT (strcmp (sigabbrev_np (SIGPOLL), "POLL") == 0);
+  #endif
+  #ifdef SIGPROF
+  ASSERT (strcmp (sigabbrev_np (SIGPROF), "PROF") == 0);
+  #endif
+  #ifdef SIGSYS
+  ASSERT (strcmp (sigabbrev_np (SIGSYS), "SYS") == 0);
+  #endif
+  #ifdef SIGTRAP
+  ASSERT (strcmp (sigabbrev_np (SIGTRAP), "TRAP") == 0);
+  #endif
+  #ifdef SIGURG
+  ASSERT (strcmp (sigabbrev_np (SIGURG), "URG") == 0);
+  #endif
+  #ifdef SIGVTALRM
+  ASSERT (strcmp (sigabbrev_np (SIGVTALRM), "VTALRM") == 0);
+  #endif
+  #ifdef SIGXCPU
+  ASSERT (strcmp (sigabbrev_np (SIGXCPU), "XCPU") == 0);
+  #endif
+  #ifdef SIGXFSZ
+  ASSERT (strcmp (sigabbrev_np (SIGXFSZ), "XFSZ") == 0);
+  #endif
+
+  /* Other signals on other systems.  */
+  /* native Windows */
+  #ifdef SIGBREAK
+  ASSERT (strcmp (sigabbrev_np (SIGBREAK), "BREAK") == 0);
+  #endif
+  /* IRIX */
+  #ifdef SIGCKPT
+  ASSERT (strcmp (sigabbrev_np (SIGCKPT), "CKPT") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGCPUFAIL
+  ASSERT (strcmp (sigabbrev_np (SIGCPUFAIL), "CPUFAIL") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGDANGER
+  ASSERT (strcmp (sigabbrev_np (SIGDANGER), "DANGER") == 0);
+  #endif
+  /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, mingw */
+  #ifdef SIGEMT
+  ASSERT (strcmp (sigabbrev_np (SIGEMT), "EMT") == 0);
+  #endif
+  /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix */
+  #ifdef SIGINFO
+  ASSERT (strcmp (sigabbrev_np (SIGINFO), "INFO") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGKAP
+  ASSERT (strcmp (sigabbrev_np (SIGKAP), "KAP") == 0);
+  #endif
+  /* Haiku */
+  #ifdef SIGKILLTHR
+  ASSERT (strcmp (sigabbrev_np (SIGKILLTHR), "KILLTHR") == 0);
+  #endif
+  /* Minix */
+  #ifdef SIGKMEM
+  ASSERT (strcmp (sigabbrev_np (SIGKMEM), "KMEM") == 0);
+  #endif
+  /* Minix */
+  #ifdef SIGKMESS
+  ASSERT (strcmp (sigabbrev_np (SIGKMESS), "KMESS") == 0);
+  #endif
+  /* Minix */
+  #ifdef SIGKSIG
+  ASSERT (strcmp (sigabbrev_np (SIGKSIG), "KSIG") == 0);
+  #endif
+  /* Minix */
+  #ifdef SIGKSIGSM
+  ASSERT (strcmp (sigabbrev_np (SIGKSIGSM), "KSIGSM") == 0);
+  #endif
+  /* FreeBSD */
+  #ifdef SIGLIBRT
+  ASSERT (strcmp (sigabbrev_np (SIGLIBRT), "LIBRT") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGMIGRATE
+  ASSERT (strcmp (sigabbrev_np (SIGMIGRATE), "MIGRATE") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGMSG
+  ASSERT (strcmp (sigabbrev_np (SIGMSG), "MSG") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGPRE
+  ASSERT (strcmp (sigabbrev_np (SIGPRE), "PRE") == 0);
+  #endif
+  /* IRIX */
+  #ifdef SIGPTINTR
+  ASSERT (strcmp (sigabbrev_np (SIGPTINTR), "PTINTR") == 0);
+  #endif
+  /* IRIX */
+  #ifdef SIGPTRESCHED
+  ASSERT (strcmp (sigabbrev_np (SIGPTRESCHED), "PTRESCHED") == 0);
+  #endif
+  /* Linux, NetBSD, Minix, AIX, IRIX, Cygwin */
+  #ifdef SIGPWR
+  ASSERT (strcmp (sigabbrev_np (SIGPWR), "PWR") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGRECONFIG
+  ASSERT (strcmp (sigabbrev_np (SIGRECONFIG), "RECONFIG") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGRECOVERY
+  ASSERT (strcmp (sigabbrev_np (SIGRECOVERY), "RECOVERY") == 0);
+  #endif
+  /* IRIX */
+  #ifdef SIGRESTART
+  ASSERT (strcmp (sigabbrev_np (SIGRESTART), "RESTART") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGRETRACT
+  ASSERT (strcmp (sigabbrev_np (SIGRETRACT), "RETRACT") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGSAK
+  ASSERT (strcmp (sigabbrev_np (SIGSAK), "SAK") == 0);
+  #endif
+  /* Minix */
+  #ifdef SIGSNDELAY
+  ASSERT (strcmp (sigabbrev_np (SIGSNDELAY), "SNDELAY") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGSOUND
+  ASSERT (strcmp (sigabbrev_np (SIGSOUND), "SOUND") == 0);
+  #endif
+  /* Linux */
+  #ifdef SIGSTKFLT
+  ASSERT (strcmp (sigabbrev_np (SIGSTKFLT), "STKFLT") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGSYSERROR
+  ASSERT (strcmp (sigabbrev_np (SIGSYSERROR), "SYSERROR") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGTALRM
+  ASSERT (strcmp (sigabbrev_np (SIGTALRM), "TALRM") == 0);
+  #endif
+  /* FreeBSD, OpenBSD */
+  #ifdef SIGTHR
+  ASSERT (strcmp (sigabbrev_np (SIGTHR), "THR") == 0);
+  #endif
+  /* IRIX */
+  #ifdef SIGUME
+  ASSERT (strcmp (sigabbrev_np (SIGUME), "UME") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGVIRT
+  ASSERT (strcmp (sigabbrev_np (SIGVIRT), "VIRT") == 0);
+  #endif
+  /* AIX */
+  #ifdef SIGWAITING
+  ASSERT (strcmp (sigabbrev_np (SIGWAITING), "WAITING") == 0);
+  #endif
+  /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, AIX, IRIX, Cygwin, Haiku */
+  #ifdef SIGWINCH
+  ASSERT (strcmp (sigabbrev_np (SIGWINCH), "WINCH") == 0);
+  #endif
+
+  ASSERT (sigabbrev_np (-714) == NULL);
+
+  return 0;
+}
-- 
2.7.4

Reply via email to