diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-12-10 12:09:50 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-12-10 12:09:50 +0900 |
| commit | 3636277dc5837bcedcd5ef43d49423194064a676 (patch) | |
| tree | 8d50cad7d133de530580817345e3ec430464c4e0 /include/ruby/internal | |
| parent | 3bb97e7707a0be8c371cb9c704cb1e21062e1fc6 (diff) | |
Add `NUM2PTR` and `PTR2NUM` macros
These macros have been defined here and there, so collect them.
Diffstat (limited to 'include/ruby/internal')
| -rw-r--r-- | include/ruby/internal/arithmetic/intptr_t.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/ruby/internal/arithmetic/intptr_t.h b/include/ruby/internal/arithmetic/intptr_t.h index a354f4469c..70090f88e6 100644 --- a/include/ruby/internal/arithmetic/intptr_t.h +++ b/include/ruby/internal/arithmetic/intptr_t.h @@ -32,6 +32,18 @@ #define rb_int_new rb_int2inum /**< @alias{rb_int2inum} */ #define rb_uint_new rb_uint2inum /**< @alias{rb_uint2inum} */ +// These definitions are same as fiddle/conversions.h +#if SIZEOF_VOIDP <= SIZEOF_LONG +# define PTR2NUM(x) (LONG2NUM((long)(x))) +# define NUM2PTR(x) ((void*)(NUM2ULONG(x))) +#elif SIZEOF_VOIDP <= SIZEOF_LONG_LONG +# define PTR2NUM(x) (LL2NUM((LONG_LONG)(x))) +# define NUM2PTR(x) ((void*)(NUM2ULL(x))) +#else +// should have been an error in ruby/internal/value.h +# error Need integer for VALUE +#endif + RBIMPL_SYMBOL_EXPORT_BEGIN() /** |
