mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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.
This commit is contained in:
parent
2ce1460c65
commit
dc5b536468
Notes:
git
2022-09-23 06:45:05 +09:00
3 changed files with 197 additions and 185 deletions
|
@ -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))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue