When you invoke clock_gettime()
it returns a timespec structure.
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
I don't find in the man page a garantee that the tv_nsec won't exceed one second. Does the garantee exist actually ? Could it be dependant on the library (glibc?) implementation for linux?
The key idea is : do I need to 'normalize' any result coming from the clock_gettime()
function?
According to opengroup
The tv_nsec member is only valid if greater than or equal to zero, and less than the number of nanoseconds in a second (1000 million). The time interval described by this structure is (tv_sec * 10'-.4m'9'.4m' + tv_nsec) nanoseconds.
So according to opengroup, it looks official that it must be less than 1 second.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With