mirror of https://git.musl-libc.org/git/musl
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
344 B
18 lines
344 B
#include <time.h>
|
|
#include <limits.h>
|
|
|
|
int __clock_gettime(clockid_t, struct timespec *);
|
|
|
|
clock_t clock()
|
|
{
|
|
struct timespec ts;
|
|
|
|
if (__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
|
|
return -1;
|
|
|
|
if (ts.tv_sec > LONG_MAX/1000000
|
|
|| ts.tv_nsec/1000 > LONG_MAX-1000000*ts.tv_sec)
|
|
return -1;
|
|
|
|
return ts.tv_sec*1000000 + ts.tv_nsec/1000;
|
|
}
|
|
|