mips: add vdso support
[musl.git] / src / time / clock.c
blobc348e39836caec86425652d6e0e3259ff9c05a2c
1 #include <time.h>
2 #include <limits.h>
4 int __clock_gettime(clockid_t, struct timespec *);
6 clock_t clock()
8 struct timespec ts;
10 if (__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
11 return -1;
13 if (ts.tv_sec > LONG_MAX/1000000
14 || ts.tv_nsec/1000 > LONG_MAX-1000000*ts.tv_sec)
15 return -1;
17 return ts.tv_sec*1000000 + ts.tv_nsec/1000;