diff options
author | Flavio Cruz <flaviocruz@gmail.com> | 2023-03-07 02:01:13 -0500 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-03-08 00:44:07 +0100 |
commit | 8e5e86fc13732b60d2e4d14152d92db1f1ae73f9 (patch) | |
tree | 07aacb1367209c143667ebaac6f838fcddad3e89 /include | |
parent | e52779eb879ea8a14bb293e97c989f52eb439cbb (diff) | |
download | gnumach-8e5e86fc13732b60d2e4d14152d92db1f1ae73f9.tar.gz gnumach-8e5e86fc13732b60d2e4d14152d92db1f1ae73f9.tar.bz2 gnumach-8e5e86fc13732b60d2e4d14152d92db1f1ae73f9.zip |
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: <ZAbhOfOzsb8qPFs6@jupiter.tail36e24.ts.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/mach/message.h | 14 |
1 files changed, 7 insertions, 7 deletions
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. |