1 This is needed to run Python on the Hurd, especially during the build of
4 Adapted from https://salsa.debian.org/glibc-team/glibc/-/blob/glibc-2.31/debian/patches/hurd-i386/unsubmitted-clock_t_centiseconds.diff
6 commit d57f2f9b4bd007846af2fb4217486ea572579010
7 Author: Richard Braun <rbraun@sceen.net>
8 Date: Tue Aug 27 11:35:31 2013 +0200
10 Express CPU time (clock_t of times(2)) in centiseconds
12 From 170c292b643fdc1eb56881e6592b07c0c019993e Mon Sep 17 00:00:00 2001
13 From: Jan Nieuwenhuizen <janneke@gnu.org>
14 Date: Mon, 2 Mar 2020 18:28:54 +0100
15 Subject: [PATCH 1/2] Express CPU time (clock_t) in centiseconds
18 sysdeps/mach/hurd/clock.c | 8 ++++----
19 sysdeps/mach/hurd/getclktck.c | 5 ++---
20 sysdeps/mach/hurd/setitimer.c | 2 +-
21 sysdeps/mach/hurd/times.c | 2 +-
22 4 files changed, 8 insertions(+), 9 deletions(-)
24 diff --git a/sysdeps/mach/hurd/clock.c b/sysdeps/mach/hurd/clock.c
25 index 7cb42df786..4db49b579d 100644
26 --- a/sysdeps/mach/hurd/clock.c
27 +++ b/sysdeps/mach/hurd/clock.c
28 @@ -44,10 +44,10 @@ clock (void)
30 return __hurd_fail (err);
32 - total = bi.user_time.seconds * 1000000 + bi.user_time.microseconds;
33 - total += tti.user_time.seconds * 1000000 + tti.user_time.microseconds;
34 - total += bi.system_time.seconds * 1000000 + bi.system_time.microseconds;
35 - total += tti.system_time.seconds * 1000000 + tti.system_time.microseconds;
36 + total = bi.user_time.seconds * 100 + bi.user_time.microseconds / 10000;
37 + total += tti.user_time.seconds * 100 + tti.user_time.microseconds / 10000;
38 + total += bi.system_time.seconds * 100 + bi.system_time.microseconds / 10000;
39 + total += tti.system_time.seconds * 100 + tti.system_time.microseconds / 10000;
43 diff --git a/sysdeps/mach/hurd/getclktck.c b/sysdeps/mach/hurd/getclktck.c
44 index 943e36e805..5a3cf0930b 100644
45 --- a/sysdeps/mach/hurd/getclktck.c
46 +++ b/sysdeps/mach/hurd/getclktck.c
51 -/* Return frequency of `times'.
52 - Since Mach reports CPU times in microseconds, we always use 1 million. */
53 +/* Return frequency of `times'. */
61 /* Before glibc 2.2, the Hurd actually did this differently, so we
62 diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c
63 index b16f4ddd5d..8bf1464830 100644
64 --- a/sysdeps/mach/hurd/setitimer.c
65 +++ b/sysdeps/mach/hurd/setitimer.c
66 @@ -43,7 +43,7 @@ quantize_timeval (struct timeval *tv)
67 static time_t quantum = -1;
70 - quantum = 1000000 / __getclktck ();
71 + quantum = 100 / __getclktck ();
73 tv->tv_usec = ((tv->tv_usec + (quantum - 1)) / quantum) * quantum;
74 if (tv->tv_usec >= 1000000)
75 diff --git a/sysdeps/mach/hurd/times.c b/sysdeps/mach/hurd/times.c
76 index 23ed992783..cbf6039b19 100644
77 --- a/sysdeps/mach/hurd/times.c
78 +++ b/sysdeps/mach/hurd/times.c
81 clock_from_time_value (const time_value_t *t)
83 - return t->seconds * 1000000 + t->microseconds;
84 + return t->seconds * 100 + t->microseconds / 10000;
87 /* Store the CPU time used by this process and all its