Ruby: include/ruby/internal/value.h Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

value.h
Go to the documentation of this file.
1#ifndef RBIMPL_VALUE_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_VALUE_H
23#include "ruby/internal/static_assert.h"
24#include "ruby/backward/2/long_long.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
93typedef uintptr_t VALUE;
94typedef 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
103typedef unsigned long VALUE;
104typedef 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
113typedef unsigned LONG_LONG VALUE;
114typedef 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 */
long_long.h
Defines old LONG_LONG.
LONG_LONG
#define LONG_LONG
Definition long_long.h:38
static_assert.h
Defines RBIMPL_STATIC_ASSERT.
RBIMPL_STATIC_ASSERT
#define RBIMPL_STATIC_ASSERT
Wraps (or simulates) static_assert
Definition static_assert.h:66
SIGNED_VALUE
intptr_t SIGNED_VALUE
A signed integer type that has the same width with VALUE.
Definition value.h:63
ID
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40