diff --git a/include/signal.h b/include/signal.h index 44baa4c60087..a7b34dfc650f 100644 --- a/include/signal.h +++ b/include/signal.h @@ -1,4 +1,4 @@ -/* $NetBSD: signal.h,v 1.10 1997/11/26 16:51:13 kleink Exp $ */ +/* $NetBSD: signal.h,v 1.11 1997/11/29 18:38:20 kleink Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -111,9 +111,14 @@ int sigpause __P((int)); int sigreturn __P((struct sigcontext *)); int sigsetmask __P((int)); int sigstack __P((const struct sigstack *, struct sigstack *)); -int sigaltstack __P((const stack_t *, stack_t *)); int sigvec __P((int, struct sigvec *, struct sigvec *)); void psignal __P((unsigned int, const char *)); +#ifdef __LIBC12_SOURCE__ +int sigaltstack __P((const struct sigaltstack13 *, struct sigaltstack13 *)); +int __sigaltstack14 __P((const stack_t *, stack_t *)); +#else +int sigaltstack __P((const stack_t *, stack_t *)) __RENAME(__sigaltstack14); +#endif #endif /* !_POSIX_SOURCE */ #endif /* !_ANSI_SOURCE */ __END_DECLS diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version index f4dee59392ed..2c23cff213f1 100644 --- a/lib/libc/shlib_version +++ b/lib/libc/shlib_version @@ -1,4 +1,4 @@ -# $NetBSD: shlib_version,v 1.45 1997/11/02 16:59:40 kleink Exp $ +# $NetBSD: shlib_version,v 1.46 1997/11/29 18:38:22 kleink Exp $ # major=12 -minor=21 +minor=22 diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 2022bfa32e01..0a46069821bf 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.76 1997/11/06 22:34:01 cgd Exp $ +# $NetBSD: Makefile.inc,v 1.77 1997/11/29 18:38:23 kleink Exp $ # @(#)Makefile.inc 8.1 (Berkeley) 6/17/93 # sys sources @@ -20,8 +20,8 @@ DPSRCS+= Lint_Ovfork.c Lint_brk.c Lint_exect.c Lint_fork.c Lint_pipe.c \ # glue to provide compatibility between GCC 1.X and 2.X and for compat # with old syscall interfaces. -SRCS+= ftruncate.c lseek.c mmap.c semctl.c truncate.c stat.c msync.c swapon.c \ - getdirentries.c +SRCS+= ftruncate.c getdirentries.c lseek.c mmap.c msync.c semctl.c \ + sigaltstack.c stat.c swapon.c truncate.c # "stub" POSIX.1b interfaces which return -1 and set errno to ENOSYS, so # we can avoid bumping libc's minor number as functions are added to the @@ -55,7 +55,7 @@ ASM= accept.o access.o acct.o adjtime.o bind.o chdir.o chflags.o chmod.o \ setpriority.o setregid.o setreuid.o \ setrlimit.o setsid.o setsockopt.o settimeofday.o \ setuid.o shmat.o shmctl.o shmdt.o shmget.o shutdown.o sigaction.o \ - sigaltstack.o socket.o socketpair.o __stat13.o statfs.o swapctl.o \ + __sigaltstack14.o socket.o socketpair.o __stat13.o statfs.o swapctl.o \ symlink.o sysarch.o umask.o undelete.o unlink.o unmount.o \ utimes.o vadvise.o wait4.o write.o writev.o __semctl.o __syscall.o \ __sysctl.o diff --git a/lib/libc/sys/sigaltstack.c b/lib/libc/sys/sigaltstack.c new file mode 100644 index 000000000000..bfa2f5772555 --- /dev/null +++ b/lib/libc/sys/sigaltstack.c @@ -0,0 +1,69 @@ +/* $NetBSD: sigaltstack.c,v 1.1 1997/11/29 18:38:23 kleink Exp $ */ + +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Klaus Klein. + * + * 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 NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 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. + */ + +#define __LIBC12_SOURCE__ + +#include +#include +#include + +int +sigaltstack(onss, ooss) + const struct sigaltstack13 *onss; + struct sigaltstack13 *ooss; +{ + stack_t nss, oss; + int error; + + nss.ss_sp = onss->ss_sp; + nss.ss_size = onss->ss_size; + nss.ss_flags = onss->ss_flags; + + error = __sigaltstack14(&nss, &oss); + + if (error == 0 && ooss != NULL) { + ooss->ss_sp = oss.ss_sp; + if (oss.ss_size > INT_MAX) + ooss->ss_size = INT_MAX; + else + ooss->ss_size = oss.ss_size; + ooss->ss_flags = oss.ss_flags; + } + + return (error); +} diff --git a/sys/compat/common/kern_sig_13.c b/sys/compat/common/kern_sig_13.c index fac9317b3a01..fff733a4a0e6 100644 --- a/sys/compat/common/kern_sig_13.c +++ b/sys/compat/common/kern_sig_13.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig_13.c,v 1.1 1997/11/25 19:32:17 kleink Exp $ */ +/* $NetBSD: kern_sig_13.c,v 1.2 1997/11/29 18:39:46 kleink Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -36,7 +36,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include @@ -45,6 +44,8 @@ #include #include +#include + #include @@ -54,7 +55,7 @@ compat_13_sys_sigaltstack(p, v, retval) void *v; register_t *retval; { - struct sys_sigaltstack_args ua; + struct sys___sigaltstack14_args ua; struct compat_13_sys_sigaltstack_args /* { syscallarg(const struct sigaltstack13 *) nss; syscallarg(struct sigaltstack13 *) oss; @@ -92,7 +93,7 @@ compat_13_sys_sigaltstack(p, v, retval) SCARG(&ua, nss) = nssp; SCARG(&ua, oss) = ossp; - error = sys_sigaltstack(p, &ua, retval); + error = sys___sigaltstack14(p, &ua, retval); if (error != 0) return (error); @@ -103,7 +104,10 @@ compat_13_sys_sigaltstack(p, v, retval) return (error); tmp13.ss_sp = tmp.ss_sp; - tmp13.ss_size = (int)tmp.ss_size; + if (tmp.ss_size > INT_MAX) + tmp13.ss_size = INT_MAX; + else + tmp13.ss_size = tmp.ss_size; tmp13.ss_flags = tmp.ss_flags; error = copyout(&tmp13, SCARG(uap, oss), diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 708904d1a62d..1c36a595c23c 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig.c,v 1.67 1997/10/16 02:45:39 mycroft Exp $ */ +/* $NetBSD: kern_sig.c,v 1.68 1997/11/29 18:38:24 kleink Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -345,12 +345,12 @@ sys_sigsuspend(p, v, retval) /* ARGSUSED */ int -sys_sigaltstack(p, v, retval) +sys___sigaltstack14(p, v, retval) struct proc *p; void *v; register_t *retval; { - register struct sys_sigaltstack_args /* { + register struct sys___sigaltstack14_args /* { syscallarg(const struct sigaltstack *) nss; syscallarg(struct sigaltstack *) oss; } */ *uap = v; diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 59588967e188..c7a83847aa50 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.65 1997/11/25 19:32:20 kleink Exp $ + $NetBSD: syscalls.master,v 1.66 1997/11/29 18:38:26 kleink Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -516,5 +516,5 @@ 278 STD { int sys___stat13(const char *path, struct stat *ub); } 279 STD { int sys___fstat13(int fd, struct stat *sb); } 280 STD { int sys___lstat13(const char *path, struct stat *ub); } -281 STD { int sys_sigaltstack(const struct sigaltstack *nss, \ - struct sigaltstack *oss); } +281 STD { int sys___sigaltstack14(const struct sigaltstack \ + *nss, struct sigaltstack *oss); } diff --git a/sys/sys/signal.h b/sys/sys/signal.h index 3c72e4ce4341..33aa8c998b02 100644 --- a/sys/sys/signal.h +++ b/sys/sys/signal.h @@ -1,4 +1,4 @@ -/* $NetBSD: signal.h,v 1.24 1997/11/25 19:32:22 kleink Exp $ */ +/* $NetBSD: signal.h,v 1.25 1997/11/29 18:38:27 kleink Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -140,13 +140,11 @@ typedef void (*sig_t) __P((int)); /* type of signal function */ /* * Structure used in sigaltstack call. */ -#ifdef _KERNEL struct sigaltstack13 { char *ss_sp; /* signal stack base */ int ss_size; /* signal stack length */ int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */ }; -#endif typedef struct #ifndef _XOPEN_SOURCE