about summary refs log tree commit diff
path: root/src/time/clock.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-05-05 14:51:25 -0400
committerRich Felker <dalias@aerifal.cx>2013-05-05 14:51:25 -0400
commitda49b872f5ef56026713855b66783c8e32570c4b (patch)
tree16d4784da229a4c9f39a84d999e806783ff9cd24 /src/time/clock.c
parent9293b765c4449c13fe355bcfcac1934fe3426847 (diff)
downloadmusl-da49b872f5ef56026713855b66783c8e32570c4b.tar.gz
musl-da49b872f5ef56026713855b66783c8e32570c4b.tar.xz
musl-da49b872f5ef56026713855b66783c8e32570c4b.zip
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.
Diffstat (limited to 'src/time/clock.c')
-rw-r--r--src/time/clock.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/time/clock.c b/src/time/clock.c
index d32cd092..78403af3 100644
--- a/src/time/clock.c
+++ b/src/time/clock.c
@@ -11,5 +11,5 @@ clock_t clock()
 	if (!__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
 		return ts.tv_sec*1000000 + ts.tv_nsec/1000;
 	__syscall(SYS_times, &tms);
-	return (tms.tms_utime + tms.tms_stime)*100;
+	return (tms.tms_utime + tms.tms_stime)*10000;
 }