summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFlavio Cruz <flaviocruz@gmail.com>2023-01-19 23:26:19 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-01-19 23:26:19 +0100
commit569df850cd7badd1e36132ad3b44aa76a4d27c25 (patch)
tree3a840d7b0ea28ffd3a542ffc6e4bfe1206b78d97 /include
parent8d30c12342c1cafa7c02ecc00244f57cb39eb148 (diff)
Add host_get_time64 RPC to return the time as time_value64_t
Also updated the mapped time to support the new 64-bit time while keeping compatible with the user land programs currently using it so they can be migrated in parallel.
Diffstat (limited to 'include')
-rw-r--r--include/mach/mach_host.defs8
-rw-r--r--include/mach/mach_types.defs5
-rw-r--r--include/mach/time_value.h44
3 files changed, 44 insertions, 13 deletions
diff --git a/include/mach/mach_host.defs b/include/mach/mach_host.defs
index 28439a01..0674c859 100644
--- a/include/mach/mach_host.defs
+++ b/include/mach/mach_host.defs
@@ -352,3 +352,11 @@ routine processor_control(
routine host_get_boot_info(
host_priv : host_priv_t;
out boot_info : kernel_boot_info_t);
+
+/*
+ * Get the time on this host.
+ * Available to all.
+ */
+routine host_get_time64(
+ host : host_t;
+ out current_time : time_value64_t);
diff --git a/include/mach/mach_types.defs b/include/mach/mach_types.defs
index a98e5c67..8f22137a 100644
--- a/include/mach/mach_types.defs
+++ b/include/mach/mach_types.defs
@@ -272,6 +272,11 @@ type time_value_t = rpc_time_value_t
#endif
;
+type time_value64_t = struct {
+ int64_t seconds;
+ int64_t nanoseconds;
+};
+
type emulation_vector_t = ^array[] of vm_offset_t;
type rpc_signature_info_t = array[*:1024] of int;
diff --git a/include/mach/time_value.h b/include/mach/time_value.h
index 9ecdd28e..3a816b22 100644
--- a/include/mach/time_value.h
+++ b/include/mach/time_value.h
@@ -98,23 +98,23 @@ static __inline__ time_value_t convert_time_value_from_user(rpc_time_value_t tv)
time_value_assert(val); \
}
-#define time_value64_add_usec(val, micros) { \
- time_value64_assert(val); \
- if (((val)->nanoseconds += (micros) * 1000) \
+#define time_value64_add_nanos(val, nanos) { \
+ time_value64_assert(val); \
+ if (((val)->nanoseconds += (nanos)) \
>= TIME_NANOS_MAX) { \
(val)->nanoseconds -= TIME_NANOS_MAX; \
(val)->seconds++; \
} \
- time_value64_assert(val); \
+ time_value64_assert(val); \
}
-#define time_value_sub_usec(val, micros) { \
- time_value_assert(val); \
- if (((val)->microseconds -= (micros)) < 0) { \
- (val)->microseconds += TIME_MICROS_MAX; \
+#define time_value64_sub_nanos(val, nanos) { \
+ time_value64_assert(val); \
+ if (((val)->nanoseconds -= (nanos)) < 0) { \
+ (val)->nanoseconds += TIME_NANOS_MAX; \
(val)->seconds--; \
} \
- time_value_assert(val); \
+ time_value64_assert(val); \
}
#define time_value_add(result, addend) { \
@@ -123,12 +123,28 @@ static __inline__ time_value_t convert_time_value_from_user(rpc_time_value_t tv)
time_value_add_usec(result, (addend)->microseconds); \
}
-#define time_value_sub(result, subtrahend) { \
- time_value_assert(subtrahend); \
- (result)->seconds -= (subtrahend)->seconds; \
- time_value_sub_usec(result, (subtrahend)->microseconds); \
+#define time_value64_add(result, addend) { \
+ time_value64_assert(addend); \
+ (result)->seconds += (addend)->seconds; \
+ time_value64_add_nanos(result, (addend)->nanoseconds); \
}
+#define time_value64_sub(result, subtrahend) { \
+ time_value64_assert(subtrahend); \
+ (result)->seconds -= (subtrahend)->seconds; \
+ time_value64_sub_nanos(result, (subtrahend)->nanoseconds); \
+ }
+
+#define TIME_VALUE64_TO_TIME_VALUE(tv64, tv) do { \
+ (tv)->seconds = (tv64)->seconds; \
+ (tv)->microseconds = (tv64)->nanoseconds / 1000; \
+} while(0)
+
+#define TIME_VALUE_TO_TIME_VALUE64(tv, tv64) do { \
+ (tv64)->seconds = (tv)->seconds; \
+ (tv64)->nanoseconds = (tv)->microseconds * 1000; \
+} while(0)
+
/*
* Time value available through the mapped-time interface.
* Read this mapped value with
@@ -144,6 +160,8 @@ typedef struct mapped_time_value {
integer_t seconds;
integer_t microseconds;
integer_t check_seconds;
+ struct time_value64 time_value;
+ int64_t check_seconds64;
} mapped_time_value_t;
/* Macros for converting between struct timespec and time_value_t. */