Messages in this thread | | | Date | Tue, 17 Aug 1999 12:13:15 +0200 (MET_DST) | From | David Weinehall <> | Subject | Re: jiffies and co |
| |
On Mon, 16 Aug 1999, Linus Torvalds wrote:
> > > On Mon, 16 Aug 1999, Gerard Roudier wrote: > > > > Why is jiffies type still 'unsigned long', given that all calculations > > that try to be not too wrong with wrap-around just cast timer values to > > signed long? > > Why not? > > You shouldn't really do compares on it anyway, so the type doesn't matter. > And to me, "unsigned" makes much more sense for time as it is implemented > in the kernel - it never goes negative, but it can wrap. That's basically > what "unsigned" means. > > Also the C standard actually guarantees nice wrapping behaviour for > unsigned, something it doesn't guarantee for signed values. So as long as > you're working with wrapping values, you should always use unsigned. We > then at the last possible moment know that we're playing with a two's > complement machine, and that's where we do the signed cast to test the > high bit to make it easy on the compiler, but you could conceptually think > of it as a test for the high bit (which is portable C) rather than as a > test for the sign (which is _not_ portable C, but nobody cares because > nobody sane does anything but two's complement). > > So I really don't see the point of trying to change the type to anything > else or trying to hide it with some random new typedef that doesn't buy > you anything in real life. Don't abstract things away unless you get some > real _advantage_ from the abstraction, and I don't see the advantage. > > Linus
From just a quick scan (grep + ocular-investigation), there seem to be at least a few places left in the kernel where jiffies are treated as int, not unsigned long. Are those left on purpose, or should I fix 'em up?!
For instance, arch/i386/kernel/io_apic.c defines jiffies to be unsigned int (this would probably not really matter, but for sake of clarity)
/David Weinehall _ _ // David Weinehall <tao@acc.umu.se> /> Northern lights wander \\ // Project MCA Linux hacker // Dance across the winter sky // \> http://www.acc.umu.se/~tao/ </ Full colour fire </
- 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/
| |