version 1.174, 2012/03/22 17:46:07 |
version 1.174.2.2, 2013/06/23 06:18:58 |
Line 190 sys___clock_gettime50(struct lwp *l, |
|
Line 190 sys___clock_gettime50(struct lwp *l, |
|
return copyout(&ats, SCARG(uap, tp), sizeof(ats)); |
return copyout(&ats, SCARG(uap, tp), sizeof(ats)); |
} |
} |
|
|
int |
|
clock_gettime1(clockid_t clock_id, struct timespec *ts) |
|
{ |
|
|
|
switch (clock_id) { |
|
case CLOCK_REALTIME: |
|
nanotime(ts); |
|
break; |
|
case CLOCK_MONOTONIC: |
|
nanouptime(ts); |
|
break; |
|
default: |
|
return EINVAL; |
|
} |
|
|
|
return 0; |
|
} |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
sys___clock_settime50(struct lwp *l, |
sys___clock_settime50(struct lwp *l, |
Line 303 sys___nanosleep50(struct lwp *l, const s |
|
Line 285 sys___nanosleep50(struct lwp *l, const s |
|
if (error) |
if (error) |
return (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)) |
if (SCARG(uap, rmtp) == NULL || (error != 0 && error != EINTR)) |
return error; |
return error; |
|
|
Line 312 sys___nanosleep50(struct lwp *l, const s |
|
Line 322 sys___nanosleep50(struct lwp *l, const s |
|
} |
} |
|
|
int |
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; |
struct timespec rmtstart; |
int error, timo; |
int error, timo; |
|
|
if ((error = itimespecfix(rqt)) != 0) |
if ((error = ts2timo(clock_id, flags, rqt, &timo, &rmtstart)) != 0) |
return error; |
return error == ETIMEDOUT ? 0 : error; |
|
|
timo = tstohz(rqt); |
|
/* |
/* |
* Avoid inadvertantly sleeping forever |
* Avoid inadvertently sleeping forever |
*/ |
*/ |
if (timo == 0) |
if (timo == 0) |
timo = 1; |
timo = 1; |
getnanouptime(&rmtstart); |
|
again: |
again: |
error = kpause("nanoslp", true, timo, NULL); |
error = kpause("nanoslp", true, timo, NULL); |
if (rmt != NULL || error == 0) { |
if (rmt != NULL || error == 0) { |
|
|
struct timespec t0; |
struct timespec t0; |
struct timespec *t; |
struct timespec *t; |
|
|
getnanouptime(&rmtend); |
(void)clock_gettime1(clock_id, &rmtend); |
t = (rmt != NULL) ? rmt : &t0; |
t = (rmt != NULL) ? rmt : &t0; |
timespecsub(&rmtend, &rmtstart, t); |
if (flags & TIMER_ABSTIME) { |
timespecsub(rqt, t, t); |
timespecsub(rqt, &rmtend, t); |
|
} else { |
|
timespecsub(&rmtend, &rmtstart, t); |
|
timespecsub(rqt, t, t); |
|
} |
if (t->tv_sec < 0) |
if (t->tv_sec < 0) |
timespecclear(t); |
timespecclear(t); |
if (error == 0) { |
if (error == 0) { |