Type for uptime in seconds
Eric S. Raymond
esr at thyrsus.com
Tue Dec 12 21:37:20 UTC 2017
Hal Murray via devel <devel at ntpsec.org>:
> Context is Issue #424
>
> It's simple to change the counters to 64 bits. But a few of the relevant
> variables are uptime in seconds. Is there a good type to use for them?
> time_t is misleading. current_time is seconds since ntpd was started not
> seconds since 1970.
>
> unsigned long current_time; /* seconds since startup */
>
> It gets initialized to 0 and bumped every second by a timer signal handler.
>
> 32 bits is enough. (I'm not going to worry about systems being up more than
> 138 years.) I'd be happy to use a 64 bit type if that makes things cleaner.
> I don't think we have to worry about conversion from 64 bit time_t.
I'd just do "typedef uint32_t uptime_t;" somewhere, myself. There isn't
a system type devoted to this sort of thing; closest would be clock_t. The
units for that are not specified, but are often microseconds.
--
<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
My work is funded by the Internet Civil Engineering Institute: https://icei.org
Please visit their site and donate: the civilization you save might be your own.
More information about the devel
mailing list