Ruby  3.4.0dev (2024-11-05 revision 348a53415339076afc4a02fcd09f3ae36e9c4c61)
value.h
Go to the documentation of this file.
1 #ifndef RBIMPL_VALUE_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_VALUE_H
25 #include "ruby/backward/2/limits.h"
26 
27 #if defined(__DOXYGEN__)
28 
40 typedef uintptr_t VALUE;
41 
52 typedef uintptr_t ID;
53 
63 typedef intptr_t SIGNED_VALUE;
64 
69 #define SIZEOF_VALUE SIZEOF_UINTPTR_T
70 
76 #define RBIMPL_VALUE_NULL UINTPTR_C(0)
77 
83 #define RBIMPL_VALUE_ONE UINTPTR_C(1)
84 
90 #define RBIMPL_VALUE_FULL UINTPTR_MAX
91 
92 #elif defined HAVE_UINTPTR_T && 0
93 typedef uintptr_t VALUE;
94 typedef uintptr_t ID;
95 # define SIGNED_VALUE intptr_t
96 # define SIZEOF_VALUE SIZEOF_UINTPTR_T
97 # undef PRI_VALUE_PREFIX
98 # define RBIMPL_VALUE_NULL UINTPTR_C(0)
99 # define RBIMPL_VALUE_ONE UINTPTR_C(1)
100 # define RBIMPL_VALUE_FULL UINTPTR_MAX
101 
102 #elif SIZEOF_LONG == SIZEOF_VOIDP
103 typedef unsigned long VALUE;
104 typedef unsigned long ID;
105 # define SIGNED_VALUE long
106 # define SIZEOF_VALUE SIZEOF_LONG
107 # define PRI_VALUE_PREFIX "l"
108 # define RBIMPL_VALUE_NULL 0UL
109 # define RBIMPL_VALUE_ONE 1UL
110 # define RBIMPL_VALUE_FULL ULONG_MAX
111 
112 #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
113 typedef unsigned LONG_LONG VALUE;
114 typedef unsigned LONG_LONG ID;
115 # define SIGNED_VALUE LONG_LONG
116 # define LONG_LONG_VALUE 1
117 # define SIZEOF_VALUE SIZEOF_LONG_LONG
118 # define PRI_VALUE_PREFIX PRI_LL_PREFIX
119 # define RBIMPL_VALUE_NULL 0ULL
120 # define RBIMPL_VALUE_ONE 1ULL
121 # define RBIMPL_VALUE_FULL ULLONG_MAX
122 
123 #else
124 # error ---->> ruby requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
125 #endif
126 
128 RBIMPL_STATIC_ASSERT(sizeof_int, SIZEOF_INT == sizeof(int));
129 RBIMPL_STATIC_ASSERT(sizeof_long, SIZEOF_LONG == sizeof(long));
130 RBIMPL_STATIC_ASSERT(sizeof_long_long, SIZEOF_LONG_LONG == sizeof(LONG_LONG));
131 RBIMPL_STATIC_ASSERT(sizeof_voidp, SIZEOF_VOIDP == sizeof(void *));
133 #endif /* RBIMPL_VALUE_H */
Defines old LONG_LONG.
#define LONG_LONG
Definition: long_long.h:38
Defines RBIMPL_STATIC_ASSERT.
#define RBIMPL_STATIC_ASSERT
Wraps (or simulates) static_assert
Definition: static_assert.h:66
intptr_t SIGNED_VALUE
A signed integer type that has the same width with VALUE.
Definition: value.h:63
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition: value.h:52
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40