unsubmitted-clock_t_centiseconds
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Tue, 18 Oct 2016 21:10:46 +0000 (21:10 +0000)
committerAurelien Jarno <aurel32@debian.org>
Tue, 18 Oct 2016 21:10:46 +0000 (21:10 +0000)
Some applications assume centisecond precision, or at most millisecond precision
(e.g. guile).  This is a work-around for them.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name unsubmitted-clock_t_centiseconds.diff

sysdeps/mach/hurd/clock.c
sysdeps/mach/hurd/getclktck.c
sysdeps/mach/hurd/setitimer.c
sysdeps/mach/hurd/times.c

index 9f4f26a17c88292074d52565e5e73f979a73f722..12a2eaed042fe27dfed217e1a784832a699957ba 100644 (file)
@@ -44,10 +44,10 @@ clock (void)
   if (err)
     return __hurd_fail (err);
 
-  total = bi.user_time.seconds * 1000000 + bi.user_time.microseconds;
-  total += tti.user_time.seconds * 1000000 + tti.user_time.microseconds;
-  total += bi.system_time.seconds * 1000000 + bi.system_time.microseconds;
-  total += tti.system_time.seconds * 1000000 + tti.system_time.microseconds;
+  total = bi.user_time.seconds * 100 + bi.user_time.microseconds / 10000;
+  total += tti.user_time.seconds * 100 + tti.user_time.microseconds / 10000;
+  total += bi.system_time.seconds * 100 + bi.system_time.microseconds / 10000;
+  total += tti.system_time.seconds * 100 + tti.system_time.microseconds / 10000;
 
   return total;
 }
index 9ed99422cccac916a563fef2d6aad5f930eda783..9928fe0c89a364584df3cb9460889547493586ef 100644 (file)
 
 #include <time.h>
 
-/* Return frequency of `times'.
-   Since Mach reports CPU times in microseconds, we always use 1 million.  */
+/* Return frequency of `times'.  */
 int
 __getclktck (void)
 {
-  return 1000000;
+  return 100;
 }
 
 /* Before glibc 2.2, the Hurd actually did this differently, so we
index 5960612e85965b678ee665e26df1bceb6d84591c..13c0435e4630e62a2df41101f1e9b72152d23a47 100644 (file)
@@ -42,7 +42,7 @@ quantize_timeval (struct timeval *tv)
   static time_t quantum = -1;
 
   if (quantum == -1)
-    quantum = 1000000 / __getclktck ();
+    quantum = 100 / __getclktck ();
 
   tv->tv_usec = ((tv->tv_usec + (quantum - 1)) / quantum) * quantum;
   if (tv->tv_usec >= 1000000)
index 27f510f1ef6e08d02b4d7d77bcd3d68f0b4ba074..fa1c85fcab6290992a30e61680b52255c3cdeee1 100644 (file)
@@ -29,7 +29,7 @@
 static inline clock_t
 clock_from_time_value (const time_value_t *t)
 {
-  return t->seconds * 1000000 + t->microseconds;
+  return t->seconds * 100 + t->microseconds / 10000;
 }
 
 /* Store the CPU time used by this process and all its