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 #define MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
00023 (a) == 0 ? 0 : \
00024 (a) == -1 ? (b) < -(max) : \
00025 (a) > 0 ? \
00026 ((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \
00027 ((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b)))
00028 #define MUL_OVERFLOW_FIXNUM_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
00029 #define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
00030
00031 struct rb_deprecated_classext_struct {
00032 char conflict[sizeof(VALUE) * 3];
00033 };
00034
00035 struct rb_classext_struct {
00036 VALUE super;
00037 struct st_table *iv_tbl;
00038 struct st_table *const_tbl;
00039 VALUE origin;
00040 VALUE refined_class;
00041 rb_alloc_func_t allocator;
00042 };
00043
00044 #undef RCLASS_SUPER
00045 #define RCLASS_EXT(c) (RCLASS(c)->ptr)
00046 #define RCLASS_SUPER(c) (RCLASS_EXT(c)->super)
00047 #define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
00048 #define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
00049 #define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
00050 #define RCLASS_IV_INDEX_TBL(c) (RCLASS(c)->iv_index_tbl)
00051 #define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin)
00052 #define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
00053
00054 struct vtm;
00055
00056
00057 VALUE rb_ary_last(int, VALUE *, VALUE);
00058 void rb_ary_set_len(VALUE, long);
00059 VALUE rb_ary_cat(VALUE, const VALUE *, long);
00060 void rb_ary_delete_same(VALUE, VALUE);
00061
00062
00063 VALUE rb_big_fdiv(VALUE x, VALUE y);
00064 VALUE rb_big_uminus(VALUE x);
00065 VALUE rb_integer_float_cmp(VALUE x, VALUE y);
00066 VALUE rb_integer_float_eq(VALUE x, VALUE y);
00067
00068
00069 VALUE rb_obj_methods(int argc, VALUE *argv, VALUE obj);
00070 VALUE rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj);
00071 VALUE rb_obj_private_methods(int argc, VALUE *argv, VALUE obj);
00072 VALUE rb_obj_public_methods(int argc, VALUE *argv, VALUE obj);
00073 int rb_obj_basic_to_s_p(VALUE);
00074 VALUE rb_special_singleton_class(VALUE);
00075 VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
00076 void Init_class_hierarchy(void);
00077
00078
00079 VALUE rb_invcmp(VALUE, VALUE);
00080
00081
00082 int rb_dvar_defined(ID);
00083 int rb_local_defined(ID);
00084 int rb_parse_in_eval(void);
00085 int rb_parse_in_main(void);
00086 const char * rb_insns_name(int i);
00087 VALUE rb_insns_name_array(void);
00088
00089
00090 VALUE rb_obj_is_fiber(VALUE);
00091 void rb_fiber_reset_root_local_storage(VALUE);
00092
00093
00094 PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
00095
00096
00097 void Init_ext(void);
00098
00099
00100 ID rb_id_encoding(void);
00101
00102
00103 void rb_gc_mark_encodings(void);
00104
00105
00106 NORETURN(PRINTF_ARGS(void rb_compile_bug(const char*, int, const char*, ...), 3, 4));
00107 VALUE rb_check_backtrace(VALUE);
00108 NORETURN(void rb_async_bug_errno(const char *,int));
00109 const char *rb_builtin_type_name(int t);
00110 const char *rb_builtin_class_name(VALUE x);
00111
00112
00113 VALUE rb_refinement_module_get_refined_class(VALUE module);
00114
00115
00116 void ruby_error_print(void);
00117 VALUE rb_get_backtrace(VALUE info);
00118
00119
00120 void rb_call_end_proc(VALUE data);
00121 void rb_mark_end_proc(void);
00122
00123
00124 VALUE rb_home_dir(const char *user, VALUE result);
00125 VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict);
00126 void rb_file_const(const char*, VALUE);
00127 int rb_file_load_ok(const char *);
00128 VALUE rb_file_expand_path_fast(VALUE, VALUE);
00129 VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE);
00130 VALUE rb_get_path_check_to_string(VALUE, int);
00131 VALUE rb_get_path_check_convert(VALUE, VALUE, int);
00132 void Init_File(void);
00133
00134 #ifdef _WIN32
00135
00136 void rb_w32_init_file(void);
00137 #endif
00138
00139
00140 void Init_heap(void);
00141 void *ruby_mimmalloc(size_t size);
00142
00143
00144 void rb_call_inits(void);
00145
00146
00147 const char *ruby_get_inplace_mode(void);
00148 void ruby_set_inplace_mode(const char *);
00149 ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
00150 void rb_stdio_set_default_encoding(void);
00151 void rb_write_error_str(VALUE mesg);
00152
00153
00154 VALUE rb_iseq_clone(VALUE iseqval, VALUE newcbase);
00155
00156
00157 VALUE rb_get_load_path(void);
00158 VALUE rb_get_expanded_load_path(void);
00159 NORETURN(void rb_load_fail(VALUE, const char*));
00160
00161
00162 VALUE rb_math_atan2(VALUE, VALUE);
00163 VALUE rb_math_cos(VALUE);
00164 VALUE rb_math_cosh(VALUE);
00165 VALUE rb_math_exp(VALUE);
00166 VALUE rb_math_hypot(VALUE, VALUE);
00167 VALUE rb_math_log(int argc, VALUE *argv);
00168 VALUE rb_math_sin(VALUE);
00169 VALUE rb_math_sinh(VALUE);
00170 VALUE rb_math_sqrt(VALUE);
00171
00172
00173 void Init_newline(void);
00174
00175
00176 int rb_num_to_uint(VALUE val, unsigned int *ret);
00177 VALUE num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
00178 int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl);
00179 double ruby_float_mod(double x, double y);
00180 int rb_num_negative_p(VALUE);
00181 VALUE rb_int_succ(VALUE num);
00182 VALUE rb_int_pred(VALUE num);
00183
00184
00185 void rb_obj_copy_ivar(VALUE dest, VALUE obj);
00186 VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
00187 VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
00188
00189
00190 VALUE rb_parser_get_yydebug(VALUE);
00191 VALUE rb_parser_set_yydebug(VALUE, VALUE);
00192 int rb_is_const_name(VALUE name);
00193 int rb_is_class_name(VALUE name);
00194 int rb_is_global_name(VALUE name);
00195 int rb_is_instance_name(VALUE name);
00196 int rb_is_attrset_name(VALUE name);
00197 int rb_is_local_name(VALUE name);
00198 int rb_is_method_name(VALUE name);
00199 int rb_is_junk_name(VALUE name);
00200 void rb_gc_mark_parser(void);
00201 void rb_gc_mark_symbols(void);
00202
00203
00204 VALUE rb_proc_location(VALUE self);
00205 st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
00206
00207
00208 #define RB_MAX_GROUPS (65536)
00209
00210 struct rb_execarg {
00211 int use_shell;
00212 union {
00213 struct {
00214 VALUE shell_script;
00215 } sh;
00216 struct {
00217 VALUE command_name;
00218 VALUE command_abspath;
00219 VALUE argv_str;
00220 VALUE argv_buf;
00221 } cmd;
00222 } invoke;
00223 VALUE redirect_fds;
00224 VALUE envp_str;
00225 VALUE envp_buf;
00226 VALUE dup2_tmpbuf;
00227 unsigned pgroup_given : 1;
00228 unsigned umask_given : 1;
00229 unsigned unsetenv_others_given : 1;
00230 unsigned unsetenv_others_do : 1;
00231 unsigned close_others_given : 1;
00232 unsigned close_others_do : 1;
00233 unsigned chdir_given : 1;
00234 unsigned new_pgroup_given : 1;
00235 unsigned new_pgroup_flag : 1;
00236 unsigned uid_given : 1;
00237 unsigned gid_given : 1;
00238 rb_pid_t pgroup_pgid;
00239 VALUE rlimit_limits;
00240 mode_t umask_mask;
00241 rb_uid_t uid;
00242 rb_gid_t gid;
00243 VALUE fd_dup2;
00244 VALUE fd_close;
00245 VALUE fd_open;
00246 VALUE fd_dup2_child;
00247 int close_others_maxhint;
00248 VALUE env_modification;
00249 VALUE chdir_dir;
00250 };
00251
00252
00253
00254
00255
00256 #define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 2)
00257 #define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str) + 1)
00258
00259 rb_pid_t rb_fork_ruby(int *status);
00260 void rb_last_status_clear(void);
00261
00262
00263 VALUE rb_lcm(VALUE x, VALUE y);
00264 VALUE rb_rational_reciprocal(VALUE x);
00265
00266
00267 VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
00268 VALUE rb_reg_check_preprocess(VALUE);
00269
00270
00271 int rb_get_next_signal(void);
00272 int rb_sigaltstack_size(void);
00273
00274
00275 #ifdef RUBY_ENCODING_H
00276 size_t rb_strftime_timespec(char *s, size_t maxsize, const char *format, rb_encoding *enc,
00277 const struct vtm *vtm, struct timespec *ts, int gmt);
00278 size_t rb_strftime(char *s, size_t maxsize, const char *format, rb_encoding *enc,
00279 const struct vtm *vtm, VALUE timev, int gmt);
00280 #endif
00281
00282
00283 int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
00284 int rb_str_symname_p(VALUE);
00285 VALUE rb_str_quote_unprintable(VALUE);
00286 VALUE rb_id_quote_unprintable(ID);
00287 #define QUOTE(str) rb_str_quote_unprintable(str)
00288 #define QUOTE_ID(id) rb_id_quote_unprintable(id)
00289 VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
00290
00291
00292 VALUE rb_struct_init_copy(VALUE copy, VALUE s);
00293
00294
00295 struct timeval rb_time_timeval(VALUE);
00296
00297
00298 VALUE rb_obj_is_mutex(VALUE obj);
00299 VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
00300 void rb_thread_execute_interrupts(VALUE th);
00301 void rb_clear_trace_func(void);
00302 VALUE rb_get_coverages(void);
00303 VALUE rb_thread_shield_new(void);
00304 VALUE rb_thread_shield_wait(VALUE self);
00305 VALUE rb_thread_shield_release(VALUE self);
00306 VALUE rb_thread_shield_destroy(VALUE self);
00307 void rb_mutex_allow_trap(VALUE self, int val);
00308 VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
00309 VALUE rb_mutex_owned_p(VALUE self);
00310
00311
00312 void Init_native_thread(void);
00313
00314
00315 VALUE rb_obj_is_thread(VALUE obj);
00316 void rb_vm_mark(void *ptr);
00317 void Init_BareVM(void);
00318 VALUE rb_vm_top_self(void);
00319 void rb_thread_recycle_stack_release(VALUE *);
00320 void rb_vm_change_state(void);
00321 void rb_vm_inc_const_missing_count(void);
00322 void rb_thread_mark(void *th);
00323 const void **rb_vm_get_insns_address_table(void);
00324 VALUE rb_sourcefilename(void);
00325 void rb_vm_pop_cfunc_frame(void);
00326
00327
00328 void rb_vm_bugreport(void);
00329
00330
00331 void Init_vm_eval(void);
00332 VALUE rb_current_realfilepath(void);
00333 VALUE rb_check_block_call(VALUE, ID, int, VALUE *, VALUE (*)(ANYARGS), VALUE);
00334 typedef void rb_check_funcall_hook(int, VALUE, ID, int, VALUE *, VALUE);
00335 VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, VALUE *argv,
00336 rb_check_funcall_hook *hook, VALUE arg);
00337
00338
00339 void Init_eval_method(void);
00340 int rb_method_defined_by(VALUE obj, ID mid, VALUE (*cfunc)(ANYARGS));
00341
00342
00343 void Init_prelude(void);
00344
00345
00346 void Init_vm_backtrace(void);
00347 VALUE vm_thread_backtrace(int argc, VALUE *argv, VALUE thval);
00348 VALUE vm_thread_backtrace_locations(int argc, VALUE *argv, VALUE thval);
00349
00350 VALUE rb_make_backtrace(void);
00351 void rb_backtrace_print_as_bugreport(void);
00352 int rb_backtrace_p(VALUE obj);
00353 VALUE rb_backtrace_to_str_ary(VALUE obj);
00354 VALUE rb_vm_backtrace_object();
00355
00356 #if defined __GNUC__ && __GNUC__ >= 4
00357 #pragma GCC visibility push(default)
00358 #endif
00359 const char *rb_objspace_data_type_name(VALUE obj);
00360
00361
00362 VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
00363
00364
00365 void rb_maygvl_fd_fix_cloexec(int fd);
00366
00367
00368 int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
00369 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);
00370 VALUE rb_execarg_new(int argc, VALUE *argv, int accept_shell);
00371 struct rb_execarg *rb_execarg_get(VALUE execarg_obj);
00372 VALUE rb_execarg_init(int argc, VALUE *argv, int accept_shell, VALUE execarg_obj);
00373 int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
00374 void rb_execarg_fixup(VALUE execarg_obj);
00375 int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);
00376 VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
00377 void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
00378
00379
00380 void rb_gc_mark_global_tbl(void);
00381 void rb_mark_generic_ivar(VALUE);
00382 void rb_mark_generic_ivar_tbl(void);
00383
00384 #if defined __GNUC__ && __GNUC__ >= 4
00385 #pragma GCC visibility pop
00386 #endif
00387
00388 #if defined(__cplusplus)
00389 #if 0
00390 {
00391 #endif
00392 }
00393 #endif
00394
00395 #endif
00396