On Thu, 2008-09-04 at 16:31 +0200, Hannes Gredler wrote:
[....]
> don't know - perhaps now now - at least we should fix the overflow
> detection. (your previous patch) when comparing timestamps to now.

Apart from a superfluous '{' (or missing '}';-), the notorious
department of "minimized run-time code" uses usually more something
like:
----  snip  ----
int time_cmp(const olsr_u32_t t1, const olsr_u32_t t2)
{
    const olsr_32_t diff = t1 - t2;
    return diff == 0 ? 0 : diff < 0 : -1 : 1;
}
----  snip  ----
which should be equivalent.
But I'm, more a fan of 
----  snip  ----
static INLINE int time_lt(const olsr_u32_t t1, const olsr_u32_t t2) {
    return (olsr_32_t)(t1 - t2) < 0;
}
static INLINE int time_gt(const olsr_u32_t t1, const olsr_u32_t t2) {
    return (olsr_32_t)(t1 - t2) > 0;
}
#define time_gteq(t1, t2) (!(time_lt((t2), (t1))))
#define time_lteq(t1, t2) (!(time_gt((t2), (t1))))
----  snip  ----
static inline's oder #define is IMHO more a question of type-safety and
compile-time checking than anything else.

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services




