summaryrefslogtreecommitdiff
path: root/vm_core.h
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-18 01:37:41 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-18 01:37:41 +0000
commit9a8b75a77eec9611c8d137dde1fbdf33426bdf52 (patch)
tree53466deb0f58d0b4684338149fe9e900ac5130ac /vm_core.h
parent2b894084eff60a010b0f606c5c9731094358b041 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h23
1 files changed, 15 insertions, 8 deletions
diff --git a/vm_core.h b/vm_core.h
index 7a89dd0..e0fc3cb 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -1743,14 +1743,21 @@ rb_current_vm(void)
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"