Use pthread API if the target platform doesn't support TLS attribute
This commit is contained in:
parent
4de514da38
commit
c41a7012ca
@ -90,13 +90,25 @@ struct rb_thread_sched {
|
|||||||
int wait_yield;
|
int wait_yield;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if __STDC_VERSION__ >= 201112
|
#ifndef RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED
|
||||||
#define RB_THREAD_LOCAL_SPECIFIER _Thread_local
|
# if __STDC_VERSION__ >= 201112
|
||||||
#elif defined(__GNUC__) && !defined(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)
|
# define RB_THREAD_LOCAL_SPECIFIER _Thread_local
|
||||||
|
# elif defined(__GNUC__)
|
||||||
/* note that ICC (linux) and Clang are covered by __GNUC__ */
|
/* note that ICC (linux) and Clang are covered by __GNUC__ */
|
||||||
#define RB_THREAD_LOCAL_SPECIFIER __thread
|
# define RB_THREAD_LOCAL_SPECIFIER __thread
|
||||||
#else
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RUBY_SYMBOL_EXPORT_BEGIN
|
||||||
|
#ifdef RB_THREAD_LOCAL_SPECIFIER
|
||||||
|
# ifdef __APPLE__
|
||||||
|
// on Darwin, TLS can not be accessed across .so
|
||||||
|
struct rb_execution_context_struct *rb_current_ec(void);
|
||||||
|
void rb_current_ec_set(struct rb_execution_context_struct *);
|
||||||
|
# else
|
||||||
|
RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
typedef pthread_key_t native_tls_key_t;
|
typedef pthread_key_t native_tls_key_t;
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
@ -113,19 +125,8 @@ native_tls_set(native_tls_key_t key, void *ptr)
|
|||||||
rb_bug("pthread_setspecific error");
|
rb_bug("pthread_setspecific error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
RUBY_SYMBOL_EXPORT_BEGIN
|
RUBY_EXTERN native_tls_key_t ruby_current_ec_key;
|
||||||
#ifdef RB_THREAD_LOCAL_SPECIFIER
|
|
||||||
#ifdef __APPLE__
|
|
||||||
// on Darwin, TLS can not be accessed across .so
|
|
||||||
struct rb_execution_context_struct *rb_current_ec(void);
|
|
||||||
void rb_current_ec_set(struct rb_execution_context_struct *);
|
|
||||||
#else
|
|
||||||
RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
RUBY_EXTERN native_tls_key_t ruby_current_ec_key;
|
|
||||||
#endif
|
#endif
|
||||||
RUBY_SYMBOL_EXPORT_END
|
RUBY_SYMBOL_EXPORT_END
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user