Re: jiffie wraps clean-ups

From: James Manning (jmm@computer.org)
Date: Wed May 10 2000 - 14:06:59 EST


[George Anzinger]
> I would be much more enlightened if your patch had included the code for
> time_after() and time_before().

The patch didn't need to include those since they're already in
include/linux/timer.h, but I'll be nice and paste for you:

/*
 * These inlines deal with timer wrapping correctly. You are
 * strongly encouraged to use them
 * 1. Because people otherwise forget
 * 2. Because if the timer wrap changes in future you wont have to
 * alter your driver code.
 *
 * 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.
 */
#define time_after(a,b) ((long)(b) - (long)(a) < 0)
#define time_before(a,b) time_after(b,a)

#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0)
#define time_before_eq(a,b) time_after_eq(b,a)

James

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



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:16 EST