ruby-changes:53559
From: normal <ko1@a...>
Date: Sun, 18 Nov 2018 10:37:47 +0900 (JST)
Subject: [ruby-changes:53559] normal:r65775 (trunk): vm_core.h (rb_thread_set_current*): convert to static inline
normal 2018-11-18 10:37:41 +0900 (Sun, 18 Nov 2018) New Revision: 65775 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65775 Log: vm_core.h (rb_thread_set_current*): convert to static inline We already use "static inline" heavily and there should be no penalty for modern compilers; this adds type-checking, too. This will make future changes easier-to-review. Modified files: trunk/vm_core.h Index: vm_core.h =================================================================== --- vm_core.h (revision 65774) +++ vm_core.h (revision 65775) @@ -1743,14 +1743,21 @@ rb_current_vm(void) https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1743 return ruby_current_vm_ptr; } -#define rb_thread_set_current_raw(th) (void)(ruby_current_execution_context_ptr = (th)->ec) -#define rb_thread_set_current(th) do { \ - if ((th)->vm->running_thread != (th)) { \ - (th)->running_time_us = 0; \ - } \ - rb_thread_set_current_raw(th); \ - (th)->vm->running_thread = (th); \ -} while (0) +static inline void +rb_thread_set_current_raw(const rb_thread_t *th) +{ + ruby_current_execution_context_ptr = th->ec; +} + +static inline void +rb_thread_set_current(rb_thread_t *th) +{ + if (th->vm->running_thread != th) { + th->running_time_us = 0; + } + rb_thread_set_current_raw(th); + th->vm->running_thread = th; +} #else #error "unsupported thread model" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/