diff options
author | davidxu <davidxu@FreeBSD.org> | 2012-08-11 23:48:39 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2012-08-11 23:48:39 +0000 |
commit | 988528484fdfe3c53b0398a959c7649029588e5f (patch) | |
tree | b01395536b5b19cc4b78e21bbb6b22addd34f20b | |
parent | ce09176548965bb0a7166f37344c1ea344bf7400 (diff) | |
download | FreeBSD-src-988528484fdfe3c53b0398a959c7649029588e5f.zip FreeBSD-src-988528484fdfe3c53b0398a959c7649029588e5f.tar.gz |
Some style fixes inspired by @bde.
-rw-r--r-- | sys/kern/kern_umtx.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index e5994c8..9562944 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -587,7 +587,7 @@ abs_timeout_init2(struct abs_timeout *timo, const struct _umtx_time *umtxtime) &umtxtime->_timeout); } -static void +static inline void abs_timeout_update(struct abs_timeout *timo) { kern_clock_gettime(curthread, timo->clockid, &timo->cur); @@ -598,10 +598,10 @@ abs_timeout_gethz(struct abs_timeout *timo) { struct timespec tts; + if (timespeccmp(&timo->end, &timo->cur, <=)) + return (-1); tts = timo->end; timespecsub(&tts, &timo->cur); - if (tts.tv_sec < 0 || (tts.tv_sec == 0 && tts.tv_nsec == 0)) - return (-1); return (tstohz(&tts)); } @@ -610,29 +610,29 @@ abs_timeout_gethz(struct abs_timeout *timo) * thread was removed from umtx queue. */ static inline int -umtxq_sleep(struct umtx_q *uq, const char *wmesg, struct abs_timeout *timo) +umtxq_sleep(struct umtx_q *uq, const char *wmesg, struct abs_timeout *abstime) { struct umtxq_chain *uc; - int error; - int pulse; + int error, timo; uc = umtxq_getchain(&uq->uq_key); UMTXQ_LOCKED_ASSERT(uc); for (;;) { if (!(uq->uq_flags & UQF_UMTXQ)) return (0); - if (timo != NULL) { - pulse = abs_timeout_gethz(timo); - if (pulse < 0) + if (abstime != NULL) { + timo = abs_timeout_gethz(abstime); + if (timo < 0) return (ETIMEDOUT); } else - pulse = 0; - error = msleep(uq, &uc->uc_lock, PCATCH|PDROP, wmesg, pulse); + timo = 0; + error = msleep(uq, &uc->uc_lock, PCATCH | PDROP, wmesg, timo); if (error != EWOULDBLOCK) { umtxq_lock(&uq->uq_key); break; } - abs_timeout_update(timo); + if (abstime != NULL) + abs_timeout_update(abstime); umtxq_lock(&uq->uq_key); } return (error); |