From 91ad310687ae37339db3dd5d51d47db87f2cf749 Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Fri, 18 Feb 2022 17:23:40 +0000 Subject: use the appropriate semantics for atomics --- kc/core/cpu/irq.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kc/core/cpu/irq.c b/kc/core/cpu/irq.c index 639aca3..e4dd29f 100644 --- a/kc/core/cpu/irq.c +++ b/kc/core/cpu/irq.c @@ -2,21 +2,22 @@ #include -static atomic_uint_fast64_t irq_lock_count = 0; +static volatile atomic_uint_fast64_t irq_lock_count = 0; void irq_lock(void) { + irq_lock_count++; __asm__ volatile ("cli;"); } void irq_unlock(void) { - if (irq_lock_count >= 1) + if (atomic_load(&irq_lock_count) >= 1) { irq_lock_count--; } - if (irq_lock_count == 0) + if (atomic_load(&irq_lock_count) == 0) { __asm__ volatile ("sti;"); } -- cgit v1.3.1-1-g115d