summaryrefslogtreecommitdiff
path: root/thread_pthread.ci
diff options
context:
space:
mode:
Diffstat (limited to 'thread_pthread.ci')
-rw-r--r--thread_pthread.ci22
1 files changed, 20 insertions, 2 deletions
diff --git a/thread_pthread.ci b/thread_pthread.ci
index d624e98487..b8b609145e 100644
--- a/thread_pthread.ci
+++ b/thread_pthread.ci
@@ -72,16 +72,34 @@ static void remove_signal_thread_list(rb_thread_t *th);
static rb_thread_lock_t signal_thread_list_lock;
+static pthread_key_t ruby_native_thread_key;
+
static void
null_func()
{
/* null */
}
+static rb_thread_t *
+ruby_thread_from_native(void)
+{
+ return pthread_getspecific(ruby_native_thread_key);
+}
+
+static int
+ruby_thread_set_native(rb_thread_t *th)
+{
+ return pthread_setspecific(ruby_native_thread_key, th) == 0;
+}
+
static void
-Init_native_thread()
+Init_native_thread(void)
{
- GET_THREAD()->thread_id = pthread_self();
+ rb_thread_t *th = GET_THREAD();
+
+ pthread_key_create(&ruby_native_thread_key, NULL);
+ th->thread_id = pthread_self();
+ ruby_thread_set_native(th);
native_mutex_initialize(&signal_thread_list_lock);
posix_signal(SIGVTALRM, null_func);
}