[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH mig] Update code generation to handle the new 64 bit ABI
From: |
Flavio Cruz |
Subject: |
[PATCH mig] Update code generation to handle the new 64 bit ABI |
Date: |
Tue, 16 May 2023 23:04:18 -0400 |
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.
---
global.h | 2 ++
utils.c | 27 +++++++++++++++++++--------
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/global.h b/global.h
index e3d42dd..11e772e 100644
--- a/global.h
+++ b/global.h
@@ -71,6 +71,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 6d6bb9e..6198144 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");
}
--
2.39.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH mig] Update code generation to handle the new 64 bit ABI,
Flavio Cruz <=