From owner-svn-src-all@FreeBSD.ORG Sat Aug 11 23:48:40 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6E54C106566C; Sat, 11 Aug 2012 23:48:40 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 03F898FC0A; Sat, 11 Aug 2012 23:48:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7BNmd4C013052; Sat, 11 Aug 2012 23:48:39 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7BNmdXq013050; Sat, 11 Aug 2012 23:48:39 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201208112348.q7BNmdXq013050@svn.freebsd.org> From: David Xu Date: Sat, 11 Aug 2012 23:48:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239202 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Aug 2012 23:48:40 -0000 Author: davidxu Date: Sat Aug 11 23:48:39 2012 New Revision: 239202 URL: http://svn.freebsd.org/changeset/base/239202 Log: Some style fixes inspired by @bde. Modified: head/sys/kern/kern_umtx.c Modified: head/sys/kern/kern_umtx.c ============================================================================== --- head/sys/kern/kern_umtx.c Sat Aug 11 23:26:19 2012 (r239201) +++ head/sys/kern/kern_umtx.c Sat Aug 11 23:48:39 2012 (r239202) @@ -587,7 +587,7 @@ abs_timeout_init2(struct abs_timeout *ti &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 *ti { 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 *ti * 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);