From f2ca66fefc809f3a6f92864d3e7d3f1769f7bfbd Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 27 Oct 2021 11:44:29 +0900 Subject: [PATCH] Add RB_VM_LOCKING macro which delimits the variable scope --- vm_sync.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vm_sync.h b/vm_sync.h index e8243d6f50..5dbd425681 100644 --- a/vm_sync.h +++ b/vm_sync.h @@ -119,10 +119,16 @@ rb_vm_lock_leave_cr(struct rb_ractor_struct *cr, unsigned int *levp, const char #define RB_VM_LOCK_ENTER() { unsigned int _lev; RB_VM_LOCK_ENTER_LEV(&_lev); #define RB_VM_LOCK_LEAVE() RB_VM_LOCK_LEAVE_LEV(&_lev); } +#define RB_VM_LOCKING() \ + for (unsigned int vm_locking_level, vm_locking_do = (RB_VM_LOCK_ENTER_LEV(&vm_locking_level), 1); \ + vm_locking_do; RB_VM_LOCK_LEAVE_LEV(&vm_locking_level), vm_locking_do = 0) #define RB_VM_LOCK_ENTER_LEV_NB(levp) rb_vm_lock_enter_nb(levp, __FILE__, __LINE__) #define RB_VM_LOCK_ENTER_NO_BARRIER() { unsigned int _lev; RB_VM_LOCK_ENTER_LEV_NB(&_lev); #define RB_VM_LOCK_LEAVE_NO_BARRIER() RB_VM_LOCK_LEAVE_LEV(&_lev); } +#define RB_VM_LOCKING_NO_BARRIER() \ + for (unsigned int vm_locking_level, vm_locking_do = (RB_VM_LOCK_ENTER_LEV_NB(&vm_locking_level), 1); \ + vm_locking_do; RB_VM_LOCK_LEAVE_LEV(&vm_locking_level), vm_locking_do = 0) #if RUBY_DEBUG > 0 void RUBY_ASSERT_vm_locking(void);