Names specified here
Name Description Notes Source Availability
struct timespec Nanosecond time type T <time.h> C11
TIME_UTC Indicator for UTC time in struct timespec M <time.h> C11
timespec_get() Read nanosecond time (·) <time.h> C11

Macros with names matching ^TIME_[A-Z] might be added to <time.h>.

<time.h> defines a type struct timespec, which represents a time duration in nanoseconds.

Fields of struct timespec
Field Meaning
time_t tv_sec Whole seconds
long tv_usec Nanoseconds

How can time_t be used here, if it's not necessarily a time in seconds? If it's not being used that way, what's the point of equating it with a time_t?

#include <time.h>
int timespec_get(struct timespec *tsp, int base);

The function timespec_get gets the current calendar time, and assigns it to *tsp. The only portable value of base is TIME_UTC.

Functions making use of struct timespec
Name Description Notes Source Availability
cnd_timedwait() Wait on a condition variable for a limited time ? (·) <threads.h> C11
mtx_timedlock() Try for some time to lock a mutex ? (·) <threads.h> C11
thrd_sleep() Suspend current thread ? (·) <threads.h> C11

CHaR
Sitemap Supported
Site format updated 2024-06-05T22:37:07.391+0000
Data updated 1970-01-01T00:00:00.000+0000
Page updated 2022-06-17T21:43:05.000+0000