diff options
| author | christos <christos@NetBSD.org> | 2021-10-26 16:16:34 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2021-10-26 16:16:34 +0000 |
| commit | 32e080b2c2c667f150d3fbde9145505e5f741a1e (patch) | |
| tree | ddc7980e73fa52fb3ba16d5f2ee23aaab74fc45b /lib/libc/sys | |
| parent | 568e3ffabd982acc53ef25d70c850a818f878c6f (diff) | |
Merge all MD __sigaction14_sigtramp.c copies into one:
- sparc and sparc64 were not using version 0 sigcontext when there were
no arguments in the signal version. This was probably a bug.
- vax is using +1 the version numbers of the other archs.
- Only hppa was defining __LIBC12_SOURCE__ so it was getting a working
sigcontext before. all the other ports that supported sigcontext had
the compat code disabled.
[pointed out by thorpej, thanks!]
If we want to remove sigcontext support from userland at least now there
is less work to do so.
Diffstat (limited to 'lib/libc/sys')
| -rw-r--r-- | lib/libc/sys/Makefile.inc | 4 | ||||
| -rw-r--r-- | lib/libc/sys/__sigaction14_sigtramp.c | 94 |
2 files changed, 96 insertions, 2 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 735cdfbb658..201a8867ee9 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.247 2021/10/01 17:13:44 christos Exp $ +# $NetBSD: Makefile.inc,v 1.248 2021/10/26 16:16:36 christos Exp $ # @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 # sys sources @@ -10,7 +10,7 @@ SRCS+= cpuset.c SRCS+= accept4.c clock_getcpuclockid.c eventfd_read.c eventfd_write.c \ posix_fadvise.c posix_madvise.c ppoll.c sched.c sigqueue.c \ sigtimedwait.c sigwait.c sigwaitinfo.c statvfs.c swapon.c semctl.c \ - vadvise.c + vadvise.c __sigaction14_sigtramp.c .if ${RUMPRUN} != "yes" # modules with non-default implementations on at least one architecture: diff --git a/lib/libc/sys/__sigaction14_sigtramp.c b/lib/libc/sys/__sigaction14_sigtramp.c new file mode 100644 index 00000000000..0880197d4de --- /dev/null +++ b/lib/libc/sys/__sigaction14_sigtramp.c @@ -0,0 +1,94 @@ +/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2021/10/26 16:16:36 christos Exp $ */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.1 2021/10/26 16:16:36 christos Exp $"); +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <stddef.h> +#include <signal.h> +#include <errno.h> + +#include "extern.h" + +#ifndef __SIGTRAMP_SIGCONTEXT_VERSION +#define __SIGTRAMP_SIGCONTEXT_VERSION 1 +#endif +#ifndef __SIGTRAMP_SIGINFO_VERSION +#define __SIGTRAMP_SIGINFO_VERSION 2 +#endif +#define C(a,b) __CONCAT(a,b) +#define __SIGTRAMP_SIGCONTEXT \ + C(__sigtramp_sigcontext_,__SIGTRAMP_SIGCONTEXT_VERSION) +#define __SIGTRAMP_SIGINFO \ + C(__sigtramp_siginfo_,__SIGTRAMP_SIGINFO_VERSION) + +__weak_alias(__sigaction14, __libc_sigaction14) + +#define __LIBC12_SOURCE__ + +int +__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) +{ + extern const int __SIGTRAMP_SIGINFO[]; + + /* + * If no sigaction, use the "default" trampoline since it won't + * be used. + */ + if (act == NULL) + return __sigaction_sigtramp(sig, act, oact, NULL, 0); + +#if defined(__HAVE_STRUCT_SIGCONTEXT) && defined(__LIBC12_SOURCE__) + /* + * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not + * set in the sigaction. + */ + if ((act->sa_flags & SA_SIGINFO) == 0) { + extern const int __SIGTRAMP_SIGCONTEXT[]; + int sav = errno; + int rv = __sigaction_sigtramp(sig, act, oact, + __SIGTRAMP_SIGCONTEXT, __SIGTRAMP_SIGCONTEXT_VERSION); + if (rv >= 0 || errno != EINVAL) + return rv; + errno = sav; + } +#endif + + /* + * If SA_SIGINFO was specified or the compatibility trampolines + * can't be used, use the siginfo trampoline. + */ + return __sigaction_sigtramp(sig, act, oact, + __SIGTRAMP_SIGINFO, __SIGTRAMP_SIGINFO_VERSION); +} |
