From d30481122a5d24ad6b921062f93b9172ef922fc3 Mon Sep 17 00:00:00 2001 From: Flavio Cruz Date: Tue, 22 Nov 2022 23:46:31 -0500 Subject: Update mach_debug interfaces to use struct. The new interfaces will be compatible both with a 64 bits kernel and userland and 64 bits kernel and 32 bit userland. Also removed many of the uses of natural_t where an unsigned int suffices. Ideally we should replace natural_t with something more portable such as uintptr_t or a basic int type for counters since for the most part we don't need counters to have the same width as the pointer type. * i386/include/mach/i386/vm_types.h: Define rpc_unsigned_long. * include/mach/mach_types.defs: Define type rpc_vm_offset_t. * include/mach_debug/hash_info.h: Use unsigned int instead of natural_t. * include/mach_debug/mach_debug_types.defs: Update cache_info_t, hash_info_bucket_t, vm_region_info_t, vm_object_info_t and vm_page_info_t to use struct. * include/mach_debug/slab_info.h: Use rpc_vm_size_t and rpc_unsigned_long for compatibility with 32 bits userland. * include/mach_debug/vm_info.h: Update struct fields to use the correct types and avoid natural_t whenever we just want to keep a count of something. Message-Id: --- i386/include/mach/i386/machine_types.defs | 14 ++++++++++++++ i386/include/mach/i386/vm_types.h | 2 ++ 2 files changed, 16 insertions(+) (limited to 'i386') diff --git a/i386/include/mach/i386/machine_types.defs b/i386/include/mach/i386/machine_types.defs index dfbc521e..0e94999b 100755 --- a/i386/include/mach/i386/machine_types.defs +++ b/i386/include/mach/i386/machine_types.defs @@ -58,6 +58,20 @@ 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. + */ +#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; +#endif /* __x86_64__ */ +#endif /* KERNEL_SERVER and USER32 */ + /* * Physical address size */ diff --git a/i386/include/mach/i386/vm_types.h b/i386/include/mach/i386/vm_types.h index 7a43d75d..9daaa15e 100644 --- a/i386/include/mach/i386/vm_types.h +++ b/i386/include/mach/i386/vm_types.h @@ -116,12 +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; #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; #endif /* MACH_KERNEL */ #endif /* __ASSEMBLER__ */ -- cgit v1.2.3