Subject: Re: Before I offically call this a time bug can someone else try this? (fwd)
To: None <perry@piermont.com, R.S.Brooks@liverpool.ac.uk>
From: Chris Torek <torek@BSDI.COM>
List: tech-kern
Date: 08/06/1998 18:21:41
>Because [negative offsets are allowed], time_t's must be able to
>take negative values.
People keep saying this, but if time_t were unsigned, and you did:
time_t now;
time_t offset;
time_t yesterday;
...
time(&now);
offset = -86400;
yesterday = now + offset;
"yesterday" would still be set to the same value as with signed
time_t's (provided time_t is unsigned int, unsigned long, or
unsigned long long, or is unsigned short with sizeof(short)==sizeof(int),
or is unsigned char with sizeof(char)==sizeof(int) -- the latter
two are due to ANSI widening rules, which depend on relative widths).
There *are* a few places (e.g., in the adjtime call itself, which
I fiddled with in my LBL days while changing hardclock()) where
someone may care whether the offset is negative, but those sections
(once they are found!) can use a cast to force a signed interpretation.
That is, "needing negative offsets" is true, but is far rarer than
one might think (see "yesterday" example above). So it *could*
be done ... not that I would want to be the one doing it (too much
work for too little payoff).
Chris