comparison src/if_ruby.c @ 4369:c9820396afb9 v7.3.933

updated for version 7.3.933 Problem: Ruby on Mac crashes due to GC failure. Solution: Init the stack from main(). (Hiroshi Shirosaki)
author Bram Moolenaar <bram@vim.org>
date Sat, 11 May 2013 13:56:18 +0200
parents 04736b4030ec
children c42e130ebf36
comparison
equal deleted inserted replaced
4368:ef6e79cb8f02 4369:c9820396afb9
142 # define VALUE int 142 # define VALUE int
143 # define RUBY_DATA_FUNC int 143 # define RUBY_DATA_FUNC int
144 #endif 144 #endif
145 145
146 static int ruby_initialized = 0; 146 static int ruby_initialized = 0;
147 static void *ruby_stack_start;
147 static VALUE objtbl; 148 static VALUE objtbl;
148 149
149 static VALUE mVIM; 150 static VALUE mVIM;
150 static VALUE cBuffer; 151 static VALUE cBuffer;
151 static VALUE cVimWindow; 152 static VALUE cVimWindow;
224 # define rb_string_value dll_rb_string_value 225 # define rb_string_value dll_rb_string_value
225 # define rb_string_value_ptr dll_rb_string_value_ptr 226 # define rb_string_value_ptr dll_rb_string_value_ptr
226 # define rb_float_new dll_rb_float_new 227 # define rb_float_new dll_rb_float_new
227 # define rb_ary_new dll_rb_ary_new 228 # define rb_ary_new dll_rb_ary_new
228 # define rb_ary_push dll_rb_ary_push 229 # define rb_ary_push dll_rb_ary_push
230 # define ruby_init_stack dll_ruby_init_stack
229 #else 231 #else
230 # define rb_str2cstr dll_rb_str2cstr 232 # define rb_str2cstr dll_rb_str2cstr
231 #endif 233 #endif
232 #ifdef RUBY19_OR_LATER 234 #ifdef RUBY19_OR_LATER
233 # define rb_errinfo dll_rb_errinfo 235 # define rb_errinfo dll_rb_errinfo
248 # define rb_enc_find_index dll_rb_enc_find_index 250 # define rb_enc_find_index dll_rb_enc_find_index
249 # define rb_enc_find dll_rb_enc_find 251 # define rb_enc_find dll_rb_enc_find
250 # define rb_enc_str_new dll_rb_enc_str_new 252 # define rb_enc_str_new dll_rb_enc_str_new
251 # define rb_sprintf dll_rb_sprintf 253 # define rb_sprintf dll_rb_sprintf
252 # define rb_require dll_rb_require 254 # define rb_require dll_rb_require
253 # define ruby_init_stack dll_ruby_init_stack
254 # define ruby_process_options dll_ruby_process_options 255 # define ruby_process_options dll_ruby_process_options
255 #endif 256 #endif
256 257
257 /* 258 /*
258 * Pointers for dynamic link 259 * Pointers for dynamic link
333 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 334 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
334 static char * (*dll_rb_string_value_ptr) (volatile VALUE*); 335 static char * (*dll_rb_string_value_ptr) (volatile VALUE*);
335 static VALUE (*dll_rb_float_new) (double); 336 static VALUE (*dll_rb_float_new) (double);
336 static VALUE (*dll_rb_ary_new) (void); 337 static VALUE (*dll_rb_ary_new) (void);
337 static VALUE (*dll_rb_ary_push) (VALUE, VALUE); 338 static VALUE (*dll_rb_ary_push) (VALUE, VALUE);
339 static void (*ruby_init_stack)(VALUE*);
338 #endif 340 #endif
339 #ifdef RUBY19_OR_LATER 341 #ifdef RUBY19_OR_LATER
340 static VALUE (*dll_rb_int2big)(SIGNED_VALUE); 342 static VALUE (*dll_rb_int2big)(SIGNED_VALUE);
341 #endif 343 #endif
342 344
345 static int (*dll_rb_enc_find_index) (const char*); 347 static int (*dll_rb_enc_find_index) (const char*);
346 static rb_encoding* (*dll_rb_enc_find) (const char*); 348 static rb_encoding* (*dll_rb_enc_find) (const char*);
347 static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*); 349 static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
348 static VALUE (*dll_rb_sprintf) (const char*, ...); 350 static VALUE (*dll_rb_sprintf) (const char*, ...);
349 static VALUE (*dll_rb_require) (const char*); 351 static VALUE (*dll_rb_require) (const char*);
350 static void (*ruby_init_stack)(VALUE*);
351 static void* (*ruby_process_options)(int, char**); 352 static void* (*ruby_process_options)(int, char**);
352 #endif 353 #endif
353 354
354 #if defined(RUBY19_OR_LATER) && !defined(PROTO) 355 #if defined(RUBY19_OR_LATER) && !defined(PROTO)
355 SIGNED_VALUE rb_num2long_stub(VALUE x) 356 SIGNED_VALUE rb_num2long_stub(VALUE x)
473 {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf}, 474 {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf},
474 # endif 475 # endif
475 #endif 476 #endif
476 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 477 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
477 {"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr}, 478 {"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr},
479 {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack},
478 # if DYNAMIC_RUBY_VER <= 19 480 # if DYNAMIC_RUBY_VER <= 19
479 {"rb_float_new", (RUBY_PROC*)&dll_rb_float_new}, 481 {"rb_float_new", (RUBY_PROC*)&dll_rb_float_new},
480 # else 482 # else
481 {"rb_float_new_in_heap", (RUBY_PROC*)&dll_rb_float_new}, 483 {"rb_float_new_in_heap", (RUBY_PROC*)&dll_rb_float_new},
482 # endif 484 # endif
489 {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index}, 491 {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
490 {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find}, 492 {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find},
491 {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new}, 493 {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
492 {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf}, 494 {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
493 {"rb_require", (RUBY_PROC*)&dll_rb_require}, 495 {"rb_require", (RUBY_PROC*)&dll_rb_require},
494 {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack},
495 {"ruby_process_options", (RUBY_PROC*)&dll_ruby_process_options}, 496 {"ruby_process_options", (RUBY_PROC*)&dll_ruby_process_options},
496 #endif 497 #endif
497 {"", NULL}, 498 {"", NULL},
498 }; 499 };
499 500
714 int argc = 1; 715 int argc = 1;
715 char *argv[] = {"gvim.exe"}; 716 char *argv[] = {"gvim.exe"};
716 NtInitialize(&argc, &argv); 717 NtInitialize(&argc, &argv);
717 #endif 718 #endif
718 { 719 {
719 #ifdef RUBY19_OR_LATER 720 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
720 RUBY_INIT_STACK; 721 ruby_init_stack(ruby_stack_start);
721 #endif 722 #endif
722 ruby_init(); 723 ruby_init();
723 } 724 }
724 #ifdef RUBY19_OR_LATER 725 #ifdef RUBY19_OR_LATER
725 { 726 {
1387 rb_define_method(cVimWindow, "cursor=", window_set_cursor, 1); 1388 rb_define_method(cVimWindow, "cursor=", window_set_cursor, 1);
1388 1389
1389 rb_define_virtual_variable("$curbuf", buffer_s_current, 0); 1390 rb_define_virtual_variable("$curbuf", buffer_s_current, 0);
1390 rb_define_virtual_variable("$curwin", window_s_current, 0); 1391 rb_define_virtual_variable("$curwin", window_s_current, 0);
1391 } 1392 }
1393
1394 void vim_ruby_init(void *stack_start)
1395 {
1396 /* should get machine stack start address early in main function */
1397 ruby_stack_start = stack_start;
1398 }