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
25 #if defined(__GLIBC__) || defined(__FreeBSD__)
35 rb_nativethread_cond_t intr;
36 rb_nativethread_cond_t gvlq;
48 rb_nativethread_lock_t lock;
61 struct list_head waitq;
66 rb_nativethread_cond_t switch_cond;
67 rb_nativethread_cond_t switch_wait_cond;
73 #if __STDC_VERSION__ >= 201112
74 #define RB_THREAD_LOCAL_SPECIFIER _Thread_local
75 #elif defined(__GNUC__)
77 #define RB_THREAD_LOCAL_SPECIFIER __thread
80 typedef pthread_key_t native_tls_key_t;
83 native_tls_get(native_tls_key_t key)
85 void *ptr = pthread_getspecific(key);
86 if (UNLIKELY(ptr == NULL)) {
87 rb_bug(
"pthread_getspecific returns NULL");
93 native_tls_set(native_tls_key_t key,
void *ptr)
95 if (UNLIKELY(pthread_setspecific(key, ptr) != 0)) {
96 rb_bug(
"pthread_setspecific error");
101 RUBY_SYMBOL_EXPORT_BEGIN
102 #ifdef RB_THREAD_LOCAL_SPECIFIER
113 RUBY_SYMBOL_EXPORT_END
#define RUBY_EXTERN
Declaration of externally visible global variables.
void rb_bug(const char *fmt,...)
Interpreter panic switch.