avoid malloc of deps arrays for ldso and vdso
[musl.git] / src / time / clock.c
blob6724012b92ef69b8dfa19e087b940aaf6a141e10
1 #include <time.h>
2 #include <limits.h>
4 clock_t clock()
6 struct timespec ts;
8 if (__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
9 return -1;
11 if (ts.tv_sec > LONG_MAX/1000000
12 || ts.tv_nsec/1000 > LONG_MAX-1000000*ts.tv_sec)
13 return -1;
15 return ts.tv_sec*1000000 + ts.tv_nsec/1000;