diff options
Diffstat (limited to 'include/ruby/ruby.h')
| -rw-r--r-- | include/ruby/ruby.h | 610 |
1 files changed, 150 insertions, 460 deletions
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 1ce73d5559..56b773b380 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -27,14 +27,6 @@ extern "C" { #endif #include "defines.h" -#include "ruby/assert.h" - -/* For MinGW, we need __declspec(dllimport) for RUBY_EXTERN on MJIT. - mswin's RUBY_EXTERN already has that. See also: win32/Makefile.sub */ -#if defined(MJIT_HEADER) && defined(_WIN32) && defined(__GNUC__) -# undef RUBY_EXTERN -# define RUBY_EXTERN extern __declspec(dllimport) -#endif #if defined(__cplusplus) /* __builtin_choose_expr and __builtin_types_compatible aren't available @@ -52,13 +44,6 @@ extern "C" { # define ASSUME(x) ((void)(x)) # endif #endif -#ifndef UNREACHABLE_RETURN -# ifdef UNREACHABLE -# define UNREACHABLE_RETURN(val) UNREACHABLE -# else -# define UNREACHABLE_RETURN(val) return (val) -# endif -#endif #ifndef UNREACHABLE # define UNREACHABLE ((void)0) /* unreachable */ #endif @@ -128,26 +113,12 @@ typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1]; #ifndef PRI_LONG_PREFIX #define PRI_LONG_PREFIX "l" #endif -#ifndef PRI_SHORT_PREFIX -#define PRI_SHORT_PREFIX "h" -#endif -#ifndef PRI_64_PREFIX #if SIZEOF_LONG == 8 #define PRI_64_PREFIX PRI_LONG_PREFIX #elif SIZEOF_LONG_LONG == 8 #define PRI_64_PREFIX PRI_LL_PREFIX #endif -#endif - -#ifndef PRIdPTR -#define PRIdPTR PRI_PTR_PREFIX"d" -#define PRIiPTR PRI_PTR_PREFIX"i" -#define PRIoPTR PRI_PTR_PREFIX"o" -#define PRIuPTR PRI_PTR_PREFIX"u" -#define PRIxPTR PRI_PTR_PREFIX"x" -#define PRIXPTR PRI_PTR_PREFIX"X" -#endif #define RUBY_PRI_VALUE_MARK "\v" #if defined PRIdPTR && !defined PRI_VALUE_PREFIX @@ -264,10 +235,10 @@ typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1]; #define RB_LONG2FIX(i) RB_INT2FIX(i) #define LONG2FIX(i) RB_INT2FIX(i) #define rb_fix_new(v) RB_INT2FIX(v) -VALUE rb_int2inum(intptr_t); +VALUE rb_int2inum(SIGNED_VALUE); #define rb_int_new(v) rb_int2inum(v) -VALUE rb_uint2inum(uintptr_t); +VALUE rb_uint2inum(VALUE); #define rb_uint_new(v) rb_uint2inum(v) @@ -513,7 +484,6 @@ enum ruby_value_type { RUBY_T_NODE = 0x1b, RUBY_T_ICLASS = 0x1c, RUBY_T_ZOMBIE = 0x1d, - RUBY_T_MOVED = 0x1e, RUBY_T_MASK = 0x1f }; @@ -544,7 +514,6 @@ enum ruby_value_type { #define T_UNDEF RUBY_T_UNDEF #define T_NODE RUBY_T_NODE #define T_ZOMBIE RUBY_T_ZOMBIE -#define T_MOVED RUBY_T_MOVED #define T_MASK RUBY_T_MASK #define RB_BUILTIN_TYPE(x) (int)(((struct RBasic*)(x))->flags & RUBY_T_MASK) @@ -604,18 +573,21 @@ char *rb_string_value_cstr(volatile VALUE*); #define StringValueCStr(v) rb_string_value_cstr(&(v)) void rb_check_safe_obj(VALUE); -#define SafeStringValue(v) StringValue(v) +#define SafeStringValue(v) do {\ + StringValue(v);\ + rb_check_safe_obj(v);\ +} while (0) #if GCC_VERSION_SINCE(4,4,0) -void rb_check_safe_str(VALUE) __attribute__((error("rb_check_safe_str() and Check_SafeStr() are obsolete; use StringValue() instead"))); +void rb_check_safe_str(VALUE) __attribute__((error("rb_check_safe_str() and Check_SafeStr() are obsolete; use SafeStringValue() instead"))); # define Check_SafeStr(v) rb_check_safe_str((VALUE)(v)) #else -# define rb_check_safe_str(x) [<"rb_check_safe_str() is obsolete; use StringValue() instead">] -# define Check_SafeStr(v) [<"Check_SafeStr() is obsolete; use StringValue() instead">] +# define rb_check_safe_str(x) [<"rb_check_safe_str() is obsolete; use SafeStringValue() instead">] +# define Check_SafeStr(v) [<"Check_SafeStr() is obsolete; use SafeStringValue() instead">] #endif VALUE rb_str_export(VALUE); #define ExportStringValue(v) do {\ - StringValue(v);\ + SafeStringValue(v);\ (v) = rb_str_export(v);\ } while (0) VALUE rb_str_export_locale(VALUE); @@ -624,9 +596,8 @@ VALUE rb_get_path(VALUE); #define FilePathValue(v) (RB_GC_GUARD(v) = rb_get_path(v)) VALUE rb_get_path_no_checksafe(VALUE); -#define FilePathStringValue(v) ((v) = rb_get_path(v)) +#define FilePathStringValue(v) ((v) = rb_get_path_no_checksafe(v)) -/* Remove in 3.0 */ #define RUBY_SAFE_LEVEL_MAX 1 void rb_secure(int); int rb_safe_level(void); @@ -773,8 +744,8 @@ rb_num2ll_inline(VALUE x) double rb_num2dbl(VALUE); #define NUM2DBL(x) rb_num2dbl((VALUE)(x)) -VALUE rb_uint2big(uintptr_t); -VALUE rb_int2big(intptr_t); +VALUE rb_uint2big(VALUE); +VALUE rb_int2big(SIGNED_VALUE); VALUE rb_newobj(void); VALUE rb_newobj_of(VALUE, VALUE); @@ -846,7 +817,6 @@ enum ruby_fl_type { RUBY_FL_FINALIZE = (1<<7), RUBY_FL_TAINT = (1<<8), RUBY_FL_UNTRUSTED = RUBY_FL_TAINT, - RUBY_FL_SEEN_OBJ_ID = (1<<9), RUBY_FL_EXIVAR = (1<<10), RUBY_FL_FREEZE = (1<<11), @@ -883,10 +853,14 @@ enum ruby_fl_type { RUBY_FL_SINGLETON = RUBY_FL_USER0 }; -struct RUBY_ALIGNAS(SIZEOF_VALUE) RBasic { +struct RBasic { VALUE flags; const VALUE klass; -}; +} +#ifdef __GNUC__ + __attribute__((aligned(sizeof(VALUE)))) +#endif +; VALUE rb_obj_hide(VALUE obj); VALUE rb_obj_reveal(VALUE obj, VALUE klass); /* do not use this API to change klass information */ @@ -905,15 +879,10 @@ VALUE rb_obj_reveal(VALUE obj, VALUE klass); /* do not use this API to change kl #define RBASIC_CLASS(obj) (RBASIC(obj)->klass) -#define RVALUE_EMBED_LEN_MAX RVALUE_EMBED_LEN_MAX -enum ruby_rvalue_flags { - RVALUE_EMBED_LEN_MAX = 3, -}; - #define ROBJECT_EMBED_LEN_MAX ROBJECT_EMBED_LEN_MAX #define ROBJECT_EMBED ROBJECT_EMBED enum ruby_robject_flags { - ROBJECT_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX, + ROBJECT_EMBED_LEN_MAX = 3, ROBJECT_EMBED = RUBY_FL_USER1, ROBJECT_ENUM_END @@ -979,12 +948,11 @@ enum ruby_rstring_flags { RSTRING_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4| RUBY_FL_USER5|RUBY_FL_USER6), RSTRING_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+2), - RSTRING_EMBED_LEN_MAX = (int)((sizeof(VALUE)*RVALUE_EMBED_LEN_MAX)/sizeof(char)-1), + RSTRING_EMBED_LEN_MAX = (int)((sizeof(VALUE)*3)/sizeof(char)-1), RSTRING_FSTR = RUBY_FL_USER17, RSTRING_ENUM_END }; - struct RString { struct RBasic basic; union { @@ -1020,31 +988,19 @@ struct RString { ((ptrvar) = RSTRING(str)->as.ary, (lenvar) = RSTRING_EMBED_LEN(str)) : \ ((ptrvar) = RSTRING(str)->as.heap.ptr, (lenvar) = RSTRING(str)->as.heap.len)) -#ifndef USE_TRANSIENT_HEAP -#define USE_TRANSIENT_HEAP 1 -#endif - enum ruby_rarray_flags { - RARRAY_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX, + RARRAY_EMBED_LEN_MAX = 3, RARRAY_EMBED_FLAG = RUBY_FL_USER1, /* RUBY_FL_USER2 is for ELTS_SHARED */ RARRAY_EMBED_LEN_MASK = (RUBY_FL_USER4|RUBY_FL_USER3), RARRAY_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+3), -#if USE_TRANSIENT_HEAP - RARRAY_TRANSIENT_FLAG = RUBY_FL_USER13, -#define RARRAY_TRANSIENT_FLAG RARRAY_TRANSIENT_FLAG -#else -#define RARRAY_TRANSIENT_FLAG 0 -#endif - RARRAY_ENUM_END }; #define RARRAY_EMBED_FLAG (VALUE)RARRAY_EMBED_FLAG #define RARRAY_EMBED_LEN_MASK (VALUE)RARRAY_EMBED_LEN_MASK #define RARRAY_EMBED_LEN_MAX RARRAY_EMBED_LEN_MAX #define RARRAY_EMBED_LEN_SHIFT RARRAY_EMBED_LEN_SHIFT - struct RArray { struct RBasic basic; union { @@ -1052,12 +1008,7 @@ struct RArray { long len; union { long capa; -#if defined(__clang__) /* <- clang++ is sane */ || \ - !defined(__cplusplus) /* <- C99 is sane */ || \ - (__cplusplus > 199711L) /* <- C++11 is sane */ - const -#endif - VALUE shared_root; + VALUE shared; } aux; const VALUE *ptr; } heap; @@ -1070,26 +1021,9 @@ struct RArray { #define RARRAY_LEN(a) rb_array_len(a) #define RARRAY_LENINT(ary) rb_long2int(RARRAY_LEN(ary)) #define RARRAY_CONST_PTR(a) rb_array_const_ptr(a) -#define RARRAY_CONST_PTR_TRANSIENT(a) rb_array_const_ptr_transient(a) -#if USE_TRANSIENT_HEAP -#define RARRAY_TRANSIENT_P(ary) FL_TEST_RAW((ary), RARRAY_TRANSIENT_FLAG) -#else -#define RARRAY_TRANSIENT_P(ary) 0 -#endif - -#define RARRAY_PTR_USE_START_TRANSIENT(a) rb_array_ptr_use_start(a, 1) -#define RARRAY_PTR_USE_END_TRANSIENT(a) rb_array_ptr_use_end(a, 1) - -#define RARRAY_PTR_USE_TRANSIENT(ary, ptr_name, expr) do { \ - const VALUE _ary = (ary); \ - VALUE *ptr_name = (VALUE *)RARRAY_PTR_USE_START_TRANSIENT(_ary); \ - expr; \ - RARRAY_PTR_USE_END_TRANSIENT(_ary); \ -} while (0) - -#define RARRAY_PTR_USE_START(a) rb_array_ptr_use_start(a, 0) -#define RARRAY_PTR_USE_END(a) rb_array_ptr_use_end(a, 0) +#define RARRAY_PTR_USE_START(a) ((VALUE *)RARRAY_CONST_PTR(a)) +#define RARRAY_PTR_USE_END(a) /* */ #define RARRAY_PTR_USE(ary, ptr_name, expr) do { \ const VALUE _ary = (ary); \ @@ -1098,13 +1032,12 @@ struct RArray { RARRAY_PTR_USE_END(_ary); \ } while (0) -#define RARRAY_AREF(a, i) (RARRAY_CONST_PTR_TRANSIENT(a)[i]) +#define RARRAY_AREF(a, i) (RARRAY_CONST_PTR(a)[i]) #define RARRAY_ASET(a, i, v) do { \ const VALUE _ary = (a); \ - const VALUE _v = (v); \ - VALUE *ptr = (VALUE *)RARRAY_PTR_USE_START_TRANSIENT(_ary); \ - RB_OBJ_WRITE(_ary, &ptr[i], _v); \ - RARRAY_PTR_USE_END_TRANSIENT(_ary); \ + VALUE *ptr = (VALUE *)RARRAY_PTR_USE_START(_ary); \ + RB_OBJ_WRITE(_ary, &ptr[i], (v)); \ + RARRAY_PTR_USE_END(_ary); \ } while (0) #define RARRAY_PTR(a) ((VALUE *)RARRAY_CONST_PTR(RB_OBJ_WB_UNPROTECT_FOR(ARRAY, a))) @@ -1121,13 +1054,11 @@ struct RRegexp { #define RREGEXP_SRC_LEN(r) RSTRING_LEN(RREGEXP(r)->src) #define RREGEXP_SRC_END(r) RSTRING_END(RREGEXP(r)->src) -/* RHash is defined at internal.h */ -size_t rb_hash_size_num(VALUE hash); - -#define RHASH_TBL(h) rb_hash_tbl(h, __FILE__, __LINE__) +/* RHASH_TBL allocates st_table if not available. */ +#define RHASH_TBL(h) rb_hash_tbl(h) #define RHASH_ITER_LEV(h) rb_hash_iter_lev(h) #define RHASH_IFNONE(h) rb_hash_ifnone(h) -#define RHASH_SIZE(h) rb_hash_size_num(h) +#define RHASH_SIZE(h) NUM2SIZET(rb_hash_size(h)) #define RHASH_EMPTY_P(h) (RHASH_SIZE(h) == 0) #define RHASH_SET_IFNONE(h, ifnone) rb_hash_set_ifnone((VALUE)h, ifnone) @@ -1136,6 +1067,9 @@ struct RFile { struct rb_io_t *fptr; }; +#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r)) +#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i)) + struct RData { struct RBasic basic; void (*dmark)(void*); @@ -1151,8 +1085,7 @@ struct rb_data_type_struct { void (*dmark)(void*); void (*dfree)(void*); size_t (*dsize)(const void *); - void (*dcompact)(void*); - void *reserved[1]; /* For future extension. + void *reserved[2]; /* For future extension. This array *must* be filled with ZERO. */ } function; const rb_data_type_t *parent; @@ -1263,7 +1196,6 @@ int rb_big_sign(VALUE); #define RBIGNUM_NEGATIVE_P(b) (RBIGNUM_SIGN(b)==0) #define R_CAST(st) (struct st*) -#define RMOVED(obj) (R_CAST(RMoved)(obj)) #define RBASIC(obj) (R_CAST(RBasic)(obj)) #define ROBJECT(obj) (R_CAST(RObject)(obj)) #define RCLASS(obj) (R_CAST(RClass)(obj)) @@ -1282,7 +1214,6 @@ int rb_big_sign(VALUE); #define FL_FINALIZE ((VALUE)RUBY_FL_FINALIZE) #define FL_TAINT ((VALUE)RUBY_FL_TAINT) #define FL_UNTRUSTED ((VALUE)RUBY_FL_UNTRUSTED) -#define FL_SEEN_OBJ_ID ((VALUE)RUBY_FL_SEEN_OBJ_ID) #define FL_EXIVAR ((VALUE)RUBY_FL_EXIVAR) #define FL_FREEZE ((VALUE)RUBY_FL_FREEZE) @@ -1307,7 +1238,7 @@ int rb_big_sign(VALUE); #define FL_USER16 ((VALUE)RUBY_FL_USER16) #define FL_USER17 ((VALUE)RUBY_FL_USER17) #define FL_USER18 ((VALUE)RUBY_FL_USER18) -#define FL_USER19 ((VALUE)(unsigned int)RUBY_FL_USER19) +#define FL_USER19 ((VALUE)RUBY_FL_USER19) #define RB_SPECIAL_CONST_P(x) (RB_IMMEDIATE_P(x) || !RB_TEST(x)) #define SPECIAL_CONST_P(x) RB_SPECIAL_CONST_P(x) @@ -1643,7 +1574,6 @@ rb_num2char_inline(VALUE x) #define LONG2NUM(x) RB_LONG2NUM(x) #define ULONG2NUM(x) RB_ULONG2NUM(x) -#define USHORT2NUM(x) RB_INT2FIX(x) #define NUM2CHR(x) RB_NUM2CHR(x) #define CHR2FIX(x) RB_CHR2FIX(x) @@ -1666,23 +1596,7 @@ rb_num2char_inline(VALUE x) #define ZALLOC(type) RB_ZALLOC(type) #define REALLOC_N(var,type,n) RB_REALLOC_N(var,type,n) -#if GCC_VERSION_BEFORE(4,9,5) -/* GCC 4.9.2 reportedly has this feature and is broken. - * The function is not officially documented below. - * Seems we should not use it. - * https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/Other-Builtins.html#Other-Builtins */ -# undef HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN -#endif - -#if defined(HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN) && defined(RUBY_ALIGNOF) -/* I don't know why but __builtin_alloca_with_align's second argument - takes bits rather than bytes. */ -#define ALLOCA_N(type, n) \ - (type*)__builtin_alloca_with_align((sizeof(type)*(n)), \ - RUBY_ALIGNOF(type) * CHAR_BIT) -#else #define ALLOCA_N(type,n) ((type*)alloca(sizeof(type)*(n))) -#endif void *rb_alloc_tmp_buffer(volatile VALUE *store, long len) RUBY_ATTR_ALLOC_SIZE((2)); void *rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t len,size_t count) RUBY_ATTR_ALLOC_SIZE((2,3)); @@ -1736,11 +1650,11 @@ rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize) #else # define RUBY_ALLOCV_LIMIT 1024 # define RB_ALLOCV(v, n) ((n) < RUBY_ALLOCV_LIMIT ? \ - ((v) = 0, alloca(n)) : \ + (RB_GC_GUARD(v) = 0, alloca(n)) : \ rb_alloc_tmp_buffer(&(v), (n))) # define RB_ALLOCV_N(type, v, n) \ ((type*)(((size_t)(n) < RUBY_ALLOCV_LIMIT / sizeof(type)) ? \ - ((v) = 0, alloca((size_t)(n) * sizeof(type))) : \ + (RB_GC_GUARD(v) = 0, alloca((size_t)(n) * sizeof(type))) : \ rb_alloc_tmp_buffer2(&(v), (long)(n), sizeof(type)))) #endif #define RB_ALLOCV_END(v) rb_free_tmp_buffer(&(v)) @@ -1753,15 +1667,6 @@ rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize) #define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(size_t)(n)) #define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(size_t)(n)) #define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(size_t)(n)) -#ifdef __GLIBC__ -static inline void * -ruby_nonempty_memcpy(void *dest, const void *src, size_t n) -{ - /* if nothing to be copied, src may be NULL */ - return (n ? memcpy(dest, src, n) : dest); -} -#define memcpy(p1,p2,n) ruby_nonempty_memcpy(p1, p2, n) -#endif void rb_obj_infect(VALUE victim, VALUE carrier); @@ -1779,31 +1684,34 @@ void rb_include_module(VALUE,VALUE); void rb_extend_object(VALUE,VALUE); void rb_prepend_module(VALUE,VALUE); -typedef VALUE rb_gvar_getter_t(ID id, VALUE *data); -typedef void rb_gvar_setter_t(VALUE val, ID id, VALUE *data); +struct rb_global_variable; + +typedef VALUE rb_gvar_getter_t(ID id, void *data, struct rb_global_variable *gvar); +typedef void rb_gvar_setter_t(VALUE val, ID id, void *data, struct rb_global_variable *gvar); typedef void rb_gvar_marker_t(VALUE *var); -rb_gvar_getter_t rb_gvar_undef_getter; -rb_gvar_setter_t rb_gvar_undef_setter; -rb_gvar_marker_t rb_gvar_undef_marker; +VALUE rb_gvar_undef_getter(ID id, void *data, struct rb_global_variable *gvar); +void rb_gvar_undef_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar); +void rb_gvar_undef_marker(VALUE *var); -rb_gvar_getter_t rb_gvar_val_getter; -rb_gvar_setter_t rb_gvar_val_setter; -rb_gvar_marker_t rb_gvar_val_marker; +VALUE rb_gvar_val_getter(ID id, void *data, struct rb_global_variable *gvar); +void rb_gvar_val_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar); +void rb_gvar_val_marker(VALUE *var); -rb_gvar_getter_t rb_gvar_var_getter; -rb_gvar_setter_t rb_gvar_var_setter; -rb_gvar_marker_t rb_gvar_var_marker; +VALUE rb_gvar_var_getter(ID id, void *data, struct rb_global_variable *gvar); +void rb_gvar_var_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar); +void rb_gvar_var_marker(VALUE *var); -NORETURN(rb_gvar_setter_t rb_gvar_readonly_setter); +NORETURN(void rb_gvar_readonly_setter(VALUE val, ID id, void *data, struct rb_global_variable *gvar)); void rb_define_variable(const char*,VALUE*); -void rb_define_virtual_variable(const char*,rb_gvar_getter_t*,rb_gvar_setter_t*); -void rb_define_hooked_variable(const char*,VALUE*,rb_gvar_getter_t*,rb_gvar_setter_t*); +void rb_define_virtual_variable(const char*,VALUE(*)(ANYARGS),void(*)(ANYARGS)); +void rb_define_hooked_variable(const char*,VALUE*,VALUE(*)(ANYARGS),void(*)(ANYARGS)); void rb_define_readonly_variable(const char*,const VALUE*); void rb_define_const(VALUE,const char*,VALUE); void rb_define_global_const(const char*,VALUE); +#define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))(func)) void rb_define_method(VALUE,const char*,VALUE(*)(ANYARGS),int); void rb_define_module_function(VALUE,const char*,VALUE(*)(ANYARGS),int); void rb_define_global_function(const char*,VALUE(*)(ANYARGS),int); @@ -1839,7 +1747,7 @@ VALUE rb_check_symbol(volatile VALUE *namep); do RUBY_CONST_ID_CACHE((var) =, (str)) while (0) #define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str) #define CONST_ID(var, str) RUBY_CONST_ID(var, str) -#if defined(HAVE_BUILTIN___BUILTIN_CONSTANT_P) && defined(HAVE_STMT_AND_DECL_IN_EXPR) +#ifdef __GNUC__ /* __builtin_constant_p and statement expression is available * since gcc-2.7.2.3 at least. */ #define rb_intern(str) \ @@ -1889,23 +1797,13 @@ VALUE rb_eval_string_protect(const char*, int*); VALUE rb_eval_string_wrap(const char*, int*); VALUE rb_funcall(VALUE, ID, int, ...); VALUE rb_funcallv(VALUE, ID, int, const VALUE*); -VALUE rb_funcallv_kw(VALUE, ID, int, const VALUE*, int); VALUE rb_funcallv_public(VALUE, ID, int, const VALUE*); -VALUE rb_funcallv_public_kw(VALUE, ID, int, const VALUE*, int); #define rb_funcall2 rb_funcallv #define rb_funcall3 rb_funcallv_public VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*); -VALUE rb_funcall_passing_block_kw(VALUE, ID, int, const VALUE*, int); VALUE rb_funcall_with_block(VALUE, ID, int, const VALUE*, VALUE); -VALUE rb_funcall_with_block_kw(VALUE, ID, int, const VALUE*, VALUE, int); int rb_scan_args(int, const VALUE*, const char*, ...); -#define RB_SCAN_ARGS_PASS_CALLED_KEYWORDS 0 -#define RB_SCAN_ARGS_KEYWORDS 1 -#define RB_SCAN_ARGS_EMPTY_KEYWORDS 2 /* Will be removed in 3.0 */ -#define RB_SCAN_ARGS_LAST_HASH_KEYWORDS 3 -int rb_scan_args_kw(int, int, const VALUE*, const char*, ...); VALUE rb_call_super(int, const VALUE*); -VALUE rb_call_super_kw(int, const VALUE*, int); VALUE rb_current_receiver(void); int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *); VALUE rb_extract_keywords(VALUE *orighash); @@ -1932,7 +1830,7 @@ enum rb_io_wait_readwrite {RB_IO_WAIT_READABLE, RB_IO_WAIT_WRITABLE}; PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char*, ...)), 2, 3); PRINTF_ARGS(NORETURN(void rb_fatal(const char*, ...)), 1, 2); -COLDFUNC PRINTF_ARGS(NORETURN(void rb_bug(const char*, ...)), 1, 2); +PRINTF_ARGS(NORETURN(void rb_bug(const char*, ...)), 1, 2); NORETURN(void rb_bug_errno(const char*, int)); NORETURN(void rb_sys_fail(const char*)); NORETURN(void rb_sys_fail_str(VALUE)); @@ -1956,40 +1854,35 @@ PRINTF_ARGS(void rb_warning(const char*, ...), 1, 2); PRINTF_ARGS(void rb_compile_warning(const char *, int, const char*, ...), 3, 4); PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2); /* reports always */ -COLDFUNC PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2); +PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2); PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4); -#define RB_BLOCK_CALL_FUNC_STRICT 1 #define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG 1 #define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg) \ VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)); + +#if defined RB_BLOCK_CALL_FUNC_STRICT && RB_BLOCK_CALL_FUNC_STRICT typedef rb_block_call_func *rb_block_call_func_t; +#else +typedef VALUE (*rb_block_call_func_t)(ANYARGS); +#endif VALUE rb_each(VALUE); VALUE rb_yield(VALUE); VALUE rb_yield_values(int n, ...); VALUE rb_yield_values2(int n, const VALUE *argv); -VALUE rb_yield_values_kw(int n, const VALUE *argv, int kw_splat); VALUE rb_yield_splat(VALUE); -VALUE rb_yield_splat_kw(VALUE, int); -VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)); /* rb_block_call_func */ -#define RB_NO_KEYWORDS 0 -#define RB_PASS_KEYWORDS 1 -#define RB_PASS_EMPTY_KEYWORDS 2 /* Will be removed in 3.0 */ -#define RB_PASS_CALLED_KEYWORDS 3 -int rb_keyword_given_p(void); +VALUE rb_yield_block(VALUE, VALUE, int, const VALUE *, VALUE); /* rb_block_call_func */ int rb_block_given_p(void); void rb_need_block(void); -VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE); +VALUE rb_iterate(VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE); VALUE rb_block_call(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE); -VALUE rb_block_call_kw(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE,int); -VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE); -VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...); -VALUE rb_vrescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,va_list); -VALUE rb_ensure(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE),VALUE); -VALUE rb_catch(const char*,rb_block_call_func_t,VALUE); -VALUE rb_catch_obj(VALUE,rb_block_call_func_t,VALUE); +VALUE rb_rescue(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE); +VALUE rb_rescue2(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...); +VALUE rb_ensure(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE); +VALUE rb_catch(const char*,VALUE(*)(ANYARGS),VALUE); +VALUE rb_catch_obj(VALUE,VALUE(*)(ANYARGS),VALUE); NORETURN(void rb_throw(const char*,VALUE)); NORETURN(void rb_throw_obj(VALUE,VALUE)); @@ -2015,20 +1908,19 @@ RUBY_EXTERN VALUE rb_cBignum; RUBY_EXTERN VALUE rb_cBinding; RUBY_EXTERN VALUE rb_cClass; RUBY_EXTERN VALUE rb_cCont; -RUBY_EXTERN VALUE rb_cData; RUBY_EXTERN VALUE rb_cDir; +RUBY_EXTERN VALUE rb_cData; +RUBY_EXTERN VALUE rb_cFalseClass; RUBY_EXTERN VALUE rb_cEncoding; RUBY_EXTERN VALUE rb_cEnumerator; -RUBY_EXTERN VALUE rb_cFalseClass; RUBY_EXTERN VALUE rb_cFile; #ifndef RUBY_INTEGER_UNIFICATION RUBY_EXTERN VALUE rb_cFixnum; #endif -RUBY_EXTERN VALUE rb_cComplex; RUBY_EXTERN VALUE rb_cFloat; RUBY_EXTERN VALUE rb_cHash; -RUBY_EXTERN VALUE rb_cIO; RUBY_EXTERN VALUE rb_cInteger; +RUBY_EXTERN VALUE rb_cIO; RUBY_EXTERN VALUE rb_cMatch; RUBY_EXTERN VALUE rb_cMethod; RUBY_EXTERN VALUE rb_cModule; @@ -2039,6 +1931,7 @@ RUBY_EXTERN VALUE rb_cProc; RUBY_EXTERN VALUE rb_cRandom; RUBY_EXTERN VALUE rb_cRange; RUBY_EXTERN VALUE rb_cRational; +RUBY_EXTERN VALUE rb_cComplex; RUBY_EXTERN VALUE rb_cRegexp; RUBY_EXTERN VALUE rb_cStat; RUBY_EXTERN VALUE rb_cString; @@ -2078,7 +1971,6 @@ RUBY_EXTERN VALUE rb_eSysStackError; RUBY_EXTERN VALUE rb_eRegexpError; RUBY_EXTERN VALUE rb_eEncodingError; RUBY_EXTERN VALUE rb_eEncCompatError; -RUBY_EXTERN VALUE rb_eNoMatchingPatternError; RUBY_EXTERN VALUE rb_eScriptError; RUBY_EXTERN VALUE rb_eNameError; @@ -2178,56 +2070,13 @@ rb_array_len(VALUE a) # define FIX_CONST_VALUE_PTR(x) (x) #endif -/* internal function. do not use this function */ static inline const VALUE * -rb_array_const_ptr_transient(VALUE a) +rb_array_const_ptr(VALUE a) { return FIX_CONST_VALUE_PTR((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ? RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr); } -/* internal function. do not use this function */ -static inline const VALUE * -rb_array_const_ptr(VALUE a) -{ -#if USE_TRANSIENT_HEAP - void rb_ary_detransient(VALUE a); - - if (RARRAY_TRANSIENT_P(a)) { - rb_ary_detransient(a); - } -#endif - return rb_array_const_ptr_transient(a); -} - -/* internal function. do not use this function */ -static inline VALUE * -rb_array_ptr_use_start(VALUE a, int allow_transient) -{ - VALUE *rb_ary_ptr_use_start(VALUE ary); - -#if USE_TRANSIENT_HEAP - if (!allow_transient) { - if (RARRAY_TRANSIENT_P(a)) { - void rb_ary_detransient(VALUE a); - rb_ary_detransient(a); - } - } -#endif - (void)allow_transient; - - return rb_ary_ptr_use_start(a); -} - -/* internal function. do not use this function */ -static inline void -rb_array_ptr_use_end(VALUE a, int allow_transient) -{ - void rb_ary_ptr_use_end(VALUE a); - rb_ary_ptr_use_end(a); - (void)allow_transient; -} - #if defined(EXTLIB) && defined(USE_DLN_A_OUT) /* hook for external modules */ static char *dln_libs_to_be_linked[] = { EXTLIB, 0 }; @@ -2255,7 +2104,6 @@ int ruby_native_thread_p(void); #define RUBY_EVENT_THREAD_BEGIN 0x0400 #define RUBY_EVENT_THREAD_END 0x0800 #define RUBY_EVENT_FIBER_SWITCH 0x1000 -#define RUBY_EVENT_SCRIPT_COMPILED 0x2000 #define RUBY_EVENT_TRACEPOINT_ALL 0xffff /* special events */ @@ -2311,9 +2159,6 @@ static inline int rb_toupper(int c) { return rb_islower(c) ? (c&0x5f) : c; } #define ISALPHA(c) rb_isalpha(c) #define ISDIGIT(c) rb_isdigit(c) #define ISXDIGIT(c) rb_isxdigit(c) -#define ISBLANK(c) rb_isblank(c) -#define ISCNTRL(c) rb_iscntrl(c) -#define ISPUNCT(c) rb_ispunct(c) #endif #define TOUPPER(c) rb_toupper(c) #define TOLOWER(c) rb_tolower(c) @@ -2331,70 +2176,74 @@ unsigned long ruby_strtoul(const char *str, char **endptr, int base); PRINTF_ARGS(int ruby_snprintf(char *str, size_t n, char const *fmt, ...), 3, 4); int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap); -/* -- Remove In 3.0, Only public for rb_scan_args optimized version -- */ -int rb_empty_keyword_given_p(void); - -#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) && defined(HAVE_VA_ARGS_MACRO) && defined(__OPTIMIZE__) +#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) && defined(__OPTIMIZE__) # define rb_scan_args(argc,argvp,fmt,...) \ __builtin_choose_expr(__builtin_constant_p(fmt), \ rb_scan_args0(argc,argvp,fmt,\ (sizeof((VALUE*[]){__VA_ARGS__})/sizeof(VALUE*)), \ ((VALUE*[]){__VA_ARGS__})), \ - rb_scan_args(argc,argvp,fmt,##__VA_ARGS__)) + rb_scan_args(argc,argvp,fmt,__VA_ARGS__)) # if HAVE_ATTRIBUTE_ERRORFUNC -ERRORFUNC(("bad scan arg format"), void rb_scan_args_bad_format(const char*)); -ERRORFUNC(("variable argument length doesn't match"), void rb_scan_args_length_mismatch(const char*,int)); +ERRORFUNC(("bad scan arg format"), int rb_scan_args_bad_format(const char*)); +ERRORFUNC(("variable argument length doesn't match"), int rb_scan_args_length_mismatch(const char*,int)); # else -# define rb_scan_args_bad_format(fmt) ((void)0) -# define rb_scan_args_length_mismatch(fmt, varc) ((void)0) +# define rb_scan_args_bad_format(fmt) 0 +# define rb_scan_args_length_mismatch(fmt, varc) 0 # endif # define rb_scan_args_isdigit(c) ((unsigned char)((c)-'0')<10) -# define rb_scan_args_count_end(fmt, ofs, vari) \ - (fmt[ofs] ? -1 : (vari)) +# define rb_scan_args_count_end(fmt, ofs, varc, vari) \ + ((vari)/(!fmt[ofs] || rb_scan_args_bad_format(fmt))) -# define rb_scan_args_count_block(fmt, ofs, vari) \ +# define rb_scan_args_count_block(fmt, ofs, varc, vari) \ (fmt[ofs]!='&' ? \ - rb_scan_args_count_end(fmt, ofs, vari) : \ - rb_scan_args_count_end(fmt, ofs+1, vari+1)) + rb_scan_args_count_end(fmt, ofs, varc, vari) : \ + rb_scan_args_count_end(fmt, ofs+1, varc, vari+1)) -# define rb_scan_args_count_hash(fmt, ofs, vari) \ +# define rb_scan_args_count_hash(fmt, ofs, varc, vari) \ (fmt[ofs]!=':' ? \ - rb_scan_args_count_block(fmt, ofs, vari) : \ - rb_scan_args_count_block(fmt, ofs+1, vari+1)) + rb_scan_args_count_block(fmt, ofs, varc, vari) : \ + rb_scan_args_count_block(fmt, ofs+1, varc, vari+1)) -# define rb_scan_args_count_trail(fmt, ofs, vari) \ +# define rb_scan_args_count_trail(fmt, ofs, varc, vari) \ (!rb_scan_args_isdigit(fmt[ofs]) ? \ - rb_scan_args_count_hash(fmt, ofs, vari) : \ - rb_scan_args_count_hash(fmt, ofs+1, vari+(fmt[ofs]-'0'))) + rb_scan_args_count_hash(fmt, ofs, varc, vari) : \ + rb_scan_args_count_hash(fmt, ofs+1, varc, vari+(fmt[ofs]-'0'))) -# define rb_scan_args_count_var(fmt, ofs, vari) \ +# define rb_scan_args_count_var(fmt, ofs, varc, vari) \ (fmt[ofs]!='*' ? \ - rb_scan_args_count_trail(fmt, ofs, vari) : \ - rb_scan_args_count_trail(fmt, ofs+1, vari+1)) + rb_scan_args_count_trail(fmt, ofs, varc, vari) : \ + rb_scan_args_count_trail(fmt, ofs+1, varc, vari+1)) -# define rb_scan_args_count_opt(fmt, ofs, vari) \ - (!rb_scan_args_isdigit(fmt[ofs]) ? \ - rb_scan_args_count_var(fmt, ofs, vari) : \ - rb_scan_args_count_var(fmt, ofs+1, vari+fmt[ofs]-'0')) +# define rb_scan_args_count_opt(fmt, ofs, varc, vari) \ + (!rb_scan_args_isdigit(fmt[1]) ? \ + rb_scan_args_count_var(fmt, ofs, varc, vari) : \ + rb_scan_args_count_var(fmt, ofs+1, varc, vari+fmt[ofs]-'0')) -# define rb_scan_args_count_lead(fmt, ofs, vari) \ - (!rb_scan_args_isdigit(fmt[ofs]) ? \ - rb_scan_args_count_var(fmt, ofs, vari) : \ - rb_scan_args_count_opt(fmt, ofs+1, vari+fmt[ofs]-'0')) +# define rb_scan_args_count(fmt, varc) \ + ((!rb_scan_args_isdigit(fmt[0]) ? \ + rb_scan_args_count_var(fmt, 0, varc, 0) : \ + rb_scan_args_count_opt(fmt, 1, varc, fmt[0]-'0')) \ + == (varc) || \ + rb_scan_args_length_mismatch(fmt, varc)) -# define rb_scan_args_count(fmt) rb_scan_args_count_lead(fmt, 0, 0) +# define rb_scan_args_verify_count(fmt, varc) \ + ((varc)/(rb_scan_args_count(fmt, varc))) -# if defined(__has_attribute) && __has_attribute(diagnose_if) -# define rb_scan_args_verify(fmt, varc) (void)0 +# ifdef __GNUC__ +# define rb_scan_args_verify(fmt, varc) \ + ({ \ + int verify; \ + _Pragma("GCC diagnostic push"); \ + _Pragma("GCC diagnostic ignored \"-Warray-bounds\""); \ + verify = rb_scan_args_verify_count(fmt, varc); \ + _Pragma("GCC diagnostic pop"); \ + verify; \ + }) # else # define rb_scan_args_verify(fmt, varc) \ - (sizeof(char[1-2*(rb_scan_args_count(fmt)<0)])!=1 ? \ - rb_scan_args_bad_format(fmt) : \ - sizeof(char[1-2*(rb_scan_args_count(fmt)!=(varc))])!=1 ? \ - rb_scan_args_length_mismatch(fmt, varc) : \ - (void)0) + rb_scan_args_verify_count(fmt, varc) # endif ALWAYS_INLINE(static int rb_scan_args_lead_p(const char *fmt)); @@ -2495,8 +2344,6 @@ rb_scan_args_end_idx(const char *fmt) } # endif -/* NOTE: Use `char *fmt` instead of `const char *fmt` because of clang's bug*/ -/* https://bugs.llvm.org/show_bug.cgi?id=38095 */ # define rb_scan_args0(argc, argv, fmt, varc, vars) \ rb_scan_args_set(argc, argv, \ rb_scan_args_n_lead(fmt), \ @@ -2505,101 +2352,45 @@ rb_scan_args_end_idx(const char *fmt) rb_scan_args_f_var(fmt), \ rb_scan_args_f_hash(fmt), \ rb_scan_args_f_block(fmt), \ - (rb_scan_args_verify(fmt, varc), vars), (char *)fmt, varc) + (rb_scan_args_verify(fmt, varc), vars)) ALWAYS_INLINE(static int rb_scan_args_set(int argc, const VALUE *argv, int n_lead, int n_opt, int n_trail, int f_var, int f_hash, int f_block, - VALUE *vars[], char *fmt, int varc)); - + VALUE *vars[])); inline int rb_scan_args_set(int argc, const VALUE *argv, int n_lead, int n_opt, int n_trail, int f_var, int f_hash, int f_block, - VALUE *vars[], RB_UNUSED_VAR(char *fmt), RB_UNUSED_VAR(int varc)) -# if defined(__has_attribute) && __has_attribute(diagnose_if) - __attribute__((diagnose_if(rb_scan_args_count(fmt)<0,"bad scan arg format","error"))) - __attribute__((diagnose_if(rb_scan_args_count(fmt)!=varc,"variable argument length doesn't match","error"))) -# endif + VALUE *vars[]) { int i, argi = 0, vari = 0, last_idx = -1; VALUE *var, hash = Qnil, last_hash = 0; const int n_mand = n_lead + n_trail; - int keyword_given = rb_keyword_given_p(); - int empty_keyword_given = 0; - VALUE tmp_buffer = 0; - - if (!keyword_given) { - empty_keyword_given = rb_empty_keyword_given_p(); - } /* capture an option hash - phase 1: pop */ - /* Ignore final positional hash if empty keywords given */ - if (argc > 0 && !(f_hash && empty_keyword_given)) { - VALUE last = argv[argc - 1]; - - if (f_hash && n_mand < argc) { - if (keyword_given) { - if (!RB_TYPE_P(last, T_HASH)) { - rb_warn("Keyword flag set when calling rb_scan_args, but last entry is not a hash"); - } - else { - hash = last; - } - } - else if (NIL_P(last)) { - /* For backwards compatibility, nil is taken as an empty - option hash only if it is not ambiguous; i.e. '*' is - not specified and arguments are given more than sufficient. - This will be removed in Ruby 3. */ - if (!f_var && n_mand + n_opt < argc) { - rb_warn("The last argument is nil, treating as empty keywords"); - argc--; - } - } - else { - hash = rb_check_hash_type(last); - } - - /* Ruby 3: Remove if branch, as it will not attempt to split hashes */ - if (!NIL_P(hash)) { - VALUE opts = rb_extract_keywords(&hash); - - if (!(last_hash = hash)) { - if (!keyword_given) { - /* Warn if treating positional as keyword, as in Ruby 3, - this will be an error */ - rb_warn("Using the last argument as keyword parameters is deprecated"); - } - argc--; - } - else { - /* Warn if splitting either positional hash to keywords or keywords - to positional hash, as in Ruby 3, no splitting will be done */ - rb_warn("The last argument is split into positional and keyword parameters"); - last_idx = argc - 1; - } - hash = opts ? opts : Qnil; - } - } - else if (f_hash && keyword_given && n_mand == argc) { - /* Warn if treating keywords as positional, as in Ruby 3, this will be an error */ - rb_warn("Passing the keyword argument as the last hash parameter is deprecated"); - } - } - if (f_hash && n_mand > 0 && n_mand == argc+1 && empty_keyword_given) { - VALUE *ptr = (VALUE *)rb_alloc_tmp_buffer2(&tmp_buffer, argc+1, sizeof(VALUE)); - memcpy(ptr, argv, sizeof(VALUE)*argc); - ptr[argc] = rb_hash_new(); - argc++; - *(&argv) = ptr; - rb_warn("Passing the keyword argument as the last hash parameter is deprecated"); + if (f_hash && n_mand < argc) { + VALUE last = argv[argc - 1]; + + if (RB_NIL_P(last)) { + /* nil is taken as an empty option hash only if it is not + ambiguous; i.e. '*' is not specified and arguments are + given more than sufficient */ + if (!f_var && n_mand + n_opt < argc) + argc--; + } + else { + hash = rb_check_hash_type(last); + if (!RB_NIL_P(hash)) { + VALUE opts = rb_extract_keywords(&hash); + if (!(last_hash = hash)) argc--; + else last_idx = argc - 1; + hash = opts ? opts : Qnil; + } + } } - - if (argc < n_mand) { - goto argc_error; - } + rb_check_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt); /* capture leading mandatory arguments */ for (i = n_lead; i-- > 0; ) { @@ -2657,18 +2448,11 @@ rb_scan_args_set(int argc, const VALUE *argv, } } - if (argi < argc) { - argc_error: - if (tmp_buffer) rb_free_tmp_buffer(&tmp_buffer); - rb_error_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt); - } - - if (tmp_buffer) rb_free_tmp_buffer(&tmp_buffer); return argc; } #endif -#if defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO) && defined(__OPTIMIZE__) +#if defined(__GNUC__) && defined(__OPTIMIZE__) # define rb_yield_values(argc, ...) \ __extension__({ \ const int rb_yield_values_argc = (argc); \ @@ -2686,7 +2470,7 @@ __extension__({ \ const VALUE rb_funcall_args[] = {__VA_ARGS__}; \ const int rb_funcall_nargs = \ (int)(sizeof(rb_funcall_args) / sizeof(VALUE)); \ - rb_funcallv(recv, mid, \ + rb_funcallv(recv, mid, \ rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \ rb_funcall_nargs ? rb_funcall_args : NULL); \ }) @@ -2730,7 +2514,13 @@ void ruby_show_copyright(void); ruby_init_stack(&variable_in_this_stack_frame); /*! @} */ +#ifdef __ia64 +void ruby_init_stack(volatile VALUE*, void*); +#define ruby_init_stack(addr) ruby_init_stack((addr), rb_ia64_bsp()) +#else void ruby_init_stack(volatile VALUE*); +#endif +#define Init_stack(addr) ruby_init_stack(addr) int ruby_setup(void); int ruby_cleanup(volatile int); @@ -2767,105 +2557,5 @@ RUBY_SYMBOL_EXPORT_END { /* satisfy cc-mode */ #endif } /* extern "C" { */ -extern "C++" { #endif - -#ifdef RB_METHOD_DEFINITION_DECL - -RB_METHOD_DEFINITION_DECL(rb_define_method, (2,3), (VALUE klass, const char *name), (klass, name)) -#ifdef __cplusplus -#define rb_define_method(m, n, f, a) rb_define_method_tmpl<a>::define(m, n, f) -#else -#define rb_define_method_if_constexpr(x, t, f) __builtin_choose_expr(__builtin_choose_expr(__builtin_constant_p(x),(x),0),(t),(f)) -#define rb_define_method_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_method15,rb_define_methodm3) -#define rb_define_method_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_method14,rb_define_method_choose_prototype15(n)) -#define rb_define_method_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_method13,rb_define_method_choose_prototype14(n)) -#define rb_define_method_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_method12,rb_define_method_choose_prototype13(n)) -#define rb_define_method_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_method11,rb_define_method_choose_prototype12(n)) -#define rb_define_method_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_method10,rb_define_method_choose_prototype11(n)) -#define rb_define_method_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_method9, rb_define_method_choose_prototype10(n)) -#define rb_define_method_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_method8, rb_define_method_choose_prototype9(n)) -#define rb_define_method_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_method7, rb_define_method_choose_prototype8(n)) -#define rb_define_method_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_method6, rb_define_method_choose_prototype7(n)) -#define rb_define_method_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_method5, rb_define_method_choose_prototype6(n)) -#define rb_define_method_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_method4, rb_define_method_choose_prototype5(n)) -#define rb_define_method_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_method3, rb_define_method_choose_prototype4(n)) -#define rb_define_method_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_method2, rb_define_method_choose_prototype3(n)) -#define rb_define_method_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_method1, rb_define_method_choose_prototype2(n)) -#define rb_define_method_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_method0, rb_define_method_choose_prototype1(n)) -#define rb_define_method_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_methodm1,rb_define_method_choose_prototype0(n)) -#define rb_define_method_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_methodm2,rb_define_method_choose_prototypem1(n)) -#define rb_define_method_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_methodm3,rb_define_method_choose_prototypem2(n)) -#define rb_define_method(klass, mid, func, arity) rb_define_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity)); -#endif - -RB_METHOD_DEFINITION_DECL(rb_define_module_function, (2,3), (VALUE klass, const char *name), (klass, name)) -#ifdef __cplusplus -#define rb_define_module_function(m, n, f, a) rb_define_module_function_tmpl<a>::define(m, n, f) -#else -#define rb_define_module_function_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_module_function15,rb_define_module_functionm3) -#define rb_define_module_function_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_module_function14,rb_define_module_function_choose_prototype15(n)) -#define rb_define_module_function_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_module_function13,rb_define_module_function_choose_prototype14(n)) -#define rb_define_module_function_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_module_function12,rb_define_module_function_choose_prototype13(n)) -#define rb_define_module_function_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_module_function11,rb_define_module_function_choose_prototype12(n)) -#define rb_define_module_function_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_module_function10,rb_define_module_function_choose_prototype11(n)) -#define rb_define_module_function_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_module_function9, rb_define_module_function_choose_prototype10(n)) -#define rb_define_module_function_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_module_function8, rb_define_module_function_choose_prototype9(n)) -#define rb_define_module_function_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_module_function7, rb_define_module_function_choose_prototype8(n)) -#define rb_define_module_function_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_module_function6, rb_define_module_function_choose_prototype7(n)) -#define rb_define_module_function_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_module_function5, rb_define_module_function_choose_prototype6(n)) -#define rb_define_module_function_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_module_function4, rb_define_module_function_choose_prototype5(n)) -#define rb_define_module_function_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_module_function3, rb_define_module_function_choose_prototype4(n)) -#define rb_define_module_function_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_module_function2, rb_define_module_function_choose_prototype3(n)) -#define rb_define_module_function_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_module_function1, rb_define_module_function_choose_prototype2(n)) -#define rb_define_module_function_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_module_function0, rb_define_module_function_choose_prototype1(n)) -#define rb_define_module_function_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_module_functionm1,rb_define_module_function_choose_prototype0(n)) -#define rb_define_module_function_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_module_functionm2,rb_define_module_function_choose_prototypem1(n)) -#define rb_define_module_function_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_module_functionm3,rb_define_module_function_choose_prototypem2(n)) -#define rb_define_module_function(klass, mid, func, arity) rb_define_module_function_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity)); -#endif - -RB_METHOD_DEFINITION_DECL(rb_define_global_function, (1,2), (const char *name), (name)) -#ifdef __cplusplus -#define rb_define_global_function(n, f, a) rb_define_global_function_tmpl<a>::define(n, f) -#else -#define rb_define_global_function_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_global_function15,rb_define_global_functionm3) -#define rb_define_global_function_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_global_function14,rb_define_global_function_choose_prototype15(n)) -#define rb_define_global_function_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_global_function13,rb_define_global_function_choose_prototype14(n)) -#define rb_define_global_function_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_global_function12,rb_define_global_function_choose_prototype13(n)) -#define rb_define_global_function_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_global_function11,rb_define_global_function_choose_prototype12(n)) -#define rb_define_global_function_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_global_function10,rb_define_global_function_choose_prototype11(n)) -#define rb_define_global_function_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_global_function9, rb_define_global_function_choose_prototype10(n)) -#define rb_define_global_function_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_global_function8, rb_define_global_function_choose_prototype9(n)) -#define rb_define_global_function_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_global_function7, rb_define_global_function_choose_prototype8(n)) -#define rb_define_global_function_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_global_function6, rb_define_global_function_choose_prototype7(n)) -#define rb_define_global_function_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_global_function5, rb_define_global_function_choose_prototype6(n)) -#define rb_define_global_function_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_global_function4, rb_define_global_function_choose_prototype5(n)) -#define rb_define_global_function_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_global_function3, rb_define_global_function_choose_prototype4(n)) -#define rb_define_global_function_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_global_function2, rb_define_global_function_choose_prototype3(n)) -#define rb_define_global_function_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_global_function1, rb_define_global_function_choose_prototype2(n)) -#define rb_define_global_function_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_global_function0, rb_define_global_function_choose_prototype1(n)) -#define rb_define_global_function_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_global_functionm1,rb_define_global_function_choose_prototype0(n)) -#define rb_define_global_function_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_global_functionm2,rb_define_global_function_choose_prototypem1(n)) -#define rb_define_global_function_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_global_functionm3,rb_define_global_function_choose_prototypem2(n)) -#define rb_define_global_function(mid, func, arity) rb_define_global_function_choose_prototypem3((arity),(func))((mid),(func),(arity)); -#endif - -#endif - -#if defined(RUBY_DEVEL) && RUBY_DEVEL && (!defined(__cplusplus) || defined(RB_METHOD_DEFINITION_DECL)) -# define RUBY_METHOD_FUNC(func) (func) -#else -# define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))(func)) -#endif - -#ifdef __cplusplus -#include "backward/cxxanyargs.hpp" - -#if 0 -{ /* satisfy cc-mode */ -#endif -} /* extern "C++" { */ -#endif - #endif /* RUBY_RUBY_H */ |
