aboutsummaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-12-01 17:13:34 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-12-01 18:52:03 +0100
commit5a2d1fb4db65d847d5bc9ea1cf5192bd81d8c7e5 (patch)
treee2044877e7250a2b06b5b0a3877c1d485775a104 /utils.c
parent39857a9745cec89da08a2d1101495a32b3535e38 (diff)
downloadmig-5a2d1fb4db65d847d5bc9ea1cf5192bd81d8c7e5.tar.gz
mig-5a2d1fb4db65d847d5bc9ea1cf5192bd81d8c7e5.tar.bz2
mig-5a2d1fb4db65d847d5bc9ea1cf5192bd81d8c7e5.zip
Add static branch prediction to type checks
Annotate generated type checks with static branch prediction optimizing well-formed messages. * utils.c (WriteBogusDefines): Define `mig_unlikely' if not defined. * server.c: Use `mig_unlikely' in generated type checks. * user.c: Likewise.
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/utils.c b/utils.c
index 6c42bc3..396e743 100644
--- a/utils.c
+++ b/utils.c
@@ -60,6 +60,11 @@ WriteBogusDefines(FILE *file)
fprintf(file, "#endif\n");
fprintf(file, "\n");
+ fprintf(file, "#ifndef\tmig_unlikely\n");
+ fprintf(file, "#define\tmig_unlikely(X)\t__builtin_expect (!! (X), 0)\n");
+ fprintf(file, "#endif\n");
+ fprintf(file, "\n");
+
fprintf(file, "#ifndef\tTypeCheck\n");
fprintf(file, "#define\tTypeCheck 1\n");
fprintf(file, "#endif\n");
@@ -70,11 +75,11 @@ WriteBogusDefines(FILE *file)
fprintf(file, "#endif\n");
fprintf(file, "\n");
- fprintf(file, "#define BAD_TYPECHECK(type, check) ({\\\n");
+ fprintf(file, "#define BAD_TYPECHECK(type, check) mig_unlikely (({\\\n");
fprintf(file,
" union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\\\n");
fprintf(file,
- " _t.t = *(type); _c.t = *(check); _t.w != _c.w; })\n");
+ " _t.t = *(type); _c.t = *(check);_t.w != _c.w; }))\n");
}
void