Apart from the difference of precision, what are the differences between struct timeval
and struct timespec
? If I need less precision than µs (say, milliseconds), why would I use one over the other?
On my compiler (gcc for ARM):
/* POSIX.1b structure for a time value. This is like a `struct timeval' but
has nanoseconds instead of microseconds. */
struct timespec
{
__time_t tv_sec; /* Seconds. */
__syscall_slong_t tv_nsec; /* Nanoseconds. */
};
/* A time value that is accurate to the nearest
microsecond but also has a range of years. */
struct timeval
{
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};
With both __syscall_slong_t
and __suseconds_t
defined as a "long word".