summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkstailey <kstailey@openbsd.org>1999-09-14 01:05:24 +0000
committerkstailey <kstailey@openbsd.org>1999-09-14 01:05:24 +0000
commit6ddc5e93cbce2ac4c919150aec2a2d43c32e1fed (patch)
tree24efc3ceb4b0526b924cb37be9846024eb555966
parentbew frame framework (diff)
downloadwireguard-openbsd-6ddc5e93cbce2ac4c919150aec2a2d43c32e1fed.tar.xz
wireguard-openbsd-6ddc5e93cbce2ac4c919150aec2a2d43c32e1fed.zip
signals
-rw-r--r--sys/arch/alpha/alpha/netbsd_machdep.c138
-rw-r--r--sys/arch/alpha/conf/files.alpha3
-rw-r--r--sys/arch/alpha/include/netbsd_machdep.h191
-rw-r--r--sys/compat/netbsd/files.netbsd7
-rw-r--r--sys/compat/netbsd/netbsd_getcwd.c3
-rw-r--r--sys/compat/netbsd/netbsd_signal.c248
-rw-r--r--sys/compat/netbsd/netbsd_signal.h67
-rw-r--r--sys/compat/netbsd/netbsd_stat.c3
-rw-r--r--sys/compat/netbsd/syscalls.master62
9 files changed, 533 insertions, 189 deletions
diff --git a/sys/arch/alpha/alpha/netbsd_machdep.c b/sys/arch/alpha/alpha/netbsd_machdep.c
new file mode 100644
index 00000000000..2c6272b9119
--- /dev/null
+++ b/sys/arch/alpha/alpha/netbsd_machdep.c
@@ -0,0 +1,138 @@
+/* $OpenBSD: netbsd_machdep.c,v 1.1 1999/09/14 01:05:24 kstailey Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signalvar.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/buf.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <sys/user.h>
+
+#include <vm/vm.h>
+
+#include <compat/netbsd/netbsd_signal.h>
+#include <compat/netbsd/netbsd_syscallargs.h>
+
+#include <machine/netbsd_machdep.h>
+#include <machine/signal.h>
+#include <machine/reg.h>
+
+#ifdef DEBUG
+extern int sigdebug;
+extern int sigpid;
+#define SDB_FOLLOW 0x01
+#define SDB_KSTACK 0x02
+#endif
+
+static void netbsd_to_openbsd_sigcontext __P ((struct netbsd_sigcontext *,
+ struct sigcontext *));
+
+static void
+netbsd_to_openbsd_sigcontext(nbsc, obsc)
+ struct netbsd_sigcontext *nbsc;
+ struct sigcontext *obsc;
+{
+ memset(obsc, 0, sizeof(obsc));
+ obsc->sc_onstack = nbsc->sc_onstack;
+ memcpy(&obsc->sc_mask, &nbsc->sc_mask.__bits[0], sizeof(sigset_t));
+ obsc->sc_pc = nbsc->sc_pc;
+ obsc->sc_ps = nbsc->sc_ps;
+ memcpy(obsc->sc_regs, nbsc->sc_regs, sizeof(obsc->sc_regs));
+ obsc->sc_ownedfp = nbsc->sc_ownedfp;
+ memcpy(obsc->sc_fpregs, nbsc->sc_fpregs, sizeof(obsc->sc_fpregs));
+ obsc->sc_fpcr = nbsc->sc_fpcr;
+ obsc->sc_fp_control = nbsc->sc_fp_control;
+}
+
+/* ARGSUSED */
+int
+netbsd_sys___sigreturn14(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct netbsd_sys___sigreturn14_args /* {
+ syscallarg(struct netbsd_sigcontext *) sigcntxp;
+ } */ *uap = v;
+ struct netbsd_sigcontext *nbscp;
+ struct sigcontext *scp, ksc;
+ extern struct proc *fpcurproc;
+
+ nbscp = SCARG(uap, sigcntxp);
+ netbsd_to_openbsd_sigcontext(nbscp, scp);
+#ifdef DEBUG
+ if (sigdebug & SDB_FOLLOW)
+ printf("sigreturn: pid %d, scp %p\n", p->p_pid, scp);
+#endif
+
+ if (ALIGN(scp) != (u_int64_t)scp)
+ return (EINVAL);
+
+ /*
+ * Test and fetch the context structure.
+ * We grab it all at once for speed.
+ */
+ if (useracc((caddr_t)scp, sizeof (*scp), B_WRITE) == 0 ||
+ copyin((caddr_t)scp, (caddr_t)&ksc, sizeof ksc))
+ return (EINVAL);
+
+ if (ksc.sc_regs[R_ZERO] != 0xACEDBADE) /* magic number */
+ return (EINVAL);
+ /*
+ * Restore the user-supplied information
+ */
+ if (ksc.sc_onstack)
+ p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
+ else
+ p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
+ p->p_sigmask = ksc.sc_mask &~ sigcantmask;
+
+ p->p_md.md_tf->tf_regs[FRAME_PC] = ksc.sc_pc;
+ p->p_md.md_tf->tf_regs[FRAME_PS] =
+ (ksc.sc_ps | ALPHA_PSL_USERSET) & ~ALPHA_PSL_USERCLR;
+
+ regtoframe((struct reg *)ksc.sc_regs, p->p_md.md_tf);
+ alpha_pal_wrusp(ksc.sc_regs[R_SP]);
+
+ /* XXX ksc.sc_ownedfp ? */
+ if (p == fpcurproc)
+ fpcurproc = NULL;
+ bcopy((struct fpreg *)ksc.sc_fpregs, &p->p_addr->u_pcb.pcb_fp,
+ sizeof(struct fpreg));
+ /* XXX ksc.sc_fp_control ? */
+
+#ifdef DEBUG
+ if (sigdebug & SDB_FOLLOW)
+ printf("sigreturn(%d): returns\n", p->p_pid);
+#endif
+ return (EJUSTRETURN);
+}
diff --git a/sys/arch/alpha/conf/files.alpha b/sys/arch/alpha/conf/files.alpha
index 0d458e86660..454c60b4f80 100644
--- a/sys/arch/alpha/conf/files.alpha
+++ b/sys/arch/alpha/conf/files.alpha
@@ -1,4 +1,4 @@
-# $OpenBSD: files.alpha,v 1.28 1999/09/12 14:15:16 kstailey Exp $
+# $OpenBSD: files.alpha,v 1.29 1999/09/14 01:05:24 kstailey Exp $
# $NetBSD: files.alpha,v 1.32 1996/11/25 04:03:21 cgd Exp $
#
# alpha-specific configuration info
@@ -297,3 +297,4 @@ include "compat/osf1/files.osf1"
# NetBSD binary compatibility (COMPAT_NETBSD)
include "../../../compat/netbsd/files.netbsd"
+file arch/alpha/alpha/netbsd_machdep.c compat_netbsd
diff --git a/sys/arch/alpha/include/netbsd_machdep.h b/sys/arch/alpha/include/netbsd_machdep.h
index c338e2642d1..2ae9917ec8e 100644
--- a/sys/arch/alpha/include/netbsd_machdep.h
+++ b/sys/arch/alpha/include/netbsd_machdep.h
@@ -1,164 +1,53 @@
-/* $NetBSD: freebsd_machdep.h,v 1.1 1995/10/10 01:22:35 mycroft Exp $ */
+/* $OpenBSD: netbsd_machdep.h,v 1.2 1999/09/14 01:05:24 kstailey Exp $ */
/*
- * Copyright (c) 1986, 1989, 1991, 1993
- * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
*
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
*
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * from: @(#)signal.h 8.1 (Berkeley) 6/11/93
- * from: Id: signal.h,v 1.4 1994/08/21 04:55:30 paul Exp
- *
- * from: @(#)frame.h 5.2 (Berkeley) 1/18/91
- * from: Id: frame.h,v 1.10 1995/03/16 18:11:42 bde Exp
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
*/
-#ifndef _FREEBSD_MACHDEP_H
-#define _FREEBSD_MACHDEP_H
-/*
- * signal support
- */
-
-struct freebsd_sigcontext {
- int sc_onstack; /* sigstack state to restore */
- int sc_mask; /* signal mask to restore */
- int sc_esp; /* machine state */
- int sc_ebp;
- int sc_isp;
- int sc_eip;
- int sc_eflags;
- int sc_es;
- int sc_ds;
- int sc_cs;
- int sc_ss;
- int sc_edi;
- int sc_esi;
- int sc_ebx;
- int sc_edx;
- int sc_ecx;
- int sc_eax;
-};
-
-struct freebsd_sigframe {
- int sf_signum;
- int sf_code;
- struct freebsd_sigcontext *sf_scp;
- char *sf_addr;
- sig_t sf_handler;
- struct freebsd_sigcontext sf_sc;
-};
+#ifndef _NETBSD_MACHDEP_H
+#define _NETBSD_MACHDEP_H
/*
- * freebsd_ptrace(2) support
+ * signal support
*/
-#define FREEBSD_USRSTACK 0xefbfe000 /* USRSTACK */
-#define FREEBSD_U_AR0_OFFSET 0x0000045c /* offsetof(struct user, u_ar0) */
-#define FREEBSD_U_SAVEFP_OFFSET 0x00000070
- /* offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_savefpu) */
-
-/* Exception/Trap Stack Frame */
-struct freebsd_trapframe {
- int tf_es;
- int tf_ds;
- int tf_edi;
- int tf_esi;
- int tf_ebp;
- int tf_isp;
- int tf_ebx;
- int tf_edx;
- int tf_ecx;
- int tf_eax;
- int tf_trapno;
- /* below portion defined in 386 hardware */
- int tf_err;
- int tf_eip;
- int tf_cs;
- int tf_eflags;
- /* below only when transitting rings (e.g. user to kernel) */
- int tf_esp;
- int tf_ss;
+struct netbsd_sigcontext {
+ long sc_onstack; /* sigstack state to restore */
+ long __sc_mask13; /* signal mask to restore (old style) */
+ long sc_pc; /* pc to restore */
+ long sc_ps; /* ps to restore */
+ unsigned long sc_regs[32]; /* integer register set (see above) */
+#define sc_sp sc_regs[R_SP]
+ long sc_ownedfp; /* fp has been used */
+ unsigned long sc_fpregs[32]; /* FP register set (see above) */
+ unsigned long sc_fpcr; /* FP control register (see above) */
+ unsigned long sc_fp_control; /* FP software control word */
+ long sc_reserved[2]; /* XXX */
+ long sc_xxx[8]; /* XXX */
+ netbsd_sigset_t sc_mask; /* signal mask to restore (new style) */
};
-/* Environment information of floating point unit */
-struct freebsd_env87 {
- long en_cw; /* control word (16bits) */
- long en_sw; /* status word (16bits) */
- long en_tw; /* tag word (16bits) */
- long en_fip; /* floating point instruction pointer */
- u_short en_fcs; /* floating code segment selector */
- u_short en_opcode; /* opcode last executed (11 bits ) */
- long en_foo; /* floating operand offset */
- long en_fos; /* floating operand segment selector */
-};
-
-/* Contents of each floating point accumulator */
-struct freebsd_fpacc87 {
-#ifdef dontdef /* too unportable */
- u_long fp_mantlo; /* mantissa low (31:0) */
- u_long fp_manthi; /* mantissa high (63:32) */
- int fp_exp:15; /* exponent */
- int fp_sgn:1; /* mantissa sign */
-#else
- u_char fp_bytes[10];
-#endif
-};
-
-/* Floating point context */
-struct freebsd_save87 {
- struct freebsd_env87 sv_env; /* floating point control/status */
- struct freebsd_fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */
- u_long sv_ex_sw; /* status word for last exception */
- /*
- * Bogus padding for emulators. Emulators should use their own
- * struct and arrange to store into this struct (ending here)
- * before it is inspected for ptracing or for core dumps. Some
- * emulators overwrite the whole struct. We have no good way of
- * knowing how much padding to leave. Leave just enough for the
- * GPL emulator's i387_union (176 bytes total).
- */
- u_char sv_pad[64]; /* padding; used by emulators */
-};
-
-struct freebsd_ptrace_reg {
- struct freebsd_trapframe freebsd_ptrace_regs;
- struct freebsd_save87 freebsd_ptrace_fpregs;
-};
-
-/* sys/i386/include/exec.h */
-#define FREEBSD___LDPGSZ 4096
-
-#ifdef _KERNEL
-void freebsd_sendsig __P((sig_t, int, int, u_long, int, union sigval));
-#endif
-
-#endif /* _FREEBSD_MACHDEP_H */
+#endif /* _NETBSD_MACHDEP_H */
diff --git a/sys/compat/netbsd/files.netbsd b/sys/compat/netbsd/files.netbsd
index 0cd8ea95014..4f2d2a39289 100644
--- a/sys/compat/netbsd/files.netbsd
+++ b/sys/compat/netbsd/files.netbsd
@@ -1,4 +1,4 @@
-# $OpenBSD: files.netbsd,v 1.1 1999/09/12 14:15:16 kstailey Exp $
+# $OpenBSD: files.netbsd,v 1.2 1999/09/14 01:05:25 kstailey Exp $
#
# Config.new file description for machine-independent NetBSD compat code.
# Included by ports that need it.
@@ -9,9 +9,6 @@
file compat/netbsd/netbsd_exec.c compat_netbsd
file compat/netbsd/netbsd_stat.c compat_netbsd
file compat/netbsd/netbsd_getcwd.c compat_netbsd
-# file compat/netbsd/netbsd_file.c compat_netbsd
-# file compat/netbsd/netbsd_ioctl.c compat_netbsd
-# file compat/netbsd/netbsd_misc.c compat_netbsd
-# file compat/netbsd/netbsd_ptrace.c compat_netbsd
+file compat/netbsd/netbsd_signal.c compat_netbsd
file compat/netbsd/netbsd_sysent.c compat_netbsd
file compat/netbsd/netbsd_syscalls.c compat_netbsd
diff --git a/sys/compat/netbsd/netbsd_getcwd.c b/sys/compat/netbsd/netbsd_getcwd.c
index 8177c8c7001..69bb3e88a16 100644
--- a/sys/compat/netbsd/netbsd_getcwd.c
+++ b/sys/compat/netbsd/netbsd_getcwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netbsd_getcwd.c,v 1.1 1999/09/12 14:15:16 kstailey Exp $ */
+/* $OpenBSD: netbsd_getcwd.c,v 1.2 1999/09/14 01:05:25 kstailey Exp $ */
/* $NetBSD: vfs_getcwd.c,v 1.3.2.3 1999/07/11 10:24:09 sommerfeld Exp $ */
/*-
@@ -53,6 +53,7 @@ int proc_isunder __P((struct proc *, struct proc*)); /* missing from proc.h */
#include <sys/dirent.h>
#include <ufs/ufs/dir.h> /* XXX only for DIRBLKSIZ */
+#include <compat/netbsd/netbsd_signal.h>
#include <compat/netbsd/netbsd_syscallargs.h>
static int
diff --git a/sys/compat/netbsd/netbsd_signal.c b/sys/compat/netbsd/netbsd_signal.c
new file mode 100644
index 00000000000..bdd354c4439
--- /dev/null
+++ b/sys/compat/netbsd/netbsd_signal.c
@@ -0,0 +1,248 @@
+/* $OpenBSD: netbsd_signal.c,v 1.1 1999/09/14 01:05:25 kstailey Exp $ */
+
+/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
+
+/*
+ * Copyright (c) 1997 Theo de Raadt. All rights reserved.
+ * Copyright (c) 1982, 1986, 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
+ */
+
+/*
+
+;293 STD { int netbsd_sys___sigprocmask14(int how, \
+; const sigset_t *set, \
+; sigset_t *oset); }
+
+;294 STD { int netbsd_sys___sigsuspend14(const sigset_t *set); }
+
+*/
+
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/signalvar.h>
+#include <sys/signal.h>
+#include <sys/systm.h>
+
+#include <compat/netbsd/netbsd_types.h>
+#include <compat/netbsd/netbsd_signal.h>
+/* #include <compat/netbsd/netbsd_stat.h> */
+#include <compat/netbsd/netbsd_syscallargs.h>
+
+static void netbsd_to_openbsd_sigaction __P((struct netbsd_sigaction *,
+ struct sigaction *));
+
+static void openbsd_to_netbsd_sigaction __P((struct sigaction *,
+ struct netbsd_sigaction *));
+
+static void netbsd_to_openbsd_sigaltstack __P((struct netbsd_sigaltstack *,
+ struct sigaltstack *));
+
+static void openbsd_to_netbsd_sigaltstack __P((struct sigaltstack *,
+ struct netbsd_sigaltstack *));
+
+static void
+openbsd_to_netbsd_sigaction(obsa, nbsa)
+ struct sigaction *obsa;
+ struct netbsd_sigaction *nbsa;
+{
+ memset(nbsa, 0, sizeof(nbsa));
+ nbsa->netbsd_sa_handler = obsa->sa_handler;
+ memcpy(&nbsa->netbsd_sa_mask.__bits[0], &obsa->sa_mask,
+ sizeof(sigset_t));
+ nbsa->netbsd_sa_flags = obsa->sa_flags;
+}
+
+static void
+netbsd_to_openbsd_sigaction(nbsa, obsa)
+ struct netbsd_sigaction *nbsa;
+ struct sigaction *obsa;
+{
+ memset(nbsa, 0, sizeof(obsa));
+ obsa->sa_handler = nbsa->netbsd_sa_handler;
+ memcpy(&obsa->sa_mask, &nbsa->netbsd_sa_mask.__bits[0],
+ sizeof(sigset_t));
+ obsa->sa_flags = nbsa->netbsd_sa_flags;
+}
+
+static void
+netbsd_to_openbsd_sigaltstack(nbss, obss)
+ struct netbsd_sigaltstack *nbss;
+ struct sigaltstack *obss;
+{
+ memset(&obss, 0, sizeof(struct sigaltstack));
+ obss->ss_sp = nbss->netbsd_ss_sp;
+ obss->ss_size = nbss->netbsd_ss_size; /* XXX may cause truncation */
+ obss->ss_flags = nbss->netbsd_ss_flags;
+}
+
+static void
+openbsd_to_netbsd_sigaltstack(obss, nbss)
+ struct sigaltstack *obss;
+ struct netbsd_sigaltstack *nbss;
+{
+ memset(&nbss, 0, sizeof(netbsd_stack_t));
+ nbss->netbsd_ss_sp = obss->ss_sp;
+ nbss->netbsd_ss_size = obss->ss_size;
+ nbss->netbsd_ss_flags = obss->ss_flags;
+}
+
+
+/* ARGSUSED */
+int
+netbsd_sys___sigaction14(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct netbsd_sys___sigaction14_args /* {
+ syscallarg(int) signum;
+ syscallarg(struct netbsd_sigaction *) nsa;
+ syscallarg(struct netbsd_sigaction *) osa;
+ } */ *uap = v;
+ struct sigaction vec;
+ register struct sigaction *sa;
+ struct netbsd_sigaction *nbsa;
+ register struct sigacts *ps = p->p_sigacts;
+ register int signum;
+ int bit, error;
+
+ signum = SCARG(uap, signum);
+ if (signum <= 0 || signum >= NSIG ||
+ (SCARG(uap, nsa) && (signum == SIGKILL || signum == SIGSTOP)))
+ return (EINVAL);
+ sa = &vec;
+ if (SCARG(uap, osa)) {
+ sa->sa_handler = ps->ps_sigact[signum];
+ sa->sa_mask = ps->ps_catchmask[signum];
+ bit = sigmask(signum);
+ sa->sa_flags = 0;
+ if ((ps->ps_sigonstack & bit) != 0)
+ sa->sa_flags |= SA_ONSTACK;
+ if ((ps->ps_sigintr & bit) == 0)
+ sa->sa_flags |= SA_RESTART;
+ if ((ps->ps_sigreset & bit) != 0)
+ sa->sa_flags |= SA_RESETHAND;
+ if ((ps->ps_siginfo & bit) != 0)
+ sa->sa_flags |= SA_SIGINFO;
+ if (signum == SIGCHLD) {
+ if ((p->p_flag & P_NOCLDSTOP) != 0)
+ sa->sa_flags |= SA_NOCLDSTOP;
+ if ((p->p_flag & P_NOCLDWAIT) != 0)
+ sa->sa_flags |= SA_NOCLDWAIT;
+ }
+ if ((sa->sa_mask & bit) == 0)
+ sa->sa_flags |= SA_NODEFER;
+ sa->sa_mask &= ~bit;
+ openbsd_to_netbsd_sigaction(sa, nbsa);
+ error = copyout((caddr_t)nbsa, (caddr_t)SCARG(uap, osa),
+ sizeof (struct netbsd_sigaction));
+ if (error)
+ return (error);
+ }
+ if (SCARG(uap, nsa)) {
+ error = copyin((caddr_t)SCARG(uap, nsa), (caddr_t)nbsa,
+ sizeof (struct netbsd_sigaction));
+ if (error)
+ return (error);
+ netbsd_to_openbsd_sigaction(nbsa, sa);
+ setsigvec(p, signum, sa);
+ }
+ return (0);
+}
+
+/* ARGSUSED */
+int
+netbsd_sys___sigaltstack14(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct netbsd_sys___sigaltstack14_args /* {
+ syscallarg(struct netbsd_sigaltstack *) nss;
+ syscallarg(struct netbsd_sigaltstack *) oss;
+ } */ *uap = v;
+ struct sigacts *psp;
+ struct sigaltstack ss;
+ struct netbsd_sigaltstack nbss;
+ int error;
+
+ psp = p->p_sigacts;
+ if ((psp->ps_flags & SAS_ALTSTACK) == 0)
+ psp->ps_sigstk.ss_flags |= SS_DISABLE;
+ if (SCARG(uap, oss)) {
+ openbsd_to_netbsd_sigaltstack(&psp->ps_sigstk, &nbss);
+ if ((error = copyout((caddr_t)&nbss, (caddr_t)SCARG(uap, oss),
+ sizeof (struct netbsd_sigaltstack))))
+ return (error);
+ }
+ if (SCARG(uap, nss) == 0)
+ return (0);
+ error = copyin((caddr_t)SCARG(uap, nss), (caddr_t)&nbss, sizeof(nbss));
+ if (error)
+ return (error);
+ netbsd_to_openbsd_sigaltstack(&nbss, &ss);
+ if (ss.ss_flags & SS_DISABLE) {
+ if (psp->ps_sigstk.ss_flags & SS_ONSTACK)
+ return (EINVAL);
+ psp->ps_flags &= ~SAS_ALTSTACK;
+ psp->ps_sigstk.ss_flags = ss.ss_flags;
+ return (0);
+ }
+ if (ss.ss_size < MINSIGSTKSZ)
+ return (ENOMEM);
+ psp->ps_flags |= SAS_ALTSTACK;
+ psp->ps_sigstk= ss;
+ return (0);
+}
+
+/* ARGSUSED */
+int
+netbsd_sys___sigpending14(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct netbsd_sys___sigpending14_args /* {
+ netbsd_sigset_t *set;
+ } */ *uap = v;
+ netbsd_sigset_t nss;
+
+ memcpy(&nss.__bits[0], &p->p_siglist, sizeof(sigset_t));
+ return (copyout((caddr_t)&nss, (caddr_t)SCARG(uap, set), sizeof(nss)));
+}
diff --git a/sys/compat/netbsd/netbsd_signal.h b/sys/compat/netbsd/netbsd_signal.h
new file mode 100644
index 00000000000..5c57e8696c4
--- /dev/null
+++ b/sys/compat/netbsd/netbsd_signal.h
@@ -0,0 +1,67 @@
+/* $OpenBSD: netbsd_signal.h,v 1.1 1999/09/14 01:05:25 kstailey Exp $ */
+/* $NetBSD: signal.h,v 1.42 1998/12/21 10:35:00 drochner Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * @(#)signal.h 8.4 (Berkeley) 5/4/95
+ */
+
+#ifndef _NETBSD_SYS_SIGNAL_H_
+#define _NETBSD_SYS_SIGNAL_H_
+
+
+typedef struct {
+ u_int32_t __bits[4];
+} netbsd_sigset_t;
+
+/*
+ * Signal vector "template" used in sigaction call.
+ */
+struct netbsd_sigaction {
+ void (*netbsd_sa_handler) __P((int));/* signal handler */
+ netbsd_sigset_t netbsd_sa_mask; /* signal mask to apply */
+ int netbsd_sa_flags; /* see signal options below */
+};
+
+typedef struct netbsd_sigaltstack {
+ void *netbsd_ss_sp; /* signal stack base */
+ size_t netbsd_ss_size; /* signal stack length */
+ int netbsd_ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
+} netbsd_stack_t;
+
+#endif /* !_NETBSD_SYS_SIGNAL_H_ */
diff --git a/sys/compat/netbsd/netbsd_stat.c b/sys/compat/netbsd/netbsd_stat.c
index eb97d3e6bf1..05d799f8cfe 100644
--- a/sys/compat/netbsd/netbsd_stat.c
+++ b/sys/compat/netbsd/netbsd_stat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netbsd_stat.c,v 1.1 1999/09/12 14:15:16 kstailey Exp $ */
+/* $OpenBSD: netbsd_stat.c,v 1.2 1999/09/14 01:05:25 kstailey Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -50,6 +50,7 @@
#include <sys/vnode.h>
#include <compat/netbsd/netbsd_types.h>
#include <compat/netbsd/netbsd_stat.h>
+#include <compat/netbsd/netbsd_signal.h>
#include <compat/netbsd/netbsd_syscallargs.h>
static void openbsd_to_netbsd_stat __P((struct stat *, struct netbsd_stat *));
diff --git a/sys/compat/netbsd/syscalls.master b/sys/compat/netbsd/syscalls.master
index bf3daed5ee0..93c6685c5f6 100644
--- a/sys/compat/netbsd/syscalls.master
+++ b/sys/compat/netbsd/syscalls.master
@@ -1,4 +1,4 @@
-; $OpenBSD: syscalls.master,v 1.2 1999/09/12 14:34:18 kstailey Exp $
+; $OpenBSD: syscalls.master,v 1.3 1999/09/14 01:05:25 kstailey Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@@ -42,6 +42,7 @@
#include <compat/netbsd/netbsd_types.h>
#include <compat/netbsd/netbsd_stat.h>
+#include <compat/netbsd/netbsd_signal.h>
#include <compat/netbsd/netbsd_syscallargs.h>
#include <machine/netbsd_machdep.h>
@@ -534,20 +535,23 @@
268 UNIMPL
269 UNIMPL
270 UNIMPL
-;270 STD { int sys___posix_rename(const char *from, \
+;270 STD { int netbsd_sys___posix_rename(const char *from, \
; const char *to); }
271 UNIMPL
-;271 STD { int sys_swapctl(int cmd, const void *arg, int misc); }
+;271 STD { int netbsd_sys_swapctl(int cmd, const void *arg,
+; int misc); }
272 UNIMPL
-;272 STD { int sys_getdents(int fd, char *buf, size_t count); }
+;272 STD { int netbsd_sys_getdents(int fd, char *buf, \
+; size_t count); }
273 NOARGS { int sys_minherit(void *addr, size_t len, \
int inherit); }
274 UNIMPL
-;274 STD { int sys_lchmod(const char *path, mode_t mode); }
+;274 STD { int netbsd_sys_lchmod(const char *path, \
+; mode_t mode); }
275 NOARGS { int sys_lchown(const char *path, uid_t uid, \
gid_t gid); }
276 UNIMPL
-;276 STD { int sys_lutimes(const char *path, \
+;276 STD { int netbsd_sys_lutimes(const char *path, \
; const struct timeval *tptr); }
277 NOARGS { int sys_msync(void *addr, size_t len, int flags); }
278 STD { int netbsd_sys___stat13(const char *path, \
@@ -556,52 +560,50 @@
struct netbsd_stat *ub); }
280 STD { int netbsd_sys___lstat13(const char *path, \
struct netbsd_stat *ub); }
-281 UNIMPL
-;281 STD { int sys___sigaltstack14( \
-; const struct sigaltstack *nss, \
-; struct sigaltstack *oss); }
+281 STD { int netbsd_sys___sigaltstack14( \
+ const struct netbsd_sigaltstack *nss, \
+ struct netbsd_sigaltstack *oss); }
282 UNIMPL
-;282 STD { int sys___vfork14(void); }
+;282 STD { int netbsd_sys___vfork14(void); }
283 UNIMPL
-;283 STD { int sys___posix_chown(const char *path, uid_t uid, \
-; gid_t gid); }
+;283 STD { int netbsd_sys___posix_chown(const char *path, \
+; uid_t uid, gid_t gid); }
284 UNIMPL
-;284 STD { int sys___posix_fchown(int fd, uid_t uid, \
+;284 STD { int netbsd_sys___posix_fchown(int fd, uid_t uid, \
; gid_t gid); }
285 UNIMPL
-;285 STD { int sys___posix_lchown(const char *path, uid_t uid, \
-; gid_t gid); }
+;285 STD { int netbsd_sys___posix_lchown(const char *path, \
+; uid_t uid, gid_t gid); }
286 NOARGS { int sys_getsid(pid_t pid); }
287 UNIMPL
#ifdef KTRACE
288 UNIMPL
-;288 STD { int sys_fktrace(const int fd, int ops, \
+;288 STD { int netbsd_sys_fktrace(const int fd, int ops, \
; int facs, int pid); }
#else
288 UNIMPL
#endif
289 UNIMPL
-;289 STD { ssize_t sys_preadv(int fd, \
+;289 STD { ssize_t netbsd_sys_preadv(int fd, \
; const struct iovec *iovp, int iovcnt, \
; int pad, off_t offset); }
290 UNIMPL
-;290 STD { ssize_t sys_pwritev(int fd, \
+;290 STD { ssize_t netbsd_sys_pwritev(int fd, \
; const struct iovec *iovp, int iovcnt, \
; int pad, off_t offset); }
-291 UNIMPL
-;291 STD { int netbsd_sys___sigaction14(int signum, \
-; const struct sigaction *nsa, \
-; struct sigaction *osa); }
-292 UNIMPL
-;292 STD { int sys___sigpending14(sigset_t *set); }
+291 STD { int netbsd_sys___sigaction14(int signum, \
+ const struct netbsd_sigaction *nsa, \
+ struct netbsd_sigaction *osa); }
+292 STD { int netbsd_sys___sigpending14(netbsd_sigset_t \
+ *set); }
293 UNIMPL
-;293 STD { int sys___sigprocmask14(int how, \
+;293 STD { int netbsd_sys___sigprocmask14(int how, \
; const sigset_t *set, \
; sigset_t *oset); }
294 UNIMPL
-;294 STD { int sys___sigsuspend14(const sigset_t *set); }
-295 UNIMPL
-;295 STD { int sys___sigreturn14(struct sigcontext *sigcntxp); }
+;294 STD { int netbsd_sys___sigsuspend14(const sigset_t *set); }
+295 STD { int netbsd_sys___sigreturn14(struct \
+ netbsd_sigcontext *sigcntxp); }
296 STD { int netbsd_sys___getcwd(char *bufp, size_t length); }
297 UNIMPL
-;297 STD { int sys_fchroot(int fd); }
+;297 STD { int netbsd_sys_fchroot(int fd); }