1 /**********************************************************************
2 
3   intern.h -
4 
5   $Author: ko1 $
6   created at: Thu Jun 10 14:22:17 JST 1993
7 
8   Copyright (C) 1993-2007 Yukihiro Matsumoto
9   Copyright (C) 2000  Network Applied Communication Laboratory, Inc.
10   Copyright (C) 2000  Information-technology Promotion Agency, Japan
11 
12 **********************************************************************/
13 
14 #ifndef RUBY_INTERN_H
15 #define RUBY_INTERN_H 1
16 
17 #if defined(__cplusplus)
18 extern "C" {
19 #if 0
20 } /* satisfy cc-mode */
21 #endif
22 #endif
23 
24 #include "ruby/defines.h"
25 #ifdef RUBY_EXTCONF_H
26 #include RUBY_EXTCONF_H
27 #endif
28 
29 #ifdef HAVE_STDARG_PROTOTYPES
30 # include <stdarg.h>
31 #else
32 # include <varargs.h>
33 #endif
34 
35 #include "ruby/st.h"
36 
37 /* On mswin, MJIT header transformation can't be used since cl.exe can't output
38    preprocessed output preserving macros. So this `MJIT_STATIC` is needed
39    to force non-static function to static on MJIT header to avoid symbol conflict. */
40 #ifdef MJIT_HEADER
41 # define MJIT_STATIC static
42 #else
43 # define MJIT_STATIC
44 #endif
45 
46 RUBY_SYMBOL_EXPORT_BEGIN
47 
48 /*
49  * Functions and variables that are used by more than one source file of
50  * the kernel.
51  */
52 
53 #define UNLIMITED_ARGUMENTS (-1)
54 
55 /* array.c */
56 void rb_mem_clear(register VALUE*, register long);
57 VALUE rb_assoc_new(VALUE, VALUE);
58 VALUE rb_check_array_type(VALUE);
59 VALUE rb_ary_new(void);
60 VALUE rb_ary_new_capa(long capa);
61 VALUE rb_ary_new_from_args(long n, ...);
62 VALUE rb_ary_new_from_values(long n, const VALUE *elts);
63 VALUE rb_ary_tmp_new(long);
64 void rb_ary_free(VALUE);
65 void rb_ary_modify(VALUE);
66 VALUE rb_ary_freeze(VALUE);
67 VALUE rb_ary_shared_with_p(VALUE, VALUE);
68 VALUE rb_ary_aref(int, const VALUE*, VALUE);
69 VALUE rb_ary_subseq(VALUE, long, long);
70 void rb_ary_store(VALUE, long, VALUE);
71 VALUE rb_ary_dup(VALUE);
72 VALUE rb_ary_resurrect(VALUE ary);
73 VALUE rb_ary_to_ary(VALUE);
74 VALUE rb_ary_to_s(VALUE);
75 VALUE rb_ary_cat(VALUE, const VALUE *, long);
76 VALUE rb_ary_push(VALUE, VALUE);
77 VALUE rb_ary_pop(VALUE);
78 VALUE rb_ary_shift(VALUE);
79 VALUE rb_ary_unshift(VALUE, VALUE);
80 VALUE rb_ary_entry(VALUE, long);
81 VALUE rb_ary_each(VALUE);
82 VALUE rb_ary_join(VALUE, VALUE);
83 VALUE rb_ary_reverse(VALUE);
84 VALUE rb_ary_rotate(VALUE, long);
85 VALUE rb_ary_sort(VALUE);
86 VALUE rb_ary_sort_bang(VALUE);
87 VALUE rb_ary_delete(VALUE, VALUE);
88 VALUE rb_ary_delete_at(VALUE, long);
89 VALUE rb_ary_clear(VALUE);
90 VALUE rb_ary_plus(VALUE, VALUE);
91 VALUE rb_ary_concat(VALUE, VALUE);
92 VALUE rb_ary_assoc(VALUE, VALUE);
93 VALUE rb_ary_rassoc(VALUE, VALUE);
94 VALUE rb_ary_includes(VALUE, VALUE);
95 VALUE rb_ary_cmp(VALUE, VALUE);
96 VALUE rb_ary_replace(VALUE copy, VALUE orig);
97 VALUE rb_get_values_at(VALUE, long, int, const VALUE*, VALUE(*)(VALUE,long));
98 VALUE rb_ary_resize(VALUE ary, long len);
99 #define rb_ary_new2 rb_ary_new_capa
100 #define rb_ary_new3 rb_ary_new_from_args
101 #define rb_ary_new4 rb_ary_new_from_values
102 /* bignum.c */
103 VALUE rb_big_new(size_t, int);
104 int rb_bigzero_p(VALUE x);
105 VALUE rb_big_clone(VALUE);
106 void rb_big_2comp(VALUE);
107 VALUE rb_big_norm(VALUE);
108 void rb_big_resize(VALUE big, size_t len);
109 VALUE rb_cstr_to_inum(const char*, int, int);
110 VALUE rb_str_to_inum(VALUE, int, int);
111 VALUE rb_cstr2inum(const char*, int);
112 VALUE rb_str2inum(VALUE, int);
113 VALUE rb_big2str(VALUE, int);
114 long rb_big2long(VALUE);
115 #define rb_big2int(x) rb_big2long(x)
116 unsigned long rb_big2ulong(VALUE);
117 #define rb_big2uint(x) rb_big2ulong(x)
118 #if HAVE_LONG_LONG
119 LONG_LONG rb_big2ll(VALUE);
120 unsigned LONG_LONG rb_big2ull(VALUE);
121 #endif  /* HAVE_LONG_LONG */
122 void rb_big_pack(VALUE val, unsigned long *buf, long num_longs);
123 VALUE rb_big_unpack(unsigned long *buf, long num_longs);
124 int rb_uv_to_utf8(char[6],unsigned long);
125 VALUE rb_dbl2big(double);
126 double rb_big2dbl(VALUE);
127 VALUE rb_big_cmp(VALUE, VALUE);
128 VALUE rb_big_eq(VALUE, VALUE);
129 VALUE rb_big_eql(VALUE, VALUE);
130 VALUE rb_big_plus(VALUE, VALUE);
131 VALUE rb_big_minus(VALUE, VALUE);
132 VALUE rb_big_mul(VALUE, VALUE);
133 VALUE rb_big_div(VALUE, VALUE);
134 VALUE rb_big_idiv(VALUE, VALUE);
135 VALUE rb_big_modulo(VALUE, VALUE);
136 VALUE rb_big_divmod(VALUE, VALUE);
137 VALUE rb_big_pow(VALUE, VALUE);
138 VALUE rb_big_and(VALUE, VALUE);
139 VALUE rb_big_or(VALUE, VALUE);
140 VALUE rb_big_xor(VALUE, VALUE);
141 VALUE rb_big_lshift(VALUE, VALUE);
142 VALUE rb_big_rshift(VALUE, VALUE);
143 
144 /* For rb_integer_pack and rb_integer_unpack: */
145 /* "MS" in MSWORD and MSBYTE means "most significant" */
146 /* "LS" in LSWORD and LSBYTE means "least significant" */
147 #define INTEGER_PACK_MSWORD_FIRST       0x01
148 #define INTEGER_PACK_LSWORD_FIRST       0x02
149 #define INTEGER_PACK_MSBYTE_FIRST       0x10
150 #define INTEGER_PACK_LSBYTE_FIRST       0x20
151 #define INTEGER_PACK_NATIVE_BYTE_ORDER  0x40
152 #define INTEGER_PACK_2COMP              0x80
153 #define INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION     0x400
154 /* For rb_integer_unpack: */
155 #define INTEGER_PACK_FORCE_BIGNUM       0x100
156 #define INTEGER_PACK_NEGATIVE           0x200
157 /* Combinations: */
158 #define INTEGER_PACK_LITTLE_ENDIAN \
159     (INTEGER_PACK_LSWORD_FIRST | \
160      INTEGER_PACK_LSBYTE_FIRST)
161 #define INTEGER_PACK_BIG_ENDIAN \
162     (INTEGER_PACK_MSWORD_FIRST | \
163      INTEGER_PACK_MSBYTE_FIRST)
164 int rb_integer_pack(VALUE val, void *words, size_t numwords, size_t wordsize, size_t nails, int flags);
165 VALUE rb_integer_unpack(const void *words, size_t numwords, size_t wordsize, size_t nails, int flags);
166 size_t rb_absint_size(VALUE val, int *nlz_bits_ret);
167 size_t rb_absint_numwords(VALUE val, size_t word_numbits, size_t *nlz_bits_ret);
168 int rb_absint_singlebit_p(VALUE val);
169 
170 /* rational.c */
171 VALUE rb_rational_raw(VALUE, VALUE);
172 #define rb_rational_raw1(x) rb_rational_raw((x), INT2FIX(1))
173 #define rb_rational_raw2(x,y) rb_rational_raw((x), (y))
174 VALUE rb_rational_new(VALUE, VALUE);
175 #define rb_rational_new1(x) rb_rational_new((x), INT2FIX(1))
176 #define rb_rational_new2(x,y) rb_rational_new((x), (y))
177 VALUE rb_Rational(VALUE, VALUE);
178 #define rb_Rational1(x) rb_Rational((x), INT2FIX(1))
179 #define rb_Rational2(x,y) rb_Rational((x), (y))
180 VALUE rb_rational_num(VALUE rat);
181 VALUE rb_rational_den(VALUE rat);
182 VALUE rb_flt_rationalize_with_prec(VALUE, VALUE);
183 VALUE rb_flt_rationalize(VALUE);
184 /* complex.c */
185 VALUE rb_complex_raw(VALUE, VALUE);
186 #define rb_complex_raw1(x) rb_complex_raw((x), INT2FIX(0))
187 #define rb_complex_raw2(x,y) rb_complex_raw((x), (y))
188 VALUE rb_complex_new(VALUE, VALUE);
189 #define rb_complex_new1(x) rb_complex_new((x), INT2FIX(0))
190 #define rb_complex_new2(x,y) rb_complex_new((x), (y))
191 VALUE rb_complex_new_polar(VALUE abs, VALUE arg);
192 DEPRECATED_BY(rb_complex_new_polar, VALUE rb_complex_polar(VALUE abs, VALUE arg));
193 VALUE rb_complex_real(VALUE z);
194 VALUE rb_complex_imag(VALUE z);
195 VALUE rb_complex_plus(VALUE x, VALUE y);
196 VALUE rb_complex_minus(VALUE x, VALUE y);
197 VALUE rb_complex_mul(VALUE x, VALUE y);
198 VALUE rb_complex_div(VALUE x, VALUE y);
199 VALUE rb_complex_uminus(VALUE z);
200 VALUE rb_complex_conjugate(VALUE z);
201 VALUE rb_complex_abs(VALUE z);
202 VALUE rb_complex_arg(VALUE z);
203 VALUE rb_complex_pow(VALUE base, VALUE exp);
204 VALUE rb_dbl_complex_new(double real, double imag);
205 #define rb_complex_add rb_complex_plus
206 #define rb_complex_sub rb_complex_minus
207 #define rb_complex_nagate rb_complex_uminus
208 
209 VALUE rb_Complex(VALUE, VALUE);
210 #define rb_Complex1(x) rb_Complex((x), INT2FIX(0))
211 #define rb_Complex2(x,y) rb_Complex((x), (y))
212 /* class.c */
213 VALUE rb_class_new(VALUE);
214 VALUE rb_mod_init_copy(VALUE, VALUE);
215 VALUE rb_singleton_class_clone(VALUE);
216 void rb_singleton_class_attached(VALUE,VALUE);
217 void rb_check_inheritable(VALUE);
218 VALUE rb_define_class_id(ID, VALUE);
219 VALUE rb_define_class_id_under(VALUE, ID, VALUE);
220 VALUE rb_module_new(void);
221 VALUE rb_define_module_id(ID);
222 VALUE rb_define_module_id_under(VALUE, ID);
223 VALUE rb_mod_included_modules(VALUE);
224 VALUE rb_mod_include_p(VALUE, VALUE);
225 VALUE rb_mod_ancestors(VALUE);
226 VALUE rb_class_instance_methods(int, const VALUE*, VALUE);
227 VALUE rb_class_public_instance_methods(int, const VALUE*, VALUE);
228 VALUE rb_class_protected_instance_methods(int, const VALUE*, VALUE);
229 VALUE rb_class_private_instance_methods(int, const VALUE*, VALUE);
230 VALUE rb_obj_singleton_methods(int, const VALUE*, VALUE);
231 void rb_define_method_id(VALUE, ID, VALUE (*)(ANYARGS), int);
232 void rb_undef(VALUE, ID);
233 void rb_define_protected_method(VALUE, const char*, VALUE (*)(ANYARGS), int);
234 void rb_define_private_method(VALUE, const char*, VALUE (*)(ANYARGS), int);
235 void rb_define_singleton_method(VALUE, const char*, VALUE(*)(ANYARGS), int);
236 VALUE rb_singleton_class(VALUE);
237 /* compar.c */
238 int rb_cmpint(VALUE, VALUE, VALUE);
239 NORETURN(void rb_cmperr(VALUE, VALUE));
240 /* cont.c */
241 VALUE rb_fiber_new(VALUE (*)(ANYARGS), VALUE);
242 VALUE rb_fiber_resume(VALUE fib, int argc, const VALUE *argv);
243 VALUE rb_fiber_yield(int argc, const VALUE *argv);
244 VALUE rb_fiber_current(void);
245 VALUE rb_fiber_alive_p(VALUE);
246 /* enum.c */
247 VALUE rb_enum_values_pack(int, const VALUE*);
248 /* enumerator.c */
249 VALUE rb_enumeratorize(VALUE, VALUE, int, const VALUE *);
250 typedef VALUE rb_enumerator_size_func(VALUE, VALUE, VALUE);
251 VALUE rb_enumeratorize_with_size(VALUE, VALUE, int, const VALUE *, rb_enumerator_size_func *);
252 #ifndef RUBY_EXPORT
253 #define rb_enumeratorize_with_size(obj, id, argc, argv, size_fn) \
254     rb_enumeratorize_with_size(obj, id, argc, argv, (rb_enumerator_size_func *)(size_fn))
255 #endif
256 #define SIZED_ENUMERATOR(obj, argc, argv, size_fn) \
257     rb_enumeratorize_with_size((obj), ID2SYM(rb_frame_this_func()), \
258 			       (argc), (argv), (size_fn))
259 #define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn) do {		\
260 	if (!rb_block_given_p())					\
261 	    return SIZED_ENUMERATOR(obj, argc, argv, size_fn);		\
262     } while (0)
263 #define RETURN_ENUMERATOR(obj, argc, argv) RETURN_SIZED_ENUMERATOR(obj, argc, argv, 0)
264 typedef struct {
265     VALUE begin;
266     VALUE end;
267     VALUE step;
268     int exclude_end;
269 } rb_arithmetic_sequence_components_t;
270 int rb_arithmetic_sequence_extract(VALUE, rb_arithmetic_sequence_components_t *);
271 /* error.c */
272 VALUE rb_exc_new(VALUE, const char*, long);
273 VALUE rb_exc_new_cstr(VALUE, const char*);
274 VALUE rb_exc_new_str(VALUE, VALUE);
275 #define rb_exc_new2 rb_exc_new_cstr
276 #define rb_exc_new3 rb_exc_new_str
277 PRINTF_ARGS(NORETURN(void rb_loaderror(const char*, ...)), 1, 2);
278 PRINTF_ARGS(NORETURN(void rb_loaderror_with_path(VALUE path, const char*, ...)), 2, 3);
279 PRINTF_ARGS(NORETURN(void rb_name_error(ID, const char*, ...)), 2, 3);
280 PRINTF_ARGS(NORETURN(void rb_name_error_str(VALUE, const char*, ...)), 2, 3);
281 NORETURN(void rb_invalid_str(const char*, const char*));
282 NORETURN(void rb_error_frozen(const char*));
283 NORETURN(void rb_error_frozen_object(VALUE));
284 void rb_error_untrusted(VALUE);
285 void rb_check_frozen(VALUE);
286 void rb_check_trusted(VALUE);
287 #define rb_check_frozen_internal(obj) do { \
288 	VALUE frozen_obj = (obj); \
289 	if (RB_UNLIKELY(RB_OBJ_FROZEN(frozen_obj))) { \
290 	    rb_error_frozen_object(frozen_obj); \
291 	} \
292     } while (0)
293 #define rb_check_trusted_internal(obj) ((void) 0)
294 #ifdef __GNUC__
295 #define rb_check_frozen(obj) __extension__({rb_check_frozen_internal(obj);})
296 #define rb_check_trusted(obj) __extension__({rb_check_trusted_internal(obj);})
297 #else
298 static inline void
rb_check_frozen_inline(VALUE obj)299 rb_check_frozen_inline(VALUE obj)
300 {
301     rb_check_frozen_internal(obj);
302 }
303 #define rb_check_frozen(obj) rb_check_frozen_inline(obj)
304 static inline void
rb_check_trusted_inline(VALUE obj)305 rb_check_trusted_inline(VALUE obj)
306 {
307     rb_check_trusted_internal(obj);
308 }
309 #define rb_check_trusted(obj) rb_check_trusted_inline(obj)
310 #endif
311 void rb_check_copyable(VALUE obj, VALUE orig);
312 
313 #define RB_OBJ_INIT_COPY(obj, orig) \
314     ((obj) != (orig) && (rb_obj_init_copy((obj), (orig)), 1))
315 #define OBJ_INIT_COPY(obj, orig) RB_OBJ_INIT_COPY(obj, orig)
316 
317 /* eval.c */
318 int rb_sourceline(void);
319 const char *rb_sourcefile(void);
320 VALUE rb_check_funcall(VALUE, ID, int, const VALUE*);
321 
322 NORETURN(MJIT_STATIC void rb_error_arity(int, int, int));
323 static inline int
rb_check_arity(int argc,int min,int max)324 rb_check_arity(int argc, int min, int max)
325 {
326     if ((argc < min) || (max != UNLIMITED_ARGUMENTS && argc > max))
327 	rb_error_arity(argc, min, max);
328     return argc;
329 }
330 #define rb_check_arity rb_check_arity /* for ifdef */
331 
332 #if defined(NFDBITS) && defined(HAVE_RB_FD_INIT)
333 typedef struct {
334     int maxfd;
335     fd_set *fdset;
336 } rb_fdset_t;
337 
338 void rb_fd_init(rb_fdset_t *);
339 void rb_fd_term(rb_fdset_t *);
340 void rb_fd_zero(rb_fdset_t *);
341 void rb_fd_set(int, rb_fdset_t *);
342 void rb_fd_clr(int, rb_fdset_t *);
343 int rb_fd_isset(int, const rb_fdset_t *);
344 void rb_fd_copy(rb_fdset_t *, const fd_set *, int);
345 void rb_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src);
346 
347 struct timeval;
348 int rb_fd_select(int, rb_fdset_t *, rb_fdset_t *, rb_fdset_t *, struct timeval *);
349 
350 #define rb_fd_ptr(f)	((f)->fdset)
351 #define rb_fd_max(f)	((f)->maxfd)
352 
353 #elif defined(_WIN32)
354 
355 typedef struct {
356     int capa;
357     fd_set *fdset;
358 } rb_fdset_t;
359 
360 void rb_fd_init(rb_fdset_t *);
361 void rb_fd_term(rb_fdset_t *);
362 #define rb_fd_zero(f)		((f)->fdset->fd_count = 0)
363 void rb_fd_set(int, rb_fdset_t *);
364 #define rb_fd_clr(n, f)		rb_w32_fdclr((n), (f)->fdset)
365 #define rb_fd_isset(n, f)	rb_w32_fdisset((n), (f)->fdset)
366 #define rb_fd_copy(d, s, n)	rb_w32_fd_copy((d), (s), (n))
367 void rb_w32_fd_copy(rb_fdset_t *, const fd_set *, int);
368 #define rb_fd_dup(d, s)	rb_w32_fd_dup((d), (s))
369 void rb_w32_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src);
370 static inline int
rb_fd_select(int n,rb_fdset_t * rfds,rb_fdset_t * wfds,rb_fdset_t * efds,struct timeval * timeout)371 rb_fd_select(int n, rb_fdset_t *rfds, rb_fdset_t *wfds, rb_fdset_t *efds, struct timeval *timeout)
372 {
373     return rb_w32_select(n,
374                          rfds ? rfds->fdset : NULL,
375                          wfds ? wfds->fdset : NULL,
376                          efds ? efds->fdset : NULL,
377                          timeout);
378 }
379 #define rb_fd_resize(n, f)	((void)(f))
380 
381 #define rb_fd_ptr(f)	((f)->fdset)
382 #define rb_fd_max(f)	((f)->fdset->fd_count)
383 
384 #else
385 
386 typedef fd_set rb_fdset_t;
387 #define rb_fd_zero(f)	FD_ZERO(f)
388 #define rb_fd_set(n, f)	FD_SET((n), (f))
389 #define rb_fd_clr(n, f)	FD_CLR((n), (f))
390 #define rb_fd_isset(n, f) FD_ISSET((n), (f))
391 #define rb_fd_copy(d, s, n) (*(d) = *(s))
392 #define rb_fd_dup(d, s) (*(d) = *(s))
393 #define rb_fd_resize(n, f)	((void)(f))
394 #define rb_fd_ptr(f)	(f)
395 #define rb_fd_init(f)	FD_ZERO(f)
396 #define rb_fd_init_copy(d, s) (*(d) = *(s))
397 #define rb_fd_term(f)	((void)(f))
398 #define rb_fd_max(f)	FD_SETSIZE
399 #define rb_fd_select(n, rfds, wfds, efds, timeout)	select((n), (rfds), (wfds), (efds), (timeout))
400 
401 #endif
402 
403 NORETURN(void rb_exc_raise(VALUE));
404 NORETURN(void rb_exc_fatal(VALUE));
405 NORETURN(VALUE rb_f_exit(int, const VALUE*));
406 NORETURN(VALUE rb_f_abort(int, const VALUE*));
407 void rb_remove_method(VALUE, const char*);
408 void rb_remove_method_id(VALUE, ID);
409 #define HAVE_RB_DEFINE_ALLOC_FUNC 1
410 typedef VALUE (*rb_alloc_func_t)(VALUE);
411 void rb_define_alloc_func(VALUE, rb_alloc_func_t);
412 void rb_undef_alloc_func(VALUE);
413 rb_alloc_func_t rb_get_alloc_func(VALUE);
414 void rb_clear_constant_cache(void);
415 void rb_clear_method_cache_by_class(VALUE);
416 void rb_alias(VALUE, ID, ID);
417 void rb_attr(VALUE,ID,int,int,int);
418 int rb_method_boundp(VALUE, ID, int);
419 int rb_method_basic_definition_p(VALUE, ID);
420 VALUE rb_eval_cmd(VALUE, VALUE, int);
421 int rb_obj_respond_to(VALUE, ID, int);
422 int rb_respond_to(VALUE, ID);
423 NORETURN(VALUE rb_f_notimplement(int argc, const VALUE *argv, VALUE obj));
424 #if !defined(RUBY_EXPORT) && defined(_WIN32)
425 RUBY_EXTERN VALUE (*const rb_f_notimplement_)(int, const VALUE *, VALUE);
426 #define rb_f_notimplement (*rb_f_notimplement_)
427 #endif
428 NORETURN(void rb_interrupt(void));
429 VALUE rb_apply(VALUE, ID, VALUE);
430 void rb_backtrace(void);
431 ID rb_frame_this_func(void);
432 VALUE rb_obj_instance_eval(int, const VALUE*, VALUE);
433 VALUE rb_obj_instance_exec(int, const VALUE*, VALUE);
434 VALUE rb_mod_module_eval(int, const VALUE*, VALUE);
435 VALUE rb_mod_module_exec(int, const VALUE*, VALUE);
436 void rb_load(VALUE, int);
437 void rb_load_protect(VALUE, int, int*);
438 NORETURN(void rb_jump_tag(int));
439 int rb_provided(const char*);
440 int rb_feature_provided(const char *, const char **);
441 void rb_provide(const char*);
442 VALUE rb_f_require(VALUE, VALUE);
443 VALUE rb_require_safe(VALUE, int);
444 void rb_obj_call_init(VALUE, int, const VALUE*);
445 VALUE rb_class_new_instance(int, const VALUE*, VALUE);
446 VALUE rb_block_proc(void);
447 VALUE rb_block_lambda(void);
448 VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE);
449 VALUE rb_obj_is_proc(VALUE);
450 VALUE rb_proc_call(VALUE, VALUE);
451 VALUE rb_proc_call_with_block(VALUE, int argc, const VALUE *argv, VALUE);
452 int rb_proc_arity(VALUE);
453 VALUE rb_proc_lambda_p(VALUE);
454 VALUE rb_binding_new(void);
455 VALUE rb_obj_method(VALUE, VALUE);
456 VALUE rb_obj_is_method(VALUE);
457 VALUE rb_method_call(int, const VALUE*, VALUE);
458 VALUE rb_method_call_with_block(int, const VALUE *, VALUE, VALUE);
459 int rb_mod_method_arity(VALUE, ID);
460 int rb_obj_method_arity(VALUE, ID);
461 VALUE rb_protect(VALUE (*)(VALUE), VALUE, int*);
462 void rb_set_end_proc(void (*)(VALUE), VALUE);
463 void rb_exec_end_proc(void);
464 void rb_thread_schedule(void);
465 void rb_thread_wait_fd(int);
466 int rb_thread_fd_writable(int);
467 void rb_thread_fd_close(int);
468 int rb_thread_alone(void);
469 void rb_thread_sleep(int);
470 void rb_thread_sleep_forever(void);
471 void rb_thread_sleep_deadly(void);
472 VALUE rb_thread_stop(void);
473 VALUE rb_thread_wakeup(VALUE);
474 VALUE rb_thread_wakeup_alive(VALUE);
475 VALUE rb_thread_run(VALUE);
476 VALUE rb_thread_kill(VALUE);
477 VALUE rb_thread_create(VALUE (*)(ANYARGS), void*);
478 int rb_thread_fd_select(int, rb_fdset_t *, rb_fdset_t *, rb_fdset_t *, struct timeval *);
479 void rb_thread_wait_for(struct timeval);
480 VALUE rb_thread_current(void);
481 VALUE rb_thread_main(void);
482 VALUE rb_thread_local_aref(VALUE, ID);
483 VALUE rb_thread_local_aset(VALUE, ID, VALUE);
484 void rb_thread_atfork(void);
485 void rb_thread_atfork_before_exec(void);
486 VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE);
487 VALUE rb_exec_recursive_paired(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE,VALUE);
488 VALUE rb_exec_recursive_outer(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE);
489 VALUE rb_exec_recursive_paired_outer(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE,VALUE);
490 /* dir.c */
491 VALUE rb_dir_getwd(void);
492 /* file.c */
493 VALUE rb_file_s_expand_path(int, const VALUE *);
494 VALUE rb_file_expand_path(VALUE, VALUE);
495 VALUE rb_file_s_absolute_path(int, const VALUE *);
496 VALUE rb_file_absolute_path(VALUE, VALUE);
497 VALUE rb_file_dirname(VALUE fname);
498 int rb_find_file_ext_safe(VALUE*, const char* const*, int);
499 VALUE rb_find_file_safe(VALUE, int);
500 int rb_find_file_ext(VALUE*, const char* const*);
501 VALUE rb_find_file(VALUE);
502 VALUE rb_file_directory_p(VALUE,VALUE);
503 VALUE rb_str_encode_ospath(VALUE);
504 int rb_is_absolute_path(const char *);
505 /* gc.c */
506 COLDFUNC NORETURN(void rb_memerror(void));
507 PUREFUNC(int rb_during_gc(void));
508 void rb_gc_mark_locations(const VALUE*, const VALUE*);
509 void rb_mark_tbl(struct st_table*);
510 void rb_mark_set(struct st_table*);
511 void rb_mark_hash(struct st_table*);
512 void rb_gc_mark_maybe(VALUE);
513 void rb_gc_mark(VALUE);
514 void rb_gc_force_recycle(VALUE);
515 void rb_gc(void);
516 void rb_gc_copy_finalizer(VALUE,VALUE);
517 void rb_gc_finalize_deferred(void);
518 void rb_gc_call_finalizer_at_exit(void);
519 VALUE rb_gc_enable(void);
520 VALUE rb_gc_disable(void);
521 VALUE rb_gc_start(void);
522 VALUE rb_define_finalizer(VALUE, VALUE);
523 VALUE rb_undefine_finalizer(VALUE);
524 size_t rb_gc_count(void);
525 size_t rb_gc_stat(VALUE);
526 VALUE rb_gc_latest_gc_info(VALUE);
527 void rb_gc_adjust_memory_usage(ssize_t);
528 /* hash.c */
529 void st_foreach_safe(struct st_table *, int (*)(ANYARGS), st_data_t);
530 VALUE rb_check_hash_type(VALUE);
531 void rb_hash_foreach(VALUE, int (*)(ANYARGS), VALUE);
532 VALUE rb_hash(VALUE);
533 VALUE rb_hash_new(void);
534 VALUE rb_hash_dup(VALUE);
535 VALUE rb_hash_freeze(VALUE);
536 VALUE rb_hash_aref(VALUE, VALUE);
537 VALUE rb_hash_lookup(VALUE, VALUE);
538 VALUE rb_hash_lookup2(VALUE, VALUE, VALUE);
539 VALUE rb_hash_fetch(VALUE, VALUE);
540 VALUE rb_hash_aset(VALUE, VALUE, VALUE);
541 VALUE rb_hash_clear(VALUE);
542 VALUE rb_hash_delete_if(VALUE);
543 VALUE rb_hash_delete(VALUE,VALUE);
544 VALUE rb_hash_set_ifnone(VALUE hash, VALUE ifnone);
545 typedef VALUE rb_hash_update_func(VALUE newkey, VALUE oldkey, VALUE value);
546 VALUE rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func);
547 struct st_table *rb_hash_tbl(VALUE, const char *file, int line);
548 int rb_path_check(const char*);
549 int rb_env_path_tainted(void);
550 VALUE rb_env_clear(void);
551 VALUE rb_hash_size(VALUE);
552 void rb_hash_free(VALUE);
553 /* io.c */
554 #define rb_defout rb_stdout
555 RUBY_EXTERN VALUE rb_fs;
556 RUBY_EXTERN VALUE rb_output_fs;
557 RUBY_EXTERN VALUE rb_rs;
558 RUBY_EXTERN VALUE rb_default_rs;
559 RUBY_EXTERN VALUE rb_output_rs;
560 VALUE rb_io_write(VALUE, VALUE);
561 VALUE rb_io_gets(VALUE);
562 VALUE rb_io_getbyte(VALUE);
563 VALUE rb_io_ungetc(VALUE, VALUE);
564 VALUE rb_io_ungetbyte(VALUE, VALUE);
565 VALUE rb_io_close(VALUE);
566 VALUE rb_io_flush(VALUE);
567 VALUE rb_io_eof(VALUE);
568 VALUE rb_io_binmode(VALUE);
569 VALUE rb_io_ascii8bit_binmode(VALUE);
570 VALUE rb_io_addstr(VALUE, VALUE);
571 VALUE rb_io_printf(int, const VALUE*, VALUE);
572 VALUE rb_io_print(int, const VALUE*, VALUE);
573 VALUE rb_io_puts(int, const VALUE*, VALUE);
574 VALUE rb_io_fdopen(int, int, const char*);
575 VALUE rb_io_get_io(VALUE);
576 VALUE rb_file_open(const char*, const char*);
577 VALUE rb_file_open_str(VALUE, const char*);
578 VALUE rb_gets(void);
579 void rb_write_error(const char*);
580 void rb_write_error2(const char*, long);
581 void rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds);
582 int rb_pipe(int *pipes);
583 int rb_reserved_fd_p(int fd);
584 int rb_cloexec_open(const char *pathname, int flags, mode_t mode);
585 int rb_cloexec_dup(int oldfd);
586 int rb_cloexec_dup2(int oldfd, int newfd);
587 int rb_cloexec_pipe(int fildes[2]);
588 int rb_cloexec_fcntl_dupfd(int fd, int minfd);
589 #define RB_RESERVED_FD_P(fd) rb_reserved_fd_p(fd)
590 void rb_update_max_fd(int fd);
591 void rb_fd_fix_cloexec(int fd);
592 /* marshal.c */
593 VALUE rb_marshal_dump(VALUE, VALUE);
594 VALUE rb_marshal_load(VALUE);
595 void rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE (*dumper)(VALUE), VALUE (*loader)(VALUE, VALUE));
596 /* numeric.c */
597 NORETURN(void rb_num_zerodiv(void));
598 #define RB_NUM_COERCE_FUNCS_NEED_OPID 1
599 VALUE rb_num_coerce_bin(VALUE, VALUE, ID);
600 VALUE rb_num_coerce_cmp(VALUE, VALUE, ID);
601 VALUE rb_num_coerce_relop(VALUE, VALUE, ID);
602 VALUE rb_num_coerce_bit(VALUE, VALUE, ID);
603 VALUE rb_num2fix(VALUE);
604 VALUE rb_fix2str(VALUE, int);
605 CONSTFUNC(VALUE rb_dbl_cmp(double, double));
606 /* object.c */
607 int rb_eql(VALUE, VALUE);
608 VALUE rb_any_to_s(VALUE);
609 VALUE rb_inspect(VALUE);
610 VALUE rb_obj_is_instance_of(VALUE, VALUE);
611 VALUE rb_obj_is_kind_of(VALUE, VALUE);
612 VALUE rb_obj_alloc(VALUE);
613 VALUE rb_obj_clone(VALUE);
614 VALUE rb_obj_dup(VALUE);
615 VALUE rb_obj_init_copy(VALUE,VALUE);
616 VALUE rb_obj_taint(VALUE);
617 PUREFUNC(VALUE rb_obj_tainted(VALUE));
618 VALUE rb_obj_untaint(VALUE);
619 VALUE rb_obj_untrust(VALUE);
620 PUREFUNC(VALUE rb_obj_untrusted(VALUE));
621 VALUE rb_obj_trust(VALUE);
622 VALUE rb_obj_freeze(VALUE);
623 PUREFUNC(VALUE rb_obj_frozen_p(VALUE));
624 VALUE rb_obj_id(VALUE);
625 VALUE rb_obj_class(VALUE);
626 PUREFUNC(VALUE rb_class_real(VALUE));
627 PUREFUNC(VALUE rb_class_inherited_p(VALUE, VALUE));
628 VALUE rb_class_superclass(VALUE);
629 VALUE rb_class_get_superclass(VALUE);
630 VALUE rb_convert_type(VALUE,int,const char*,const char*);
631 VALUE rb_check_convert_type(VALUE,int,const char*,const char*);
632 VALUE rb_check_to_integer(VALUE, const char *);
633 VALUE rb_check_to_float(VALUE);
634 VALUE rb_to_int(VALUE);
635 VALUE rb_check_to_int(VALUE);
636 VALUE rb_Integer(VALUE);
637 VALUE rb_to_float(VALUE);
638 VALUE rb_Float(VALUE);
639 VALUE rb_String(VALUE);
640 VALUE rb_Array(VALUE);
641 VALUE rb_Hash(VALUE);
642 double rb_cstr_to_dbl(const char*, int);
643 double rb_str_to_dbl(VALUE, int);
644 /* parse.y */
645 ID rb_id_attrset(ID);
646 CONSTFUNC(int rb_is_const_id(ID));
647 CONSTFUNC(int rb_is_global_id(ID));
648 CONSTFUNC(int rb_is_instance_id(ID));
649 CONSTFUNC(int rb_is_attrset_id(ID));
650 CONSTFUNC(int rb_is_class_id(ID));
651 CONSTFUNC(int rb_is_local_id(ID));
652 CONSTFUNC(int rb_is_junk_id(ID));
653 int rb_symname_p(const char*);
654 int rb_sym_interned_p(VALUE);
655 VALUE rb_backref_get(void);
656 void rb_backref_set(VALUE);
657 VALUE rb_lastline_get(void);
658 void rb_lastline_set(VALUE);
659 /* process.c */
660 void rb_last_status_set(int status, rb_pid_t pid);
661 VALUE rb_last_status_get(void);
662 int rb_proc_exec(const char*);
663 NORETURN(VALUE rb_f_exec(int, const VALUE*));
664 rb_pid_t rb_waitpid(rb_pid_t pid, int *status, int flags);
665 void rb_syswait(rb_pid_t pid);
666 rb_pid_t rb_spawn(int, const VALUE*);
667 rb_pid_t rb_spawn_err(int, const VALUE*, char*, size_t);
668 VALUE rb_proc_times(VALUE);
669 VALUE rb_detach_process(rb_pid_t pid);
670 /* range.c */
671 VALUE rb_range_new(VALUE, VALUE, int);
672 VALUE rb_range_beg_len(VALUE, long*, long*, long, int);
673 int rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp);
674 /* random.c */
675 unsigned int rb_genrand_int32(void);
676 double rb_genrand_real(void);
677 void rb_reset_random_seed(void);
678 VALUE rb_random_bytes(VALUE rnd, long n);
679 VALUE rb_random_int(VALUE rnd, VALUE max);
680 unsigned int rb_random_int32(VALUE rnd);
681 double rb_random_real(VALUE rnd);
682 unsigned long rb_random_ulong_limited(VALUE rnd, unsigned long limit);
683 unsigned long rb_genrand_ulong_limited(unsigned long i);
684 /* re.c */
685 #define rb_memcmp memcmp
686 int rb_memcicmp(const void*,const void*,long);
687 void rb_match_busy(VALUE);
688 VALUE rb_reg_nth_defined(int, VALUE);
689 VALUE rb_reg_nth_match(int, VALUE);
690 int rb_reg_backref_number(VALUE match, VALUE backref);
691 VALUE rb_reg_last_match(VALUE);
692 VALUE rb_reg_match_pre(VALUE);
693 VALUE rb_reg_match_post(VALUE);
694 VALUE rb_reg_match_last(VALUE);
695 #define HAVE_RB_REG_NEW_STR 1
696 VALUE rb_reg_new_str(VALUE, int);
697 VALUE rb_reg_new(const char *, long, int);
698 VALUE rb_reg_alloc(void);
699 VALUE rb_reg_init_str(VALUE re, VALUE s, int options);
700 VALUE rb_reg_match(VALUE, VALUE);
701 VALUE rb_reg_match2(VALUE);
702 int rb_reg_options(VALUE);
703 /* ruby.c */
704 #define rb_argv rb_get_argv()
705 RUBY_EXTERN VALUE rb_argv0;
706 VALUE rb_get_argv(void);
707 void *rb_load_file(const char*);
708 void *rb_load_file_str(VALUE);
709 /* signal.c */
710 VALUE rb_f_kill(int, const VALUE*);
711 #ifdef POSIX_SIGNAL
712 #define posix_signal ruby_posix_signal
713 RETSIGTYPE (*posix_signal(int, RETSIGTYPE (*)(int)))(int);
714 #endif
715 void rb_trap_exit(void);
716 void rb_trap_exec(void);
717 const char *ruby_signal_name(int);
718 void ruby_default_signal(int);
719 /* sprintf.c */
720 VALUE rb_f_sprintf(int, const VALUE*);
721 PRINTF_ARGS(VALUE rb_sprintf(const char*, ...), 1, 2);
722 VALUE rb_vsprintf(const char*, va_list);
723 PRINTF_ARGS(VALUE rb_str_catf(VALUE, const char*, ...), 2, 3);
724 VALUE rb_str_vcatf(VALUE, const char*, va_list);
725 VALUE rb_str_format(int, const VALUE *, VALUE);
726 /* string.c */
727 VALUE rb_str_new(const char*, long);
728 VALUE rb_str_new_cstr(const char*);
729 VALUE rb_str_new_shared(VALUE);
730 VALUE rb_str_new_frozen(VALUE);
731 VALUE rb_str_new_with_class(VALUE, const char*, long);
732 VALUE rb_tainted_str_new_cstr(const char*);
733 VALUE rb_tainted_str_new(const char*, long);
734 VALUE rb_external_str_new(const char*, long);
735 VALUE rb_external_str_new_cstr(const char*);
736 VALUE rb_locale_str_new(const char*, long);
737 VALUE rb_locale_str_new_cstr(const char*);
738 VALUE rb_filesystem_str_new(const char*, long);
739 VALUE rb_filesystem_str_new_cstr(const char*);
740 VALUE rb_str_buf_new(long);
741 VALUE rb_str_buf_new_cstr(const char*);
742 VALUE rb_str_buf_new2(const char*);
743 VALUE rb_str_tmp_new(long);
744 VALUE rb_usascii_str_new(const char*, long);
745 VALUE rb_usascii_str_new_cstr(const char*);
746 VALUE rb_utf8_str_new(const char*, long);
747 VALUE rb_utf8_str_new_cstr(const char*);
748 VALUE rb_str_new_static(const char *, long);
749 VALUE rb_usascii_str_new_static(const char *, long);
750 VALUE rb_utf8_str_new_static(const char *, long);
751 void rb_str_free(VALUE);
752 void rb_str_shared_replace(VALUE, VALUE);
753 VALUE rb_str_buf_append(VALUE, VALUE);
754 VALUE rb_str_buf_cat(VALUE, const char*, long);
755 VALUE rb_str_buf_cat2(VALUE, const char*);
756 VALUE rb_str_buf_cat_ascii(VALUE, const char*);
757 VALUE rb_obj_as_string(VALUE);
758 VALUE rb_check_string_type(VALUE);
759 void rb_must_asciicompat(VALUE);
760 VALUE rb_str_dup(VALUE);
761 VALUE rb_str_resurrect(VALUE str);
762 VALUE rb_str_locktmp(VALUE);
763 VALUE rb_str_unlocktmp(VALUE);
764 VALUE rb_str_dup_frozen(VALUE);
765 #define rb_str_dup_frozen rb_str_new_frozen
766 VALUE rb_str_plus(VALUE, VALUE);
767 VALUE rb_str_times(VALUE, VALUE);
768 long rb_str_sublen(VALUE, long);
769 VALUE rb_str_substr(VALUE, long, long);
770 VALUE rb_str_subseq(VALUE, long, long);
771 char *rb_str_subpos(VALUE, long, long*);
772 void rb_str_modify(VALUE);
773 void rb_str_modify_expand(VALUE, long);
774 VALUE rb_str_freeze(VALUE);
775 void rb_str_set_len(VALUE, long);
776 VALUE rb_str_resize(VALUE, long);
777 VALUE rb_str_cat(VALUE, const char*, long);
778 VALUE rb_str_cat_cstr(VALUE, const char*);
779 VALUE rb_str_cat2(VALUE, const char*);
780 VALUE rb_str_append(VALUE, VALUE);
781 VALUE rb_str_concat(VALUE, VALUE);
782 st_index_t rb_memhash(const void *ptr, long len);
783 st_index_t rb_hash_start(st_index_t);
784 st_index_t rb_hash_uint32(st_index_t, uint32_t);
785 st_index_t rb_hash_uint(st_index_t, st_index_t);
786 st_index_t rb_hash_end(st_index_t);
787 #define rb_hash_uint32(h, i) st_hash_uint32((h), (i))
788 #define rb_hash_uint(h, i) st_hash_uint((h), (i))
789 #define rb_hash_end(h) st_hash_end(h)
790 st_index_t rb_str_hash(VALUE);
791 int rb_str_hash_cmp(VALUE,VALUE);
792 int rb_str_comparable(VALUE, VALUE);
793 int rb_str_cmp(VALUE, VALUE);
794 VALUE rb_str_equal(VALUE str1, VALUE str2);
795 VALUE rb_str_drop_bytes(VALUE, long);
796 void rb_str_update(VALUE, long, long, VALUE);
797 VALUE rb_str_replace(VALUE, VALUE);
798 VALUE rb_str_inspect(VALUE);
799 VALUE rb_str_dump(VALUE);
800 VALUE rb_str_split(VALUE, const char*);
801 void rb_str_setter(VALUE, ID, VALUE*);
802 VALUE rb_str_intern(VALUE);
803 VALUE rb_sym_to_s(VALUE);
804 long rb_str_strlen(VALUE);
805 VALUE rb_str_length(VALUE);
806 long rb_str_offset(VALUE, long);
807 PUREFUNC(size_t rb_str_capacity(VALUE));
808 VALUE rb_str_ellipsize(VALUE, long);
809 VALUE rb_str_scrub(VALUE, VALUE);
810 /* symbol.c */
811 VALUE rb_sym_all_symbols(void);
812 
813 #ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
814 #define rb_str_new(str, len) RB_GNUC_EXTENSION_BLOCK(	\
815     (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
816 	rb_str_new_static((str), (len)) : \
817 	rb_str_new((str), (len))	  \
818 )
819 #define rb_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK(	\
820     (__builtin_constant_p(str)) ?		\
821 	rb_str_new_static((str), (long)strlen(str)) : \
822 	rb_str_new_cstr(str)			\
823 )
824 #define rb_usascii_str_new(str, len) RB_GNUC_EXTENSION_BLOCK( \
825     (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
826 	rb_usascii_str_new_static((str), (len)) : \
827 	rb_usascii_str_new((str), (len))	  \
828 )
829 #define rb_utf8_str_new(str, len) RB_GNUC_EXTENSION_BLOCK( \
830     (__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
831 	rb_utf8_str_new_static((str), (len)) : \
832 	rb_utf8_str_new((str), (len))	  \
833 )
834 #define rb_tainted_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
835     (__builtin_constant_p(str)) ?	       \
836 	rb_tainted_str_new((str), (long)strlen(str)) : \
837 	rb_tainted_str_new_cstr(str)	       \
838 )
839 #define rb_usascii_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
840     (__builtin_constant_p(str)) ?	       \
841 	rb_usascii_str_new_static((str), (long)strlen(str)) : \
842 	rb_usascii_str_new_cstr(str)	       \
843 )
844 #define rb_utf8_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
845     (__builtin_constant_p(str)) ?		\
846 	rb_utf8_str_new_static((str), (long)strlen(str)) : \
847 	rb_utf8_str_new_cstr(str)		\
848 )
849 #define rb_external_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
850     (__builtin_constant_p(str)) ?		\
851 	rb_external_str_new((str), (long)strlen(str)) : \
852 	rb_external_str_new_cstr(str)		\
853 )
854 #define rb_locale_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
855     (__builtin_constant_p(str)) ?	       \
856 	rb_locale_str_new((str), (long)strlen(str)) :  \
857 	rb_locale_str_new_cstr(str)	       \
858 )
859 #define rb_str_buf_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
860     (__builtin_constant_p(str)) ?		\
861 	rb_str_buf_cat(rb_str_buf_new((long)strlen(str)), \
862 		       (str), (long)strlen(str)) : \
863 	rb_str_buf_new_cstr(str)		\
864 )
865 #define rb_str_cat_cstr(str, ptr) RB_GNUC_EXTENSION_BLOCK( \
866     (__builtin_constant_p(ptr)) ?	        \
867 	rb_str_cat((str), (ptr), (long)strlen(ptr)) : \
868 	rb_str_cat_cstr((str), (ptr))		\
869 )
870 #define rb_exc_new_cstr(klass, ptr) RB_GNUC_EXTENSION_BLOCK( \
871     (__builtin_constant_p(ptr)) ?	        \
872 	rb_exc_new((klass), (ptr), (long)strlen(ptr)) : \
873 	rb_exc_new_cstr((klass), (ptr))		\
874 )
875 #endif
876 #define rb_str_new2 rb_str_new_cstr
877 #define rb_str_new3 rb_str_new_shared
878 #define rb_str_new4 rb_str_new_frozen
879 #define rb_str_new5 rb_str_new_with_class
880 #define rb_tainted_str_new2 rb_tainted_str_new_cstr
881 #define rb_str_buf_new2 rb_str_buf_new_cstr
882 #define rb_usascii_str_new2 rb_usascii_str_new_cstr
883 #define rb_str_buf_cat rb_str_cat
884 #define rb_str_buf_cat2 rb_str_cat_cstr
885 #define rb_str_cat2 rb_str_cat_cstr
886 #define rb_strlen_lit(str) (sizeof(str "") - 1)
887 #define rb_str_new_lit(str) rb_str_new_static((str), rb_strlen_lit(str))
888 #define rb_usascii_str_new_lit(str) rb_usascii_str_new_static((str), rb_strlen_lit(str))
889 #define rb_utf8_str_new_lit(str) rb_utf8_str_new_static((str), rb_strlen_lit(str))
890 #define rb_enc_str_new_lit(str, enc) rb_enc_str_new_static((str), rb_strlen_lit(str), (enc))
891 #define rb_str_new_literal(str) rb_str_new_lit(str)
892 #define rb_usascii_str_new_literal(str) rb_usascii_str_new_lit(str)
893 #define rb_utf8_str_new_literal(str) rb_utf8_str_new_lit(str)
894 #define rb_enc_str_new_literal(str, enc) rb_enc_str_new_lit(str, enc)
895 
896 /* struct.c */
897 VALUE rb_struct_new(VALUE, ...);
898 VALUE rb_struct_define(const char*, ...);
899 VALUE rb_struct_define_under(VALUE, const char*, ...);
900 VALUE rb_struct_alloc(VALUE, VALUE);
901 VALUE rb_struct_initialize(VALUE, VALUE);
902 VALUE rb_struct_aref(VALUE, VALUE);
903 VALUE rb_struct_aset(VALUE, VALUE, VALUE);
904 VALUE rb_struct_getmember(VALUE, ID);
905 VALUE rb_struct_s_members(VALUE);
906 VALUE rb_struct_members(VALUE);
907 VALUE rb_struct_size(VALUE s);
908 VALUE rb_struct_alloc_noinit(VALUE);
909 VALUE rb_struct_define_without_accessor(const char *, VALUE, rb_alloc_func_t, ...);
910 VALUE rb_struct_define_without_accessor_under(VALUE outer, const char *class_name, VALUE super, rb_alloc_func_t alloc, ...);
911 
912 /* thread.c */
913 typedef void rb_unblock_function_t(void *);
914 typedef VALUE rb_blocking_function_t(void *);
915 void rb_thread_check_ints(void);
916 int rb_thread_interrupted(VALUE thval);
917 
918 #define RUBY_UBF_IO ((rb_unblock_function_t *)-1)
919 #define RUBY_UBF_PROCESS ((rb_unblock_function_t *)-1)
920 VALUE rb_mutex_new(void);
921 VALUE rb_mutex_locked_p(VALUE mutex);
922 VALUE rb_mutex_trylock(VALUE mutex);
923 VALUE rb_mutex_lock(VALUE mutex);
924 VALUE rb_mutex_unlock(VALUE mutex);
925 VALUE rb_mutex_sleep(VALUE self, VALUE timeout);
926 VALUE rb_mutex_synchronize(VALUE mutex, VALUE (*func)(VALUE arg), VALUE arg);
927 /* time.c */
928 void rb_timespec_now(struct timespec *);
929 VALUE rb_time_new(time_t, long);
930 VALUE rb_time_nano_new(time_t, long);
931 VALUE rb_time_timespec_new(const struct timespec *, int);
932 VALUE rb_time_num_new(VALUE, VALUE);
933 struct timeval rb_time_interval(VALUE num);
934 struct timeval rb_time_timeval(VALUE time);
935 struct timespec rb_time_timespec(VALUE time);
936 VALUE rb_time_utc_offset(VALUE time);
937 /* variable.c */
938 VALUE rb_mod_name(VALUE);
939 VALUE rb_class_path(VALUE);
940 VALUE rb_class_path_cached(VALUE);
941 void rb_set_class_path(VALUE, VALUE, const char*);
942 void rb_set_class_path_string(VALUE, VALUE, VALUE);
943 VALUE rb_path_to_class(VALUE);
944 VALUE rb_path2class(const char*);
945 void rb_name_class(VALUE, ID);
946 VALUE rb_class_name(VALUE);
947 VALUE rb_autoload_load(VALUE, ID);
948 VALUE rb_autoload_p(VALUE, ID);
949 VALUE rb_f_trace_var(int, const VALUE*);
950 VALUE rb_f_untrace_var(int, const VALUE*);
951 VALUE rb_f_global_variables(void);
952 void rb_alias_variable(ID, ID);
953 void rb_copy_generic_ivar(VALUE,VALUE);
954 void rb_free_generic_ivar(VALUE);
955 VALUE rb_ivar_get(VALUE, ID);
956 VALUE rb_ivar_set(VALUE, ID, VALUE);
957 VALUE rb_ivar_defined(VALUE, ID);
958 void rb_ivar_foreach(VALUE, int (*)(ANYARGS), st_data_t);
959 st_index_t rb_ivar_count(VALUE);
960 VALUE rb_attr_get(VALUE, ID);
961 VALUE rb_obj_instance_variables(VALUE);
962 VALUE rb_obj_remove_instance_variable(VALUE, VALUE);
963 void *rb_mod_const_at(VALUE, void*);
964 void *rb_mod_const_of(VALUE, void*);
965 VALUE rb_const_list(void*);
966 VALUE rb_mod_constants(int, const VALUE *, VALUE);
967 VALUE rb_mod_remove_const(VALUE, VALUE);
968 int rb_const_defined(VALUE, ID);
969 int rb_const_defined_at(VALUE, ID);
970 int rb_const_defined_from(VALUE, ID);
971 VALUE rb_const_get(VALUE, ID);
972 VALUE rb_const_get_at(VALUE, ID);
973 VALUE rb_const_get_from(VALUE, ID);
974 void rb_const_set(VALUE, ID, VALUE);
975 VALUE rb_const_remove(VALUE, ID);
976 #if 0 /* EXPERIMENTAL: remove if no problem */
977 NORETURN(VALUE rb_mod_const_missing(VALUE,VALUE));
978 #endif
979 VALUE rb_cvar_defined(VALUE, ID);
980 void rb_cvar_set(VALUE, ID, VALUE);
981 VALUE rb_cvar_get(VALUE, ID);
982 void rb_cv_set(VALUE, const char*, VALUE);
983 VALUE rb_cv_get(VALUE, const char*);
984 void rb_define_class_variable(VALUE, const char*, VALUE);
985 VALUE rb_mod_class_variables(int, const VALUE*, VALUE);
986 VALUE rb_mod_remove_cvar(VALUE, VALUE);
987 
988 ID rb_frame_callee(void);
989 int rb_frame_method_id_and_class(ID *idp, VALUE *klassp);
990 VALUE rb_str_succ(VALUE);
991 VALUE rb_time_succ(VALUE);
992 VALUE rb_make_backtrace(void);
993 VALUE rb_make_exception(int, const VALUE*);
994 
995 RUBY_SYMBOL_EXPORT_END
996 
997 #if defined(__cplusplus)
998 #if 0
999 { /* satisfy cc-mode */
1000 #endif
1001 }  /* extern "C" { */
1002 #endif
1003 
1004 #endif /* RUBY_INTERN_H */
1005