From 388b97e039d4bdde9b68e9a61aab1f036df461f4 Mon Sep 17 00:00:00 2001 From: cube Date: Sun, 23 Oct 2005 00:09:14 +0000 Subject: [PATCH] Implement a few changes needed to properly resolve PR#30924, as discussed in the PR. - introduce sys/timevar.h to hold kernel-specific stuff relevant to sys/time.h. Ideally, timevar.h would contain all (or almost) of the #ifdef _KERNEL part of time.h, but that's a pretty big and tedious change to make. For now, it will contain only the prototypes I introduced when working on COMPAT_NETBSD32. - split copyinout_t into copyin_t and copyout_t, it makes prototypes more explicit about the meaning of a given argument. Suggested by yamt@. - move copyinout_t definition in sys/time.h to systm.h as copyin_t and copyout_t - make everything uses the new types and include the proper headers at the proper places. --- sys/compat/netbsd32/netbsd32_time.c | 5 +-- sys/kern/kern_sig.c | 6 ++-- sys/kern/kern_time.c | 7 ++-- sys/sys/signalvar.h | 7 ++-- sys/sys/systm.h | 7 +++- sys/sys/time.h | 20 +---------- sys/sys/timevar.h | 53 +++++++++++++++++++++++++++++ 7 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 sys/sys/timevar.h diff --git a/sys/compat/netbsd32/netbsd32_time.c b/sys/compat/netbsd32/netbsd32_time.c index 3556ecda556c..9686ffa5f7a4 100644 --- a/sys/compat/netbsd32/netbsd32_time.c +++ b/sys/compat/netbsd32/netbsd32_time.c @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_time.c,v 1.12 2005/08/19 04:24:38 christos Exp $ */ +/* $NetBSD: netbsd32_time.c,v 1.13 2005/10/23 00:09:14 cube Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.12 2005/08/19 04:24:38 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.13 2005/10/23 00:09:14 cube Exp $"); #if defined(_KERNEL_OPT) #include "opt_ntp.h" @@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.12 2005/08/19 04:24:38 christos #include #include #include +#include #include #include #include diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index edf92f707a06..5b266dfe6014 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig.c,v 1.209 2005/10/02 17:51:27 chs Exp $ */ +/* $NetBSD: kern_sig.c,v 1.210 2005/10/23 00:09:14 cube Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.209 2005/10/02 17:51:27 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.210 2005/10/23 00:09:14 cube Exp $"); #include "opt_ktrace.h" #include "opt_compat_sunos.h" @@ -2349,7 +2349,7 @@ sys___sigtimedwait(struct lwp *l, void *v, register_t *retval) int __sigtimedwait1(struct lwp *l, void *v, register_t *retval, - copyinout_t put_info, copyinout_t fetch_timeout, copyinout_t put_timeout) + copyout_t put_info, copyin_t fetch_timeout, copyout_t put_timeout) { struct sys___sigtimedwait_args /* { syscallarg(const sigset_t *) set; diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index c1b866283e70..05aec127b09f 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.94 2005/10/02 17:51:27 chs Exp $ */ +/* $NetBSD: kern_time.c,v 1.95 2005/10/23 00:09:14 cube Exp $ */ /*- * Copyright (c) 2000, 2004, 2005 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.94 2005/10/02 17:51:27 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.95 2005/10/23 00:09:14 cube Exp $"); #include "fs_nfs.h" #include "opt_nfs.h" @@ -85,6 +85,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.94 2005/10/02 17:51:27 chs Exp $"); #include #include #include +#include #include #include @@ -510,7 +511,7 @@ sys_timer_create(struct lwp *l, void *v, register_t *retval) int timer_create1(timer_t *tid, clockid_t id, struct sigevent *evp, - copyinout_t fetch_event, struct proc *p) + copyin_t fetch_event, struct proc *p) { int error; timer_t timerid; diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index 1a96d4a0c839..cf4b3ec155ee 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: signalvar.h,v 1.59 2005/10/02 17:51:27 chs Exp $ */ +/* $NetBSD: signalvar.h,v 1.60 2005/10/23 00:09:14 cube Exp $ */ /* * Copyright (c) 1991, 1993 @@ -37,6 +37,7 @@ #include #include #include +#include /* * Kernel signal definitions and data structures, @@ -180,8 +181,8 @@ void kpsendsig(struct lwp *, const struct ksiginfo *, const sigset_t *); siginfo_t *siginfo_alloc(int); void siginfo_free(void *); -int __sigtimedwait1(struct lwp *, void *, register_t *, copyinout_t, - copyinout_t, copyinout_t); +int __sigtimedwait1(struct lwp *, void *, register_t *, copyout_t, + copyin_t, copyout_t); /* * Machine-dependent functions: diff --git a/sys/sys/systm.h b/sys/sys/systm.h index b010d66de7cf..dcd17bc5363a 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $NetBSD: systm.h,v 1.180 2005/08/28 20:58:14 reinoud Exp $ */ +/* $NetBSD: systm.h,v 1.181 2005/10/23 00:09:14 cube Exp $ */ /*- * Copyright (c) 1982, 1988, 1991, 1993 @@ -240,6 +240,11 @@ int copyoutstr(const void *, void *, size_t, size_t *); int copyin(const void *, void *, size_t); int copyout(const void *, void *, size_t); +#ifdef _KERNEL +typedef int (*copyin_t)(const void *, void *, size_t); +typedef int (*copyout_t)(const void *, void *, size_t); +#endif + int copyin_proc(struct proc *, const void *, void *, size_t); int copyout_proc(struct proc *, const void *, void *, size_t); diff --git a/sys/sys/time.h b/sys/sys/time.h index d552fad996f3..fa6daa3f0d70 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -1,4 +1,4 @@ -/* $NetBSD: time.h,v 1.50 2005/09/12 16:21:31 christos Exp $ */ +/* $NetBSD: time.h,v 1.51 2005/10/23 00:09:14 cube Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -227,24 +227,6 @@ void timers_alloc(struct proc *); void timers_free(struct proc *, int); void realtimerexpire(void *); -int dogetitimer(struct proc *, int, struct itimerval *); -int dosetitimer(struct proc *, int, struct itimerval *); - -/* - * XXX-cube - * - * This definition really should be in systm.h, but systm.h cannot be - * included before time.h, otherwise it breaks kern/kern_clock.c - * because "clockframe" gets redefined by cpu.h (at least on i386 and - * amd64). - */ -typedef int (*copyinout_t)(const void *, void *, size_t); - -int timer_create1(timer_t *, clockid_t, struct sigevent *, - copyinout_t, struct proc *); -int dotimer_settime(int, struct itimerspec *, struct itimerspec *, int, - struct proc *); -int dotimer_gettime(int, struct proc *, struct itimerspec *); #else /* !_KERNEL */ #ifndef _STANDALONE diff --git a/sys/sys/timevar.h b/sys/sys/timevar.h new file mode 100644 index 000000000000..6821a89d1a80 --- /dev/null +++ b/sys/sys/timevar.h @@ -0,0 +1,53 @@ +/* $NetBSD: timevar.h,v 1.1 2005/10/23 00:09:14 cube Exp $ */ + +/* + * Copyright (c) 2005 The NetBSD Foundation. + * All rights reserved. + * + * This code is derived from software contributed to the NetBSD Foundation + * by Quentin Garnier. + * + * 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. + */ + +#ifndef _SYS_TIMEVAR_H_ +#define _SYS_TIMEVAR_H_ + +#include + +int dogetitimer(struct proc *, int, struct itimerval *); +int dosetitimer(struct proc *, int, struct itimerval *); + +int timer_create1(timer_t *, clockid_t, struct sigevent *, copyin_t, + struct proc *); +int dotimer_settime(int, struct itimerspec *, struct itimerspec *, int, + struct proc *); +int dotimer_gettime(int, struct proc *, struct itimerspec *); + +#endif