public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Coywolf Qi Hunt" <coywolf@lovecn.org>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [patch] time_after_eq fix
Date: Thu, 19 May 2005 06:44:15 +0800	[thread overview]
Message-ID: <20050518224415.GA5768@lovecn.org> (raw)

Hello,

The two macros time_after and time_after_eq were added to do wrapping
correctly, but only time_after does it the right way, time_after_eq has
been wrong since the very beginning(v2.1.127, 07-Nov-1998).  Now this
patch fixes it.

And I don't agree with the the original code comment. I don't think this
is gcc's fault.  If it is "a good compiler" or "a really good compiler",
trying to be smarter than human, it wouldn't still be a C compiler.
So I'd like it be removed.

Signed-off-by: Coywolf Qi Hunt <coywolf@lovecn.org>
---

 jiffies.h |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff -pruN 2.6.12-rc4-mm2/include/linux/jiffies.h 2.6.12-rc4-mm2-cy/include/linux/jiffies.h
--- 2.6.12-rc4-mm2/include/linux/jiffies.h	2005-03-03 17:12:13.000000000 +0800
+++ 2.6.12-rc4-mm2-cy/include/linux/jiffies.h	2005-05-19 05:32:52.000000000 +0800
@@ -102,9 +102,7 @@ static inline u64 get_jiffies_64(void)
  *
  * time_after(a,b) returns true if the time a is after time b.
  *
- * Do this with "<0" and ">=0" to only test the sign of the result. A
- * good compiler would generate better code (and a really good compiler
- * wouldn't care). Gcc is currently neither.
+ * Do this with "<0" and "<=0" to only test the sign of the result.
  */
 #define time_after(a,b)		\
 	(typecheck(unsigned long, a) && \
@@ -115,7 +113,7 @@ static inline u64 get_jiffies_64(void)
 #define time_after_eq(a,b)	\
 	(typecheck(unsigned long, a) && \
 	 typecheck(unsigned long, b) && \
-	 ((long)(a) - (long)(b) >= 0))
+	 ((long)(b) - (long)(a) <= 0))
 #define time_before_eq(a,b)	time_after_eq(b,a)
 
 /*

             reply	other threads:[~2005-05-18 22:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-18 22:44 Coywolf Qi Hunt [this message]
2005-05-18 23:14 ` [patch] time_after_eq fix Chris Friesen
2005-05-18 23:36 ` Linus Torvalds
2005-05-19  1:03 ` George Anzinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050518224415.GA5768@lovecn.org \
    --to=coywolf@lovecn.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox