Ruby: thread_win32.h Source File

Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)

thread_win32.h
1#ifndef RUBY_THREAD_WIN32_H
2#define RUBY_THREAD_WIN32_H
3/**********************************************************************
4
5 thread_win32.h -
6
7 $Author$
8
9 Copyright (C) 2004-2007 Koichi Sasada
10
11**********************************************************************/
12
13/* interface */
14
15# ifdef __CYGWIN__
16# undef _WIN32
17# endif
18
19#define USE_VM_CLOCK 1
20
21WINBASEAPI BOOL WINAPI
22TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
23
24struct rb_native_thread {
25 HANDLE thread_id;
26 HANDLE interrupt_event;
27};
28
29struct rb_thread_sched_item {
30 void *vm_stack;
31};
32
33struct rb_thread_sched {
34 HANDLE lock;
35};
36
37typedef DWORD native_tls_key_t; // TLS index
38
39static inline void *
40native_tls_get(native_tls_key_t key)
41{
42 // return value should be checked by caller.
43 return TlsGetValue(key);
44}
45
46static inline void
47native_tls_set(native_tls_key_t key, void *ptr)
48{
49 if (UNLIKELY(TlsSetValue(key, ptr) == 0)) {
50 rb_bug("TlsSetValue() error");
51 }
52}
53
54RUBY_SYMBOL_EXPORT_BEGIN
55 RUBY_EXTERN native_tls_key_t ruby_current_ec_key;
56RUBY_SYMBOL_EXPORT_END
57
58#endif /* RUBY_THREAD_WIN32_H */
RUBY_EXTERN
#define RUBY_EXTERN
Declaration of externally visible global variables.
Definition dllexport.h:45
rb_native_thread
Definition thread_none.h:11
rb_thread_sched_item
Definition thread_none.h:15
rb_thread_sched
Definition thread_none.h:16