Re: [patch] time_after_eq fix

From: Linus Torvalds
Date: Wed May 18 2005 - 18:37:26 EST




On Thu, 19 May 2005, Coywolf Qi Hunt wrote:
>
> 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.

The original comment is correct, and your changed comment is nonsensical,
since "<= 0" doesn't actually test the sign of the result like your
comment says.

Also, your patch itself seems not very sensible. Why do you think your
patch matters?

> - ((long)(a) - (long)(b) >= 0))
> + ((long)(b) - (long)(a) <= 0))

Now, tell me why that one line would make any difference, except for the
(undefined) case where we don't know and the time is as far behind as it
is ahead?

Notice: you switch the order of the subtraction, and you switch the sign
of the test. The original code allowed old gcc versions to generate better
code. Your new code doesn't.

What am I missing?

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/