PageRenderTime 167ms CodeModel.GetById 123ms app.highlight 36ms RepoModel.GetById 1ms app.codeStats 1ms

/tools/Ruby/lib/ruby/1.8/i386-mingw32/ruby.h

http://github.com/agross/netopenspace
C Header | 796 lines | 660 code | 113 blank | 23 comment | 54 complexity | 86c7a1c9a35d3f69c11229de008b56f3 MD5 | raw file
  1/**********************************************************************
  2
  3  ruby.h -
  4
  5  $Author: shyouhei $
  6  created at: Thu Jun 10 14:26:32 JST 1993
  7
  8  Copyright (C) 1993-2003 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_H
 15#define RUBY_H
 16
 17#if defined(__cplusplus)
 18extern "C" {
 19#if 0
 20} /* satisfy cc-mode */
 21#endif
 22#endif
 23
 24#include "config.h"
 25#ifdef RUBY_EXTCONF_H
 26#include RUBY_EXTCONF_H
 27#endif
 28
 29#define NORETURN_STYLE_NEW 1
 30#ifndef NORETURN
 31# define NORETURN(x) x
 32#endif
 33#ifndef NOINLINE
 34# define NOINLINE(x) x
 35#endif
 36
 37#include "defines.h"
 38
 39#ifdef HAVE_STDLIB_H
 40# include <stdlib.h>
 41#endif
 42
 43#ifdef HAVE_STRING_H
 44# include <string.h>
 45#else
 46# include <strings.h>
 47#endif
 48
 49#ifdef HAVE_INTRINSICS_H
 50# include <intrinsics.h>
 51#endif
 52
 53#ifdef HAVE_STDINT_H
 54# include <stdint.h>
 55#endif
 56
 57#include <stddef.h>
 58#include <stdio.h>
 59
 60/* need to include <ctype.h> to use these macros */
 61#ifndef ISPRINT
 62#define ISASCII(c) isascii((int)(unsigned char)(c))
 63#undef ISPRINT
 64#define ISPRINT(c) (ISASCII(c) && isprint((int)(unsigned char)(c)))
 65#define ISSPACE(c) (ISASCII(c) && isspace((int)(unsigned char)(c)))
 66#define ISUPPER(c) (ISASCII(c) && isupper((int)(unsigned char)(c)))
 67#define ISLOWER(c) (ISASCII(c) && islower((int)(unsigned char)(c)))
 68#define ISALNUM(c) (ISASCII(c) && isalnum((int)(unsigned char)(c)))
 69#define ISALPHA(c) (ISASCII(c) && isalpha((int)(unsigned char)(c)))
 70#define ISDIGIT(c) (ISASCII(c) && isdigit((int)(unsigned char)(c)))
 71#define ISXDIGIT(c) (ISASCII(c) && isxdigit((int)(unsigned char)(c)))
 72#endif
 73
 74#if defined(HAVE_ALLOCA_H)
 75#include <alloca.h>
 76#else
 77#  ifdef _AIX
 78#pragma alloca
 79#  endif
 80#endif
 81
 82#if defined(__VMS)
 83# pragma builtins
 84# define alloca __alloca
 85#endif
 86
 87#if SIZEOF_LONG != SIZEOF_VOIDP
 88# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
 89#else
 90typedef unsigned long VALUE;
 91typedef unsigned long ID;
 92#endif
 93
 94#ifdef __STDC__
 95# include <limits.h>
 96#else
 97# ifndef LONG_MAX
 98#  ifdef HAVE_LIMITS_H
 99#   include <limits.h>
100#  else
101    /* assuming 32bit(2's compliment) long */
102#   define LONG_MAX 2147483647
103#  endif
104# endif
105# ifndef LONG_MIN
106#  define LONG_MIN (-LONG_MAX-1)
107# endif
108# ifndef CHAR_BIT
109#  define CHAR_BIT 8
110# endif
111#endif
112
113#ifdef HAVE_LONG_LONG
114# ifndef LLONG_MAX
115#  ifdef LONG_LONG_MAX
116#   define LLONG_MAX  LONG_LONG_MAX
117#  else
118#   ifdef _I64_MAX
119#    define LLONG_MAX _I64_MAX
120#   else
121    /* assuming 64bit(2's complement) long long */
122#    define LLONG_MAX 9223372036854775807LL
123#   endif
124#  endif
125# endif
126# ifndef LLONG_MIN
127#  ifdef LONG_LONG_MIN
128#   define LLONG_MIN  LONG_LONG_MIN
129#  else
130#   ifdef _I64_MIN
131#    define LLONG_MIN _I64_MIN
132#   else
133#    define LLONG_MIN (-LLONG_MAX-1)
134#   endif
135#  endif
136# endif
137#endif
138
139#define FIXNUM_MAX (LONG_MAX>>1)
140#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
141
142#define FIXNUM_FLAG 0x01
143#define INT2FIX(i) ((VALUE)(((long)(i))<<1 | FIXNUM_FLAG))
144#define LONG2FIX(i) INT2FIX(i)
145#define rb_fix_new(v) INT2FIX(v)
146VALUE rb_int2inum _((long));
147#define INT2NUM(v) rb_int2inum(v)
148#define LONG2NUM(v) INT2NUM(v)
149#define rb_int_new(v) rb_int2inum(v)
150VALUE rb_uint2inum _((unsigned long));
151#define UINT2NUM(v) rb_uint2inum(v)
152#define ULONG2NUM(v) UINT2NUM(v)
153#define rb_uint_new(v) rb_uint2inum(v)
154
155#ifdef HAVE_LONG_LONG
156VALUE rb_ll2inum _((LONG_LONG));
157#define LL2NUM(v) rb_ll2inum(v)
158VALUE rb_ull2inum _((unsigned LONG_LONG));
159#define ULL2NUM(v) rb_ull2inum(v)
160#endif
161
162#if SIZEOF_OFF_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
163# define OFFT2NUM(v) LL2NUM(v)
164#elif SIZEOF_OFF_T == SIZEOF_LONG
165# define OFFT2NUM(v) LONG2NUM(v)
166#else
167# define OFFT2NUM(v) INT2NUM(v)
168#endif
169
170#define FIX2LONG(x) RSHIFT((long)x,1)
171#define FIX2ULONG(x) (((unsigned long)(x))>>1)
172#define FIXNUM_P(f) (((long)(f))&FIXNUM_FLAG)
173#define POSFIXABLE(f) ((f) < FIXNUM_MAX+1)
174#define NEGFIXABLE(f) ((f) >= FIXNUM_MIN)
175#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
176
177#define IMMEDIATE_MASK 0x03
178#define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK)
179
180#define SYMBOL_FLAG 0x0e
181#define SYMBOL_P(x) (((VALUE)(x)&0xff)==SYMBOL_FLAG)
182#define ID2SYM(x) ((VALUE)(((long)(x))<<8|SYMBOL_FLAG))
183#define SYM2ID(x) RSHIFT((unsigned long)x,8)
184
185/* special contants - i.e. non-zero and non-fixnum constants */
186#define Qfalse ((VALUE)0)
187#define Qtrue  ((VALUE)2)
188#define Qnil   ((VALUE)4)
189#define Qundef ((VALUE)6)	/* undefined value for placeholder */
190
191#define RTEST(v) (((VALUE)(v) & ~Qnil) != 0)
192#define NIL_P(v) ((VALUE)(v) == Qnil)
193
194#define CLASS_OF(v) rb_class_of((VALUE)(v))
195
196#define T_NONE   0x00
197
198#define T_NIL    0x01
199#define T_OBJECT 0x02
200#define T_CLASS  0x03
201#define T_ICLASS 0x04
202#define T_MODULE 0x05
203#define T_FLOAT  0x06
204#define T_STRING 0x07
205#define T_REGEXP 0x08
206#define T_ARRAY  0x09
207#define T_FIXNUM 0x0a
208#define T_HASH   0x0b
209#define T_STRUCT 0x0c
210#define T_BIGNUM 0x0d
211#define T_FILE   0x0e
212
213#define T_TRUE   0x20
214#define T_FALSE  0x21
215#define T_DATA   0x22
216#define T_MATCH  0x23
217#define T_SYMBOL 0x24
218
219#define T_BLKTAG 0x3b
220#define T_UNDEF  0x3c
221#define T_VARMAP 0x3d
222#define T_SCOPE  0x3e
223#define T_NODE   0x3f
224
225#define T_MASK   0x3f
226
227#define BUILTIN_TYPE(x) (((struct RBasic*)(x))->flags & T_MASK)
228
229#define TYPE(x) rb_type((VALUE)(x))
230
231#ifdef __GNUC__
232#define RB_GC_GUARD_PTR(ptr) \
233    __extension__ ({volatile VALUE *rb_gc_guarded_ptr = (ptr); rb_gc_guarded_ptr;})
234#else
235#define RB_GC_GUARD_PTR(ptr) (volatile VALUE *)(ptr)
236#endif
237#define RB_GC_GUARD(v) (*RB_GC_GUARD_PTR(&(v)))
238
239void rb_check_type _((VALUE,int));
240#define Check_Type(v,t) rb_check_type((VALUE)(v),t)
241
242VALUE rb_str_to_str _((VALUE));
243VALUE rb_string_value _((volatile VALUE*));
244char *rb_string_value_ptr _((volatile VALUE*));
245char *rb_string_value_cstr _((volatile VALUE*));
246
247#define StringValue(v) rb_string_value(&(v))
248#define StringValuePtr(v) rb_string_value_ptr(&(v))
249#define StringValueCStr(v) rb_string_value_cstr(&(v))
250
251void rb_check_safe_obj _((VALUE));
252void rb_check_safe_str _((VALUE));
253#define SafeStringValue(v) do {\
254    StringValue(v);\
255    rb_check_safe_obj(v);\
256} while (0)
257/* obsolete macro - use SafeStringValue(v) */
258#define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
259
260void rb_secure _((int));
261RUBY_EXTERN int ruby_safe_level;
262#define rb_safe_level() (ruby_safe_level)
263void rb_set_safe_level _((int));
264void rb_secure_update _((VALUE));
265
266long rb_num2long _((VALUE));
267unsigned long rb_num2ulong _((VALUE));
268#define NUM2LONG(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2long((VALUE)x))
269#define NUM2ULONG(x) rb_num2ulong((VALUE)x)
270#if SIZEOF_INT < SIZEOF_LONG
271long rb_num2int _((VALUE));
272#define NUM2INT(x) (FIXNUM_P(x)?FIX2INT(x):rb_num2int((VALUE)x))
273long rb_fix2int _((VALUE));
274#define FIX2INT(x) rb_fix2int((VALUE)x)
275unsigned long rb_num2uint _((VALUE));
276#define NUM2UINT(x) rb_num2uint(x)
277unsigned long rb_fix2uint _((VALUE));
278#define FIX2UINT(x) rb_fix2uint(x)
279#else
280#define NUM2INT(x) ((int)NUM2LONG(x))
281#define NUM2UINT(x) ((unsigned int)NUM2ULONG(x))
282#define FIX2INT(x) ((int)FIX2LONG(x))
283#define FIX2UINT(x) ((unsigned int)FIX2ULONG(x))
284#endif
285
286#ifdef HAVE_LONG_LONG
287LONG_LONG rb_num2ll _((VALUE));
288unsigned LONG_LONG rb_num2ull _((VALUE));
289# define NUM2LL(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x))
290# define NUM2ULL(x) rb_num2ull((VALUE)x)
291#endif
292
293#if defined(HAVE_LONG_LONG) && SIZEOF_OFF_T > SIZEOF_LONG
294# define NUM2OFFT(x) ((off_t)NUM2LL(x))
295#else
296# define NUM2OFFT(x) NUM2LONG(x)
297#endif
298
299double rb_num2dbl _((VALUE));
300#define NUM2DBL(x) rb_num2dbl((VALUE)(x))
301
302/* obsolete API - use StringValue() */
303char *rb_str2cstr _((VALUE,long*));
304/* obsolete API - use StringValuePtr() */
305#define STR2CSTR(x) rb_str2cstr((VALUE)(x),0)
306
307#define NUM2CHR(x) (((TYPE(x) == T_STRING)&&(RSTRING(x)->len>=1))?\
308                     RSTRING(x)->ptr[0]:(char)(NUM2INT(x)&0xff))
309#define CHR2FIX(x) INT2FIX((long)((x)&0xff))
310
311VALUE rb_newobj _((void));
312#define NEWOBJ(obj,type) type *obj = (type*)rb_newobj()
313#define OBJSETUP(obj,c,t) do {\
314    RBASIC(obj)->flags = (t);\
315    RBASIC(obj)->klass = (c);\
316    if (rb_safe_level() >= 3) FL_SET(obj, FL_TAINT);\
317} while (0)
318#define CLONESETUP(clone,obj) do {\
319    OBJSETUP(clone,rb_singleton_class_clone((VALUE)obj),RBASIC(obj)->flags);\
320    rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);\
321    if (FL_TEST(obj, FL_EXIVAR)) rb_copy_generic_ivar((VALUE)clone,(VALUE)obj);\
322} while (0)
323#define DUPSETUP(dup,obj) do {\
324    OBJSETUP(dup,rb_obj_class(obj),(RBASIC(obj)->flags)&(T_MASK|FL_EXIVAR|FL_TAINT));\
325    if (FL_TEST(obj, FL_EXIVAR)) rb_copy_generic_ivar((VALUE)dup,(VALUE)obj);\
326} while (0)
327
328struct RBasic {
329    unsigned long flags;
330    VALUE klass;
331};
332
333struct RObject {
334    struct RBasic basic;
335    struct st_table *iv_tbl;
336};
337
338struct RClass {
339    struct RBasic basic;
340    struct st_table *iv_tbl;
341    struct st_table *m_tbl;
342    VALUE super;
343};
344#define RCLASS_IV_TBL(c) (RCLASS(c)->iv_tbl)
345#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
346#define RCLASS_SUPER(c) (RCLASS(c)->super)
347#define RMODULE_IV_TBL(m) RCLASS_IV_TBL(m)
348#define RMODULE_M_TBL(m) RCLASS_M_TBL(m)
349#define RMODULE_SUPER(m) RCLASS_SUPER(m)
350
351struct RFloat {
352    struct RBasic basic;
353    double value;
354};
355#define RFLOAT_VALUE(v) (RFLOAT(v)->value)
356
357#define ELTS_SHARED FL_USER2
358
359struct RString {
360    struct RBasic basic;
361    long len;
362    char *ptr;
363    union {
364	long capa;
365	VALUE shared;
366    } aux;
367};
368#define RSTRING_PTR(s) (RSTRING(s)->ptr)
369#define RSTRING_LEN(s) (RSTRING(s)->len)
370#define RSTRING_END(s) (RSTRING_PTR(s)+RSTRING_LEN(s))
371
372struct RArray {
373    struct RBasic basic;
374    long len;
375    union {
376	long capa;
377	VALUE shared;
378    } aux;
379    VALUE *ptr;
380};
381#define RARRAY_PTR(s) (RARRAY(s)->ptr)
382#define RARRAY_LEN(s) (RARRAY(s)->len)
383
384struct RRegexp {
385    struct RBasic basic;
386    struct re_pattern_buffer *ptr;
387    long len;
388    char *str;
389};
390#define RREGEXP_SRC_PTR(r) (RREGEXP(r)->src)
391#define RREGEXP_SRC_LEN(r) (RREGEXP(r)->len)
392
393struct RHash {
394    struct RBasic basic;
395    struct st_table *tbl;
396    int iter_lev;
397    VALUE ifnone;
398};
399#define RHASH_TBL(h) (RHASH(h)->tbl)
400#define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
401#define RHASH_IFNONE(h) (RHASH(h)->ifnone)
402#define RHASH_SIZE(h) (RHASH(h)->tbl->num_entries)
403#define RHASH_EMPTY_P(h) (RHASH_SIZE(h) == 0)
404
405struct RFile {
406    struct RBasic basic;
407    struct rb_io_t *fptr;
408};
409
410struct RData {
411    struct RBasic basic;
412    void (*dmark) _((void*));
413    void (*dfree) _((void*));
414    void *data;
415};
416
417#define DATA_PTR(dta) (RDATA(dta)->data)
418
419/*
420#define RUBY_DATA_FUNC(func) ((void (*)_((void*)))func)
421*/
422typedef void (*RUBY_DATA_FUNC) _((void*));
423
424VALUE rb_data_object_alloc _((VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
425
426#define Data_Wrap_Struct(klass,mark,free,sval)\
427    rb_data_object_alloc(klass,sval,(RUBY_DATA_FUNC)mark,(RUBY_DATA_FUNC)free)
428
429#define Data_Make_Struct(klass,type,mark,free,sval) (\
430    sval = ALLOC(type),\
431    memset(sval, 0, sizeof(type)),\
432    Data_Wrap_Struct(klass,mark,free,sval)\
433)
434
435#define Data_Get_Struct(obj,type,sval) do {\
436    Check_Type(obj, T_DATA); \
437    sval = (type*)DATA_PTR(obj);\
438} while (0)
439
440struct RStruct {
441    struct RBasic basic;
442    long len;
443    VALUE *ptr;
444};
445#define RSTRUCT_LEN(st) (RSTRUCT(st)->len)
446#define RSTRUCT_PTR(st) (RSTRUCT(st)->ptr)
447
448struct RBignum {
449    struct RBasic basic;
450    char sign;
451    long len;
452    void *digits;
453};
454#define RBIGNUM_SIGN(b)       (RBIGNUM(b)->sign)
455#define RBIGNUM_SET_SIGN(b,s) (RBIGNUM(b)->sign = (s))
456#define RBIGNUM_POSITIVE_P(b) RBIGNUM_SIGN(b)
457#define RBIGNUM_NEGATIVE_P(b) (!RBIGNUM_SIGN(b))
458#define RBIGNUM_LEN(b)        (RBIGNUM(b)->len)
459#define RBIGNUM_DIGITS(b)     (RBIGNUM(b)->digits)
460
461#define R_CAST(st)   (struct st*)
462#define RBASIC(obj)  (R_CAST(RBasic)(obj))
463#define ROBJECT(obj) (R_CAST(RObject)(obj))
464#define RCLASS(obj)  (R_CAST(RClass)(obj))
465#define RMODULE(obj) RCLASS(obj)
466#define RFLOAT(obj)  (R_CAST(RFloat)(obj))
467#define RSTRING(obj) (R_CAST(RString)(obj))
468#define RREGEXP(obj) (R_CAST(RRegexp)(obj))
469#define RARRAY(obj)  (R_CAST(RArray)(obj))
470#define RHASH(obj)   (R_CAST(RHash)(obj))
471#define RDATA(obj)   (R_CAST(RData)(obj))
472#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
473#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
474#define RFILE(obj)   (R_CAST(RFile)(obj))
475
476#define FL_SINGLETON FL_USER0
477#define FL_MARK      (1<<6)
478#define FL_FINALIZE  (1<<7)
479#define FL_TAINT     (1<<8)
480#define FL_EXIVAR    (1<<9)
481#define FL_FREEZE    (1<<10)
482
483#define FL_USHIFT    11
484
485#define FL_USER0     (1<<(FL_USHIFT+0))
486#define FL_USER1     (1<<(FL_USHIFT+1))
487#define FL_USER2     (1<<(FL_USHIFT+2))
488#define FL_USER3     (1<<(FL_USHIFT+3))
489#define FL_USER4     (1<<(FL_USHIFT+4))
490#define FL_USER5     (1<<(FL_USHIFT+5))
491#define FL_USER6     (1<<(FL_USHIFT+6))
492#define FL_USER7     (1<<(FL_USHIFT+7))
493
494#define FL_UMASK  (0xff<<FL_USHIFT)
495
496#define SPECIAL_CONST_P(x) (IMMEDIATE_P(x) || !RTEST(x))
497
498#define FL_ABLE(x) (!SPECIAL_CONST_P(x))
499#define FL_TEST(x,f) (FL_ABLE(x)?(RBASIC(x)->flags&(f)):0)
500#define FL_SET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags |= (f);} while (0)
501#define FL_UNSET(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags &= ~(f);} while (0)
502#define FL_REVERSE(x,f) do {if (FL_ABLE(x)) RBASIC(x)->flags ^= (f);} while (0)
503
504#define OBJ_TAINTED(x) FL_TEST((x), FL_TAINT)
505#define OBJ_TAINT(x) FL_SET((x), FL_TAINT)
506#define OBJ_INFECT(x,s) do {if (FL_ABLE(x) && FL_ABLE(s)) RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT;} while (0)
507
508#define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE)
509#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
510
511#define ALLOC_N(type,n) (type*)xmalloc(sizeof(type)*(n))
512#define ALLOC(type) (type*)xmalloc(sizeof(type))
513#define REALLOC_N(var,type,n) (var)=(type*)xrealloc((char*)(var),sizeof(type)*(n))
514
515#define ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n))
516
517#define MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
518#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
519#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
520#define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))
521
522void rb_obj_infect _((VALUE,VALUE));
523
524typedef int ruby_glob_func(const char*,VALUE);
525void rb_glob _((const char*,void(*)(const char*,VALUE),VALUE));
526void rb_globi _((const char*,void(*)(const char*,VALUE),VALUE));
527int ruby_brace_expand _((const char*,int,ruby_glob_func*,VALUE));
528int ruby_brace_glob _((const char*,int,ruby_glob_func*,VALUE));
529
530VALUE rb_define_class _((const char*,VALUE));
531VALUE rb_define_module _((const char*));
532VALUE rb_define_class_under _((VALUE, const char*, VALUE));
533VALUE rb_define_module_under _((VALUE, const char*));
534
535void rb_include_module _((VALUE,VALUE));
536void rb_extend_object _((VALUE,VALUE));
537
538void rb_define_variable _((const char*,VALUE*));
539void rb_define_virtual_variable _((const char*,VALUE(*)(ANYARGS),void(*)(ANYARGS)));
540void rb_define_hooked_variable _((const char*,VALUE*,VALUE(*)(ANYARGS),void(*)(ANYARGS)));
541int ruby_glob _((const char*,int,int(*)(const char*,VALUE),VALUE));
542int ruby_globi _((const char*,int,int(*)(const char*,VALUE),VALUE));
543void rb_define_readonly_variable _((const char*,VALUE*));
544void rb_define_const _((VALUE,const char*,VALUE));
545void rb_define_global_const _((const char*,VALUE));
546
547#define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))func)
548void rb_define_method _((VALUE,const char*,VALUE(*)(ANYARGS),int));
549void rb_define_module_function _((VALUE,const char*,VALUE(*)(ANYARGS),int));
550void rb_define_global_function _((const char*,VALUE(*)(ANYARGS),int));
551
552void rb_undef_method _((VALUE,const char*));
553void rb_define_alias _((VALUE,const char*,const char*));
554void rb_define_attr _((VALUE,const char*,int,int));
555
556void rb_global_variable _((VALUE*));
557void rb_gc_register_address _((VALUE*));
558void rb_gc_unregister_address _((VALUE*));
559
560ID rb_intern _((const char*));
561const char *rb_id2name _((ID));
562ID rb_to_id _((VALUE));
563
564const char *rb_class2name _((VALUE));
565const char *rb_obj_classname _((VALUE));
566
567void rb_p _((VALUE));
568
569VALUE rb_eval_string _((const char*));
570VALUE rb_eval_string_protect _((const char*, int*));
571VALUE rb_eval_string_wrap _((const char*, int*));
572VALUE rb_funcall __((VALUE, ID, int, ...));
573VALUE rb_funcall2 _((VALUE, ID, int, const VALUE*));
574VALUE rb_funcall3 _((VALUE, ID, int, const VALUE*));
575int rb_scan_args __((int, const VALUE*, const char*, ...));
576VALUE rb_call_super _((int, const VALUE*));
577
578VALUE rb_gv_set _((const char*, VALUE));
579VALUE rb_gv_get _((const char*));
580VALUE rb_iv_get _((VALUE, const char*));
581VALUE rb_iv_set _((VALUE, const char*, VALUE));
582
583VALUE rb_equal _((VALUE,VALUE));
584
585RUBY_EXTERN VALUE ruby_verbose, ruby_debug;
586
587NORETURN(void rb_raise __((VALUE, const char*, ...)));
588NORETURN(void rb_fatal __((const char*, ...)));
589NORETURN(void rb_bug __((const char*, ...)));
590NORETURN(void rb_sys_fail _((const char*)));
591NORETURN(void rb_iter_break _((void)));
592NORETURN(void rb_exit _((int)));
593NORETURN(void rb_notimplement _((void)));
594
595void rb_warning __((const char*, ...));		/* reports if `-w' specified */
596void rb_sys_warning __((const char*, ...));	/* reports if `-w' specified */
597void rb_warn __((const char*, ...));		/* reports always */
598
599typedef VALUE rb_block_call_func _((VALUE, VALUE));
600
601VALUE rb_each _((VALUE));
602VALUE rb_yield _((VALUE));
603VALUE rb_yield_values __((int n, ...));
604VALUE rb_yield_splat _((VALUE));
605int rb_block_given_p _((void));
606void rb_need_block _((void));
607VALUE rb_iterate _((VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE));
608VALUE rb_rescue _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
609VALUE rb_rescue2 __((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...));
610VALUE rb_ensure _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
611VALUE rb_catch _((const char*,VALUE(*)(ANYARGS),VALUE));
612NORETURN(void rb_throw _((const char*,VALUE)));
613
614VALUE rb_require _((const char*));
615
616#ifdef __ia64
617void ruby_init_stack(VALUE*, void*);
618#define RUBY_INIT_STACK \
619    VALUE variable_in_this_stack_frame; \
620    ruby_init_stack(&variable_in_this_stack_frame, rb_ia64_bsp());
621#else
622void ruby_init_stack(VALUE*);
623#define RUBY_INIT_STACK \
624    VALUE variable_in_this_stack_frame; \
625    ruby_init_stack(&variable_in_this_stack_frame);
626#endif
627void ruby_init _((void));
628void ruby_options _((int, char**));
629NORETURN(void ruby_run _((void)));
630
631RUBY_EXTERN VALUE rb_mKernel;
632RUBY_EXTERN VALUE rb_mComparable;
633RUBY_EXTERN VALUE rb_mEnumerable;
634RUBY_EXTERN VALUE rb_mPrecision;
635RUBY_EXTERN VALUE rb_mErrno;
636RUBY_EXTERN VALUE rb_mFileTest;
637RUBY_EXTERN VALUE rb_mGC;
638RUBY_EXTERN VALUE rb_mMath;
639RUBY_EXTERN VALUE rb_mProcess;
640
641RUBY_EXTERN VALUE rb_cObject;
642RUBY_EXTERN VALUE rb_cArray;
643RUBY_EXTERN VALUE rb_cBignum;
644RUBY_EXTERN VALUE rb_cBinding;
645RUBY_EXTERN VALUE rb_cClass;
646RUBY_EXTERN VALUE rb_cCont;
647RUBY_EXTERN VALUE rb_cDir;
648RUBY_EXTERN VALUE rb_cData;
649RUBY_EXTERN VALUE rb_cEnumerator;
650RUBY_EXTERN VALUE rb_cFalseClass;
651RUBY_EXTERN VALUE rb_cFile;
652RUBY_EXTERN VALUE rb_cFixnum;
653RUBY_EXTERN VALUE rb_cFloat;
654RUBY_EXTERN VALUE rb_cHash;
655RUBY_EXTERN VALUE rb_cInteger;
656RUBY_EXTERN VALUE rb_cIO;
657RUBY_EXTERN VALUE rb_cMatch;
658RUBY_EXTERN VALUE rb_cMethod;
659RUBY_EXTERN VALUE rb_cModule;
660RUBY_EXTERN VALUE rb_cNameErrorMesg;
661RUBY_EXTERN VALUE rb_cNilClass;
662RUBY_EXTERN VALUE rb_cNumeric;
663RUBY_EXTERN VALUE rb_cProc;
664RUBY_EXTERN VALUE rb_cRange;
665RUBY_EXTERN VALUE rb_cRegexp;
666RUBY_EXTERN VALUE rb_cStat;
667RUBY_EXTERN VALUE rb_cString;
668RUBY_EXTERN VALUE rb_cStruct;
669RUBY_EXTERN VALUE rb_cSymbol;
670RUBY_EXTERN VALUE rb_cThread;
671RUBY_EXTERN VALUE rb_cTime;
672RUBY_EXTERN VALUE rb_cTrueClass;
673RUBY_EXTERN VALUE rb_cUnboundMethod;
674
675RUBY_EXTERN VALUE rb_eException;
676RUBY_EXTERN VALUE rb_eStandardError;
677RUBY_EXTERN VALUE rb_eSystemExit;
678RUBY_EXTERN VALUE rb_eInterrupt;
679RUBY_EXTERN VALUE rb_eSignal;
680RUBY_EXTERN VALUE rb_eFatal;
681RUBY_EXTERN VALUE rb_eArgError;
682RUBY_EXTERN VALUE rb_eEOFError;
683RUBY_EXTERN VALUE rb_eIndexError;
684RUBY_EXTERN VALUE rb_eStopIteration;
685RUBY_EXTERN VALUE rb_eRangeError;
686RUBY_EXTERN VALUE rb_eIOError;
687RUBY_EXTERN VALUE rb_eRuntimeError;
688RUBY_EXTERN VALUE rb_eSecurityError;
689RUBY_EXTERN VALUE rb_eSystemCallError;
690RUBY_EXTERN VALUE rb_eThreadError;
691RUBY_EXTERN VALUE rb_eTypeError;
692RUBY_EXTERN VALUE rb_eZeroDivError;
693RUBY_EXTERN VALUE rb_eNotImpError;
694RUBY_EXTERN VALUE rb_eNoMemError;
695RUBY_EXTERN VALUE rb_eNoMethodError;
696RUBY_EXTERN VALUE rb_eFloatDomainError;
697RUBY_EXTERN VALUE rb_eLocalJumpError;
698RUBY_EXTERN VALUE rb_eSysStackError;
699RUBY_EXTERN VALUE rb_eRegexpError;
700
701RUBY_EXTERN VALUE rb_eScriptError;
702RUBY_EXTERN VALUE rb_eNameError;
703RUBY_EXTERN VALUE rb_eSyntaxError;
704RUBY_EXTERN VALUE rb_eLoadError;
705
706RUBY_EXTERN VALUE rb_stdin, rb_stdout, rb_stderr;
707RUBY_EXTERN VALUE ruby_errinfo;
708
709static inline VALUE
710#if defined(HAVE_PROTOTYPES)
711rb_class_of(VALUE obj)
712#else
713rb_class_of(obj)
714    VALUE obj;
715#endif
716{
717    if (FIXNUM_P(obj)) return rb_cFixnum;
718    if (obj == Qnil) return rb_cNilClass;
719    if (obj == Qfalse) return rb_cFalseClass;
720    if (obj == Qtrue) return rb_cTrueClass;
721    if (SYMBOL_P(obj)) return rb_cSymbol;
722
723    return RBASIC(obj)->klass;
724}
725
726static inline int
727#if defined(HAVE_PROTOTYPES)
728rb_type(VALUE obj)
729#else
730rb_type(obj)
731   VALUE obj;
732#endif
733{
734    if (FIXNUM_P(obj)) return T_FIXNUM;
735    if (obj == Qnil) return T_NIL;
736    if (obj == Qfalse) return T_FALSE;
737    if (obj == Qtrue) return T_TRUE;
738    if (obj == Qundef) return T_UNDEF;
739    if (SYMBOL_P(obj)) return T_SYMBOL;
740    return BUILTIN_TYPE(obj);
741}
742
743static inline int
744#if defined(HAVE_PROTOTYPES)
745rb_special_const_p(VALUE obj)
746#else
747rb_special_const_p(obj)
748    VALUE obj;
749#endif
750{
751    if (SPECIAL_CONST_P(obj)) return Qtrue;
752    return Qfalse;
753}
754
755#include "missing.h"
756#include "intern.h"
757
758#if defined(EXTLIB) && defined(USE_DLN_A_OUT)
759/* hook for external modules */
760static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
761#endif
762
763#if defined(HAVE_LIBPTHREAD)
764#ifdef HAVE_PTHREAD_H
765#include <pthread.h>
766#endif
767typedef pthread_t rb_nativethread_t;
768# define NATIVETHREAD_CURRENT() pthread_self()
769# define NATIVETHREAD_EQUAL(t1,t2) pthread_equal((t1),(t2))
770# define HAVE_NATIVETHREAD
771
772# define NATIVETHREAD_KILL(th,sig) pthread_kill((th),(sig))
773# define HAVE_NATIVETHREAD_KILL
774#elif defined(_WIN32) || defined(_WIN32_WCE)
775typedef DWORD rb_nativethread_t;
776# define NATIVETHREAD_CURRENT() GetCurrentThreadId()
777# define NATIVETHREAD_EQUAL(t1,t2) ((t1) == (t2))
778# define HAVE_NATIVETHREAD
779#endif
780#ifdef HAVE_NATIVETHREAD
781int is_ruby_native_thread _((void));
782#else
783#define is_ruby_native_thread() (1)
784#endif
785#ifdef HAVE_NATIVETHREAD_KILL
786void ruby_native_thread_kill _((int));
787#endif
788
789#if defined(__cplusplus)
790#if 0
791{ /* satisfy cc-mode */
792#endif
793}  /* extern "C" { */
794#endif
795
796#endif /* ifndef RUBY_H */