diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2022-09-22 21:39:54 +0900 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2022-09-23 06:44:28 +0900 |
commit | dc5b536468f8def4ab808da57462aee6a99a6fe0 (patch) | |
tree | 0aebe23c3db5e8d61c0fbe247b8bc879022f1d31 /mjit_compiler.c | |
parent | 2ce1460c6504bfefab85814c175de684b3e40381 (diff) |
Bindgen offsetof struct and union with builtin
except for bit fields.
I made a risky assumption on leading bit fields and just gave up
non-leading bit fields for now. I'll change it to let C code access bit
fields later.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6418
Diffstat (limited to 'mjit_compiler.c')
-rw-r--r-- | mjit_compiler.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mjit_compiler.c b/mjit_compiler.c index 2b518feffd..5ed3aa5a68 100644 --- a/mjit_compiler.c +++ b/mjit_compiler.c @@ -164,6 +164,10 @@ has_cache_for_send(rb_execution_context_t *ec, VALUE self, VALUE cc_addr, VALUE extern bool rb_splat_or_kwargs_p(const struct rb_callinfo *restrict ci); +// An offsetof implementation that works for unnamed struct and union. +// Multiplying 8 for compatibility with libclang's offsetof. +#define OFFSETOF(ptr, member) RB_SIZE2NUM(((char *)&ptr.member - (char*)&ptr) * 8) + #define SIZEOF(type) RB_SIZE2NUM(sizeof(type)) #define SIGNED_TYPE_P(type) RBOOL((type)(-1) < (type)(0)) |