From 8e5e86fc13732b60d2e4d14152d92db1f1ae73f9 Mon Sep 17 00:00:00 2001 From: Flavio Cruz Date: Tue, 7 Mar 2023 02:01:13 -0500 Subject: Align mach_msg_type_t and mach_msg_type_long_t with the same alignment as uintptr_t. With this change, any 64 bit code using the IPC subsystem without relying on MiG will work without any changes. We have a few examples of this inside gnumach but also in the Hurd servers. For example, in hurd/console/display.c typedef struct { mach_msg_header_t Head; mach_msg_type_t ticknoType; natural_t tickno; mach_msg_type_t changeType; file_changed_type_t change; mach_msg_type_t startType; loff_t start; mach_msg_type_t endType; loff_t end; } Request; This will now work correctly in 64 bits, without requiring any explicit padding. As a follow up, we can simplify mach_msg_type_long_t so that we only need an 8 byte structure where the second field will include the number of elements for the long form. This is already included in mach_msg_type_t as unused_msgtl_number. Message-Id: --- include/mach/message.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include/mach/message.h') diff --git a/include/mach/message.h b/include/mach/message.h index 22a17b03..0eab9d41 100644 --- a/include/mach/message.h +++ b/include/mach/message.h @@ -132,9 +132,6 @@ typedef unsigned int mach_msg_size_t; typedef natural_t mach_msg_seqno_t; typedef integer_t mach_msg_id_t; -/* Force 4-byte alignment to simplify how the kernel parses the messages */ -#pragma pack(push, 4) - /* full header structure, may have different size in user/kernel spaces */ typedef struct mach_msg_header { mach_msg_bits_t msgh_bits; @@ -232,16 +229,19 @@ typedef struct { msgt_longform : 1, msgt_deallocate : 1, msgt_unused : 1; -} mach_msg_type_t; +#ifdef __x86_64__ + /* TODO: We want to eventually use this in favor of mach_msg_type_long_t + * as it makes the mach_msg protocol require only mach_msg_type_t. */ + mach_msg_type_number_t unused_msgtl_number; +#endif +} __attribute__ ((aligned (__alignof__ (uintptr_t)))) mach_msg_type_t; typedef struct { mach_msg_type_t msgtl_header; unsigned short msgtl_name; unsigned short msgtl_size; natural_t msgtl_number; -} mach_msg_type_long_t; - -#pragma pack(pop) +} __attribute__ ((aligned (__alignof__ (uintptr_t)))) mach_msg_type_long_t; /* * Known values for the msgt_name field. -- cgit v1.2.3