Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 745 lines (625 sloc) 16.745 kb
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
1 /* -*-c-*- */
2 /**********************************************************************
3
c334a09 Koichi Sasada * common.mk, *.ci: renamed to *.c.
ko1 authored
4 thread_win32.c -
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
5
6 $Author$
7
d907cbc Koichi Sasada * blockinlining.c, compile.c, compile.h, debug.c, debug.h,
ko1 authored
8 Copyright (C) 2004-2007 Koichi Sasada
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
9
10 **********************************************************************/
11
12 #ifdef THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION
13
14 #include <process.h>
15
16 #define WIN32_WAIT_TIMEOUT 10 /* 10 ms */
604a1e2 kosaki fix win32 compile error.
kosaki authored
17 #define RB_CONDATTR_CLOCK_MONOTONIC 1 /* no effect */
18
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
19 #undef Sleep
20
21 #define native_thread_yield() Sleep(0)
ae317b5 Koichi Sasada * yarvcore.h, thread.c: fix to use pthread on cygwin.
ko1 authored
22 #define remove_signal_thread_list(th)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
23
6fc746d Nobuyoshi Nakada * thread.c (is_ruby_native_thread): check properly. [ruby-dev:31166]
nobu authored
24 static volatile DWORD ruby_native_thread_key = TLS_OUT_OF_INDEXES;
25
5f131b6 Nobuyoshi Nakada * thread_win32.c, include/ruby/win32.h: add prototypes.
nobu authored
26 static int w32_wait_events(HANDLE *events, int count, DWORD timeout, rb_thread_t *th);
27 static int native_mutex_lock(rb_thread_lock_t *lock);
28 static int native_mutex_unlock(rb_thread_lock_t *lock);
29
450463d Koichi Sasada * thread.c, vm_core.h: make gvl_acquire/release/init/destruct
ko1 authored
30 static void
31 w32_error(const char *func)
32 {
33 LPVOID lpMsgBuf;
34 DWORD err = GetLastError();
35 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
36 FORMAT_MESSAGE_FROM_SYSTEM |
37 FORMAT_MESSAGE_IGNORE_INSERTS,
38 NULL,
39 err,
40 MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
41 (LPTSTR) & lpMsgBuf, 0, NULL) == 0)
42 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
43 FORMAT_MESSAGE_FROM_SYSTEM |
44 FORMAT_MESSAGE_IGNORE_INSERTS,
45 NULL,
46 err,
47 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
48 (LPTSTR) & lpMsgBuf, 0, NULL);
49 rb_bug("%s: %s", func, (char*)lpMsgBuf);
50 }
51
52 static int
53 w32_mutex_lock(HANDLE lock)
54 {
55 DWORD result;
56 while (1) {
57 thread_debug("native_mutex_lock: %p\n", lock);
58 result = w32_wait_events(&lock, 1, INFINITE, 0);
59 switch (result) {
60 case WAIT_OBJECT_0:
61 /* get mutex object */
62 thread_debug("acquire mutex: %p\n", lock);
63 return 0;
64 case WAIT_OBJECT_0 + 1:
65 /* interrupt */
66 errno = EINTR;
67 thread_debug("acquire mutex interrupted: %p\n", lock);
68 return 0;
69 case WAIT_TIMEOUT:
70 thread_debug("timeout mutex: %p\n", lock);
71 break;
72 case WAIT_ABANDONED:
73 rb_bug("win32_mutex_lock: WAIT_ABANDONED");
74 break;
75 default:
f0445d1 Nobuyoshi Nakada * thread_win32.c (gvl_release, gvl_init): suppress warnings.
nobu authored
76 rb_bug("win32_mutex_lock: unknown result (%ld)", result);
450463d Koichi Sasada * thread.c, vm_core.h: make gvl_acquire/release/init/destruct
ko1 authored
77 break;
78 }
79 }
80 return 0;
81 }
82
83 static HANDLE
84 w32_mutex_create(void)
85 {
86 HANDLE lock = CreateMutex(NULL, FALSE, NULL);
87 if (lock == NULL) {
88 w32_error("native_mutex_initialize");
89 }
90 return lock;
91 }
92
93 #define GVL_DEBUG 0
94
95 static void
96 gvl_acquire(rb_vm_t *vm, rb_thread_t *th)
97 {
98 w32_mutex_lock(vm->gvl.lock);
99 if (GVL_DEBUG) fprintf(stderr, "gvl acquire (%p): acquire\n", th);
100 }
101
102 static void
103 gvl_release(rb_vm_t *vm)
104 {
105 ReleaseMutex(vm->gvl.lock);
106 }
107
108 static void
109 gvl_atfork(rb_vm_t *vm)
110 {
111 rb_bug("gvl_atfork() is called on win32");
112 }
113
114 static void
115 gvl_init(rb_vm_t *vm)
116 {
117 if (GVL_DEBUG) fprintf(stderr, "gvl init\n");
118 vm->gvl.lock = w32_mutex_create();
119 }
120
121 static void
122 gvl_destroy(rb_vm_t *vm)
123 {
124 if (GVL_DEBUG) fprintf(stderr, "gvl destroy\n");
125 CloseHandle(vm->gvl.lock);
126 }
127
6fc746d Nobuyoshi Nakada * thread.c (is_ruby_native_thread): check properly. [ruby-dev:31166]
nobu authored
128 static rb_thread_t *
129 ruby_thread_from_native(void)
130 {
131 return TlsGetValue(ruby_native_thread_key);
132 }
133
134 static int
135 ruby_thread_set_native(rb_thread_t *th)
136 {
137 return TlsSetValue(ruby_native_thread_key, th);
138 }
139
f40d2c9 akr * vm.c (Init_BareVM): call Init_native_thread here.
akr authored
140 void
6fc746d Nobuyoshi Nakada * thread.c (is_ruby_native_thread): check properly. [ruby-dev:31166]
nobu authored
141 Init_native_thread(void)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
142 {
9c57438 Koichi Sasada * blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
ko1 authored
143 rb_thread_t *th = GET_THREAD();
6fc746d Nobuyoshi Nakada * thread.c (is_ruby_native_thread): check properly. [ruby-dev:31166]
nobu authored
144
145 ruby_native_thread_key = TlsAlloc();
b451955 unak * thread_win32.c (Init_native_thread): need to call
unak authored
146 ruby_thread_set_native(th);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
147 DuplicateHandle(GetCurrentProcess(),
148 GetCurrentThread(),
149 GetCurrentProcess(),
150 &th->thread_id, 0, FALSE, DUPLICATE_SAME_ACCESS);
151
152 th->native_thread_data.interrupt_event = CreateEvent(0, TRUE, FALSE, 0);
153
154 thread_debug("initial thread (th: %p, thid: %p, event: %p)\n",
155 th, GET_THREAD()->thread_id,
156 th->native_thread_data.interrupt_event);
157 }
158
159 static void
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
160 w32_set_event(HANDLE handle)
161 {
162 if (SetEvent(handle) == 0) {
5bc85d6 unak * thread_win32.c (w32_error): should report the function.
unak authored
163 w32_error("w32_set_event");
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
164 }
165 }
166
167 static void
168 w32_reset_event(HANDLE handle)
169 {
170 if (ResetEvent(handle) == 0) {
5bc85d6 unak * thread_win32.c (w32_error): should report the function.
unak authored
171 w32_error("w32_reset_event");
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
172 }
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
173 }
174
175 static int
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
176 w32_wait_events(HANDLE *events, int count, DWORD timeout, rb_thread_t *th)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
177 {
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
178 HANDLE *targets = events;
00f60d0 unak * thread_win32.ci (w32_wait_events): check whether interrupt_event is
unak authored
179 HANDLE intr;
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
180 DWORD ret;
181
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
182 thread_debug(" w32_wait_events events:%p, count:%d, timeout:%ld, th:%p\n",
183 events, count, timeout, th);
00f60d0 unak * thread_win32.ci (w32_wait_events): check whether interrupt_event is
unak authored
184 if (th && (intr = th->native_thread_data.interrupt_event)) {
450463d Koichi Sasada * thread.c, vm_core.h: make gvl_acquire/release/init/destruct
ko1 authored
185 gvl_acquire(th->vm, th);
bd21118 wanabe * thread_win32.c (w32_wait_events): get GVL before handle interrupt
wanabe authored
186 if (intr == th->native_thread_data.interrupt_event) {
187 w32_reset_event(intr);
188 if (RUBY_VM_INTERRUPTED(th)) {
189 w32_set_event(intr);
190 }
191
192 targets = ALLOCA_N(HANDLE, count + 1);
193 memcpy(targets, events, sizeof(HANDLE) * count);
194
195 targets[count++] = intr;
196 thread_debug(" * handle: %p (count: %d, intr)\n", intr, count);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
197 }
450463d Koichi Sasada * thread.c, vm_core.h: make gvl_acquire/release/init/destruct
ko1 authored
198 gvl_release(th->vm);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
199 }
200
201 thread_debug(" WaitForMultipleObjects start (count: %d)\n", count);
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
202 ret = WaitForMultipleObjects(count, targets, FALSE, timeout);
87e4ad0 Nobuyoshi Nakada * io.c, signal.c, thread.c, thread_win32.c, include/ruby/intern.h:
nobu authored
203 thread_debug(" WaitForMultipleObjects end (ret: %lu)\n", ret);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
204
060f18c wanabe * thread_win32.c (w32_wait_events, w32_close_handle): suppress warnings.
wanabe authored
205 if (ret == (DWORD)(WAIT_OBJECT_0 + count - 1) && th) {
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
206 errno = EINTR;
207 }
060f18c wanabe * thread_win32.c (w32_wait_events, w32_close_handle): suppress warnings.
wanabe authored
208 if (ret == WAIT_FAILED && THREAD_DEBUG) {
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
209 int i;
210 DWORD dmy;
211 for (i = 0; i < count; i++) {
212 thread_debug(" * error handle %d - %s\n", i,
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
213 GetHandleInformation(targets[i], &dmy) ? "OK" : "NG");
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
214 }
215 }
216 return ret;
217 }
218
3453b2b Koichi Sasada * gc.h, vm_core.h: decl of rb_gc_save_machine_context()
ko1 authored
219 static void ubf_handle(void *ptr);
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
220 #define ubf_select ubf_handle
221
222 int
c034fce Nobuyoshi Nakada * process.c (rb_waitpid_blocking, rb_waitpid): use UBF feature.
nobu authored
223 rb_w32_wait_events_blocking(HANDLE *events, int num, DWORD timeout)
224 {
225 return w32_wait_events(events, num, timeout, GET_THREAD());
226 }
227
228 int
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
229 rb_w32_wait_events(HANDLE *events, int num, DWORD timeout)
230 {
231 int ret;
232
3453b2b Koichi Sasada * gc.h, vm_core.h: decl of rb_gc_save_machine_context()
ko1 authored
233 BLOCKING_REGION(ret = rb_w32_wait_events_blocking(events, num, timeout),
4b645dc Yusuke Endoh * thread.c, thread_win32.c, vm_core.h: try to remove false positive of
mame authored
234 ubf_handle, GET_THREAD());
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
235 return ret;
236 }
237
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
238 static void
239 w32_close_handle(HANDLE handle)
240 {
241 if (CloseHandle(handle) == 0) {
5bc85d6 unak * thread_win32.c (w32_error): should report the function.
unak authored
242 w32_error("w32_close_handle");
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
243 }
244 }
245
246 static void
247 w32_resume_thread(HANDLE handle)
248 {
060f18c wanabe * thread_win32.c (w32_wait_events, w32_close_handle): suppress warnings.
wanabe authored
249 if (ResumeThread(handle) == (DWORD)-1) {
5bc85d6 unak * thread_win32.c (w32_error): should report the function.
unak authored
250 w32_error("w32_resume_thread");
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
251 }
252 }
253
2840fa6 Nobuyoshi Nakada * common.mk: inverted rules order.
nobu authored
254 #ifdef _MSC_VER
255 #define HAVE__BEGINTHREADEX 1
256 #else
257 #undef HAVE__BEGINTHREADEX
258 #endif
259
260 #ifdef HAVE__BEGINTHREADEX
261 #define start_thread (HANDLE)_beginthreadex
9e0f3e0 Nobuyoshi Nakada * thread_win32.c (thread_errno): CreateThread does not set errno.
nobu authored
262 #define thread_errno errno
2840fa6 Nobuyoshi Nakada * common.mk: inverted rules order.
nobu authored
263 typedef unsigned long (_stdcall *w32_thread_start_func)(void*);
264 #else
265 #define start_thread CreateThread
9e0f3e0 Nobuyoshi Nakada * thread_win32.c (thread_errno): CreateThread does not set errno.
nobu authored
266 #define thread_errno rb_w32_map_errno(GetLastError())
2840fa6 Nobuyoshi Nakada * common.mk: inverted rules order.
nobu authored
267 typedef LPTHREAD_START_ROUTINE w32_thread_start_func;
268 #endif
269
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
270 static HANDLE
2840fa6 Nobuyoshi Nakada * common.mk: inverted rules order.
nobu authored
271 w32_create_thread(DWORD stack_size, w32_thread_start_func func, void *val)
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
272 {
2840fa6 Nobuyoshi Nakada * common.mk: inverted rules order.
nobu authored
273 return start_thread(0, stack_size, func, val, CREATE_SUSPENDED, 0);
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
274 }
275
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
276 int
277 rb_w32_sleep(unsigned long msec)
278 {
279 return w32_wait_events(0, 0, msec, GET_THREAD());
280 }
281
282 int WINAPI
283 rb_w32_Sleep(unsigned long msec)
284 {
285 int ret;
286
3453b2b Koichi Sasada * gc.h, vm_core.h: decl of rb_gc_save_machine_context()
ko1 authored
287 BLOCKING_REGION(ret = rb_w32_sleep(msec),
4b645dc Yusuke Endoh * thread.c, thread_win32.c, vm_core.h: try to remove false positive of
mame authored
288 ubf_handle, GET_THREAD());
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
289 return ret;
290 }
ae317b5 Koichi Sasada * yarvcore.h, thread.c: fix to use pthread on cygwin.
ko1 authored
291
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
292 static void
47e3f4e Nobuyoshi Nakada * thread.c (thread_start_func_2): wake up joining threads.
nobu authored
293 native_sleep(rb_thread_t *th, struct timeval *tv)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
294 {
a146829 Nobuyoshi Nakada * thread.c (sleep_forever): wait until timed out. [ruby-core:17270]
nobu authored
295 DWORD msec;
4b02286 unak * thread_win32.c (native_sleep): fixed previous commit.
unak authored
296
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
297 if (tv) {
298 msec = tv->tv_sec * 1000 + tv->tv_usec / 1000;
299 }
300 else {
301 msec = INFINITE;
302 }
303
304 GVL_UNLOCK_BEGIN();
305 {
a146829 Nobuyoshi Nakada * thread.c (sleep_forever): wait until timed out. [ruby-core:17270]
nobu authored
306 DWORD ret;
307
8724448 unak * thread_win32.c (native_sleep): must block reentrance when accessing
unak authored
308 native_mutex_lock(&th->interrupt_lock);
1b63d7b Nobuyoshi Nakada * vm_core.h (struct rb_unblock_callback), thread.c
nobu authored
309 th->unblock.func = ubf_handle;
310 th->unblock.arg = th;
8724448 unak * thread_win32.c (native_sleep): must block reentrance when accessing
unak authored
311 native_mutex_unlock(&th->interrupt_lock);
5f0b8af Koichi Sasada * vm_core.h, thread.c, cont.c: add RUBY_VM_SET_INTERRUPT(),
ko1 authored
312
313 if (RUBY_VM_INTERRUPTED(th)) {
314 /* interrupted. return immediate */
315 }
316 else {
87e4ad0 Nobuyoshi Nakada * io.c, signal.c, thread.c, thread_win32.c, include/ruby/intern.h:
nobu authored
317 thread_debug("native_sleep start (%lu)\n", msec);
5f0b8af Koichi Sasada * vm_core.h, thread.c, cont.c: add RUBY_VM_SET_INTERRUPT(),
ko1 authored
318 ret = w32_wait_events(0, 0, msec, th);
87e4ad0 Nobuyoshi Nakada * io.c, signal.c, thread.c, thread_win32.c, include/ruby/intern.h:
nobu authored
319 thread_debug("native_sleep done (%lu)\n", ret);
5f0b8af Koichi Sasada * vm_core.h, thread.c, cont.c: add RUBY_VM_SET_INTERRUPT(),
ko1 authored
320 }
321
8724448 unak * thread_win32.c (native_sleep): must block reentrance when accessing
unak authored
322 native_mutex_lock(&th->interrupt_lock);
1b63d7b Nobuyoshi Nakada * vm_core.h (struct rb_unblock_callback), thread.c
nobu authored
323 th->unblock.func = 0;
324 th->unblock.arg = 0;
8724448 unak * thread_win32.c (native_sleep): must block reentrance when accessing
unak authored
325 native_mutex_unlock(&th->interrupt_lock);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
326 }
327 GVL_UNLOCK_END();
328 }
329
42f0b52 Koichi Sasada * thread_pthread.c, thread_pthread.h, thread_win32.c,
ko1 authored
330 static int
8ee7d07 Koichi Sasada * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
331 native_mutex_lock(rb_thread_lock_t *lock)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
332 {
333 #if USE_WIN32_MUTEX
450463d Koichi Sasada * thread.c, vm_core.h: make gvl_acquire/release/init/destruct
ko1 authored
334 w32_mutex_lock(*lock);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
335 #else
336 EnterCriticalSection(lock);
337 return 0;
338 #endif
339 }
340
42f0b52 Koichi Sasada * thread_pthread.c, thread_pthread.h, thread_win32.c,
ko1 authored
341 static int
8ee7d07 Koichi Sasada * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
342 native_mutex_unlock(rb_thread_lock_t *lock)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
343 {
344 #if USE_WIN32_MUTEX
345 thread_debug("release mutex: %p\n", *lock);
346 return ReleaseMutex(*lock);
347 #else
348 LeaveCriticalSection(lock);
349 return 0;
350 #endif
351 }
352
42f0b52 Koichi Sasada * thread_pthread.c, thread_pthread.h, thread_win32.c,
ko1 authored
353 static int
8ee7d07 Koichi Sasada * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
354 native_mutex_trylock(rb_thread_lock_t *lock)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
355 {
35eb542 Nobuyoshi Nakada * thread_win32.ci: fixed typo.
nobu authored
356 #if USE_WIN32_MUTEX
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
357 int result;
358 thread_debug("native_mutex_trylock: %p\n", *lock);
bb022be unak * thread.c (rb_thread_polling): check interrupts here.
unak authored
359 result = w32_wait_events(&*lock, 1, 1, 0);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
360 thread_debug("native_mutex_trylock result: %d\n", result);
361 switch (result) {
99d65b1 Nobuyoshi Nakada * compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
nobu authored
362 case WAIT_OBJECT_0:
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
363 return 0;
99d65b1 Nobuyoshi Nakada * compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
nobu authored
364 case WAIT_TIMEOUT:
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
365 return EBUSY;
366 }
367 return EINVAL;
368 #else
369 return TryEnterCriticalSection(lock) == 0;
370 #endif
371 }
372
42f0b52 Koichi Sasada * thread_pthread.c, thread_pthread.h, thread_win32.c,
ko1 authored
373 static void
8ee7d07 Koichi Sasada * blockinlining.c, compile.c, compile.h, error.c, eval.c,
ko1 authored
374 native_mutex_initialize(rb_thread_lock_t *lock)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
375 {
35eb542 Nobuyoshi Nakada * thread_win32.ci: fixed typo.
nobu authored
376 #if USE_WIN32_MUTEX
450463d Koichi Sasada * thread.c, vm_core.h: make gvl_acquire/release/init/destruct
ko1 authored
377 *lock = w32_mutex_create();
205f310 Nobuyoshi Nakada * call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
nobu authored
378 /* thread_debug("initialize mutex: %p\n", *lock); */
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
379 #else
380 InitializeCriticalSection(lock);
381 #endif
382 }
383
42f0b52 Koichi Sasada * thread_pthread.c, thread_pthread.h, thread_win32.c,
ko1 authored
384 static void
a902624 Koichi Sasada * thread.c, thread_pthread.ci, thread_win32.ci (thread_start_func_1):
ko1 authored
385 native_mutex_destroy(rb_thread_lock_t *lock)
386 {
35eb542 Nobuyoshi Nakada * thread_win32.ci: fixed typo.
nobu authored
387 #if USE_WIN32_MUTEX
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
388 w32_close_handle(lock);
389 #else
390 DeleteCriticalSection(lock);
391 #endif
a902624 Koichi Sasada * thread.c, thread_pthread.ci, thread_win32.ci (thread_start_func_1):
ko1 authored
392 }
393
a73ba1d unak * thread_win32.[ch] (cond_every_entry, rb_thread_cond_struct): reverted
unak authored
394 struct cond_event_entry {
395 struct cond_event_entry* next;
94e4d61 kosaki fix win32 native_cond_timedwait() makes SIGSEGV.
kosaki authored
396 struct cond_event_entry* prev;
a73ba1d unak * thread_win32.[ch] (cond_every_entry, rb_thread_cond_struct): reverted
unak authored
397 HANDLE event;
398 };
399
42f0b52 Koichi Sasada * thread_pthread.c, thread_pthread.h, thread_win32.c,
ko1 authored
400 static void
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
401 native_cond_signal(rb_thread_cond_t *cond)
402 {
403 /* cond is guarded by mutex */
404 struct cond_event_entry *e = cond->next;
94e4d61 kosaki fix win32 native_cond_timedwait() makes SIGSEGV.
kosaki authored
405 struct cond_event_entry *head = (struct cond_event_entry*)cond;
406
407 if (e != head) {
408 struct cond_event_entry *next = e->next;
409 struct cond_event_entry *prev = e->prev;
410
411 prev->next = next;
412 next->prev = prev;
413 e->next = e->prev = e;
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
414
415 SetEvent(e->event);
416 }
417 else {
418 rb_bug("native_cond_signal: no pending threads");
419 }
420 }
421
42f0b52 Koichi Sasada * thread_pthread.c, thread_pthread.h, thread_win32.c,
ko1 authored
422 static void
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
423 native_cond_broadcast(rb_thread_cond_t *cond)
424 {
425 /* cond is guarded by mutex */
426 struct cond_event_entry *e = cond->next;
94e4d61 kosaki fix win32 native_cond_timedwait() makes SIGSEGV.
kosaki authored
427 struct cond_event_entry *head = (struct cond_event_entry*)cond;
428
429 while (e != head) {
430 struct cond_event_entry *next = e->next;
431 struct cond_event_entry *prev = e->prev;
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
432
433 SetEvent(e->event);
94e4d61 kosaki fix win32 native_cond_timedwait() makes SIGSEGV.
kosaki authored
434
435 prev->next = next;
436 next->prev = prev;
437 e->next = e->prev = e;
438
439 e = next;
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
440 }
441 }
442
b4c5fad kosaki * thread_win32.c (native_cond_timedwait): New. r31373 caused
kosaki authored
443
444 static int
445 __cond_timedwait(rb_thread_cond_t *cond, rb_thread_lock_t *mutex, unsigned long msec)
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
446 {
447 DWORD r;
448 struct cond_event_entry entry;
94e4d61 kosaki fix win32 native_cond_timedwait() makes SIGSEGV.
kosaki authored
449 struct cond_event_entry *head = (struct cond_event_entry*)cond;
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
450
451 entry.event = CreateEvent(0, FALSE, FALSE, 0);
94e4d61 kosaki fix win32 native_cond_timedwait() makes SIGSEGV.
kosaki authored
452 entry.mutex = mutex;
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
453
454 /* cond is guarded by mutex */
94e4d61 kosaki fix win32 native_cond_timedwait() makes SIGSEGV.
kosaki authored
455 entry.next = head;
456 entry.prev = head->prev;
457 head->prev->next = &entry;
458 head->prev = &entry;
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
459
460 native_mutex_unlock(mutex);
461 {
b4c5fad kosaki * thread_win32.c (native_cond_timedwait): New. r31373 caused
kosaki authored
462 r = WaitForSingleObject(entry.event, msec);
463 if ((r != WAIT_OBJECT_0) && (r != WAIT_TIMEOUT)) {
87e4ad0 Nobuyoshi Nakada * io.c, signal.c, thread.c, thread_win32.c, include/ruby/intern.h:
nobu authored
464 rb_bug("native_cond_wait: WaitForSingleObject returns %lu", r);
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
465 }
466 }
467 native_mutex_lock(mutex);
468
94e4d61 kosaki fix win32 native_cond_timedwait() makes SIGSEGV.
kosaki authored
469 entry.prev->next = entry.next;
470 entry.next->prev = entry.prev;
471
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
472 w32_close_handle(entry.event);
b4c5fad kosaki * thread_win32.c (native_cond_timedwait): New. r31373 caused
kosaki authored
473 return (r == WAIT_OBJECT_0) ? 0 : ETIMEDOUT;
474 }
475
476 static int
477 native_cond_wait(rb_thread_cond_t *cond, rb_thread_lock_t *mutex)
478 {
479 return __cond_timedwait(cond, mutex, INFINITE);
480 }
481
482 static unsigned long
483 abs_timespec_to_timeout_ms(struct timespec *ts)
484 {
485 struct timeval tv;
486 struct timeval now;
487
488 gettimeofday(&now, NULL);
489 tv.tv_sec = ts->tv_sec;
471fb33 kosaki fix mutex deadlock test hang-up.
kosaki authored
490 tv.tv_usec = ts->tv_nsec / 1000;
b4c5fad kosaki * thread_win32.c (native_cond_timedwait): New. r31373 caused
kosaki authored
491
492 if (!rb_w32_time_subtract(&tv, &now))
493 return 0;
494
495 return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
496 }
497
498 static int
499 native_cond_timedwait(rb_thread_cond_t *cond, rb_thread_lock_t *mutex, struct timespec *ts)
500 {
501 unsigned long timeout_ms;
502
503 timeout_ms = abs_timespec_to_timeout_ms(ts);
504 if (!timeout_ms)
505 return ETIMEDOUT;
506
507 return __cond_timedwait(cond, mutex, timeout_ms);
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
508 }
509
7ac6b70 kosaki sleep_cond use monotonic time if possible.
kosaki authored
510 #if SIZEOF_TIME_T == SIZEOF_LONG
511 typedef unsigned long unsigned_time_t;
512 #elif SIZEOF_TIME_T == SIZEOF_INT
513 typedef unsigned int unsigned_time_t;
514 #elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
515 typedef unsigned LONG_LONG unsigned_time_t;
516 #else
517 # error cannot find integer type which size is same as time_t.
518 #endif
519
520 #define TIMET_MAX (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0))
521
b2ea836 kosaki mutex: deadlock check timeout use monotonic time.
kosaki authored
522 static struct timespec
523 native_cond_timeout(rb_thread_cond_t *cond, struct timespec timeout_rel)
524 {
525 int ret;
526 struct timeval tv;
527 struct timespec timeout;
7ac6b70 kosaki sleep_cond use monotonic time if possible.
kosaki authored
528 struct timespec now;
b2ea836 kosaki mutex: deadlock check timeout use monotonic time.
kosaki authored
529
530 ret = gettimeofday(&tv, 0);
531 if (ret != 0)
532 rb_sys_fail(0);
7ac6b70 kosaki sleep_cond use monotonic time if possible.
kosaki authored
533 now.tv_sec = tv.tv_sec;
534 now.tv_nsec = tv.tv_usec * 1000;
b2ea836 kosaki mutex: deadlock check timeout use monotonic time.
kosaki authored
535
7ac6b70 kosaki sleep_cond use monotonic time if possible.
kosaki authored
536 out:
537 timeout.tv_sec = now.tv_sec;
538 timeout.tv_nsec = now.tv_nsec;
b2ea836 kosaki mutex: deadlock check timeout use monotonic time.
kosaki authored
539 timeout.tv_sec += timeout_rel.tv_sec;
540 timeout.tv_nsec += timeout_rel.tv_nsec;
7ac6b70 kosaki sleep_cond use monotonic time if possible.
kosaki authored
541
b2ea836 kosaki mutex: deadlock check timeout use monotonic time.
kosaki authored
542 if (timeout.tv_nsec >= 1000*1000*1000) {
543 timeout.tv_sec++;
544 timeout.tv_nsec -= 1000*1000*1000;
545 }
7ac6b70 kosaki sleep_cond use monotonic time if possible.
kosaki authored
546
547 if (timeout.tv_sec < now.tv_sec)
548 timeout.tv_sec = TIMET_MAX;
549
b2ea836 kosaki mutex: deadlock check timeout use monotonic time.
kosaki authored
550 return timeout;
551 }
552
42f0b52 Koichi Sasada * thread_pthread.c, thread_pthread.h, thread_win32.c,
ko1 authored
553 static void
a1cfaf4 kosaki * thread_pthread.h (rb_thread_cond_t): add clockid field. it's
kosaki authored
554 native_cond_initialize(rb_thread_cond_t *cond, int flags)
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
555 {
94e4d61 kosaki fix win32 native_cond_timedwait() makes SIGSEGV.
kosaki authored
556 cond->next = (struct cond_event_entry *)cond;
557 cond->prev = (struct cond_event_entry *)cond;
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
558 }
559
42f0b52 Koichi Sasada * thread_pthread.c, thread_pthread.h, thread_win32.c,
ko1 authored
560 static void
6244e50 Koichi Sasada * thread.c: fix Mutex to be interruptable lock.
ko1 authored
561 native_cond_destroy(rb_thread_cond_t *cond)
562 {
563 /* */
564 }
a902624 Koichi Sasada * thread.c, thread_pthread.ci, thread_win32.ci (thread_start_func_1):
ko1 authored
565
fc3c60f Nobuyoshi Nakada * gc.h (STACK_UPPER): moved from gc.c
nobu authored
566 void
c7853b4 Nobuyoshi Nakada * eval.c (ruby_cleanup): the order of local variables on stack is
nobu authored
567 ruby_init_stack(volatile VALUE *addr)
fc3c60f Nobuyoshi Nakada * gc.h (STACK_UPPER): moved from gc.c
nobu authored
568 {
569 }
570
571 #define CHECK_ERR(expr) \
572 {if (!(expr)) {rb_bug("err: %lu - %s", GetLastError(), #expr);}}
573
574 static void
575 native_thread_init_stack(rb_thread_t *th)
576 {
577 MEMORY_BASIC_INFORMATION mi;
578 char *base, *end;
579 DWORD size, space;
580
581 CHECK_ERR(VirtualQuery(&mi, &mi, sizeof(mi)));
582 base = mi.AllocationBase;
583 end = mi.BaseAddress;
584 end += mi.RegionSize;
585 size = end - base;
586 space = size / 5;
587 if (space > 1024*1024) space = 1024*1024;
588 th->machine_stack_start = (VALUE *)end - 1;
589 th->machine_stack_maxsize = size - space;
590 }
591
dfc07e8 unak * thread_win32.c (InterlockedExchangePointer): old SDK support.
unak authored
592 #ifndef InterlockedExchangePointer
593 #define InterlockedExchangePointer(t, v) \
594 (void *)InterlockedExchange((long *)(t), (long)(v))
595 #endif
a902624 Koichi Sasada * thread.c, thread_pthread.ci, thread_win32.ci (thread_start_func_1):
ko1 authored
596 static void
597 native_thread_destroy(rb_thread_t *th)
598 {
9f90682 unak * thread_win32.c (native_thread_destroy): decreased the probability of
unak authored
599 HANDLE intr = InterlockedExchangePointer(&th->native_thread_data.interrupt_event, 0);
00f60d0 unak * thread_win32.ci (w32_wait_events): check whether interrupt_event is
unak authored
600 thread_debug("close handle - intr: %p, thid: %p\n", intr, th->thread_id);
601 w32_close_handle(intr);
a902624 Koichi Sasada * thread.c, thread_pthread.ci, thread_win32.ci (thread_start_func_1):
ko1 authored
602 }
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
603
2840fa6 Nobuyoshi Nakada * common.mk: inverted rules order.
nobu authored
604 static unsigned long _stdcall
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
605 thread_start_func_1(void *th_ptr)
606 {
9c57438 Koichi Sasada * blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
ko1 authored
607 rb_thread_t *th = th_ptr;
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
608 volatile HANDLE thread_id = th->thread_id;
609
fc3c60f Nobuyoshi Nakada * gc.h (STACK_UPPER): moved from gc.c
nobu authored
610 native_thread_init_stack(th);
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
611 th->native_thread_data.interrupt_event = CreateEvent(0, TRUE, FALSE, 0);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
612
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
613 /* run */
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
614 thread_debug("thread created (th: %p, thid: %p, event: %p)\n", th,
615 th->thread_id, th->native_thread_data.interrupt_event);
5732566 Nobuyoshi Nakada * thread.c (rb_thread_stop_timer_thread): terminates timer thread
nobu authored
616
df6ea23 Nobuyoshi Nakada * thread_win32.c (thread_start_func_1): use already gotten stack info.
nobu authored
617 thread_start_func_2(th, th->machine_stack_start, rb_ia64_bsp());
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
618
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
619 w32_close_handle(thread_id);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
620 thread_debug("thread deleted (th: %p)\n", th);
621 return 0;
622 }
623
624 static int
9c57438 Koichi Sasada * blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
ko1 authored
625 native_thread_create(rb_thread_t *th)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
626 {
a902624 Koichi Sasada * thread.c, thread_pthread.ci, thread_win32.ci (thread_start_func_1):
ko1 authored
627 size_t stack_size = 4 * 1024; /* 4KB */
628 th->thread_id = w32_create_thread(stack_size, thread_start_func_1, th);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
629
a902624 Koichi Sasada * thread.c, thread_pthread.ci, thread_win32.ci (thread_start_func_1):
ko1 authored
630 if ((th->thread_id) == 0) {
9e0f3e0 Nobuyoshi Nakada * thread_win32.c (thread_errno): CreateThread does not set errno.
nobu authored
631 return thread_errno;
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
632 }
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
633
634 w32_resume_thread(th->thread_id);
635
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
636 if (THREAD_DEBUG) {
637 Sleep(0);
cea3919 Nobuyoshi Nakada * configure.in (RUBY_CHECK_PRINTF_PREFIX): check for printf format
nobu authored
638 thread_debug("create: (th: %p, thid: %p, intr: %p), stack size: %"PRIdSIZE"\n",
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
639 th, th->thread_id,
640 th->native_thread_data.interrupt_event, stack_size);
641 }
642 return 0;
643 }
644
645 static void
84f8da1 Koichi Sasada * thread.c (rb_thread_stop_timer_thread(), rb_thread_reset_timer_thread(...
ko1 authored
646 native_thread_join(HANDLE th)
647 {
6198f53 unak * thread_win32.c (native_thread_join): need to wait thread, of course.
unak authored
648 w32_wait_events(&th, 1, INFINITE, 0);
84f8da1 Koichi Sasada * thread.c (rb_thread_stop_timer_thread(), rb_thread_reset_timer_thread(...
ko1 authored
649 }
650
16612b3 Koichi Sasada * thread.c, vm_core.h: add manual priority support
ko1 authored
651 #if USE_NATIVE_THREAD_PRIORITY
652
84f8da1 Koichi Sasada * thread.c (rb_thread_stop_timer_thread(), rb_thread_reset_timer_thread(...
ko1 authored
653 static void
9c57438 Koichi Sasada * blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
ko1 authored
654 native_thread_apply_priority(rb_thread_t *th)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
655 {
656 int priority = th->priority;
657 if (th->priority > 0) {
658 priority = THREAD_PRIORITY_ABOVE_NORMAL;
659 }
660 else if (th->priority < 0) {
661 priority = THREAD_PRIORITY_BELOW_NORMAL;
662 }
663 else {
664 priority = THREAD_PRIORITY_NORMAL;
665 }
666
667 SetThreadPriority(th->thread_id, priority);
668 }
669
16612b3 Koichi Sasada * thread.c, vm_core.h: add manual priority support
ko1 authored
670 #endif /* USE_NATIVE_THREAD_PRIORITY */
671
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
672 static void
3453b2b Koichi Sasada * gc.h, vm_core.h: decl of rb_gc_save_machine_context()
ko1 authored
673 ubf_handle(void *ptr)
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
674 {
3453b2b Koichi Sasada * gc.h, vm_core.h: decl of rb_gc_save_machine_context()
ko1 authored
675 rb_thread_t *th = (rb_thread_t *)ptr;
ae317b5 Koichi Sasada * yarvcore.h, thread.c: fix to use pthread on cygwin.
ko1 authored
676 thread_debug("ubf_handle: %p\n", th);
25498d2 unak * thread_win32.c (ubf_handle): cancel blocking IO if it can (only
unak authored
677
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
678 w32_set_event(th->native_thread_data.interrupt_event);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
679 }
680
84f8da1 Koichi Sasada * thread.c (rb_thread_stop_timer_thread(), rb_thread_reset_timer_thread(...
ko1 authored
681 static HANDLE timer_thread_id = 0;
5732566 Nobuyoshi Nakada * thread.c (rb_thread_stop_timer_thread): terminates timer thread
nobu authored
682 static HANDLE timer_thread_lock;
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
683
2840fa6 Nobuyoshi Nakada * common.mk: inverted rules order.
nobu authored
684 static unsigned long _stdcall
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
685 timer_thread_func(void *dummy)
686 {
687 thread_debug("timer_thread\n");
5732566 Nobuyoshi Nakada * thread.c (rb_thread_stop_timer_thread): terminates timer thread
nobu authored
688 while (WaitForSingleObject(timer_thread_lock, WIN32_WAIT_TIMEOUT) ==
689 WAIT_TIMEOUT) {
6bbbf98 Nobuyoshi Nakada * thread.c (thread_initialize): NUM2INT() returns int.
nobu authored
690 timer_thread_function(dummy);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
691 }
692 thread_debug("timer killed\n");
693 return 0;
694 }
695
5732566 Nobuyoshi Nakada * thread.c (rb_thread_stop_timer_thread): terminates timer thread
nobu authored
696 static void
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
697 rb_thread_create_timer_thread(void)
698 {
84f8da1 Koichi Sasada * thread.c (rb_thread_stop_timer_thread(), rb_thread_reset_timer_thread(...
ko1 authored
699 if (timer_thread_id == 0) {
5732566 Nobuyoshi Nakada * thread.c (rb_thread_stop_timer_thread): terminates timer thread
nobu authored
700 if (!timer_thread_lock) {
701 timer_thread_lock = CreateEvent(0, TRUE, FALSE, 0);
702 }
a534e39 Nobuyoshi Nakada * thread_{pthread,win32}.c (rb_thread_create_timer_thread): needs more
nobu authored
703 timer_thread_id = w32_create_thread(1024 + (THREAD_DEBUG ? BUFSIZ : 0),
5732566 Nobuyoshi Nakada * thread.c (rb_thread_stop_timer_thread): terminates timer thread
nobu authored
704 timer_thread_func, 0);
a5abb1c Koichi Sasada * thread_win32.ci (w32_show_error_message): renamed to w32_error.
ko1 authored
705 w32_resume_thread(timer_thread_id);
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
706 }
707 }
708
641f43d Nobuyoshi Nakada * thread_pthread.c (thread_timer): checks working flags again.
nobu authored
709 static int
710 native_stop_timer_thread(void)
711 {
712 int stopped = --system_working <= 0;
713 if (stopped) {
9ee5e61 unak * thread_{pthread,win32}.c (native_stop_timer_thread): join the thread
unak authored
714 SetEvent(timer_thread_lock);
715 native_thread_join(timer_thread_id);
641f43d Nobuyoshi Nakada * thread_pthread.c (thread_timer): checks working flags again.
nobu authored
716 CloseHandle(timer_thread_lock);
717 timer_thread_lock = 0;
718 }
719 return stopped;
720 }
5732566 Nobuyoshi Nakada * thread.c (rb_thread_stop_timer_thread): terminates timer thread
nobu authored
721
9ee5e61 unak * thread_{pthread,win32}.c (native_stop_timer_thread): join the thread
unak authored
722 static void
723 native_reset_timer_thread(void)
724 {
725 if (timer_thread_id) {
726 CloseHandle(timer_thread_id);
727 timer_thread_id = 0;
728 }
729 }
730
767d708 Nobuyoshi Nakada * Makefile.in (ASFLAGS): needs INCFLAGS.
nobu authored
731 #ifdef RUBY_ALLOCA_CHKSTK
732 void
733 ruby_alloca_chkstk(size_t len, void *sp)
734 {
735 if (ruby_stack_length(NULL) * sizeof(VALUE) >= len) {
736 rb_thread_t *th = GET_THREAD();
737 if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW)) {
738 rb_thread_raised_set(th, RAISED_STACKOVERFLOW);
739 rb_exc_raise(sysstack_error);
740 }
741 }
742 }
743 #endif
a3e1b1c Koichi Sasada * Merge YARV
ko1 authored
744 #endif /* THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION */
Something went wrong with that request. Please try again.