00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef RUBY_INTERNAL_H
00013 #define RUBY_INTERNAL_H 1
00014
00015 #if defined(__cplusplus)
00016 extern "C" {
00017 #if 0
00018 }
00019 #endif
00020 #endif
00021
00022 #ifdef HAVE_VALGRIND_MEMCHECK_H
00023 # include <valgrind/memcheck.h>
00024 # ifndef VALGRIND_MAKE_MEM_DEFINED
00025 # define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n))
00026 # endif
00027 # ifndef VALGRIND_MAKE_MEM_UNDEFINED
00028 # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n))
00029 # endif
00030 #else
00031 # define VALGRIND_MAKE_MEM_DEFINED(p, n) 0
00032 # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
00033 #endif
00034
00035 #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
00036
00037 #define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]
00038
00039 #define GCC_VERSION_SINCE(major, minor, patchlevel) \
00040 (defined(__GNUC__) && !defined(__INTEL_COMPILER) && \
00041 ((__GNUC__ > (major)) || \
00042 (__GNUC__ == (major) && __GNUC_MINOR__ > (minor)) || \
00043 (__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patchlevel))))
00044
00045 #define SIGNED_INTEGER_TYPE_P(int_type) (0 > ((int_type)0)-1)
00046 #define SIGNED_INTEGER_MAX(sint_type) \
00047 (sint_type) \
00048 ((((sint_type)1) << (sizeof(sint_type) * CHAR_BIT - 2)) | \
00049 ((((sint_type)1) << (sizeof(sint_type) * CHAR_BIT - 2)) - 1))
00050 #define SIGNED_INTEGER_MIN(sint_type) (-SIGNED_INTEGER_MAX(sint_type)-1)
00051 #define UNSIGNED_INTEGER_MAX(uint_type) (~(uint_type)0)
00052
00053 #if SIGNEDNESS_OF_TIME_T < 0
00054 # define TIMET_MAX SIGNED_INTEGER_MAX(time_t)
00055 # define TIMET_MIN SIGNED_INTEGER_MIN(time_t)
00056 #elif SIGNEDNESS_OF_TIME_T > 0
00057 # define TIMET_MAX UNSIGNED_INTEGER_MAX(time_t)
00058 # define TIMET_MIN ((time_t)0)
00059 #endif
00060 #define TIMET_MAX_PLUS_ONE (2*(double)(TIMET_MAX/2+1))
00061
00062 #define MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
00063 (a) == 0 ? 0 : \
00064 (a) == -1 ? (b) < -(max) : \
00065 (a) > 0 ? \
00066 ((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \
00067 ((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b)))
00068 #define MUL_OVERFLOW_FIXNUM_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
00069 #define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
00070 #define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
00071
00072 #ifndef swap16
00073 # ifdef HAVE_BUILTIN___BUILTIN_BSWAP16
00074 # define swap16(x) __builtin_bswap16(x)
00075 # endif
00076 #endif
00077
00078 #ifndef swap16
00079 # define swap16(x) ((uint16_t)((((x)&0xFF)<<8) | (((x)>>8)&0xFF)))
00080 #endif
00081
00082 #ifndef swap32
00083 # ifdef HAVE_BUILTIN___BUILTIN_BSWAP32
00084 # define swap32(x) __builtin_bswap32(x)
00085 # endif
00086 #endif
00087
00088 #ifndef swap32
00089 # define swap32(x) ((uint32_t)((((x)&0xFF)<<24) \
00090 |(((x)>>24)&0xFF) \
00091 |(((x)&0x0000FF00)<<8) \
00092 |(((x)&0x00FF0000)>>8) ))
00093 #endif
00094
00095 #ifndef swap64
00096 # ifdef HAVE_BUILTIN___BUILTIN_BSWAP64
00097 # define swap64(x) __builtin_bswap64(x)
00098 # endif
00099 #endif
00100
00101 #ifndef swap64
00102 # ifdef HAVE_INT64_T
00103 # define byte_in_64bit(n) ((uint64_t)0xff << (n))
00104 # define swap64(x) ((uint64_t)((((x)&byte_in_64bit(0))<<56) \
00105 |(((x)>>56)&0xFF) \
00106 |(((x)&byte_in_64bit(8))<<40) \
00107 |(((x)&byte_in_64bit(48))>>40) \
00108 |(((x)&byte_in_64bit(16))<<24) \
00109 |(((x)&byte_in_64bit(40))>>24) \
00110 |(((x)&byte_in_64bit(24))<<8) \
00111 |(((x)&byte_in_64bit(32))>>8)))
00112 # endif
00113 #endif
00114
00115 static inline int
00116 nlz_int(unsigned int x)
00117 {
00118 #if defined(HAVE_BUILTIN___BUILTIN_CLZ)
00119 if (x == 0) return SIZEOF_INT * CHAR_BIT;
00120 return __builtin_clz(x);
00121 #else
00122 unsigned int y;
00123 # if 64 < SIZEOF_INT * CHAR_BIT
00124 int n = 128;
00125 # elif 32 < SIZEOF_INT * CHAR_BIT
00126 int n = 64;
00127 # else
00128 int n = 32;
00129 # endif
00130 # if 64 < SIZEOF_INT * CHAR_BIT
00131 y = x >> 64; if (y) {n -= 64; x = y;}
00132 # endif
00133 # if 32 < SIZEOF_INT * CHAR_BIT
00134 y = x >> 32; if (y) {n -= 32; x = y;}
00135 # endif
00136 y = x >> 16; if (y) {n -= 16; x = y;}
00137 y = x >> 8; if (y) {n -= 8; x = y;}
00138 y = x >> 4; if (y) {n -= 4; x = y;}
00139 y = x >> 2; if (y) {n -= 2; x = y;}
00140 y = x >> 1; if (y) {return n - 2;}
00141 return (int)(n - x);
00142 #endif
00143 }
00144
00145 static inline int
00146 nlz_long(unsigned long x)
00147 {
00148 #if defined(HAVE_BUILTIN___BUILTIN_CLZL)
00149 if (x == 0) return SIZEOF_LONG * CHAR_BIT;
00150 return __builtin_clzl(x);
00151 #else
00152 unsigned long y;
00153 # if 64 < SIZEOF_LONG * CHAR_BIT
00154 int n = 128;
00155 # elif 32 < SIZEOF_LONG * CHAR_BIT
00156 int n = 64;
00157 # else
00158 int n = 32;
00159 # endif
00160 # if 64 < SIZEOF_LONG * CHAR_BIT
00161 y = x >> 64; if (y) {n -= 64; x = y;}
00162 # endif
00163 # if 32 < SIZEOF_LONG * CHAR_BIT
00164 y = x >> 32; if (y) {n -= 32; x = y;}
00165 # endif
00166 y = x >> 16; if (y) {n -= 16; x = y;}
00167 y = x >> 8; if (y) {n -= 8; x = y;}
00168 y = x >> 4; if (y) {n -= 4; x = y;}
00169 y = x >> 2; if (y) {n -= 2; x = y;}
00170 y = x >> 1; if (y) {return n - 2;}
00171 return (int)(n - x);
00172 #endif
00173 }
00174
00175 #ifdef HAVE_LONG_LONG
00176 static inline int
00177 nlz_long_long(unsigned LONG_LONG x)
00178 {
00179 #if defined(HAVE_BUILTIN___BUILTIN_CLZLL)
00180 if (x == 0) return SIZEOF_LONG_LONG * CHAR_BIT;
00181 return __builtin_clzll(x);
00182 #else
00183 unsigned LONG_LONG y;
00184 # if 64 < SIZEOF_LONG_LONG * CHAR_BIT
00185 int n = 128;
00186 # elif 32 < SIZEOF_LONG_LONG * CHAR_BIT
00187 int n = 64;
00188 # else
00189 int n = 32;
00190 # endif
00191 # if 64 < SIZEOF_LONG_LONG * CHAR_BIT
00192 y = x >> 64; if (y) {n -= 64; x = y;}
00193 # endif
00194 # if 32 < SIZEOF_LONG_LONG * CHAR_BIT
00195 y = x >> 32; if (y) {n -= 32; x = y;}
00196 # endif
00197 y = x >> 16; if (y) {n -= 16; x = y;}
00198 y = x >> 8; if (y) {n -= 8; x = y;}
00199 y = x >> 4; if (y) {n -= 4; x = y;}
00200 y = x >> 2; if (y) {n -= 2; x = y;}
00201 y = x >> 1; if (y) {return n - 2;}
00202 return (int)(n - x);
00203 #endif
00204 }
00205 #endif
00206
00207 #ifdef HAVE_UINT128_T
00208 static inline int
00209 nlz_int128(uint128_t x)
00210 {
00211 uint128_t y;
00212 int n = 128;
00213 y = x >> 64; if (y) {n -= 64; x = y;}
00214 y = x >> 32; if (y) {n -= 32; x = y;}
00215 y = x >> 16; if (y) {n -= 16; x = y;}
00216 y = x >> 8; if (y) {n -= 8; x = y;}
00217 y = x >> 4; if (y) {n -= 4; x = y;}
00218 y = x >> 2; if (y) {n -= 2; x = y;}
00219 y = x >> 1; if (y) {return n - 2;}
00220 return (int)(n - x);
00221 }
00222 #endif
00223
00224 #if defined(HAVE_UINT128_T)
00225 # define bit_length(x) \
00226 (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
00227 sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
00228 sizeof(x) <= SIZEOF_LONG_LONG ? SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)) : \
00229 SIZEOF_INT128_T * CHAR_BIT - nlz_int128((uint128_t)(x)))
00230 #elif defined(HAVE_LONG_LONG)
00231 # define bit_length(x) \
00232 (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
00233 sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
00234 SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)))
00235 #else
00236 # define bit_length(x) \
00237 (sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
00238 SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)))
00239 #endif
00240
00241 struct rb_deprecated_classext_struct {
00242 char conflict[sizeof(VALUE) * 3];
00243 };
00244
00245 struct rb_subclass_entry;
00246 typedef struct rb_subclass_entry rb_subclass_entry_t;
00247
00248 struct rb_subclass_entry {
00249 VALUE klass;
00250 rb_subclass_entry_t *next;
00251 };
00252
00253 #if defined(HAVE_LONG_LONG)
00254 typedef unsigned LONG_LONG rb_serial_t;
00255 #define SERIALT2NUM ULL2NUM
00256 #elif defined(HAVE_UINT64_T)
00257 typedef uint64_t rb_serial_t;
00258 #define SERIALT2NUM SIZET2NUM
00259 #else
00260 typedef unsigned long rb_serial_t;
00261 #define SERIALT2NUM ULONG2NUM
00262 #endif
00263
00264 struct rb_classext_struct {
00265 struct st_table *iv_index_tbl;
00266 struct st_table *iv_tbl;
00267 struct st_table *const_tbl;
00268 rb_subclass_entry_t *subclasses;
00269 rb_subclass_entry_t **parent_subclasses;
00275 rb_subclass_entry_t **module_subclasses;
00276 rb_serial_t class_serial;
00277 VALUE origin;
00278 VALUE refined_class;
00279 rb_alloc_func_t allocator;
00280 };
00281
00282 struct method_table_wrapper {
00283 st_table *tbl;
00284 size_t serial;
00285 };
00286
00287
00288 void rb_class_subclass_add(VALUE super, VALUE klass);
00289 void rb_class_remove_from_super_subclasses(VALUE);
00290
00291 #define RCLASS_EXT(c) (RCLASS(c)->ptr)
00292 #define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
00293 #define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
00294 #define RCLASS_M_TBL_WRAPPER(c) (RCLASS(c)->m_tbl_wrapper)
00295 #define RCLASS_M_TBL(c) (RCLASS_M_TBL_WRAPPER(c) ? RCLASS_M_TBL_WRAPPER(c)->tbl : 0)
00296 #define RCLASS_IV_INDEX_TBL(c) (RCLASS_EXT(c)->iv_index_tbl)
00297 #define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin)
00298 #define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
00299 #define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
00300
00301 static inline void
00302 RCLASS_M_TBL_INIT(VALUE c)
00303 {
00304 struct method_table_wrapper *wrapper;
00305 wrapper = ALLOC(struct method_table_wrapper);
00306 wrapper->tbl = st_init_numtable();
00307 wrapper->serial = 0;
00308 RCLASS_M_TBL_WRAPPER(c) = wrapper;
00309 }
00310
00311 #undef RCLASS_SUPER
00312 static inline VALUE
00313 RCLASS_SUPER(VALUE klass)
00314 {
00315 return RCLASS(klass)->super;
00316 }
00317
00318 static inline VALUE
00319 RCLASS_SET_SUPER(VALUE klass, VALUE super)
00320 {
00321 if (super) {
00322 rb_class_remove_from_super_subclasses(klass);
00323 rb_class_subclass_add(super, klass);
00324 }
00325 RB_OBJ_WRITE(klass, &RCLASS(klass)->super, super);
00326 return super;
00327 }
00328
00329 struct vtm;
00330
00331
00332 VALUE rb_ary_last(int, VALUE *, VALUE);
00333 void rb_ary_set_len(VALUE, long);
00334 void rb_ary_delete_same(VALUE, VALUE);
00335
00336
00337 VALUE rb_big_fdiv(VALUE x, VALUE y);
00338 VALUE rb_big_uminus(VALUE x);
00339 VALUE rb_integer_float_cmp(VALUE x, VALUE y);
00340 VALUE rb_integer_float_eq(VALUE x, VALUE y);
00341
00342
00343 void rb_class_foreach_subclass(VALUE klass, void(*f)(VALUE));
00344 void rb_class_detach_subclasses(VALUE);
00345 void rb_class_detach_module_subclasses(VALUE);
00346 void rb_class_remove_from_module_subclasses(VALUE);
00347 VALUE rb_obj_methods(int argc, VALUE *argv, VALUE obj);
00348 VALUE rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj);
00349 VALUE rb_obj_private_methods(int argc, VALUE *argv, VALUE obj);
00350 VALUE rb_obj_public_methods(int argc, VALUE *argv, VALUE obj);
00351 int rb_obj_basic_to_s_p(VALUE);
00352 VALUE rb_special_singleton_class(VALUE);
00353 VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
00354 VALUE rb_singleton_class_get(VALUE obj);
00355 void Init_class_hierarchy(void);
00356
00357
00358 VALUE rb_invcmp(VALUE, VALUE);
00359
00360
00361 int rb_dvar_defined(ID);
00362 int rb_local_defined(ID);
00363 int rb_parse_in_eval(void);
00364 int rb_parse_in_main(void);
00365 const char * rb_insns_name(int i);
00366 VALUE rb_insns_name_array(void);
00367
00368
00369 VALUE rb_obj_is_fiber(VALUE);
00370 void rb_fiber_reset_root_local_storage(VALUE);
00371 void ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(ANYARGS), VALUE (*rollback_func)(ANYARGS));
00372
00373
00374 PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
00375
00376
00377 void Init_ext(void);
00378
00379
00380 #ifdef RUBY_ENCODING_H
00381 enum ruby_preserved_encindex {
00382 ENCINDEX_ASCII,
00383 ENCINDEX_UTF_8,
00384 ENCINDEX_US_ASCII,
00385
00386
00387 ENCINDEX_UTF_16BE,
00388 ENCINDEX_UTF_16LE,
00389 ENCINDEX_UTF_32BE,
00390 ENCINDEX_UTF_32LE,
00391 ENCINDEX_UTF_16,
00392 ENCINDEX_UTF_32,
00393 ENCINDEX_UTF8_MAC,
00394
00395
00396 ENCINDEX_EUC_JP,
00397 ENCINDEX_Windows_31J,
00398
00399 ENCINDEX_BUILTIN_MAX
00400 };
00401 #endif
00402 #define rb_ascii8bit_encindex() ENCINDEX_ASCII
00403 #define rb_utf8_encindex() ENCINDEX_UTF_8
00404 #define rb_usascii_encindex() ENCINDEX_US_ASCII
00405 ID rb_id_encoding(void);
00406 void rb_gc_mark_encodings(void);
00407
00408
00409 NORETURN(PRINTF_ARGS(void rb_compile_bug(const char*, int, const char*, ...), 3, 4));
00410 VALUE rb_check_backtrace(VALUE);
00411 NORETURN(void rb_async_bug_errno(const char *,int));
00412 const char *rb_builtin_type_name(int t);
00413 const char *rb_builtin_class_name(VALUE x);
00414
00415
00416 VALUE rb_refinement_module_get_refined_class(VALUE module);
00417
00418
00419 void ruby_error_print(void);
00420 VALUE rb_get_backtrace(VALUE info);
00421
00422
00423 void rb_call_end_proc(VALUE data);
00424 void rb_mark_end_proc(void);
00425
00426
00427 VALUE rb_home_dir_of(VALUE user, VALUE result);
00428 VALUE rb_default_home_dir(VALUE result);
00429 VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict);
00430 void rb_file_const(const char*, VALUE);
00431 int rb_file_load_ok(const char *);
00432 VALUE rb_file_expand_path_fast(VALUE, VALUE);
00433 VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE);
00434 VALUE rb_get_path_check_to_string(VALUE, int);
00435 VALUE rb_get_path_check_convert(VALUE, VALUE, int);
00436 void Init_File(void);
00437
00438 #ifdef RUBY_FUNCTION_NAME_STRING
00439 # if defined __GNUC__ && __GNUC__ >= 4
00440 # pragma GCC visibility push(default)
00441 # endif
00442 NORETURN(void rb_sys_fail_path_in(const char *func_name, VALUE path));
00443 NORETURN(void rb_syserr_fail_path_in(const char *func_name, int err, VALUE path));
00444 # if defined __GNUC__ && __GNUC__ >= 4
00445 # pragma GCC visibility pop
00446 # endif
00447 # define rb_sys_fail_path(path) rb_sys_fail_path_in(RUBY_FUNCTION_NAME_STRING, path)
00448 # define rb_syserr_fail_path(err, path) rb_syserr_fail_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
00449 #else
00450 # define rb_sys_fail_path(path) rb_sys_fail_str(path)
00451 # define rb_syserr_fail_path(err, path) rb_syserr_fail_str((err), (path))
00452 #endif
00453
00454
00455 void Init_heap(void);
00456 void *ruby_mimmalloc(size_t size);
00457 void ruby_mimfree(void *ptr);
00458 void rb_objspace_set_event_hook(const rb_event_flag_t event);
00459 void rb_gc_writebarrier_remember_promoted(VALUE obj);
00460 void ruby_gc_set_params(int safe_level);
00461
00462 #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
00463 #define ruby_sized_xrealloc(ptr, new_size, old_size) ruby_xrealloc(ptr, new_size)
00464 #define ruby_sized_xrealloc2(ptr, new_count, element_size, old_count) ruby_xrealloc(ptr, new_count, element_size)
00465 #define ruby_sized_xfree(ptr, size) ruby_xfree(ptr)
00466 #define SIZED_REALLOC_N(var,type,n,old_n) REALLOC_N(var, type, n)
00467 #else
00468 void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_ALLOC_SIZE((2));
00469 void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_ALLOC_SIZE((2, 3));
00470 void ruby_sized_xfree(void *x, size_t size);
00471 #define SIZED_REALLOC_N(var,type,n,old_n) ((var)=(type*)ruby_sized_xrealloc((char*)(var), (n) * sizeof(type), (old_n) * sizeof(type)))
00472 #endif
00473
00474 void rb_gc_resurrect(VALUE ptr);
00475
00476
00477 struct st_table *rb_hash_tbl_raw(VALUE hash);
00478 #define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
00479 VALUE rb_hash_keys(VALUE hash);
00480 VALUE rb_hash_values(VALUE hash);
00481 #define HASH_DELETED FL_USER1
00482 #define HASH_PROC_DEFAULT FL_USER2
00483
00484
00485 void rb_call_inits(void);
00486
00487
00488 const char *ruby_get_inplace_mode(void);
00489 void ruby_set_inplace_mode(const char *);
00490 ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
00491 void rb_stdio_set_default_encoding(void);
00492 void rb_write_error_str(VALUE mesg);
00493 VALUE rb_io_flush_raw(VALUE, int);
00494
00495
00496 VALUE rb_iseq_clone(VALUE iseqval, VALUE newcbase);
00497 VALUE rb_iseq_path(VALUE iseqval);
00498 VALUE rb_iseq_absolute_path(VALUE iseqval);
00499 VALUE rb_iseq_label(VALUE iseqval);
00500 VALUE rb_iseq_base_label(VALUE iseqval);
00501 VALUE rb_iseq_first_lineno(VALUE iseqval);
00502 VALUE rb_iseq_klass(VALUE iseqval);
00503 VALUE rb_iseq_method_name(VALUE self);
00504
00505
00506 VALUE rb_get_load_path(void);
00507 VALUE rb_get_expanded_load_path(void);
00508 NORETURN(void rb_load_fail(VALUE, const char*));
00509
00510
00511 VALUE rb_math_atan2(VALUE, VALUE);
00512 VALUE rb_math_cos(VALUE);
00513 VALUE rb_math_cosh(VALUE);
00514 VALUE rb_math_exp(VALUE);
00515 VALUE rb_math_hypot(VALUE, VALUE);
00516 VALUE rb_math_log(int argc, VALUE *argv);
00517 VALUE rb_math_sin(VALUE);
00518 VALUE rb_math_sinh(VALUE);
00519 VALUE rb_math_sqrt(VALUE);
00520
00521
00522 void Init_newline(void);
00523
00524
00525 int rb_num_to_uint(VALUE val, unsigned int *ret);
00526 VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
00527 int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl);
00528 double ruby_float_mod(double x, double y);
00529 int rb_num_negative_p(VALUE);
00530 VALUE rb_int_succ(VALUE num);
00531 VALUE rb_int_pred(VALUE num);
00532 VALUE rb_dbl_hash(double d);
00533
00534 #if USE_FLONUM
00535 #define RUBY_BIT_ROTL(v, n) (((v) << (n)) | ((v) >> ((sizeof(v) * 8) - n)))
00536 #define RUBY_BIT_ROTR(v, n) (((v) >> (n)) | ((v) << ((sizeof(v) * 8) - n)))
00537 #endif
00538
00539 static inline double
00540 rb_float_value_inline(VALUE v)
00541 {
00542 #if USE_FLONUM
00543 if (FLONUM_P(v)) {
00544 if (v != (VALUE)0x8000000000000002) {
00545 union {
00546 double d;
00547 VALUE v;
00548 } t;
00549
00550 VALUE b63 = (v >> 63);
00551
00552
00553
00554 t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~0x03), 3);
00555 return t.d;
00556 }
00557 else {
00558 return 0.0;
00559 }
00560 }
00561 #endif
00562 return ((struct RFloat *)v)->float_value;
00563 }
00564
00565 static inline VALUE
00566 rb_float_new_inline(double d)
00567 {
00568 #if USE_FLONUM
00569 union {
00570 double d;
00571 VALUE v;
00572 } t;
00573 int bits;
00574
00575 t.d = d;
00576 bits = (int)((VALUE)(t.v >> 60) & 0x7);
00577
00578
00579
00580
00581
00582 if (t.v != 0x3000000000000000 &&
00583 !((bits-3) & ~0x01)) {
00584 return (RUBY_BIT_ROTL(t.v, 3) & ~(VALUE)0x01) | 0x02;
00585 }
00586 else if (t.v == (VALUE)0) {
00587
00588 return 0x8000000000000002;
00589 }
00590
00591 #endif
00592 return rb_float_new_in_heap(d);
00593 }
00594
00595 #define rb_float_value(v) rb_float_value_inline(v)
00596 #define rb_float_new(d) rb_float_new_inline(d)
00597
00598
00599 void rb_obj_copy_ivar(VALUE dest, VALUE obj);
00600 VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
00601 VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
00602 NORETURN(void rb_undefined_alloc(VALUE klass));
00603
00604 struct RBasicRaw {
00605 VALUE flags;
00606 VALUE klass;
00607 };
00608
00609 #define RBASIC_CLEAR_CLASS(obj) (((struct RBasicRaw *)((VALUE)(obj)))->klass = 0)
00610 #define RBASIC_SET_CLASS_RAW(obj, cls) (((struct RBasicRaw *)((VALUE)(obj)))->klass = (cls))
00611 #define RBASIC_SET_CLASS(obj, cls) do { \
00612 VALUE _obj_ = (obj); \
00613 RB_OBJ_WRITE(_obj_, &((struct RBasicRaw *)(_obj_))->klass, cls); \
00614 } while (0)
00615
00616
00617 VALUE rb_parser_get_yydebug(VALUE);
00618 VALUE rb_parser_set_yydebug(VALUE, VALUE);
00619 int rb_is_const_name(VALUE name);
00620 int rb_is_class_name(VALUE name);
00621 int rb_is_global_name(VALUE name);
00622 int rb_is_instance_name(VALUE name);
00623 int rb_is_attrset_name(VALUE name);
00624 int rb_is_local_name(VALUE name);
00625 int rb_is_method_name(VALUE name);
00626 int rb_is_junk_name(VALUE name);
00627 void rb_gc_mark_parser(void);
00628 void rb_gc_mark_symbols(int full_mark);
00629
00630
00631 VALUE rb_proc_location(VALUE self);
00632 st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
00633 int rb_block_arity(void);
00634 VALUE rb_block_clear_env_self(VALUE proc);
00635
00636
00637 #define RB_MAX_GROUPS (65536)
00638
00639 struct rb_execarg {
00640 int use_shell;
00641 union {
00642 struct {
00643 VALUE shell_script;
00644 } sh;
00645 struct {
00646 VALUE command_name;
00647 VALUE command_abspath;
00648 VALUE argv_str;
00649 VALUE argv_buf;
00650 } cmd;
00651 } invoke;
00652 VALUE redirect_fds;
00653 VALUE envp_str;
00654 VALUE envp_buf;
00655 VALUE dup2_tmpbuf;
00656 unsigned pgroup_given : 1;
00657 unsigned umask_given : 1;
00658 unsigned unsetenv_others_given : 1;
00659 unsigned unsetenv_others_do : 1;
00660 unsigned close_others_given : 1;
00661 unsigned close_others_do : 1;
00662 unsigned chdir_given : 1;
00663 unsigned new_pgroup_given : 1;
00664 unsigned new_pgroup_flag : 1;
00665 unsigned uid_given : 1;
00666 unsigned gid_given : 1;
00667 rb_pid_t pgroup_pgid;
00668 VALUE rlimit_limits;
00669 mode_t umask_mask;
00670 rb_uid_t uid;
00671 rb_gid_t gid;
00672 VALUE fd_dup2;
00673 VALUE fd_close;
00674 VALUE fd_open;
00675 VALUE fd_dup2_child;
00676 int close_others_maxhint;
00677 VALUE env_modification;
00678 VALUE chdir_dir;
00679 };
00680
00681
00682
00683
00684
00685 #define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 2)
00686 #define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str) + 1)
00687
00688 rb_pid_t rb_fork_ruby(int *status);
00689 void rb_last_status_clear(void);
00690
00691
00692 VALUE rb_lcm(VALUE x, VALUE y);
00693 VALUE rb_rational_reciprocal(VALUE x);
00694
00695
00696 VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
00697 VALUE rb_reg_check_preprocess(VALUE);
00698
00699
00700 int rb_get_next_signal(void);
00701 int rb_sigaltstack_size(void);
00702
00703
00704 #ifdef RUBY_ENCODING_H
00705 size_t rb_strftime_timespec(char *s, size_t maxsize, const char *format, rb_encoding *enc,
00706 const struct vtm *vtm, struct timespec *ts, int gmt);
00707 size_t rb_strftime(char *s, size_t maxsize, const char *format, rb_encoding *enc,
00708 const struct vtm *vtm, VALUE timev, int gmt);
00709 #endif
00710
00711
00712 VALUE rb_fstring(VALUE);
00713 int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
00714 int rb_str_symname_p(VALUE);
00715 VALUE rb_str_quote_unprintable(VALUE);
00716 VALUE rb_id_quote_unprintable(ID);
00717 #define QUOTE(str) rb_str_quote_unprintable(str)
00718 #define QUOTE_ID(id) rb_id_quote_unprintable(id)
00719 void rb_str_fill_terminator(VALUE str, const int termlen);
00720 VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
00721 #ifdef RUBY_ENCODING_H
00722 VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
00723 #endif
00724 #define STR_NOEMBED FL_USER1
00725 #define STR_SHARED FL_USER2
00726 #define STR_ASSOC FL_USER3
00727 #define STR_SHARED_P(s) FL_ALL_RAW((s), STR_NOEMBED|ELTS_SHARED)
00728 #define STR_ASSOC_P(s) FL_ALL_RAW((s), STR_NOEMBED|STR_ASSOC)
00729 #define STR_NOCAPA (STR_NOEMBED|ELTS_SHARED|STR_ASSOC)
00730 #define STR_NOCAPA_P(s) (FL_TEST_RAW((s),STR_NOEMBED) && FL_ANY_RAW((s),ELTS_SHARED|STR_ASSOC))
00731 #define STR_EMBED_P(str) (!FL_TEST_RAW((str), STR_NOEMBED))
00732 #define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
00733 #define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
00734
00735
00736 VALUE rb_struct_init_copy(VALUE copy, VALUE s);
00737
00738
00739 struct timeval rb_time_timeval(VALUE);
00740
00741
00742 VALUE rb_obj_is_mutex(VALUE obj);
00743 VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
00744 void rb_thread_execute_interrupts(VALUE th);
00745 void rb_clear_trace_func(void);
00746 VALUE rb_get_coverages(void);
00747 VALUE rb_thread_shield_new(void);
00748 VALUE rb_thread_shield_wait(VALUE self);
00749 VALUE rb_thread_shield_release(VALUE self);
00750 VALUE rb_thread_shield_destroy(VALUE self);
00751 void rb_mutex_allow_trap(VALUE self, int val);
00752 VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
00753 VALUE rb_mutex_owned_p(VALUE self);
00754 void ruby_kill(rb_pid_t pid, int sig);
00755
00756
00757 void Init_native_thread(void);
00758
00759
00760 rb_serial_t rb_next_class_serial(void);
00761
00762
00763 VALUE rb_obj_is_thread(VALUE obj);
00764 void rb_vm_mark(void *ptr);
00765 void Init_BareVM(void);
00766 VALUE rb_vm_top_self(void);
00767 void rb_thread_recycle_stack_release(VALUE *);
00768 void rb_vm_change_state(void);
00769 void rb_vm_inc_const_missing_count(void);
00770 void rb_thread_mark(void *th);
00771 const void **rb_vm_get_insns_address_table(void);
00772 VALUE rb_sourcefilename(void);
00773 void rb_vm_pop_cfunc_frame(void);
00774
00775
00776 void rb_vm_bugreport(void);
00777 void rb_print_backtrace(void);
00778
00779
00780 void Init_vm_eval(void);
00781 VALUE rb_current_realfilepath(void);
00782 VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE);
00783 typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
00784 VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
00785 rb_check_funcall_hook *hook, VALUE arg);
00786 VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr);
00787
00788
00789 VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
00790 int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *);
00791 VALUE rb_extract_keywords(VALUE *orighash);
00792
00793
00794 void Init_eval_method(void);
00795 int rb_method_defined_by(VALUE obj, ID mid, VALUE (*cfunc)(ANYARGS));
00796
00797
00798 void Init_prelude(void);
00799
00800
00801 void Init_vm_backtrace(void);
00802 VALUE rb_vm_thread_backtrace(int argc, VALUE *argv, VALUE thval);
00803 VALUE rb_vm_thread_backtrace_locations(int argc, VALUE *argv, VALUE thval);
00804
00805 VALUE rb_make_backtrace(void);
00806 void rb_backtrace_print_as_bugreport(void);
00807 int rb_backtrace_p(VALUE obj);
00808 VALUE rb_backtrace_to_str_ary(VALUE obj);
00809 VALUE rb_backtrace_to_location_ary(VALUE obj);
00810 void rb_backtrace_print_to(VALUE output);
00811 VALUE rb_vm_backtrace_object(void);
00812
00813 RUBY_SYMBOL_EXPORT_BEGIN
00814 const char *rb_objspace_data_type_name(VALUE obj);
00815
00816
00817 VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
00818
00819
00820 VALUE rb_big_mul_normal(VALUE x, VALUE y);
00821 VALUE rb_big_mul_balance(VALUE x, VALUE y);
00822 VALUE rb_big_mul_karatsuba(VALUE x, VALUE y);
00823 VALUE rb_big_mul_toom3(VALUE x, VALUE y);
00824 VALUE rb_big_sq_fast(VALUE x);
00825 VALUE rb_big_divrem_normal(VALUE x, VALUE y);
00826 VALUE rb_big2str_poweroftwo(VALUE x, int base);
00827 VALUE rb_big2str_generic(VALUE x, int base);
00828 VALUE rb_str2big_poweroftwo(VALUE arg, int base, int badcheck);
00829 VALUE rb_str2big_normal(VALUE arg, int base, int badcheck);
00830 VALUE rb_str2big_karatsuba(VALUE arg, int base, int badcheck);
00831 #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
00832 VALUE rb_big_mul_gmp(VALUE x, VALUE y);
00833 VALUE rb_big_divrem_gmp(VALUE x, VALUE y);
00834 VALUE rb_big2str_gmp(VALUE x, int base);
00835 VALUE rb_str2big_gmp(VALUE arg, int base, int badcheck);
00836 #endif
00837
00838
00839 int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);
00840
00841
00842 #ifdef __APPLE__
00843 VALUE rb_str_normalize_ospath(const char *ptr, long len);
00844 #endif
00845
00846
00847 void rb_maygvl_fd_fix_cloexec(int fd);
00848
00849
00850 VALUE rb_int_positive_pow(long x, unsigned long y);
00851
00852
00853 int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
00854 rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen);
00855 VALUE rb_execarg_new(int argc, VALUE *argv, int accept_shell);
00856 struct rb_execarg *rb_execarg_get(VALUE execarg_obj);
00857 VALUE rb_execarg_init(int argc, VALUE *argv, int accept_shell, VALUE execarg_obj);
00858 int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
00859 void rb_execarg_fixup(VALUE execarg_obj);
00860 int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);
00861 VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
00862 void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
00863
00864
00865 VALUE rb_gcd_normal(VALUE self, VALUE other);
00866 #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
00867 VALUE rb_gcd_gmp(VALUE x, VALUE y);
00868 #endif
00869
00870
00871 extern const signed char ruby_digit36_to_number_table[];
00872 extern unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow);
00873
00874
00875 void rb_gc_mark_global_tbl(void);
00876 void rb_mark_generic_ivar(VALUE);
00877 void rb_mark_generic_ivar_tbl(void);
00878
00879 int rb_st_insert_id_and_value(VALUE obj, st_table *tbl, ID key, VALUE value);
00880 st_table *rb_st_copy(VALUE obj, struct st_table *orig_tbl);
00881
00882
00883 size_t rb_obj_memsize_of(VALUE);
00884 #define RB_OBJ_GC_FLAGS_MAX 5
00885 size_t rb_obj_gc_flags(VALUE, ID[], size_t);
00886
00887 RUBY_SYMBOL_EXPORT_END
00888
00889 #if defined(__cplusplus)
00890 #if 0
00891 {
00892 #endif
00893 }
00894 #endif
00895
00896 #endif
00897