mirror of git://git.musl-libc.org/musl
fix incorrect clock tick scaling in fallback case of clock()
since CLOCKS_PER_SEC is 1000000 (required by XSI) and the times syscall reports values in 1/100 second units (Linux), the correct scaling factor is 10000, not 100. note that only ancient kernels which lack clock_gettime are affected.
This commit is contained in:
parent
9293b765c4
commit
da49b872f5
|
@ -11,5 +11,5 @@ clock_t clock()
|
||||||
if (!__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
|
if (!__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
|
||||||
return ts.tv_sec*1000000 + ts.tv_nsec/1000;
|
return ts.tv_sec*1000000 + ts.tv_nsec/1000;
|
||||||
__syscall(SYS_times, &tms);
|
__syscall(SYS_times, &tms);
|
||||||
return (tms.tms_utime + tms.tms_stime)*100;
|
return (tms.tms_utime + tms.tms_stime)*10000;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue