[vlc-devel] [RFC] signed versus unsigned integer types

Rémi Denis-Courmont rdenis at simphalempin.com
Tue Jan 29 17:11:32 CET 2008


Le Tuesday 29 January 2008 16:23:47 André Weber, vous avez écrit :
> >> Why is mtime_t a signed type ?
> >
> >Because this type is often used to compute a difference between two
> >dates, and a difference can be signed.
>
> right -
>
> and whats about dates -- B.C.? ;-) they are truely exists, not for VLC
> but in general.

mtime_t does NOT -generally- represent a wall clock time and date.

On Windows and Linux, this happens to be whenever the kernel started the 
clock. On MacOS X and BSD, it happens to be the Unix epoch because we have no 
better alternatives; this is wrong as it screws up when the wall clock is 
adjusted by the user, or by some NTP client software.

As Meuuh pointed out, it is therefore conceivable that VLC would deal with a 
negative time. If my PC booted 2 minutes ago, then "five minutes ago" is a 
mtime_t value.

In fact, it is much more likely that VLC will have to represent "5 minutes 
ago" than "292271 years in the future", which is approximately when mtime_t 
will reach 2^63 and overflow to very negative values. As such, I think 
mtime_t should be signed.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20080129/6eacd1cd/attachment.sig>


More information about the vlc-devel mailing list