]> git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/time/clock.c
WASI libc prototype implementation.
[wasi-libc.git] / libc-top-half / musl / src / time / clock.c
1 #include <time.h>
2 #include <limits.h>
3
4 clock_t clock()
5 {
6 struct timespec ts;
7
8 if (__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
9 return -1;
10
11 if (ts.tv_sec > LONG_MAX/1000000
12 || ts.tv_nsec/1000 > LONG_MAX-1000000*ts.tv_sec)
13 return -1;
14
15 return ts.tv_sec*1000000 + ts.tv_nsec/1000;
16 }