Module Name: src Committed By: christos Date: Tue Oct 2 01:44:29 UTC 2012
Modified Files: src/sys/compat/common: kern_time_50.c src/sys/compat/ibcs2: ibcs2_misc.c src/sys/compat/linux/common: linux_time.c src/sys/compat/linux32/common: linux32_time.c src/sys/compat/netbsd32: netbsd32_compat_50.c netbsd32_time.c syscalls.master src/sys/kern: kern_time.c syscalls.master src/sys/sys: param.h timevar.h Log Message: kernel portion of clock_nanosleep() To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/compat/common/kern_time_50.c cvs rdiff -u -r1.111 -r1.112 src/sys/compat/ibcs2/ibcs2_misc.c cvs rdiff -u -r1.35 -r1.36 src/sys/compat/linux/common/linux_time.c cvs rdiff -u -r1.36 -r1.37 src/sys/compat/linux32/common/linux32_time.c cvs rdiff -u -r1.20 -r1.21 src/sys/compat/netbsd32/netbsd32_compat_50.c cvs rdiff -u -r1.41 -r1.42 src/sys/compat/netbsd32/netbsd32_time.c cvs rdiff -u -r1.95 -r1.96 src/sys/compat/netbsd32/syscalls.master cvs rdiff -u -r1.174 -r1.175 src/sys/kern/kern_time.c cvs rdiff -u -r1.260 -r1.261 src/sys/kern/syscalls.master cvs rdiff -u -r1.419 -r1.420 src/sys/sys/param.h cvs rdiff -u -r1.31 -r1.32 src/sys/sys/timevar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/common/kern_time_50.c diff -u src/sys/compat/common/kern_time_50.c:1.22 src/sys/compat/common/kern_time_50.c:1.23 --- src/sys/compat/common/kern_time_50.c:1.22 Wed Jan 4 09:31:17 2012 +++ src/sys/compat/common/kern_time_50.c Mon Oct 1 21:44:27 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time_50.c,v 1.22 2012/01/04 14:31:17 apb Exp $ */ +/* $NetBSD: kern_time_50.c,v 1.23 2012/10/02 01:44:27 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_time_50.c,v 1.22 2012/01/04 14:31:17 apb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time_50.c,v 1.23 2012/10/02 01:44:27 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_aio.h" @@ -152,7 +152,8 @@ compat_50_sys_nanosleep(struct lwp *l, return error; timespec50_to_timespec(&rqt50, &rqt); - error = nanosleep1(l, &rqt, SCARG(uap, rmtp) ? &rmt : NULL); + error = nanosleep1(l, CLOCK_MONOTONIC, 0, &rqt, + SCARG(uap, rmtp) ? &rmt : NULL); if (SCARG(uap, rmtp) == NULL || (error != 0 && error != EINTR)) return error; Index: src/sys/compat/ibcs2/ibcs2_misc.c diff -u src/sys/compat/ibcs2/ibcs2_misc.c:1.111 src/sys/compat/ibcs2/ibcs2_misc.c:1.112 --- src/sys/compat/ibcs2/ibcs2_misc.c:1.111 Thu Jun 24 09:03:06 2010 +++ src/sys/compat/ibcs2/ibcs2_misc.c Mon Oct 1 21:44:27 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ibcs2_misc.c,v 1.111 2010/06/24 13:03:06 hannken Exp $ */ +/* $NetBSD: ibcs2_misc.c,v 1.112 2012/10/02 01:44:27 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -95,7 +95,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.111 2010/06/24 13:03:06 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.112 2012/10/02 01:44:27 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1254,7 +1254,7 @@ xenix_sys_nap(struct lwp *l, const struc rqt.tv_sec = 0; rqt.tv_nsec = SCARG(uap, millisec) * 1000; - error = nanosleep1(l, &rqt, &rmt); + error = nanosleep1(l, CLOCK_MONOTONIC, 0, &rqt, &rmt); /* If interrupted we can either report EINTR, or the time left */ if (error != 0 && error != EINTR) return error; Index: src/sys/compat/linux/common/linux_time.c diff -u src/sys/compat/linux/common/linux_time.c:1.35 src/sys/compat/linux/common/linux_time.c:1.36 --- src/sys/compat/linux/common/linux_time.c:1.35 Thu Nov 17 23:07:44 2011 +++ src/sys/compat/linux/common/linux_time.c Mon Oct 1 21:44:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_time.c,v 1.35 2011/11/18 04:07:44 christos Exp $ */ +/* $NetBSD: linux_time.c,v 1.36 2012/10/02 01:44:28 christos Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.35 2011/11/18 04:07:44 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.36 2012/10/02 01:44:28 christos Exp $"); #include <sys/param.h> #include <sys/ucred.h> @@ -155,7 +155,8 @@ linux_sys_nanosleep(struct lwp *l, const return error; linux_to_native_timespec(&rqts, &lrqts); - error = nanosleep1(l, &rqts, SCARG(uap, rmtp) ? &rmts : NULL); + error = nanosleep1(l, CLOCK_MONOTONIC, 0, &rqts, + SCARG(uap, rmtp) ? &rmts : NULL); if (SCARG(uap, rmtp) == NULL || (error != 0 && error != EINTR)) return error; @@ -269,11 +270,10 @@ linux_sys_clock_nanosleep(struct lwp *l, } */ struct linux_timespec lrqts, lrmts; struct timespec rqts, rmts; - int error, error1; + int error, error1, flags; clockid_t nwhich; - if (SCARG(uap, flags) != 0) - return EINVAL; /* XXX deal with TIMER_ABSTIME */ + flags = SCARG(uap, flags) != 0 ? TIMER_ABSTIME : 0; error = linux_to_native_clockid(&nwhich, SCARG(uap, which)); if (error != 0) @@ -285,7 +285,8 @@ linux_sys_clock_nanosleep(struct lwp *l, linux_to_native_timespec(&rqts, &lrqts); - error = nanosleep1(l, &rqts, SCARG(uap, rmtp) ? &rmts : NULL); + error = nanosleep1(l, nwhich, flags, &rqts, + SCARG(uap, rmtp) ? &rmts : NULL); if (SCARG(uap, rmtp) == NULL || (error != 0 && error != EINTR)) return error; Index: src/sys/compat/linux32/common/linux32_time.c diff -u src/sys/compat/linux32/common/linux32_time.c:1.36 src/sys/compat/linux32/common/linux32_time.c:1.37 --- src/sys/compat/linux32/common/linux32_time.c:1.36 Thu Nov 17 23:08:56 2011 +++ src/sys/compat/linux32/common/linux32_time.c Mon Oct 1 21:44:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_time.c,v 1.36 2011/11/18 04:08:56 christos Exp $ */ +/* $NetBSD: linux32_time.c,v 1.37 2012/10/02 01:44:28 christos Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_time.c,v 1.36 2011/11/18 04:08:56 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_time.c,v 1.37 2012/10/02 01:44:28 christos Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -265,7 +265,8 @@ linux32_sys_nanosleep(struct lwp *l, return error; linux32_to_native_timespec(&rqts, &lrqts); - error = nanosleep1(l, &rqts, SCARG_P32(uap, rmtp) ? &rmts : NULL); + error = nanosleep1(l, CLOCK_MONOTONIC, 0, &rqts, + SCARG_P32(uap, rmtp) ? &rmts : NULL); if (SCARG_P32(uap, rmtp) == NULL || (error != 0 && error != EINTR)) return error; @@ -360,11 +361,10 @@ linux32_sys_clock_nanosleep(struct lwp * } */ struct linux32_timespec lrqts, lrmts; struct timespec rqts, rmts; - int error, error1; + int error, error1, flags; clockid_t id; - if (SCARG(uap, flags) != 0) - return EINVAL; /* XXX deal with TIMER_ABSTIME */ + flags = SCARG(uap, flags) != 0 ? TIMER_ABSTIME : 0; error = linux_to_native_clockid(&id, SCARG(uap, which)); if (error != 0) @@ -375,7 +375,8 @@ linux32_sys_clock_nanosleep(struct lwp * return error; linux32_to_native_timespec(&rqts, &lrqts); - error = nanosleep1(l, &rqts, SCARG_P32(uap, rmtp) ? &rmts : NULL); + error = nanosleep1(l, id, flags, &rqts, + SCARG_P32(uap, rmtp) ? &rmts : NULL); if (SCARG_P32(uap, rmtp) == NULL || (error != 0 && error != EINTR)) return error; Index: src/sys/compat/netbsd32/netbsd32_compat_50.c diff -u src/sys/compat/netbsd32/netbsd32_compat_50.c:1.20 src/sys/compat/netbsd32/netbsd32_compat_50.c:1.21 --- src/sys/compat/netbsd32/netbsd32_compat_50.c:1.20 Thu Nov 17 22:34:13 2011 +++ src/sys/compat/netbsd32/netbsd32_compat_50.c Mon Oct 1 21:44:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_compat_50.c,v 1.20 2011/11/18 03:34:13 christos Exp $ */ +/* $NetBSD: netbsd32_compat_50.c,v 1.21 2012/10/02 01:44:28 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.20 2011/11/18 03:34:13 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.21 2012/10/02 01:44:28 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_sysv.h" @@ -438,7 +438,8 @@ compat_50_netbsd32_nanosleep(struct lwp return (error); netbsd32_to_timespec50(&ts32, &rqt); - error = nanosleep1(l, &rqt, SCARG_P32(uap, rmtp) ? &rmt : NULL); + error = nanosleep1(l, CLOCK_MONOTONIC, 0, &rqt, + SCARG_P32(uap, rmtp) ? &rmt : NULL); if (SCARG_P32(uap, rmtp) == NULL || (error != 0 && error != EINTR)) return error; Index: src/sys/compat/netbsd32/netbsd32_time.c diff -u src/sys/compat/netbsd32/netbsd32_time.c:1.41 src/sys/compat/netbsd32/netbsd32_time.c:1.42 --- src/sys/compat/netbsd32/netbsd32_time.c:1.41 Thu Apr 8 07:51:14 2010 +++ src/sys/compat/netbsd32/netbsd32_time.c Mon Oct 1 21:44:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_time.c,v 1.41 2010/04/08 11:51:14 njoly Exp $ */ +/* $NetBSD: netbsd32_time.c,v 1.42 2012/10/02 01:44:28 christos Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.41 2010/04/08 11:51:14 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.42 2012/10/02 01:44:28 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ntp.h" @@ -422,12 +422,41 @@ netbsd32___nanosleep50(struct lwp *l, co return (error); netbsd32_to_timespec(&ts32, &rqt); - error = nanosleep1(l, &rqt, SCARG_P32(uap, rmtp) ? &rmt : NULL); + error = nanosleep1(l, CLOCK_MONOTONIC, 0, &rqt, + SCARG_P32(uap, rmtp) ? &rmt : NULL); if (SCARG_P32(uap, rmtp) == NULL || (error != 0 && error != EINTR)) return error; netbsd32_from_timespec(&rmt, &ts32); - error1 = copyout(&ts32, SCARG_P32(uap,rmtp), sizeof(ts32)); + error1 = copyout(&ts32, SCARG_P32(uap, rmtp), sizeof(ts32)); + return error1 ? error1 : error; +} + +int +netbsd32_clock_nanosleep(struct lwp *l, const struct netbsd32_clock_nanosleep_args *uap, register_t *retval) +{ + /* { + clockid_t clock_id; + int flags; + syscallarg(const netbsd32_timespecp_t) rqtp; + syscallarg(netbsd32_timespecp_t) rmtp; + } */ + struct netbsd32_timespec ts32; + struct timespec rqt, rmt; + int error, error1; + + error = copyin(SCARG_P32(uap, rqtp), &ts32, sizeof(ts32)); + if (error) + return (error); + netbsd32_to_timespec(&ts32, &rqt); + + error = nanosleep1(l, SCARG(uap, clock_id), SCARG(uap, flags), + &rqt, SCARG_P32(uap, rmtp) ? &rmt : NULL); + if (SCARG_P32(uap, rmtp) == NULL || (error != 0 && error != EINTR)) + return error; + + netbsd32_from_timespec(&rmt, &ts32); + error1 = copyout(&ts32, SCARG_P32(uap, rmtp), sizeof(ts32)); return error1 ? error1 : error; } Index: src/sys/compat/netbsd32/syscalls.master diff -u src/sys/compat/netbsd32/syscalls.master:1.95 src/sys/compat/netbsd32/syscalls.master:1.96 --- src/sys/compat/netbsd32/syscalls.master:1.95 Sun Apr 8 07:27:44 2012 +++ src/sys/compat/netbsd32/syscalls.master Mon Oct 1 21:44:28 2012 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.95 2012/04/08 11:27:44 martin Exp $ + $NetBSD: syscalls.master,v 1.96 2012/10/02 01:44:28 christos Exp $ ; from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -1030,3 +1030,12 @@ const netbsd32_posix_spawnattrp attrp, \ netbsd32_charpp argv, netbsd32_charpp envp); } +475 UNIMPL { int|netbsd32||recvmmsg(int s, struct mmsghdr *mmsg, \ + unsigned int vlen, unsigned int flags, \ + netbsd32_timespecp_t timeout); } +476 UNIMPL { int|netbsd32||sendmmsg(int s, struct mmsghdr *mmsg, \ + unsigned int vlen, unsigned int flags); } +477 STD { int|netbsd32||clock_nanosleep(\ + netbsd32_clockid_t clock_id, \ + int flags, const netbsd32_timespecp_t rqtp, \ + netbsd32_timespecp_t rmtp); } Index: src/sys/kern/kern_time.c diff -u src/sys/kern/kern_time.c:1.174 src/sys/kern/kern_time.c:1.175 --- src/sys/kern/kern_time.c:1.174 Thu Mar 22 13:46:07 2012 +++ src/sys/kern/kern_time.c Mon Oct 1 21:44:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.174 2012/03/22 17:46:07 dholland Exp $ */ +/* $NetBSD: kern_time.c,v 1.175 2012/10/02 01:44:28 christos Exp $ */ /*- * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.174 2012/03/22 17:46:07 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.175 2012/10/02 01:44:28 christos Exp $"); #include <sys/param.h> #include <sys/resourcevar.h> @@ -303,7 +303,35 @@ sys___nanosleep50(struct lwp *l, const s if (error) return (error); - error = nanosleep1(l, &rqt, SCARG(uap, rmtp) ? &rmt : NULL); + error = nanosleep1(l, CLOCK_MONOTONIC, 0, &rqt, + SCARG(uap, rmtp) ? &rmt : NULL); + if (SCARG(uap, rmtp) == NULL || (error != 0 && error != EINTR)) + return error; + + error1 = copyout(&rmt, SCARG(uap, rmtp), sizeof(rmt)); + return error1 ? error1 : error; +} + +/* ARGSUSED */ +int +sys_clock_nanosleep(struct lwp *l, const struct sys_clock_nanosleep_args *uap, + register_t *retval) +{ + /* { + syscallarg(clockid_t) clock_id; + syscallarg(int) flags; + syscallarg(struct timespec *) rqtp; + syscallarg(struct timespec *) rmtp; + } */ + struct timespec rmt, rqt; + int error, error1; + + error = copyin(SCARG(uap, rqtp), &rqt, sizeof(struct timespec)); + if (error) + return (error); + + error = nanosleep1(l, SCARG(uap, clock_id), SCARG(uap, flags), &rqt, + SCARG(uap, rmtp) ? &rmt : NULL); if (SCARG(uap, rmtp) == NULL || (error != 0 && error != EINTR)) return error; @@ -312,21 +340,27 @@ sys___nanosleep50(struct lwp *l, const s } int -nanosleep1(struct lwp *l, struct timespec *rqt, struct timespec *rmt) +nanosleep1(struct lwp *l, clockid_t clock_id, int flags, struct timespec *rqt, + struct timespec *rmt) { struct timespec rmtstart; int error, timo; + if ((error = clock_gettime1(clock_id, &rmtstart)) != 0) + return ENOTSUP; + + if (flags & TIMER_ABSTIME) + timespecsub(rqt, &rmtstart, rqt); + if ((error = itimespecfix(rqt)) != 0) return error; timo = tstohz(rqt); /* - * Avoid inadvertantly sleeping forever + * Avoid inadvertently sleeping forever */ if (timo == 0) timo = 1; - getnanouptime(&rmtstart); again: error = kpause("nanoslp", true, timo, NULL); if (rmt != NULL || error == 0) { @@ -334,7 +368,7 @@ again: struct timespec t0; struct timespec *t; - getnanouptime(&rmtend); + (void)clock_gettime1(clock_id, &rmtend); t = (rmt != NULL) ? rmt : &t0; timespecsub(&rmtend, &rmtstart, t); timespecsub(rqt, t, t); Index: src/sys/kern/syscalls.master diff -u src/sys/kern/syscalls.master:1.260 src/sys/kern/syscalls.master:1.261 --- src/sys/kern/syscalls.master:1.260 Fri Jun 22 14:26:35 2012 +++ src/sys/kern/syscalls.master Mon Oct 1 21:44:28 2012 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.260 2012/06/22 18:26:35 christos Exp $ + $NetBSD: syscalls.master,v 1.261 2012/10/02 01:44:28 christos Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -938,3 +938,6 @@ struct timespec *timeout); } 476 STD { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, \ unsigned int vlen, unsigned int flags); } +477 STD { int|sys||clock_nanosleep(clockid_t clock_id, \ + int flags, const struct timespec *rqtp, \ + struct timespec *rmtp); } Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.419 src/sys/sys/param.h:1.420 --- src/sys/sys/param.h:1.419 Fri Aug 31 20:27:12 2012 +++ src/sys/sys/param.h Mon Oct 1 21:44:29 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.419 2012/09/01 00:27:12 matt Exp $ */ +/* $NetBSD: param.h,v 1.420 2012/10/02 01:44:29 christos Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -63,7 +63,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 699001100 /* NetBSD 6.99.11 */ +#define __NetBSD_Version__ 699001200 /* NetBSD 6.99.12 */ #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \ (m) * 1000000) + (p) * 100) <= __NetBSD_Version__) Index: src/sys/sys/timevar.h diff -u src/sys/sys/timevar.h:1.31 src/sys/sys/timevar.h:1.32 --- src/sys/sys/timevar.h:1.31 Tue Feb 21 10:41:24 2012 +++ src/sys/sys/timevar.h Mon Oct 1 21:44:29 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: timevar.h,v 1.31 2012/02/21 15:41:24 martin Exp $ */ +/* $NetBSD: timevar.h,v 1.32 2012/10/02 01:44:29 christos Exp $ */ /* * Copyright (c) 2005, 2008 The NetBSD Foundation. @@ -165,7 +165,8 @@ int ppsratecheck(struct timeval *, int * int ratecheck(struct timeval *, const struct timeval *); void realtimerexpire(void *); int settime(struct proc *p, struct timespec *); -int nanosleep1(struct lwp *l, struct timespec *, struct timespec *); +int nanosleep1(struct lwp *, clockid_t, int, struct timespec *, + struct timespec *); int settimeofday1(const struct timeval *, bool, const void *, struct lwp *, bool); int timer_create1(timer_t *, clockid_t, struct sigevent *, copyin_t,