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

Ruby 3.4.9p82 (2026-03-11 revision 76cca827ab52ab1d346a728f068d5b8da3e2952b)

globals.h
Go to the documentation of this file.
1#ifndef RBIMPL_GLOBALS_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_GLOBALS_H
23#include "ruby/internal/attr/pure.h"
24#include "ruby/internal/dllexport.h"
25#include "ruby/internal/fl_type.h"
26#include "ruby/internal/special_consts.h"
27#include "ruby/internal/value.h"
28#include "ruby/internal/value_type.h"
29
44
45 RBIMPL_SYMBOL_EXPORT_BEGIN()
46
47
54#define RUBY_INTEGER_UNIFICATION 1
55
56 RUBY_EXTERN VALUE rb_mKernel;
57 RUBY_EXTERN VALUE rb_mComparable;
58 RUBY_EXTERN VALUE rb_mEnumerable;
59 RUBY_EXTERN VALUE rb_mErrno;
60 RUBY_EXTERN VALUE rb_mFileTest;
61 RUBY_EXTERN VALUE rb_mGC;
62 RUBY_EXTERN VALUE rb_mMath;
63 RUBY_EXTERN VALUE rb_mProcess;
64 RUBY_EXTERN VALUE rb_mWaitReadable;
65 RUBY_EXTERN VALUE rb_mWaitWritable;
66
67 RUBY_EXTERN VALUE rb_cBasicObject;
68 RUBY_EXTERN VALUE rb_cObject;
69 RUBY_EXTERN VALUE rb_cArray;
70 RUBY_EXTERN VALUE rb_cBinding;
71 RUBY_EXTERN VALUE rb_cClass;
72 RUBY_EXTERN VALUE rb_cDir;
73 RUBY_EXTERN VALUE rb_cEncoding;
74 RUBY_EXTERN VALUE rb_cEnumerator;
75 RUBY_EXTERN VALUE rb_cFalseClass;
76 RUBY_EXTERN VALUE rb_cFile;
77 RUBY_EXTERN VALUE rb_cComplex;
78 RUBY_EXTERN VALUE rb_cFloat;
79 RUBY_EXTERN VALUE rb_cHash;
80 RUBY_EXTERN VALUE rb_cIO;
81 RUBY_EXTERN VALUE rb_cInteger;
82 RUBY_EXTERN VALUE rb_cMatch;
83 RUBY_EXTERN VALUE rb_cMethod;
84 RUBY_EXTERN VALUE rb_cModule;
85 RUBY_EXTERN VALUE rb_cRefinement;
86 RUBY_EXTERN VALUE rb_cNameErrorMesg;
87 RUBY_EXTERN VALUE rb_cNilClass;
88 RUBY_EXTERN VALUE rb_cNumeric;
89 RUBY_EXTERN VALUE rb_cProc;
90 RUBY_EXTERN VALUE rb_cRandom;
91 RUBY_EXTERN VALUE rb_cRange;
92 RUBY_EXTERN VALUE rb_cRational;
93 RUBY_EXTERN VALUE rb_cRegexp;
94 RUBY_EXTERN VALUE rb_cStat;
95 RUBY_EXTERN VALUE rb_cString;
96 RUBY_EXTERN VALUE rb_cStruct;
97 RUBY_EXTERN VALUE rb_cSymbol;
98 RUBY_EXTERN VALUE rb_cThread;
99 RUBY_EXTERN VALUE rb_cTime;
100 RUBY_EXTERN VALUE rb_cTrueClass;
101 RUBY_EXTERN VALUE rb_cUnboundMethod;
102
108
109 RUBY_EXTERN VALUE rb_eException;
110 RUBY_EXTERN VALUE rb_eStandardError;
111 RUBY_EXTERN VALUE rb_eSystemExit;
112 RUBY_EXTERN VALUE rb_eInterrupt;
113 RUBY_EXTERN VALUE rb_eSignal;
114 RUBY_EXTERN VALUE rb_eFatal;
115 RUBY_EXTERN VALUE rb_eArgError;
116 RUBY_EXTERN VALUE rb_eEOFError;
117 RUBY_EXTERN VALUE rb_eIndexError;
118 RUBY_EXTERN VALUE rb_eStopIteration;
119 RUBY_EXTERN VALUE rb_eKeyError;
120 RUBY_EXTERN VALUE rb_eRangeError;
121 RUBY_EXTERN VALUE rb_eIOError;
122 RUBY_EXTERN VALUE rb_eRuntimeError;
123 RUBY_EXTERN VALUE rb_eFrozenError;
124 RUBY_EXTERN VALUE rb_eSecurityError;
125 RUBY_EXTERN VALUE rb_eSystemCallError;
126 RUBY_EXTERN VALUE rb_eThreadError;
127 RUBY_EXTERN VALUE rb_eTypeError;
128 RUBY_EXTERN VALUE rb_eZeroDivError;
129 RUBY_EXTERN VALUE rb_eNotImpError;
130 RUBY_EXTERN VALUE rb_eNoMemError;
131 RUBY_EXTERN VALUE rb_eNoMethodError;
132 RUBY_EXTERN VALUE rb_eFloatDomainError;
133 RUBY_EXTERN VALUE rb_eLocalJumpError;
134 RUBY_EXTERN VALUE rb_eSysStackError;
135 RUBY_EXTERN VALUE rb_eRegexpError;
136 RUBY_EXTERN VALUE rb_eEncodingError;
137 RUBY_EXTERN VALUE rb_eEncCompatError;
138 RUBY_EXTERN VALUE rb_eNoMatchingPatternError;
139 RUBY_EXTERN VALUE rb_eNoMatchingPatternKeyError;
140
141 RUBY_EXTERN VALUE rb_eScriptError;
142 RUBY_EXTERN VALUE rb_eNameError;
143 RUBY_EXTERN VALUE rb_eSyntaxError;
144 RUBY_EXTERN VALUE rb_eLoadError;
145
146 RUBY_EXTERN VALUE rb_eMathDomainError;
147
153
154 RUBY_EXTERN VALUE rb_stdin;
155 RUBY_EXTERN VALUE rb_stdout;
156 RUBY_EXTERN VALUE rb_stderr;
157
158 RBIMPL_ATTR_PURE()
171static inline VALUE
172rb_class_of(VALUE obj)
173{
174 if (! RB_SPECIAL_CONST_P(obj)) {
175 return RBASIC_CLASS(obj);
176 }
177 else if (obj == RUBY_Qfalse) {
178 return rb_cFalseClass;
179 }
180 else if (obj == RUBY_Qnil) {
181 return rb_cNilClass;
182 }
183 else if (obj == RUBY_Qtrue) {
184 return rb_cTrueClass;
185 }
186 else if (RB_FIXNUM_P(obj)) {
187 return rb_cInteger;
188 }
189 else if (RB_STATIC_SYM_P(obj)) {
190 return rb_cSymbol;
191 }
192 else if (RB_FLONUM_P(obj)) {
193 return rb_cFloat;
194 }
195
196#if !RUBY_DEBUG
197 RBIMPL_UNREACHABLE_RETURN(Qfalse);
198#else
199 RUBY_ASSERT_FAIL("unexpected type");
200#endif
201}
202
203#define CLASS_OF rb_class_of
204
205 RBIMPL_SYMBOL_EXPORT_END()
206
207
208
209#endif /* RBIMPL_GLOBALS_H */
dllexport.h
Tweaking visibility of C variables/functions.
RUBY_EXTERN
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition dllexport.h:45
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
fl_type.h
Defines enum ruby_fl_type.
Qfalse
#define Qfalse
Old name of RUBY_Qfalse.
Definition special_consts.h:59
rb_eLocalJumpError
VALUE rb_eLocalJumpError
LocalJumpError exception.
Definition eval.c:49
rb_eNotImpError
VALUE rb_eNotImpError
NotImplementedError exception.
Definition error.c:1440
rb_eScriptError
VALUE rb_eScriptError
ScriptError exception.
Definition error.c:1446
rb_eKeyError
VALUE rb_eKeyError
KeyError exception.
Definition error.c:1433
rb_cNameErrorMesg
VALUE rb_cNameErrorMesg
NameError::Message class.
Definition error.c:1442
rb_eSystemExit
VALUE rb_eSystemExit
SystemExit exception.
Definition error.c:1423
rb_eZeroDivError
VALUE rb_eZeroDivError
ZeroDivisionError exception.
Definition numeric.c:200
rb_eIOError
VALUE rb_eIOError
IOError exception.
Definition io.c:189
rb_eStandardError
VALUE rb_eStandardError
StandardError exception.
Definition error.c:1427
rb_mErrno
VALUE rb_mErrno
Errno module.
Definition error.c:1451
rb_eRegexpError
VALUE rb_eRegexpError
RegexpError exception.
Definition re.c:32
rb_eFrozenError
VALUE rb_eFrozenError
FrozenError exception.
Definition error.c:1429
rb_eNoMemError
VALUE rb_eNoMemError
NoMemoryError exception.
Definition error.c:1441
rb_eRangeError
VALUE rb_eRangeError
RangeError exception.
Definition error.c:1434
rb_eLoadError
VALUE rb_eLoadError
LoadError exception.
Definition error.c:1448
rb_eTypeError
VALUE rb_eTypeError
TypeError exception.
Definition error.c:1430
rb_eEOFError
VALUE rb_eEOFError
EOFError exception.
Definition io.c:188
rb_eNoMatchingPatternError
VALUE rb_eNoMatchingPatternError
NoMatchingPatternError exception.
Definition error.c:1443
rb_eEncCompatError
VALUE rb_eEncCompatError
Encoding::CompatibilityError exception.
Definition error.c:1437
rb_eFatal
VALUE rb_eFatal
fatal exception.
Definition error.c:1426
rb_eInterrupt
VALUE rb_eInterrupt
Interrupt exception.
Definition error.c:1424
rb_eNameError
VALUE rb_eNameError
NameError exception.
Definition error.c:1435
rb_eNoMethodError
VALUE rb_eNoMethodError
NoMethodError exception.
Definition error.c:1438
rb_eRuntimeError
VALUE rb_eRuntimeError
RuntimeError exception.
Definition error.c:1428
rb_eStopIteration
VALUE rb_eStopIteration
StopIteration exception.
Definition enumerator.c:182
rb_eFloatDomainError
VALUE rb_eFloatDomainError
FloatDomainError exception.
Definition numeric.c:201
rb_eNoMatchingPatternKeyError
VALUE rb_eNoMatchingPatternKeyError
NoMatchingPatternKeyError exception.
Definition error.c:1444
rb_eException
VALUE rb_eException
Mother of all exceptions.
Definition error.c:1422
rb_eIndexError
VALUE rb_eIndexError
IndexError exception.
Definition error.c:1432
rb_eSysStackError
VALUE rb_eSysStackError
SystemStackError exception.
Definition eval.c:50
rb_eSyntaxError
VALUE rb_eSyntaxError
SyntaxError exception.
Definition error.c:1447
rb_eEncodingError
VALUE rb_eEncodingError
EncodingError exception.
Definition error.c:1436
rb_eSecurityError
VALUE rb_eSecurityError
SecurityError exception.
Definition error.c:1439
rb_eThreadError
VALUE rb_eThreadError
ThreadError exception.
Definition eval.c:955
rb_eMathDomainError
VALUE rb_eMathDomainError
Math::DomainError exception.
Definition math.c:30
rb_eSystemCallError
VALUE rb_eSystemCallError
SystemCallError exception.
Definition error.c:1450
rb_eSignal
VALUE rb_eSignal
SignalException exception.
Definition error.c:1425
rb_cClass
VALUE rb_cClass
Class class.
Definition object.c:68
rb_cRational
VALUE rb_cRational
Rational class.
Definition rational.c:53
rb_cUnboundMethod
VALUE rb_cUnboundMethod
UnboundMethod class.
Definition proc.c:42
rb_cTime
VALUE rb_cTime
Time class.
Definition time.c:678
rb_cDir
VALUE rb_cDir
Dir class.
Definition dir.c:504
rb_mKernel
VALUE rb_mKernel
Kernel module.
Definition object.c:65
rb_cComplex
VALUE rb_cComplex
Complex class.
Definition complex.c:39
rb_cArray
VALUE rb_cArray
Array class.
Definition array.c:40
rb_mProcess
VALUE rb_mProcess
Process module.
Definition process.c:8825
rb_mMath
VALUE rb_mMath
Math module.
Definition math.c:29
rb_cIO
VALUE rb_cIO
IO class.
Definition io.c:187
rb_mEnumerable
VALUE rb_mEnumerable
Enumerable module.
Definition enum.c:27
rb_cMatch
VALUE rb_cMatch
MatchData class.
Definition re.c:967
rb_cStruct
VALUE rb_cStruct
Struct class.
Definition struct.c:33
rb_cEnumerator
VALUE rb_cEnumerator
Enumerator class.
Definition enumerator.c:164
rb_cRefinement
VALUE rb_cRefinement
Refinement class.
Definition object.c:69
rb_cInteger
VALUE rb_cInteger
Module class.
Definition numeric.c:198
rb_cNilClass
VALUE rb_cNilClass
NilClass class.
Definition object.c:71
rb_stdin
VALUE rb_stdin
STDIN constant.
Definition io.c:201
rb_cStat
VALUE rb_cStat
File::Stat class.
Definition file.c:177
rb_cBinding
VALUE rb_cBinding
Binding class.
Definition proc.c:44
rb_cRegexp
VALUE rb_cRegexp
Regexp class.
Definition re.c:2640
rb_mGC
VALUE rb_mGC
GC module.
Definition gc.c:431
rb_cHash
VALUE rb_cHash
Hash class.
Definition hash.c:113
rb_stderr
VALUE rb_stderr
STDERR constant.
Definition io.c:201
rb_cFalseClass
VALUE rb_cFalseClass
FalseClass class.
Definition object.c:73
rb_cNumeric
VALUE rb_cNumeric
Numeric class.
Definition numeric.c:196
rb_class_of
static VALUE rb_class_of(VALUE obj)
Object to class mapping function.
Definition globals.h:172
rb_cRandom
VALUE rb_cRandom
Random class.
Definition random.c:236
rb_cEncoding
VALUE rb_cEncoding
Encoding class.
Definition encoding.c:57
rb_cSymbol
VALUE rb_cSymbol
Symbol class.
Definition string.c:80
rb_cBasicObject
VALUE rb_cBasicObject
BasicObject class.
Definition object.c:64
rb_cThread
VALUE rb_cThread
Thread class.
Definition vm.c:544
rb_cModule
VALUE rb_cModule
Module class.
Definition object.c:67
rb_cRange
VALUE rb_cRange
Range class.
Definition range.c:31
rb_mFileTest
VALUE rb_mFileTest
FileTest module.
Definition file.c:176
rb_mWaitReadable
VALUE rb_mWaitReadable
IO::WaitReadable module.
Definition io.c:191
rb_mWaitWritable
VALUE rb_mWaitWritable
IO::WaitReadable module.
Definition io.c:192
rb_mComparable
VALUE rb_mComparable
Comparable module.
Definition compar.c:19
rb_cFloat
VALUE rb_cFloat
Float class.
Definition numeric.c:197
rb_cProc
VALUE rb_cProc
Proc class.
Definition proc.c:45
rb_cFile
VALUE rb_cFile
File class.
Definition file.c:175
rb_cTrueClass
VALUE rb_cTrueClass
TrueClass class.
Definition object.c:72
rb_stdout
VALUE rb_stdout
STDOUT constant.
Definition io.c:201
rb_cString
VALUE rb_cString
String class.
Definition string.c:79
rb_cMethod
VALUE rb_cMethod
Method class.
Definition proc.c:43
RBIMPL_UNREACHABLE_RETURN
#define RBIMPL_UNREACHABLE_RETURN(_)
Wraps (or simulates) __builtin_unreachable.
Definition assume.h:48
inline
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition defines.h:91
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure)).
Definition pure.h:33
RBASIC_CLASS
static VALUE RBASIC_CLASS(VALUE obj)
Queries the class of an object.
Definition rbasic.h:153
special_consts.h
Defines enum ruby_special_consts.
RB_STATIC_SYM_P
static bool RB_STATIC_SYM_P(VALUE obj)
Checks if the given object is a static symbol.
Definition special_consts.h:267
RB_FIXNUM_P
static bool RB_FIXNUM_P(VALUE obj)
Checks if the given object is a so-called Fixnum.
Definition special_consts.h:247
RB_SPECIAL_CONST_P
static bool RB_SPECIAL_CONST_P(VALUE obj)
Checks if the given object is of enum ruby_special_consts.
Definition special_consts.h:327
RUBY_Qtrue
@ RUBY_Qtrue
Definition special_consts.h:89
RUBY_Qnil
@ RUBY_Qnil
Definition special_consts.h:90
RUBY_Qfalse
@ RUBY_Qfalse
Definition special_consts.h:88
RB_FLONUM_P
static bool RB_FLONUM_P(VALUE obj)
Checks if the given object is a so-called Flonum.
Definition special_consts.h:288
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40
value_type.h
Defines enum ruby_value_type.