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
23 struct ccan_list_node ubf;
24 struct ccan_list_node readyq;
31 rb_nativethread_id_t thread_id;
33#ifdef RB_THREAD_T_HAS_NATIVE_ID
40#if defined(__GLIBC__) || defined(__FreeBSD__)
50 rb_nativethread_cond_t intr;
51 rb_nativethread_cond_t readyq;
69 rb_nativethread_lock_t lock;
82 struct ccan_list_head readyq;
87 rb_nativethread_cond_t switch_cond;
88 rb_nativethread_cond_t switch_wait_cond;
93#ifndef RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED
94# if __STDC_VERSION__ >= 201112
95# define RB_THREAD_LOCAL_SPECIFIER _Thread_local
96# elif defined(__GNUC__)
98# define RB_THREAD_LOCAL_SPECIFIER __thread
102RUBY_SYMBOL_EXPORT_BEGIN
103#ifdef RB_THREAD_LOCAL_SPECIFIER
112typedef pthread_key_t native_tls_key_t;
115native_tls_get(native_tls_key_t key)
118 return pthread_getspecific(key);
122native_tls_set(native_tls_key_t key,
void *ptr)
124 if (UNLIKELY(pthread_setspecific(key, ptr) != 0)) {
125 rb_bug(
"pthread_setspecific error");
131RUBY_SYMBOL_EXPORT_END
#define RUBY_EXTERN
Declaration of externally visible global variables.
void rb_bug(const char *fmt,...)
Interpreter panic switch.