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
47 struct ccan_list_node node;
53 struct ccan_list_node ubf;
57 struct ccan_list_node readyq;
61 struct ccan_list_node timeslice_threads;
65 struct ccan_list_node running_threads;
68 struct ccan_list_node zombie_threads;
83 rb_nativethread_id_t thread_id;
85#ifdef RB_THREAD_T_HAS_NATIVE_ID
92#if defined(__GLIBC__) || defined(__FreeBSD__)
102 rb_nativethread_cond_t intr;
103 rb_nativethread_cond_t readyq;
106#ifdef USE_SIGALTSTACK
113 size_t machine_stack_maxsize;
123 rb_nativethread_lock_t lock_;
129 bool is_running_timeslice;
130 bool enable_mn_threads;
132 struct ccan_list_head readyq;
135 struct ccan_list_node grq_node;
138#ifdef RB_THREAD_LOCAL_SPECIFIER
141 # ifdef RB_THREAD_CURRENT_EC_NOINLINE
148 #define RUBY_NT_SERIAL 1
151typedef pthread_key_t native_tls_key_t;
154native_tls_get(native_tls_key_t key)
157 return pthread_getspecific(key);
161native_tls_set(native_tls_key_t key,
void *ptr)
163 if (UNLIKELY(pthread_setspecific(key, ptr) != 0)) {
164 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.