Ruby: include/ruby/internal/arithmetic/intptr_t.h Source File

Ruby 4.0.6p0 (2026-07-14 revision 03b6d3f8898a28604fe6cb00eae3226b821168f4)

intptr_t.h
Go to the documentation of this file.
1#ifndef RBIMPL_ARITHMETIC_INTPTR_T_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_ARITHMETIC_INTPTR_T_H
23#include "ruby/internal/config.h"
24
25#ifdef HAVE_STDINT_H
26# include <stdint.h>
27#endif
28
29#include "ruby/internal/value.h"
30#include "ruby/internal/dllexport.h"
31
32#define rb_int_new rb_int2inum
33#define rb_uint_new rb_uint2inum
34
35// These definitions are same as fiddle/conversions.h
36#if SIZEOF_VOIDP <= SIZEOF_LONG
37# define PTR2NUM(x) (LONG2NUM((long)(x)))
38# define NUM2PTR(x) ((void*)(NUM2ULONG(x)))
39#elif SIZEOF_VOIDP <= SIZEOF_LONG_LONG
40# define PTR2NUM(x) (LL2NUM((LONG_LONG)(x)))
41# define NUM2PTR(x) ((void*)(NUM2ULL(x)))
42#else
43// should have been an error in ruby/internal/value.h
44# error Need integer for VALUE
45#endif
46
47 RBIMPL_SYMBOL_EXPORT_BEGIN()
48
49
57 VALUE rb_int2big(intptr_t i);
58
65 VALUE rb_int2inum(intptr_t i);
66
75 VALUE rb_uint2big(uintptr_t i);
76
83 VALUE rb_uint2inum(uintptr_t i);
84 RBIMPL_SYMBOL_EXPORT_END()
85
86#endif /* RBIMPL_ARITHMETIC_INTPTR_T_H */
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
rb_int2inum
VALUE rb_int2inum(intptr_t i)
Converts a C's intptr_t into an instance of rb_cInteger.
Definition bignum.c:3290
rb_uint2inum
VALUE rb_uint2inum(uintptr_t i)
Converts a C's uintptr_t into an instance of rb_cInteger.
Definition bignum.c:3283
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40