diff --git a/include/time.h b/include/time.h index dc88070..c2e4637 100644 --- a/include/time.h +++ b/include/time.h @@ -129,6 +129,12 @@ int stime(const time_t *); time_t timegm(struct tm *); #endif +#if __STDC_VERSION__ >= 201112L + /* Beware that TIME_UTC per the standard must be greater than 0. */ +#define TIME_UTC 1 +int timespec_get(struct timespec *, int); +#endif + #ifdef __cplusplus } #endif diff --git a/src/time/timespec_get.c b/src/time/timespec_get.c new file mode 100644 index 0000000..bf78e5a --- /dev/null +++ b/src/time/timespec_get.c @@ -0,0 +1,9 @@ +#include + +int __clock_gettime(clockid_t clk, struct timespec *ts); + +/* the base argument is simply ignored, there is no other implemented + value than TIME_UTC. */ +int timespec_get(struct timespec * ts, int base) { + return __clock_gettime(CLOCK_REALTIME, ts) < 0 ? 0 : base; +}