summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2020-03-20 04:08:26 +0000
committercheloha <cheloha@cvs.openbsd.org>2020-03-20 04:08:26 +0000
commitcbe45a968b2763560533629933fd933d7b011e3e (patch)
tree4bd31564d2d2992d800122e6e904bc2ed1e1834e /sys
parent7487fd60442281fe2ebce93427234e1ac570392e (diff)
nanosleep(2): tsleep(9) -> tsleep_nsec(9)
While here, rename the wait channel so the tsleep_nsec(9) call will fit onto a single line. It isn't a global channel so the name is arbitrary anyway. With input from visa@. ok visa@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_time.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 06dabb1fdfb..cd3147a791e 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.126 2019/11/07 14:49:07 cheloha Exp $ */
+/* $OpenBSD: kern_time.c,v 1.127 2020/03/20 04:08:25 cheloha Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -270,12 +270,13 @@ sys_clock_getres(struct proc *p, void *v, register_t *retval)
int
sys_nanosleep(struct proc *p, void *v, register_t *retval)
{
- static int nanowait;
+ static int chan;
struct sys_nanosleep_args/* {
syscallarg(const struct timespec *) rqtp;
syscallarg(struct timespec *) rmtp;
} */ *uap = v;
struct timespec elapsed, remainder, request, start, stop;
+ uint64_t nsecs;
struct timespec *rmtp;
int copyout_error, error;
@@ -293,8 +294,8 @@ sys_nanosleep(struct proc *p, void *v, register_t *retval)
do {
getnanouptime(&start);
- error = tsleep(&nanowait, PWAIT | PCATCH, "nanosleep",
- MAX(1, tstohz(&request)));
+ nsecs = MAX(1, MIN(TIMESPEC_TO_NSEC(&request), MAXTSLP));
+ error = tsleep_nsec(&chan, PWAIT | PCATCH, "nanosleep", nsecs);
getnanouptime(&stop);
timespecsub(&stop, &start, &elapsed);
timespecsub(&request, &elapsed, &request);