mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix integer casting on 64 bit platforms.
On platforms where `sizeof(long)` is 4, casting `(long)` can lose data or sign information.
This commit is contained in:
@@ -52,9 +52,9 @@ enum mrb_special_consts {
|
||||
#define BOXWORD_IMMEDIATE_MASK 0x07
|
||||
|
||||
#define BOXWORD_SHIFT_VALUE(o,n,t) \
|
||||
(t)(((long)(o)) >> BOXWORD_##n##_SHIFT)
|
||||
(t)(((intptr_t)(o)) >> BOXWORD_##n##_SHIFT)
|
||||
#define BOXWORD_SET_SHIFT_VALUE(o,n,v) \
|
||||
((o) = (((unsigned long)(v)) << BOXWORD_##n##_SHIFT) | BOXWORD_##n##_FLAG)
|
||||
((o) = (((uintptr_t)(v)) << BOXWORD_##n##_SHIFT) | BOXWORD_##n##_FLAG)
|
||||
#define BOXWORD_SHIFT_VALUE_P(o,n) \
|
||||
(((o) & BOXWORD_##n##_MASK) == BOXWORD_##n##_FLAG)
|
||||
#define BOXWORD_OBJ_TYPE_P(o,n) \
|
||||
|
||||
Reference in New Issue
Block a user