diff options
author | Koichi Sasada <ko1@atdot.net> | 2023-03-31 03:52:58 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2023-03-31 11:28:18 +0900 |
commit | 2093e4c2db1e19991e601bf5191eddb4652de35d (patch) | |
tree | 486cb12704655596fdec0227a37450da23d8b5f4 /thread_pthread.h | |
parent | 83667008b925c32b3ab70fb6ec70f7398e960d1e (diff) | |
download | ruby-2093e4c2db1e19991e601bf5191eddb4652de35d.tar.gz |
`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`.
Diffstat (limited to 'thread_pthread.h')
-rw-r--r-- | thread_pthread.h | 20 |
1 files changed, 12 insertions, 8 deletions
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; |