From: nobu.nokada@... Date: 2003-06-26T10:17:52+09:00 Subject: Re: collect info about ruby-api Hi, At Wed, 25 Jun 2003 22:21:37 +0900, Simon Strandgaard wrote: > > grep Init_stack *.h > > > > It doesn't seems to something public available to the embedding/extension > Rubyist's. To me it looks like an internal routine. Yes, it's an internal but would be necessary to embed (see eruby). And I think it should have other name, e.g. ruby_stack_init. > > #if 0 /* no need */ > >> /* tell GC that there is a new instance in town. */ > >> rb_gc_register_address(&instance); > > #endif > > Yes it not necessary for this small program, but for bigger pieces of code > where GC takes place.. then I think its necessary. It worked even if rb_gc_start() was before `rb_p'. > > Better solution is separating from "args[0] = ..." through > > ruby_finalize() to another function. > > Me don't understand ? It's just the line before return. Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.469 diff -u -2 -p -r1.469 eval.c --- eval.c 24 Jun 2003 08:59:34 -0000 1.469 +++ eval.c 25 Jun 2003 23:44:51 -0000 @@ -1144,5 +1144,4 @@ char **rb_origenviron; void rb_call_inits _((void)); -void Init_stack _((void*)); void Init_heap _((void)); void Init_ext _((void)); @@ -1169,5 +1168,5 @@ ruby_init() #endif - Init_stack((void*)&state); + ruby_stack_init((void*)&state); Init_heap(); PUSH_SCOPE(); @@ -1303,5 +1302,5 @@ ruby_options(argc, argv) int state; - Init_stack((void*)&state); + ruby_stack_init((void*)&state); PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { @@ -1364,5 +1363,5 @@ ruby_exec() volatile NODE *tmp; - Init_stack((void*)&tmp); + ruby_stack_init((void*)&tmp); ruby_running = 1; PUSH_TAG(PROT_NONE); @@ -9321,5 +9320,5 @@ rb_thread_create(fn, arg) void *arg; { - Init_stack((VALUE*)&arg); + ruby_stack_init((VALUE*)&arg); return rb_thread_start_0(fn, arg, rb_thread_alloc(rb_cThread)); } Index: gc.c =================================================================== RCS file: /cvs/ruby/src/ruby/gc.c,v retrieving revision 1.137 diff -u -2 -p -r1.137 gc.c --- gc.c 16 Jun 2003 07:14:36 -0000 1.137 +++ gc.c 25 Jun 2003 23:48:59 -0000 @@ -1282,6 +1282,6 @@ stack_growup_p(addr) void -Init_stack(addr) - VALUE *addr; +ruby_stack_init(ptr) + void *ptr; { #if defined(__human68k__) @@ -1289,5 +1289,6 @@ Init_stack(addr) rb_gc_stack_start = _SEND; #else - if (!addr) addr = (VALUE *)&addr; + VALUE *const addr = ptr ? ptr : (VALUE *)&ptr; + if (rb_gc_stack_start) { if (stack_growup_p(addr)) { @@ -1318,8 +1319,16 @@ Init_stack(addr) void +Init_stack(addr) + void *addr; +{ + if (!addr) addr = (void *)&addr; + ruby_stack_init(addr); +} + +void Init_heap() { if (!rb_gc_stack_start) { - Init_stack(0); + ruby_stack_init(0); } add_heap(); Index: intern.h =================================================================== RCS file: /cvs/ruby/src/ruby/intern.h,v retrieving revision 1.124 diff -u -2 -p -r1.124 intern.h --- intern.h 20 Jun 2003 07:11:40 -0000 1.124 +++ intern.h 25 Jun 2003 23:37:28 -0000 @@ -222,4 +222,5 @@ VALUE rb_find_file _((VALUE)); /* gc.c */ NORETURN(void rb_memerror __((void))); +void ruby_stack_init _((void*)); int ruby_stack_check _((void)); int ruby_stack_length _((VALUE**)); -- Nobu Nakada