1 # Apply ruby 2.0 fix to ruby 1.9 as well. Needed to allow |
|
2 # vim to build with ruby 1.9. |
|
3 # These changes were applied upstream to vim 7.4.224. See |
|
4 # https://groups.google.com/forum/#!msg/vim_dev/r8wzUVNYIfQ/m0DM8Wt97vkJ |
|
5 |
|
6 # Also applies fixes for Ruby 2.1 |
|
7 # from vim 7.4.570 |
|
8 # https://github.com/vim/vim/commit/0c7485fdbb5023731b006572cc224cbf52e34288 |
|
9 # and Ruby 2.2, from fixes to vim 7.4.705 |
|
10 # https://github.com/vim/vim/commit/bbc1a592a0e0efd5101a58032e7e7cc9f3e9f417 |
|
11 |
|
12 --- src/if_ruby.c 2013-08-10 06:00:24.000000000 -0700 |
|
13 +++ src/if_ruby.c 2015-09-16 15:16:02.741823755 -0700 |
|
14 @@ -88,14 +88,24 @@ |
|
15 # define rb_int2big rb_int2big_stub |
|
16 #endif |
|
17 |
|
18 -#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20 \ |
|
19 +#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 \ |
|
20 && SIZEOF_INT < SIZEOF_LONG |
|
21 -/* Ruby 2.0 defines a number of static functions which use rb_fix2int and |
|
22 +/* Ruby 1.9 defines a number of static functions which use rb_fix2int and |
|
23 * rb_num2int if SIZEOF_INT < SIZEOF_LONG (64bit) */ |
|
24 # define rb_fix2int rb_fix2int_stub |
|
25 # define rb_num2int rb_num2int_stub |
|
26 #endif |
|
27 |
|
28 +#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21 |
|
29 +/* Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses |
|
30 + * rb_gc_writebarrier_unprotect_promoted if USE_RGENGC */ |
|
31 +# define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub |
|
32 +#endif |
|
33 +#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22 |
|
34 +# define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub |
|
35 +# define rb_check_type rb_check_type_stub |
|
36 +#endif |
|
37 + |
|
38 #include <ruby.h> |
|
39 #ifdef RUBY19_OR_LATER |
|
40 # include <ruby/encoding.h> |
|
41 @@ -197,8 +207,10 @@ static void ruby_vim_init(void); |
|
42 # define rb_inspect dll_rb_inspect |
|
43 # define rb_int2inum dll_rb_int2inum |
|
44 # if SIZEOF_INT < SIZEOF_LONG /* 64 bits only */ |
|
45 +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 18 |
|
46 # define rb_fix2int dll_rb_fix2int |
|
47 # define rb_num2int dll_rb_num2int |
|
48 +# endif |
|
49 # define rb_num2uint dll_rb_num2uint |
|
50 # endif |
|
51 # define rb_lastline_get dll_rb_lastline_get |
|
52 @@ -373,8 +385,20 @@ static VALUE (*dll_rb_require) (const ch |
|
53 static void* (*ruby_process_options)(int, char**); |
|
54 # endif |
|
55 |
|
56 +# if defined(USE_RGENGC) && USE_RGENGC |
|
57 +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21 |
|
58 +static void (*dll_rb_gc_writebarrier_unprotect_promoted)(VALUE); |
|
59 +# else |
|
60 +static void (*dll_rb_gc_writebarrier_unprotect)(VALUE obj); |
|
61 +# endif |
|
62 +# endif |
|
63 + |
|
64 # if defined(RUBY19_OR_LATER) && !defined(PROTO) |
|
65 +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22 |
|
66 +long rb_num2long_stub(VALUE x) |
|
67 +# else |
|
68 SIGNED_VALUE rb_num2long_stub(VALUE x) |
|
69 +# endif |
|
70 { |
|
71 return dll_rb_num2long(x); |
|
72 } |
|
73 @@ -382,7 +406,7 @@ VALUE rb_int2big_stub(SIGNED_VALUE x) |
|
74 { |
|
75 return dll_rb_int2big(x); |
|
76 } |
|
77 -# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20 \ |
|
78 +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 \ |
|
79 && SIZEOF_INT < SIZEOF_LONG |
|
80 long rb_fix2int_stub(VALUE x) |
|
81 { |
|
82 @@ -399,13 +423,39 @@ rb_float_new_in_heap(double d) |
|
83 { |
|
84 return dll_rb_float_new(d); |
|
85 } |
|
86 +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22 |
|
87 +unsigned long rb_num2ulong(VALUE x) |
|
88 +# else |
|
89 VALUE rb_num2ulong(VALUE x) |
|
90 +# endif |
|
91 { |
|
92 return (long)RSHIFT((SIGNED_VALUE)(x),1); |
|
93 } |
|
94 # endif |
|
95 # endif |
|
96 |
|
97 + /* Do not generate a prototype here, VALUE isn't always defined. */ |
|
98 +# if defined(USE_RGENGC) && USE_RGENGC && !defined(PROTO) |
|
99 +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21 |
|
100 +void rb_gc_writebarrier_unprotect_promoted_stub(VALUE obj) |
|
101 +{ |
|
102 + dll_rb_gc_writebarrier_unprotect_promoted(obj); |
|
103 +} |
|
104 +# else |
|
105 +void rb_gc_writebarrier_unprotect_stub(VALUE obj) |
|
106 +{ |
|
107 + dll_rb_gc_writebarrier_unprotect(obj); |
|
108 +} |
|
109 +# endif |
|
110 +# endif |
|
111 + |
|
112 +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22 |
|
113 +void rb_check_type_stub(VALUE v, int i) |
|
114 +{ |
|
115 + dll_rb_check_type(v, i); |
|
116 +} |
|
117 +# endif |
|
118 + |
|
119 static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */ |
|
120 |
|
121 /* |
|
122 @@ -521,6 +571,13 @@ static struct |
|
123 # endif |
|
124 {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack}, |
|
125 # endif |
|
126 +# if defined(USE_RGENGC) && USE_RGENGC |
|
127 +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21 |
|
128 + {"rb_gc_writebarrier_unprotect_promoted", (RUBY_PROC*)&dll_rb_gc_writebarrier_unprotect_promoted}, |
|
129 +# else |
|
130 + {"rb_gc_writebarrier_unprotect", (RUBY_PROC*)&dll_rb_gc_writebarrier_unprotect}, |
|
131 +# endif |
|
132 +# endif |
|
133 {"", NULL}, |
|
134 }; |
|
135 |
|