summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Cruz <flaviocruz@gmail.com>2023-05-16 23:04:18 -0400
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-09-24 23:31:15 +0200
commitb5a567954ce3b4d236b7a2375a6a00f3a4a853e8 (patch)
tree56cc650be6577b1590dbeb0854a33dc557825ee5
parentd9a36da6d785844139d291b37f80fbe087b2b59e (diff)
Update code generation to handle the new 64 bit ABI
Mostly, we don't set the fields that do not exist and avoid type mismatching (like casting unsigned short to unsigned char for msgt_name). We also revamp type checking to compare mach_msg_type_t to uint64_t instead of just uint32_t as we now use the whole structure. Message-Id: <ZGREMgn19Zptc/Pf@jupiter.tail36e24.ts.net>
-rw-r--r--global.h2
-rw-r--r--utils.c27
2 files changed, 21 insertions, 8 deletions
diff --git a/global.h b/global.h
index 1b7be96..15e9876 100644
--- a/global.h
+++ b/global.h
@@ -70,6 +70,8 @@ extern size_t port_size;
extern size_t port_size_in_bits;
extern size_t complex_alignof;
+#define IS_64BIT_ABI (desired_complex_alignof == 8)
+
extern void more_global(void);
#ifndef NULL
diff --git a/utils.c b/utils.c
index 4835290..ec0f2d1 100644
--- a/utils.c
+++ b/utils.c
@@ -78,7 +78,7 @@ WriteBogusDefines(FILE *file)
fprintf(file, "#define BAD_TYPECHECK(type, check) mig_unlikely (({\\\n");
fprintf(file,
- " union { mach_msg_type_t t; uint32_t w; } _t, _c;\\\n");
+ " union { mach_msg_type_t t; uint%d_t w; } _t, _c;\\\n", desired_complex_alignof * 8);
fprintf(file,
" _t.t = *(type); _c.t = *(check);_t.w != _c.w; }))\n");
}
@@ -358,11 +358,21 @@ static void
WriteStaticLongDecl(FILE *file, const ipc_type_t *it,
dealloc_t dealloc, bool inname, identifier_t name)
{
+ const_string_t msgt_name = inname ? it->itInNameStr : it->itOutNameStr;
fprintf(file, "\tconst mach_msg_type_long_t %s = {\n", name);
fprintf(file, "\t\t.msgtl_header = {\n");
- fprintf(file, "\t\t\t.msgt_name =\t\t0,\n");
- fprintf(file, "\t\t\t.msgt_size =\t\t0,\n");
- fprintf(file, "\t\t\t.msgt_number =\t\t0,\n");
+ if (IS_64BIT_ABI) {
+ /* For the 64 bit ABI we don't really have mach_msg_type_long_t
+ * so we fill mach_msg_type_long_t just like mach_msg_type_t.
+ */
+ fprintf(file, "\t\t\t.msgt_name =\t\t(unsigned char) %s,\n", msgt_name);
+ fprintf(file, "\t\t\t.msgt_size =\t\t%d,\n", it->itSize);
+ fprintf(file, "\t\t\t.msgt_number =\t\t%d,\n", it->itNumber);
+ } else {
+ fprintf(file, "\t\t\t.msgt_name =\t\t0,\n");
+ fprintf(file, "\t\t\t.msgt_size =\t\t0,\n");
+ fprintf(file, "\t\t\t.msgt_number =\t\t0,\n");
+ }
fprintf(file, "\t\t\t.msgt_inline =\t\t%s,\n",
strbool(it->itInLine));
fprintf(file, "\t\t\t.msgt_longform =\t\tTRUE,\n");
@@ -370,10 +380,11 @@ WriteStaticLongDecl(FILE *file, const ipc_type_t *it,
strdealloc(dealloc));
fprintf(file, "\t\t\t.msgt_unused =\t\t0\n");
fprintf(file, "\t\t},\n");
- fprintf(file, "\t\t.msgtl_name =\t(unsigned short) %s,\n",
- inname ? it->itInNameStr : it->itOutNameStr);
- fprintf(file, "\t\t.msgtl_size =\t%d,\n", it->itSize);
- fprintf(file, "\t\t.msgtl_number =\t%d,\n", it->itNumber);
+ if (!IS_64BIT_ABI) {
+ fprintf(file, "\t\t.msgtl_name =\t(unsigned short) %s,\n", msgt_name);
+ fprintf(file, "\t\t.msgtl_size =\t%d,\n", it->itSize);
+ fprintf(file, "\t\t.msgtl_number =\t%d,\n", it->itNumber);
+ }
fprintf(file, "\t};\n");
}