logo

utils-std

Collection of commonly available Unix tools
commit: 34425ed4c12736d8357835e1ee12d3b08ef2d9e8
parent 42cee09fd958a8ea12cb40df494c923da2eccf45
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat,  4 May 2024 21:24:27 +0200

lib/sys_signame: Work around lack of NSIG on FreeBSD & NetBSD

Diffstat:

Mlib/sys_signame.h15+++++++++++++++
Mlib/sys_signame.sh22++++++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/lib/sys_signame.h b/lib/sys_signame.h @@ -1,11 +1,26 @@ // utils-std: Collection of commonly available Unix tools // SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> // SPDX-License-Identifier: CC0-1.0 OR WTFPL +// /!\ File generated by lib/sys_signame.sh avoid editing #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE // NSIG #endif #include <signal.h> // NSIG + +// POSIX defect 741 (applied in issue 8 draft 4.1) adds _SC_NSIG +// https://www.austingroupbugs.net/view.php?id=741 +// But it isn't implemented in current (musl 1.2.5, glibc 2.38) systems, +// so I'm keeping it this way for now. +#ifndef NSIG +#if defined(SIGMAX) +#define NSIG (SIGMAX + 1) +#else +#warning NSIG nor SIGMAX were defined, this might be a bug. +#define NSIG (8 * sizeof(sigset_t) + 1) +#endif +#endif + static char *util_sys_signame[NSIG]; static size_t util_sys_signame_len = NSIG; diff --git a/lib/sys_signame.sh b/lib/sys_signame.sh @@ -2,15 +2,33 @@ # utils-std: Collection of commonly available Unix tools # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> # SPDX-License-Identifier: CC0-1.0 OR WTFPL + cat <<-EOF // utils-std: Collection of commonly available Unix tools // SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me> // SPDX-License-Identifier: CC0-1.0 OR WTFPL -#define _BSD_SOURCE // NSIG -#define _GNU_SOURCE // NSIG +// /!\ File generated by lib/sys_signame.sh avoid editing +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE // NSIG +#endif #include <signal.h> // NSIG + +// POSIX defect 741 (applied in issue 8 draft 4.1) adds _SC_NSIG +// https://www.austingroupbugs.net/view.php?id=741 +// But it isn't implemented in current (musl 1.2.5, glibc 2.38) systems, +// so I'm keeping it this way for now. +#ifndef NSIG +#if defined(SIGMAX) +#define NSIG (SIGMAX + 1) +#else +#warning NSIG nor SIGMAX were defined, this might be a bug. +#define NSIG (8 * sizeof(sigset_t) + 1) +#endif +#endif + static char *util_sys_signame[NSIG]; +static size_t util_sys_signame_len = NSIG; static void init_util_sys_signame()