diff options
author | Flavio Cruz <flaviocruz@gmail.com> | 2022-12-06 00:35:01 -0500 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-12-06 21:26:19 +0100 |
commit | 2a7263559572f178322451a6a1e0a43dc90cdb32 (patch) | |
tree | beb008838cac227cc7844ac02067731a5ca3ef20 /i386/include | |
parent | 45afcc68979b700bdef1dc0e27ba79e0822b1c18 (diff) | |
download | gnumach-2a7263559572f178322451a6a1e0a43dc90cdb32.tar.gz gnumach-2a7263559572f178322451a6a1e0a43dc90cdb32.tar.bz2 gnumach-2a7263559572f178322451a6a1e0a43dc90cdb32.zip |
Make task_info.h structs more portable
Changed vm_size_t to rpc_size_t so that both userland and kernel agree
on the same size. Also changed the denominator for the maximum struct
sizes to be integer_t to match the other declarations.
Introduced long_natural_t and rpc_long_natural_t to represent large
counters. Replaced rpc_unsigned_long with rpc_long_natural_t.
Message-Id: <Y47UhaOzKnqhgYq4@reue>
Diffstat (limited to 'i386/include')
-rwxr-xr-x | i386/include/mach/i386/machine_types.defs | 35 | ||||
-rw-r--r-- | i386/include/mach/i386/vm_types.h | 26 |
2 files changed, 32 insertions, 29 deletions
diff --git a/i386/include/mach/i386/machine_types.defs b/i386/include/mach/i386/machine_types.defs index 0e94999b..f3de1e44 100755 --- a/i386/include/mach/i386/machine_types.defs +++ b/i386/include/mach/i386/machine_types.defs @@ -38,14 +38,10 @@ /* * A natural_t is the type for the native - * integer type, e.g. 32 or 64 or.. whatever - * register size the machine has. Unsigned, it is - * used for entities that might be either - * unsigned integers or pointers, and for - * type-casting between the two. - * For instance, the IPC system represents - * a port in user space as an integer and - * in kernel space as a pointer. + * unsigned integer type, usually 32 bits. It is suitable for + * most counters with a small chance of overflow. + * While historically natural_t was meant to be the same + * as a pointer, that is not the case here. */ type natural_t = uint32_t; @@ -59,17 +55,24 @@ type natural_t = uint32_t; type integer_t = int32_t; /* - * unsigned long for kernel <-> userland interfaces size depends on the architecture - * of both kernel and userland. + * A long_natural_t is a possibly larger unsigned integer type than natural_t. + * Should be used instead of natural_t when we want the data to be less subject + * to overflows. */ -#if defined(KERNEL) && defined(USER32) -type rpc_unsigned_long = uint32_t; -#else /* KERNEL and USER32 */ #if defined(__x86_64__) -type rpc_unsigned_long = uint64_t; -#else /* __x86_64__ */ -type rpc_unsigned_long = uint32_t; +type long_natural_t = uint64_t; +#else +type long_natural_t = uint32_t; #endif /* __x86_64__ */ + +/* + * long_natural_t for kernel <-> userland interfaces as the size depends on the + * architecture of both kernel and userland. + */ +#if defined(KERNEL) && defined(USER32) +type rpc_long_natural_t = uint32_t; +#else /* KERNEL and USER32 */ +type rpc_long_natural_t = long_natural_t; #endif /* KERNEL_SERVER and USER32 */ /* diff --git a/i386/include/mach/i386/vm_types.h b/i386/include/mach/i386/vm_types.h index 9daaa15e..a50665c8 100644 --- a/i386/include/mach/i386/vm_types.h +++ b/i386/include/mach/i386/vm_types.h @@ -45,18 +45,11 @@ /* * A natural_t is the type for the native - * integer type, e.g. 32 or 64 or.. whatever - * register size the machine has. Unsigned, it is - * used for entities that might be either - * unsigned integers or pointers, and for - * type-casting between the two. - * For instance, the IPC system represents - * a port in user space as an integer and - * in kernel space as a pointer. + * unsigned integer type, usually 32 bits. It is suitable for + * most counters with a small chance of overflow. + * While historically natural_t was meant to be the same + * as a pointer, that is not the case here. */ -#ifdef __x86_64__ -// unsigned long ? -#endif typedef unsigned int natural_t; /* @@ -69,6 +62,13 @@ typedef unsigned int natural_t; typedef int integer_t; /* + * A long_natural_t is a possibly larger unsigned integer type than natural_t. + * Should be used instead of natural_t when we want the data to be less subject + * to overflows. + */ +typedef unsigned long long_natural_t; + +/* * A vm_offset_t is a type-neutral pointer, * e.g. an offset into a virtual memory space. */ @@ -116,14 +116,14 @@ static inline __mach_uint32_t convert_vm_to_user(__mach_uint64_t kaddr) assert(kaddr <= 0xFFFFFFFF); return (__mach_uint32_t)kaddr; } -typedef __mach_uint32_t rpc_unsigned_long; +typedef __mach_uint32_t rpc_long_natural_t; #else /* MACH_KERNEL */ typedef vm_offset_t rpc_vm_address_t; typedef vm_offset_t rpc_vm_offset_t; typedef vm_size_t rpc_vm_size_t; #define convert_vm_to_user null_conversion #define convert_vm_from_user null_conversion -typedef unsigned long rpc_unsigned_long; +typedef long_natural_t rpc_long_natural_t; #endif /* MACH_KERNEL */ #endif /* __ASSEMBLER__ */ |