summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Cruz <flaviocruz@gmail.com>2023-02-19 18:11:05 -0500
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-02-27 23:16:34 +0100
commitd486384a2c027a69666a1f9392712ad3fecde2e7 (patch)
treeb5f67f379ca418583700a68a991f220c2567e49e
parentd69cf5529d3fdbbfd3d1d6b429a67f912e3c4f44 (diff)
Change complex_align_of to be sizeof(uintptr_t)
By using uintptr_t, we ensure that all 64 bit stubs are free of undefined behavior since we support up to 8-byte alignment. This works fine given that Mig will type check types that have higher alignment requirements through the use of _Static_assert. This even works for a 64 bit kernel / 32 bit user land since we can use mig64 to build stubs for the 8-byte aligned kernel stubs and existing 32 bit mig to build the old user side stubs. Pragma is no longer required as we take advantage of the compiler to drive the alignment and avoid undefined behavior. Message-Id: <Y/KsiXZKkq1q/D+3@jupiter.tail36e24.ts.net>
-rw-r--r--cpu.sym2
-rw-r--r--utils.c2
2 files changed, 1 insertions, 3 deletions
diff --git a/cpu.sym b/cpu.sym
index 39ae712..bee12f0 100644
--- a/cpu.sym
+++ b/cpu.sym
@@ -95,7 +95,7 @@ expr MACH_MSG_TYPE_POLYMORPHIC
/* Types used in interfaces */
-expr sizeof(natural_t) desired_complex_alignof
+expr sizeof(uintptr_t) desired_complex_alignof
expr sizeof(void*) sizeof_pointer
expr sizeof(char) sizeof_char
expr sizeof(short) sizeof_short
diff --git a/utils.c b/utils.c
index 000a47f..64ab496 100644
--- a/utils.c
+++ b/utils.c
@@ -347,12 +347,10 @@ void
WriteStructDecl(FILE *file, const argument_t *args, write_list_fn_t *func,
u_int mask, const char *name)
{
- fprintf(file, "#pragma pack(push,%d)\n", complex_alignof);
fprintf(file, "\ttypedef struct {\n");
fprintf(file, "\t\tmach_msg_header_t Head;\n");
WriteList(file, args, func, mask, "\n", "\n");
fprintf(file, "\t} %s;\n", name);
- fprintf(file, "#pragma pack(pop)\n");
fprintf(file, "\n");
}