bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH mig] Also align mach_msg_type_long_t to complex_alignof


From: Flavio Cruz
Subject: [PATCH mig] Also align mach_msg_type_long_t to complex_alignof
Date: Fri, 17 Feb 2023 00:51:04 -0500

This was a miss in the previous patch given that mach_msg_type_long_t is
12 bytes long so won't neatly align to 8 bytes.
---
 utils.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/utils.c b/utils.c
index f2f45f6..9af78e9 100644
--- a/utils.c
+++ b/utils.c
@@ -304,10 +304,14 @@ WriteFieldDeclPrim(FILE *file, const argument_t *arg,
 
     fprintf(file, "\t\tmach_msg_type_%st %s;\n",
            arg->argLongForm ? "long_" : "", arg->argTTName);
-    if (!arg->argLongForm && complex_alignof > sizeof_mach_msg_type_t) {
-        /* Pad mach_msg_type_t in case we need alignment by more than its 
size. */
-       fprintf(file, "\t\tchar %s_pad[%d];\n", arg->argTTName, complex_alignof 
- sizeof_mach_msg_type_t);
-    }
+       /* Pad mach_msg_type_t/mach_msg_type_long_t in case we need alignment 
by more than its size. */
+    if (!arg->argLongForm && sizeof_mach_msg_type_t % complex_alignof) {
+        fprintf(file, "\t\tchar %s_pad[%d];\n",
+                arg->argTTName, complex_alignof - sizeof_mach_msg_type_t % 
complex_alignof);
+    } else if (arg->argLongForm && sizeof_mach_msg_type_long_t % 
complex_alignof) {
+           fprintf(file, "\t\tchar %s_pad[%d];\n", arg->argTTName,
+                complex_alignof - sizeof_mach_msg_type_long_t % 
complex_alignof);
+       }
 
     if (it->itInLine && it->itVarArray)
     {
-- 
2.39.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]