diff options
author | Flavio Cruz <flaviocruz@gmail.com> | 2022-12-16 21:06:25 -0500 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-12-17 03:23:52 +0100 |
commit | e493c4e8c54ece41bd24b209cfb9efc24254214b (patch) | |
tree | e2d22783de731d40126bb76a35ac0d90e8ae1c0a /include | |
parent | c00d8d62878434e82b04d5ad5901f938d120debf (diff) | |
download | gnumach-e493c4e8c54ece41bd24b209cfb9efc24254214b.tar.gz gnumach-e493c4e8c54ece41bd24b209cfb9efc24254214b.tar.bz2 gnumach-e493c4e8c54ece41bd24b209cfb9efc24254214b.zip |
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: <Y50kIaIgaIdGjDAk@mars>
Diffstat (limited to 'include')
-rw-r--r-- | include/mach/mach_types.defs | 13 | ||||
-rw-r--r-- | include/mach/time_value.h | 27 |
2 files changed, 38 insertions, 2 deletions
diff --git a/include/mach/mach_types.defs b/include/mach/mach_types.defs index 74b85232..da74a3f2 100644 --- a/include/mach/mach_types.defs +++ b/include/mach/mach_types.defs @@ -261,7 +261,18 @@ type kernel_version_t = (MACH_MSG_TYPE_STRING, 512*8); type kernel_boot_info_t = (MACH_MSG_TYPE_STRING, 4096*8); -type time_value_t = struct[2] of integer_t; +type rpc_time_value_t = struct { + rpc_long_integer_t seconds; + integer_t microseconds; +}; +type time_value_t = rpc_time_value_t +#if defined(KERNEL_SERVER) + intran: time_value_t convert_time_value_from_user(rpc_time_value_t) + outtran: rpc_time_value_t convert_time_value_to_user(time_value_t) +#elif defined(KERNEL_USER) + ctype: rpc_time_value_t +#endif + ; type emulation_vector_t = ^array[] of vm_offset_t; 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). |