[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH glic] hurd: Add CLOCK_MONOTONIC case in clock_gettime()
From: |
Zhaoming Luo |
Subject: |
[RFC PATCH glic] hurd: Add CLOCK_MONOTONIC case in clock_gettime() |
Date: |
Wed, 1 Jan 2025 17:51:36 +0800 |
---
sysdeps/mach/clock_gettime.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sysdeps/mach/clock_gettime.c b/sysdeps/mach/clock_gettime.c
index 6fffad39f5..22faf85730 100644
--- a/sysdeps/mach/clock_gettime.c
+++ b/sysdeps/mach/clock_gettime.c
@@ -31,6 +31,18 @@ __clock_gettime (clockid_t clock_id, struct timespec *ts)
switch (clock_id) {
+ case CLOCK_MONOTONIC:
+ {
+ /* __host_get_uptime64 can only fail if passed an invalid host_t.
+ __mach_host_self could theoretically fail (producing an
+ invalid host_t) due to resource exhaustion, but we assume
+ this will never happen. */
+ time_value64_t tv;
+ __host_get_uptime64 (__mach_host_self (), &tv);
+ TIME_VALUE64_TO_TIMESPEC (&tv, ts);
+ return 0;
+ }
+
case CLOCK_REALTIME:
{
/* __host_get_time can only fail if passed an invalid host_t.
--
2.45.2
- [RFC PATCH glic] hurd: Add CLOCK_MONOTONIC case in clock_gettime(),
Zhaoming Luo <=