mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
Revert "spinlock: insert return address into spinlock"
This reverts commit 3420125d6d.
This commit is contained in:
@@ -4,22 +4,19 @@
|
||||
#include <stdbool.h>
|
||||
#include <kernel/interrupt.h>
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user