15 #include "ruby/internal/config.h"
19 #ifdef HAVE_INTRINSICS_H
20 # include <intrinsics.h>
26 #include "ruby/internal/abi.h"
54 #include "ruby/backward/2/inttypes.h"
55 #include "ruby/backward/2/limits.h"
67 #define USE_SYMBOL_AS_METHOD_NAME 1
90 #define FilePathValue(v) (RB_GC_GUARD(v) = rb_get_path(v))
105 #define FilePathStringValue(v) ((v) = rb_get_path(v))
108 #if defined(HAVE_BUILTIN___BUILTIN_CONSTANT_P) && defined(HAVE_STMT_AND_DECL_IN_EXPR)
109 # define rb_varargs_argc_check_runtime(argc, vargc) \
110 (((argc) <= (vargc)) ? (argc) : \
111 (rb_fatal("argc(%d) exceeds actual arguments(%d)", \
113 # define rb_varargs_argc_valid_p(argc, vargc) \
114 ((argc) == 0 ? (vargc) <= 1 : \
116 # if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
117 # ifdef HAVE_ATTRIBUTE_ERRORFUNC
118 ERRORFUNC((
" argument length doesn't match"),
int rb_varargs_bad_length(
int,
int));
120 # define rb_varargs_bad_length(argc, vargc) \
121 ((argc)/rb_varargs_argc_valid_p(argc, vargc))
123 # define rb_varargs_argc_check(argc, vargc) \
124 __builtin_choose_expr(__builtin_constant_p(argc), \
125 (rb_varargs_argc_valid_p(argc, vargc) ? (argc) : \
126 rb_varargs_bad_length(argc, vargc)), \
127 rb_varargs_argc_check_runtime(argc, vargc))
129 # define rb_varargs_argc_check(argc, vargc) \
130 rb_varargs_argc_check_runtime(argc, vargc)
212 #define HAVE_NATIVETHREAD
231 #define InitVM(ext) {void InitVM_##ext(void);InitVM_##ext();}
252 int ruby_snprintf(
char *str,
size_t n,
char const *fmt, ...);
273 int ruby_vsnprintf(
char *str,
size_t n,
char const *fmt, va_list ap);
386 #define rb_orig_errno errno
388 #define errno (*rb_errno_ptr())
394 #if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
396 #elif defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO) && defined(__OPTIMIZE__)
397 # define rb_yield_values(argc, ...) \
399 const int rb_yield_values_argc = (argc); \
400 const VALUE rb_yield_values_args[] = {__VA_ARGS__}; \
401 const int rb_yield_values_nargs = \
402 (int)(sizeof(rb_yield_values_args) / sizeof(VALUE)); \
404 rb_varargs_argc_check(rb_yield_values_argc, rb_yield_values_nargs), \
405 rb_yield_values_nargs ? rb_yield_values_args : NULL); \
408 # define rb_funcall(recv, mid, argc, ...) \
410 const int rb_funcall_argc = (argc); \
411 const VALUE rb_funcall_args[] = {__VA_ARGS__}; \
412 const int rb_funcall_nargs = \
413 (int)(sizeof(rb_funcall_args) / sizeof(VALUE)); \
414 rb_funcallv(recv, mid, \
415 rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
416 rb_funcall_nargs ? rb_funcall_args : NULL); \
421 #ifndef RUBY_DONT_SUBST
422 #include "ruby/subst.h"
425 #if !defined RUBY_EXPORT && !defined RUBY_NO_OLD_COMPATIBILITY
426 # include "ruby/backward.h"
Function overloads to issue warnings around ANYARGS.
Conversion between C's arithmetic types and Ruby's numeric types.
Defines ASSUME / RB_LIKELY / UNREACHABLE.
Core data structures, definitions and manipulations.
Our own, locale independent, character handling routines.
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Debugging and tracing APIs.
Defines enum ruby_fl_type.
Ruby-level global variables / constants, visible from C.
VALUE rb_equal(VALUE lhs, VALUE rhs)
This function is an optimised version of calling #==.
Defines RBIMPL_HAS_WARNING.
Declares rb_eval_string().
Registering values to the GC.
Creation and modification of Ruby methods.
Declares rb_define_variable().
Interpreter embedding APIs.
Creation and modification of Ruby modules.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Macro definitions used throughout the prism library.
VALUE rb_get_path(VALUE obj)
Converts an object to a path.
static int * rb_orig_errno_ptr(void)
Not sure if it is necessary for extension libraries but this is where the "bare" errno is located.
const char * rb_class2name(VALUE klass)
Queries the name of the passed class.
int * rb_errno_ptr(void)
The location of errno
const char * rb_obj_classname(VALUE obj)
Queries the name of the class of the passed object.
VALUE rb_require(const char *feature)
Identical to rb_require_string(), except it takes C's string instead of Ruby's.
void rb_p(VALUE obj)
Inspects an object.
int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap)
Identical to ruby_snprintf(), except it takes a va_list.
int rb_errno(void)
Identical to system errno.
void rb_errno_set(int err)
Set the errno.
#define errno
Ractor-aware version of errno.
VALUE rb_get_path_no_checksafe(VALUE)
int ruby_native_thread_p(void)
Queries if the thread which calls this function is a ruby's thread.
int ruby_snprintf(char *str, size_t n, char const *fmt,...)
Our own locale-insensitive version of snprintf(3).
Compile-time static implementation of rb_scan_args().
Defines enum ruby_special_consts.
uintptr_t VALUE
Type that represents a Ruby object.
Defines enum ruby_value_type.