From e1fcac33ded8c00cefc909148a2f70177e736e37 Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 29 Dec 2025 08:34:11 -0300 Subject: [PATCH] Revert "spinlock: insert return address into spinlock" This reverts commit 3420125d6d8d5780ee13e684b5d6032fbbaaed8f. --- kernel-src/include/spinlock.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/kernel-src/include/spinlock.h b/kernel-src/include/spinlock.h index e01caee4..3420f50d 100644 --- a/kernel-src/include/spinlock.h +++ b/kernel-src/include/spinlock.h @@ -4,22 +4,19 @@ #include #include -typedef uintptr_t spinlock_t; +typedef int spinlock_t; #define SPINLOCK_INIT_VALUE 0 #define SPINLOCK_INIT(x) x = SPINLOCK_INIT_VALUE #define SPINLOCK_DEFINE(x) spinlock_t x = SPINLOCK_INIT_VALUE static inline bool spinlock_try(spinlock_t *lock) { - spinlock_t expected = SPINLOCK_INIT_VALUE; - return __atomic_compare_exchange_n(lock, &expected, (uintptr_t)__builtin_return_address(0), false, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED); + return __sync_bool_compare_and_swap(lock, 0, 1); } static inline void spinlock_acquire(spinlock_t *lock) { - spinlock_t expected = SPINLOCK_INIT_VALUE; - while (!__atomic_compare_exchange_n(lock, &expected, (uintptr_t)__builtin_return_address(0), false, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { + while (!__sync_bool_compare_and_swap(lock, 0, 1)) { while (*lock) asm volatile ("pause" : : : "memory"); - expected = SPINLOCK_INIT_VALUE; } } @@ -30,7 +27,7 @@ static inline bool spinlock_acquire_irq_clear(spinlock_t *lock) { } static inline void spinlock_release(spinlock_t *lock) { - __atomic_store_n(lock, 0, __ATOMIC_RELEASE); + *lock = 0; } static inline void spinlock_release_irq_restore(spinlock_t *lock, bool irqstate) {