* lib/signal.in.h (SIG2STR_MAX): New macro.
(sig2str, str2sig): New declarations.
* lib/sig2str.h: Don't include intprops.h.
(SIG2STR_MAX): Remove macro.
(sig2str, str2sig): Remove declarations.
* lib/sig2str.c: Include <signal.h> as the specification header.
* m4/signal_h.m4 (gl_SIGNAL_H): Test whether sig2str, str2sig are
declared.
(gl_SIGNAL_H_REQUIRE_DEFAULTS): Initialize GNULIB_SIG2STR.
(gl_SIGNAL_H_DEFAULTS): Initialize HAVE_SIG2STR, HAVE_STR2SIG.
* m4/sig2str.m4 (gl_FUNC_SIG2STR): Require gl_SIGNAL_H_DEFAULTS. Check
also for str2sig. Set HAVE_SIG2STR, HAVE_STR2SIG.
* modules/signal-h (Makefile.am): Substitute GNULIB_SIG2STR,
HAVE_SIG2STR, HAVE_STR2SIG.
* modules/sig2str (Depends-on): Add signal-h. Remove intprops.
(configure.ac): Test HAVE_SIG2STR, HAVE_STR2SIG. Invoke
gl_SIGNAL_MODULE_INDICATOR.
(Include): Add <signal.h>.
* doc/posix-functions/sig2str.texi: Mention as implemented through the
sig2str module.
* doc/posix-functions/str2sig.texi: Likewise.
+2024-08-09 Bruno Haible <bruno@clisp.org>
+
+ sig2str: Align with POSIX:2024.
+ * lib/signal.in.h (SIG2STR_MAX): New macro.
+ (sig2str, str2sig): New declarations.
+ * lib/sig2str.h: Don't include intprops.h.
+ (SIG2STR_MAX): Remove macro.
+ (sig2str, str2sig): Remove declarations.
+ * lib/sig2str.c: Include <signal.h> as the specification header.
+ * m4/signal_h.m4 (gl_SIGNAL_H): Test whether sig2str, str2sig are
+ declared.
+ (gl_SIGNAL_H_REQUIRE_DEFAULTS): Initialize GNULIB_SIG2STR.
+ (gl_SIGNAL_H_DEFAULTS): Initialize HAVE_SIG2STR, HAVE_STR2SIG.
+ * m4/sig2str.m4 (gl_FUNC_SIG2STR): Require gl_SIGNAL_H_DEFAULTS. Check
+ also for str2sig. Set HAVE_SIG2STR, HAVE_STR2SIG.
+ * modules/signal-h (Makefile.am): Substitute GNULIB_SIG2STR,
+ HAVE_SIG2STR, HAVE_STR2SIG.
+ * modules/sig2str (Depends-on): Add signal-h. Remove intprops.
+ (configure.ac): Test HAVE_SIG2STR, HAVE_STR2SIG. Invoke
+ gl_SIGNAL_MODULE_INDICATOR.
+ (Include): Add <signal.h>.
+ * doc/posix-functions/sig2str.texi: Mention as implemented through the
+ sig2str module.
+ * doc/posix-functions/str2sig.texi: Likewise.
+
2024-08-09 Paul Eggert <eggert@cs.ucla.edu>
test-utime: port to noatime file systems
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/sig2str.html}
-Gnulib module: ---
+Gnulib module: sig2str
Portability problems fixed by Gnulib:
@itemize
-@end itemize
-
-Portability problems not fixed by Gnulib:
-@itemize
@item
This function is missing on many platforms:
glibc 2.40, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Minix 3.3.0, AIX 7.3.1, HP-UX 11.31, Cygwin 3.2.x, mingw, MSVC 14, Android 9.0.
@end itemize
-Note: Gnulib has a module @code{sig2str} that implements this function,
-but declares it in a different header file.
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/str2sig.html}
-Gnulib module: ---
+Gnulib module: sig2str
Portability problems fixed by Gnulib:
@itemize
-@end itemize
-
-Portability problems not fixed by Gnulib:
-@itemize
@item
This function is missing on many platforms:
glibc 2.40, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Minix 3.3.0, AIX 7.3.1, HP-UX 11.31, Cygwin 3.2.x, mingw, MSVC 14, Android 9.0.
@end itemize
-Note: Gnulib has a module @code{sig2str} that implements this function,
-but declares it in a different header file.
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
#include <config.h>
-#include <limits.h>
+/* Specification. */
#include <signal.h>
+
+#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
-/* Don't override system declarations of SIG2STR_MAX, sig2str, str2sig. */
-#ifndef SIG2STR_MAX
-
-# include "intprops.h"
-
-/* Size of a buffer needed to hold a signal name like "HUP". */
-# define SIG2STR_MAX (sizeof "SIGRTMAX" + INT_STRLEN_BOUND (int) - 1)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int sig2str (int, char *);
-int str2sig (char const *, int *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
/* An upper bound on signal numbers allowed by the system. */
#if defined _sys_nsig
#endif
+/* Maximum size of a signal name returned by sig2str(), including the
+ terminating NUL byte. */
+#ifndef SIG2STR_MAX
+/* The longest one: "RTMAX", then "+" or "-", then up to 10 digits, then NUL.
+ Add + 2 as a reserve for the future. */
+# define SIG2STR_MAX (5 + 1 + 10 + 1 + 2)
+#endif
+
+#if @GNULIB_SIG2STR@
+# if !@HAVE_SIG2STR@
+_GL_FUNCDECL_SYS (sig2str, int, (int signo, char *str));
+# endif
+_GL_CXXALIAS_SYS (sig2str, int, (int signo, char *str));
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (sig2str);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef sig2str
+# if HAVE_RAW_DECL_SIG2STR
+_GL_WARN_ON_USE (sig2str, "sig2str is not portable - "
+ "use gnulib module sig2str for portability");
+# endif
+#endif
+
+#if @GNULIB_SIG2STR@
+# if !@HAVE_STR2SIG@
+_GL_FUNCDECL_SYS (str2sig, int, (char const *str, int *signo_p));
+# endif
+_GL_CXXALIAS_SYS (str2sig, int, (char const *str, int *signo_p));
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (str2sig);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef str2sig
+# if HAVE_RAW_DECL_STR2SIG
+_GL_WARN_ON_USE (str2sig, "str2sig is not portable - "
+ "use gnulib module sig2str for portability");
+# endif
+#endif
+
+
#if @GNULIB_PTHREAD_SIGMASK@
# if @REPLACE_PTHREAD_SIGMASK@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# sig2str.m4
-# serial 7
+# serial 8
dnl Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFUN([gl_FUNC_SIG2STR],
[
- AC_CHECK_FUNCS([sig2str])
+ AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
+ AC_CHECK_FUNCS([sig2str str2sig])
+ if test $ac_cv_func_sig2str = no; then
+ HAVE_SIG2STR=0
+ fi
+ if test $ac_cv_func_str2sig = no; then
+ HAVE_STR2SIG=0
+ fi
])
# Prerequisites of lib/sig2str.c.
# signal_h.m4
-# serial 22
+# serial 23
dnl Copyright (C) 2007-2024 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 Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use.
gl_WARN_ON_USE_PREPARE([[#include <signal.h>
- ]], [pthread_sigmask sigaction
+ ]], [sig2str str2sig
+ pthread_sigmask sigaction
sigaddset sigdelset sigemptyset sigfillset sigismember
sigpending sigprocmask])
m4_defun(GL_MODULE_INDICATOR_PREFIX[_SIGNAL_H_MODULE_INDICATOR_DEFAULTS], [
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTHREAD_SIGMASK])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAISE])
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIG2STR])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNAL_H_SIGPIPE])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGPROCMASK])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGACTION])
HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING])
HAVE_PTHREAD_SIGMASK=1; AC_SUBST([HAVE_PTHREAD_SIGMASK])
HAVE_RAISE=1; AC_SUBST([HAVE_RAISE])
+ HAVE_SIG2STR=1; AC_SUBST([HAVE_SIG2STR])
HAVE_SIGSET_T=1; AC_SUBST([HAVE_SIGSET_T])
HAVE_SIGINFO_T=1; AC_SUBST([HAVE_SIGINFO_T])
HAVE_SIGACTION=1; AC_SUBST([HAVE_SIGACTION])
+ HAVE_STR2SIG=1; AC_SUBST([HAVE_STR2SIG])
HAVE_STRUCT_SIGACTION_SA_SIGACTION=1;
AC_SUBST([HAVE_STRUCT_SIGACTION_SA_SIGACTION])
HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1;
m4/sig2str.m4
Depends-on:
-intprops
+signal-h
configure.ac:
gl_FUNC_SIG2STR
-gl_CONDITIONAL([GL_COND_OBJ_SIG2STR], [test $ac_cv_func_sig2str = no])
+gl_CONDITIONAL([GL_COND_OBJ_SIG2STR],
+ [test $HAVE_SIG2STR = 0 || test $HAVE_STR2SIG = 0])
AM_COND_IF([GL_COND_OBJ_SIG2STR], [
gl_PREREQ_SIG2STR
])
+gl_SIGNAL_MODULE_INDICATOR([sig2str])
Makefile.am:
if GL_COND_OBJ_SIG2STR
endif
Include:
-"sig2str.h"
+<signal.h>
+"sig2str.h" /* for SIGNUM_BOUND */
License:
GPL
-e 's|@''NEXT_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \
-e 's/@''GNULIB_PTHREAD_SIGMASK''@/$(GNULIB_PTHREAD_SIGMASK)/g' \
-e 's/@''GNULIB_RAISE''@/$(GNULIB_RAISE)/g' \
+ -e 's/@''GNULIB_SIG2STR''@/$(GNULIB_SIG2STR)/g' \
-e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GNULIB_SIGNAL_H_SIGPIPE)/g' \
-e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \
-e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \
-e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \
-e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \
-e 's|@''HAVE_RAISE''@|$(HAVE_RAISE)|g' \
+ -e 's|@''HAVE_SIG2STR''@|$(HAVE_SIG2STR)|g' \
-e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \
-e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \
-e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \
+ -e 's|@''HAVE_STR2SIG''@|$(HAVE_STR2SIG)|g' \
-e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \
-e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \
-e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \