From 40245925ce9d6b9a9c4ed6140cea39d948d10898 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 18 Feb 2020 11:17:43 +0100 Subject: [PATCH] Cygwin: rename NSIG to _NSIG, change visibility of NSIG to MISC NSIG is a deprecated symbol only visible under MISC visibility. _NSIG is used widely instead, and on most systems NSIG is defined in terms of _NSIG. Follow suit: Change NSIG to _NSIG throughout and change visiblity of NSIG to be defined only in __MISC_VISIBLE case. Signed-off-by: Corinna Vinschen --- winsup/cygwin/exceptions.cc | 6 +++--- winsup/cygwin/include/cygwin/signal.h | 10 +++++++--- winsup/cygwin/release/3.1.4 | 4 ++++ winsup/cygwin/signal.cc | 14 +++++++------- winsup/cygwin/sigproc.cc | 8 ++++---- winsup/cygwin/sigproc.h | 22 +++++++++++----------- winsup/cygwin/strsig.cc | 2 +- 7 files changed, 37 insertions(+), 29 deletions(-) diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 3e7d7275c..b331dc8d1 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1166,7 +1166,7 @@ extern "C" int sighold (int sig) { /* check that sig is in right range */ - if (sig < 0 || sig >= NSIG) + if (sig < 0 || sig >= _NSIG) { set_errno (EINVAL); syscall_printf ("signal %d out of range", sig); @@ -1182,7 +1182,7 @@ extern "C" int sigrelse (int sig) { /* check that sig is in right range */ - if (sig < 0 || sig >= NSIG) + if (sig < 0 || sig >= _NSIG) { set_errno (EINVAL); syscall_printf ("signal %d out of range", sig); @@ -1201,7 +1201,7 @@ sigset (int sig, _sig_func_ptr func) _sig_func_ptr prev; /* check that sig is in right range */ - if (sig < 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) + if (sig < 0 || sig >= _NSIG || sig == SIGKILL || sig == SIGSTOP) { set_errno (EINVAL); syscall_printf ("SIG_ERR = sigset (%d, %p)", sig, func); diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h index e659d7ae0..bc4ad1832 100644 --- a/winsup/cygwin/include/cygwin/signal.h +++ b/winsup/cygwin/include/cygwin/signal.h @@ -438,14 +438,18 @@ struct sigaction #define SIGUSR2 31 /* user defined signal 2 */ #if __WORDSIZE == 64 -#define NSIG 65 /* signal 0 implied */ +#define _NSIG 65 /* signal 0 implied */ #else -#define NSIG 33 /* signal 0 implied */ +#define _NSIG 33 /* signal 0 implied */ +#endif + +#if __MISC_VISIBLE +#define NSIG _NSIG #endif /* Real-Time signals per SUSv3. RT_SIGMAX is defined as 8 in limits.h */ #define SIGRTMIN 32 -#define SIGRTMAX (NSIG - 1) +#define SIGRTMAX (_NSIG - 1) #define SIG_HOLD ((_sig_func_ptr)2) /* Signal in signal mask */ diff --git a/winsup/cygwin/release/3.1.4 b/winsup/cygwin/release/3.1.4 index 06ed1eb57..1c4495445 100644 --- a/winsup/cygwin/release/3.1.4 +++ b/winsup/cygwin/release/3.1.4 @@ -13,6 +13,10 @@ What changed: - Allow AF_LOCAL sockets to be opened with O_PATH. +- : New macro _NSIG replacing NSIG. NSIG is now only + visible to MISC builds, as on Linux. + + Bug Fixes: ---------- diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 8ac59d4b9..bd1168e90 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -36,7 +36,7 @@ signal (int sig, _sig_func_ptr func) _sig_func_ptr prev; /* check that sig is in right range */ - if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) + if (sig <= 0 || sig >= _NSIG || sig == SIGKILL || sig == SIGSTOP) { set_errno (EINVAL); syscall_printf ("SIG_ERR = signal (%d, %p)", sig, func); @@ -311,7 +311,7 @@ kill0 (pid_t pid, siginfo_t& si) { syscall_printf ("kill (%d, %d)", pid, si.si_signo); /* check that sig is in right range */ - if (si.si_signo < 0 || si.si_signo >= NSIG) + if (si.si_signo < 0 || si.si_signo >= _NSIG) { set_errno (EINVAL); syscall_printf ("signal %d out of range", si.si_signo); @@ -417,7 +417,7 @@ sigaction_worker (int sig, const struct sigaction *newact, { sig_dispatch_pending (); /* check that sig is in right range */ - if (sig <= 0 || sig >= NSIG) + if (sig <= 0 || sig >= _NSIG) set_errno (EINVAL); else { @@ -480,7 +480,7 @@ extern "C" int sigaddset (sigset_t *set, const int sig) { /* check that sig is in right range */ - if (sig <= 0 || sig >= NSIG) + if (sig <= 0 || sig >= _NSIG) { set_errno (EINVAL); syscall_printf ("SIG_ERR = sigaddset signal %d out of range", sig); @@ -495,7 +495,7 @@ extern "C" int sigdelset (sigset_t *set, const int sig) { /* check that sig is in right range */ - if (sig <= 0 || sig >= NSIG) + if (sig <= 0 || sig >= _NSIG) { set_errno (EINVAL); syscall_printf ("SIG_ERR = sigdelset signal %d out of range", sig); @@ -510,7 +510,7 @@ extern "C" int sigismember (const sigset_t *set, int sig) { /* check that sig is in right range */ - if (sig <= 0 || sig >= NSIG) + if (sig <= 0 || sig >= _NSIG) { set_errno (EINVAL); syscall_printf ("SIG_ERR = sigdelset signal %d out of range", sig); @@ -709,7 +709,7 @@ sigqueue (pid_t pid, int sig, const union sigval value) } if (sig == 0) return 0; - if (sig < 0 || sig >= NSIG) + if (sig < 0 || sig >= _NSIG) { set_errno (EINVAL); return -1; diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index aff1ed61b..7286e3238 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -71,7 +71,7 @@ static void WINAPI wait_sig (VOID *arg); class pending_signals { - sigpacket sigs[NSIG + 1]; + sigpacket sigs[_NSIG + 1]; sigpacket start; bool retry; @@ -91,7 +91,7 @@ void __stdcall sigalloc () { cygheap->sigs = global_sigs = - (struct sigaction *) ccalloc_abort (HEAP_SIGS, NSIG, sizeof (struct sigaction)); + (struct sigaction *) ccalloc_abort (HEAP_SIGS, _NSIG, sizeof (struct sigaction)); global_sigs[SIGSTOP].sa_flags = SA_RESTART | SA_NODEFER; } @@ -100,7 +100,7 @@ signal_fixup_after_exec () { global_sigs = cygheap->sigs; /* Set up child's signal handlers */ - for (int i = 0; i < NSIG; i++) + for (int i = 0; i < _NSIG; i++) { global_sigs[i].sa_mask = 0; if (global_sigs[i].sa_handler != SIG_IGN) @@ -449,7 +449,7 @@ sigproc_init () char char_sa_buf[1024]; PSECURITY_ATTRIBUTES sa = sec_user_nih ((PSECURITY_ATTRIBUTES) char_sa_buf, cygheap->user.sid()); DWORD err = fhandler_pipe::create (sa, &my_readsig, &my_sendsig, - NSIG * sizeof (sigpacket), "sigwait", + _NSIG * sizeof (sigpacket), "sigwait", PIPE_ADD_PID); if (err) { diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index a6f1428ce..f8f92d350 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -10,19 +10,19 @@ details. */ #include #include "sync.h" -#ifdef NSIG +#ifdef _NSIG enum { - __SIGFLUSH = -(NSIG + 1), - __SIGSTRACE = -(NSIG + 2), - __SIGCOMMUNE = -(NSIG + 3), - __SIGPENDING = -(NSIG + 4), - __SIGDELETE = -(NSIG + 5), /* Not currently used */ - __SIGFLUSHFAST = -(NSIG + 6), - __SIGHOLD = -(NSIG + 7), - __SIGNOHOLD = -(NSIG + 8), - __SIGSETPGRP = -(NSIG + 9), - __SIGTHREADEXIT = -(NSIG + 10) + __SIGFLUSH = -(_NSIG + 1), + __SIGSTRACE = -(_NSIG + 2), + __SIGCOMMUNE = -(_NSIG + 3), + __SIGPENDING = -(_NSIG + 4), + __SIGDELETE = -(_NSIG + 5), /* Not currently used */ + __SIGFLUSHFAST = -(_NSIG + 6), + __SIGHOLD = -(_NSIG + 7), + __SIGNOHOLD = -(_NSIG + 8), + __SIGSETPGRP = -(_NSIG + 9), + __SIGTHREADEXIT = -(_NSIG + 10) }; #endif diff --git a/winsup/cygwin/strsig.cc b/winsup/cygwin/strsig.cc index 6c7bdd37c..03f959f88 100644 --- a/winsup/cygwin/strsig.cc +++ b/winsup/cygwin/strsig.cc @@ -174,7 +174,7 @@ psiginfo (const siginfo_t *info, const char *s) ADD (strsignal (info->si_signo)); - if (info->si_signo > 0 && info->si_signo < NSIG) + if (info->si_signo > 0 && info->si_signo < _NSIG) { switch (info->si_signo) {