From e493c4e8c54ece41bd24b209cfb9efc24254214b Mon Sep 17 00:00:00 2001 From: Flavio Cruz Date: Fri, 16 Dec 2022 21:06:25 -0500 Subject: Use struct for time_value_t and define seconds as long_integer_t. On 64 bit kernels, seconds will be 64 bits long and won't suffer from the 2038 problem. We also add a new type rpc_time_value_t to handle the conversion between 32 bit userland and 64 bit kernel. Message-Id: --- include/mach/time_value.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'include/mach/time_value.h') diff --git a/include/mach/time_value.h b/include/mach/time_value.h index 3a9c384c..53692bcf 100644 --- a/include/mach/time_value.h +++ b/include/mach/time_value.h @@ -33,12 +33,37 @@ * Time value returned by kernel. */ +struct rpc_time_value { + /* TODO: this should be 64 bits regardless of the arch to be Y2038 proof. */ + rpc_long_integer_t seconds; + integer_t microseconds; +}; +typedef struct rpc_time_value rpc_time_value_t; + +/* + * Time value used by kernel. + */ struct time_value { - integer_t seconds; + long_integer_t seconds; integer_t microseconds; }; typedef struct time_value time_value_t; +/** + * Functions used by Mig to perform user to kernel conversion and vice-versa. + * We only do this because we may run a 64 bit kernel with a 32 bit user space. + */ +static inline rpc_time_value_t convert_time_value_to_user(time_value_t tv) +{ + rpc_time_value_t user = {.seconds = tv.seconds, .microseconds = tv.microseconds}; + return user; +} +static inline time_value_t convert_time_value_from_user(rpc_time_value_t tv) +{ + time_value_t kernel = {.seconds = tv.seconds, .microseconds = tv.microseconds}; + return kernel; +} + /* * Macros to manipulate time values. Assume that time values * are normalized (microseconds <= 999999). -- cgit v1.2.3