Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Jun 2001 16:18:08 -0700 (PDT)
From:      David Wolfskill <david@catwhisker.org>
To:        stable@freebsd.org
Subject:   Re: time_t definition is worng
Message-ID:  <200106012318.f51NI8w38590@bunrab.catwhisker.org>
In-Reply-To: <200106012300.f51N0VT90830@earth.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>Date: Fri, 1 Jun 2001 16:00:31 -0700 (PDT)
>From: Matt Dillon <dillon@earth.backplane.com>

>:I never understood why it isn't at _least_ made unsigned. This at least 
>:puts off the 2038 issue until 2106. I may live to see the former, but 
>:certainly not the latter. :-)

>    Historically people compared time stamps by subtracting one from 
>    another.

Which is a practice that the difftime() function was invented to
replace.

>    If they are unsigned, that breaks horribly (you never get
>    a negative result).

Ummm.  With respect, I think the excerpt from "man 3 time" that reads:

     Upon successful completion, time() returns the value of time.  Otherwise
     a value of ((time_t) -1) is returned and the global variable errno is set
     to indicate the error.

is probably a more significant restriction:  both could be gotten around
if time_t were unsigned, but in the mean time (no pun intended!), I suspect
that a lot of naively-coded applications would break mysteriously.

>    Internally there is nothing preventing us from
>    treating time_t as an unsigned, er, long.

Well, I don't write much code (and never have written a lot of it), so
please feel free to take what I wrote with an appropriately-sized
"grain of salt".  But it may be worth noting (iin this context) that
the result of difftime() is a double.  :-}

Cheers,
david
-- 
David H. Wolfskill				david@catwhisker.org
As a computing professional, I believe it would be unethical for me to
advise, recommend, or support the use (save possibly for personal
amusement) of any product that is or depends on any Microsoft product.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106012318.f51NI8w38590>