From 2093e4c2db1e19991e601bf5191eddb4652de35d Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 31 Mar 2023 03:52:58 +0900 Subject: `nt->serial` for `RUBY_DEBUG_LOG` Show native thread's serial on `RUBY_DEBUG_LOG`. `nt->serial` is also stored into `ruby_nt_serial` if the compiler supports `RB_THREAD_LOCAL_SPECIFIER`. --- thread_pthread.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'thread_pthread.h') diff --git a/thread_pthread.h b/thread_pthread.h index 0f8e4d6096..40d7a13aa0 100644 --- a/thread_pthread.h +++ b/thread_pthread.h @@ -26,7 +26,7 @@ struct rb_thread_sched_item { }; struct rb_native_thread { - int id; + rb_atomic_t serial; rb_nativethread_id_t thread_id; @@ -101,13 +101,17 @@ struct rb_thread_sched { 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 + # 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; + + // for RUBY_DEBUG_LOG() + RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER rb_atomic_t ruby_nt_serial; + #define RUBY_NT_SERIAL 1 + # endif #else typedef pthread_key_t native_tls_key_t; -- cgit v1.2.1