1#ifndef RUBY_THREAD_PTHREAD_H
2#define RUBY_THREAD_PTHREAD_H
13#ifdef HAVE_PTHREAD_NP_H
14#include <pthread_np.h>
17#define RB_NATIVETHREAD_LOCK_INIT PTHREAD_MUTEX_INITIALIZER
18#define RB_NATIVETHREAD_COND_INIT PTHREAD_COND_INITIALIZER
21#if defined(__arm64__) || defined(__aarch64__) || defined(__powerpc64__)
22# define RB_THREAD_CURRENT_EC_NOINLINE
27 enum thread_sched_waiting_flag {
28 thread_sched_waiting_none = 0x00,
29 thread_sched_waiting_timeout = 0x01,
30 thread_sched_waiting_io_read = 0x02,
31 thread_sched_waiting_io_write = 0x08,
32 thread_sched_waiting_io_force = 0x40,
37#ifdef MY_RUBY_BUILD_MAY_TIME_TRAVEL
42 uint32_t event_serial;
48 struct ccan_list_node node;
54 struct ccan_list_node ubf;
58 struct ccan_list_node readyq;
65 struct ccan_list_node timeslice_threads;
69 struct ccan_list_node running_threads;
72 struct ccan_list_node zombie_threads;
76 uint32_t event_serial;
81 size_t context_stack_size;
89 rb_nativethread_id_t thread_id;
91#ifdef RB_THREAD_T_HAS_NATIVE_ID
98#if defined(__GLIBC__) || defined(__FreeBSD__)
108 rb_nativethread_cond_t intr;
109 rb_nativethread_cond_t readyq;
112#ifdef USE_SIGALTSTACK
119 size_t machine_stack_maxsize;
129 rb_nativethread_lock_t lock_;
138 int runnable_hot_th_waiting;
140 bool is_running_timeslice;
141 bool enable_mn_threads;
143 struct ccan_list_head readyq;
146 struct ccan_list_node grq_node;
149#ifdef RB_THREAD_LOCAL_SPECIFIER
152 # ifdef RB_THREAD_CURRENT_EC_NOINLINE
159 #define RUBY_NT_SERIAL 1
162typedef pthread_key_t native_tls_key_t;
165native_tls_get(native_tls_key_t key)
168 return pthread_getspecific(key);
172native_tls_set(native_tls_key_t key,
void *ptr)
174 if (UNLIKELY(pthread_setspecific(key, ptr) != 0)) {
175 rb_bug(
"pthread_setspecific error");
std::atomic< unsigned > rb_atomic_t
Type that is eligible for atomic operations.
#define RUBY_EXTERN
Declaration of externally visible global variables.
void rb_unblock_function_t(void *)
This is the type of UBFs.