This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rbraun at sceen dot net: [PATCH] Make __getclktck return 100 for the Hurd]


----- Forwarded message from Richard Braun <rbraun@sceen.net> -----

Date: Mon,  6 May 2013 21:49:56 +0200
From: Richard Braun <rbraun@sceen.net>
To: bug-hurd@gnu.org
Subject: [PATCH] Make __getclktck return 100 for the Hurd
X-Mailer: git-send-email 1.7.2.5

While it's true that Mach time values are returned in microseconds, they
are correctly handled as such, and not as clock ticks, by applications.
On the other hand, tools such as top provide wrong results since values
in /proc are actually provided as true clock ticks.
---
 sysdeps/mach/hurd/getclktck.c |    5 ++---
 sysdeps/mach/hurd/setitimer.c |    2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/sysdeps/mach/hurd/getclktck.c b/sysdeps/mach/hurd/getclktck.c
index 5ea4781..feebd56 100644
--- a/sysdeps/mach/hurd/getclktck.c
+++ b/sysdeps/mach/hurd/getclktck.c
@@ -18,12 +18,11 @@
 
 #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 ()
 {
-  return 1000000;
+  return 100;
 }
 
 /* Before glibc 2.2, the Hurd actually did this differently, so we
diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c
index 8b012ec..b33e7cf 100644
--- a/sysdeps/mach/hurd/setitimer.c
+++ b/sysdeps/mach/hurd/setitimer.c
@@ -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)
-- 
1.7.10.4



----- End forwarded message -----

Forwarding to libc-alpha for reviewing. Thanks.

-- 
Richard Braun


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]