Ruby: thread_win32.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

thread_win32.h
Go to the documentation of this file.
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
24 typedef struct rb_thread_cond_struct {
25 struct cond_event_entry *next;
26 struct cond_event_entry *prev;
27} rb_nativethread_cond_t;
28
29typedef struct native_thread_data_struct {
30 HANDLE interrupt_event;
31} native_thread_data_t;
32
33typedef struct rb_global_vm_lock_struct {
34 HANDLE lock;
35} rb_global_vm_lock_t;
36
37 typedef DWORD native_tls_key_t; // TLS index
38
39static inline void *
40native_tls_get(native_tls_key_t key)
41{
42 void *ptr = TlsGetValue(key);
43 if (UNLIKELY(ptr == NULL)) {
44 rb_bug("TlsGetValue() returns NULL");
45 }
46 return ptr;
47}
48
49static inline void
50native_tls_set(native_tls_key_t key, void *ptr)
51{
52 if (UNLIKELY(TlsSetValue(key, ptr) == 0)) {
53 rb_bug("TlsSetValue() error");
54 }
55}
56
57RUBY_SYMBOL_EXPORT_BEGIN
58 RUBY_EXTERN native_tls_key_t ruby_current_ec_key;
59RUBY_SYMBOL_EXPORT_END
60
61#endif /* RUBY_THREAD_WIN32_H */
ptr
struct RIMemo * ptr
Definition: debug.c:88
RUBY_EXTERN
#define RUBY_EXTERN
Definition: dllexport.h:36
UNLIKELY
#define UNLIKELY(x)
Definition: ffi_common.h:126
rb_bug
void rb_bug(const char *fmt,...)
Definition: error.c:768
key
key
Definition: openssl_missing.h:185
NULL
#define NULL
Definition: regenc.h:69
native_thread_data_struct
Definition: thread_pthread.h:20
native_thread_data_struct::interrupt_event
HANDLE interrupt_event
Definition: thread_win32.h:30
rb_global_vm_lock_struct
Definition: thread_pthread.h:45
rb_global_vm_lock_struct::lock
HANDLE lock
Definition: thread_win32.h:34
rb_thread_cond_struct
Definition: thread_win32.h:24
rb_thread_cond_struct::next
struct cond_event_entry * next
Definition: thread_win32.h:25
rb_thread_cond_struct::prev
struct cond_event_entry * prev
Definition: thread_win32.h:26
rb_nativethread_cond_t
struct rb_thread_cond_struct rb_nativethread_cond_t
native_tls_key_t
DWORD native_tls_key_t
Definition: thread_win32.h:37
ruby_current_ec_key
native_tls_key_t ruby_current_ec_key
Definition: vm.c:400
native_thread_data_t
struct native_thread_data_struct native_thread_data_t
TryEnterCriticalSection
WINBASEAPI BOOL WINAPI TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection)
rb_global_vm_lock_t
struct rb_global_vm_lock_struct rb_global_vm_lock_t
DWORD
IUnknown DWORD
Definition: win32ole.c:33