Signed overflow optimization hazards in the kernel
Signed overflow optimization hazards in the kernel
Posted Aug 18, 2012 22:51 UTC (Sat) by jzbiciak (guest, #5246)Parent article: Signed overflow optimization hazards in the kernel
This seems like it argues for a macro to hide the ugliness. Name it something obvious such as "before()". It makes the intent obvious and ensures the ugly math is done correctly. Something like:
/* return true if timestamp 'a' is earlier than timestamp 'b' */ #define before(a,b) (ULONG_MAX/2 > ((unsigned long)(a) - (unsigned long)(b)))
Or is this just an invitation to more problems?
