42 lines
873 B
C
42 lines
873 B
C
/*
|
|
* Copyright (c) 2015 Travis Geiselbrecht
|
|
*
|
|
* Use of this source code is governed by a MIT-style
|
|
* license that can be found in the LICENSE file or at
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
#pragma once
|
|
|
|
#include <arch/ops.h>
|
|
#include <arch/x86.h>
|
|
#include <stdbool.h>
|
|
|
|
#define SPIN_LOCK_INITIAL_VALUE (0)
|
|
|
|
typedef unsigned long spin_lock_t;
|
|
|
|
/* simple implementation of spinlocks for no smp support */
|
|
static inline void arch_spin_lock_init(spin_lock_t *lock) {
|
|
*lock = SPIN_LOCK_INITIAL_VALUE;
|
|
}
|
|
|
|
static inline bool arch_spin_lock_held(spin_lock_t *lock) {
|
|
return *lock != 0;
|
|
}
|
|
|
|
static inline void arch_spin_lock(spin_lock_t *lock) {
|
|
*lock = 1;
|
|
}
|
|
|
|
static inline int arch_spin_trylock(spin_lock_t *lock) {
|
|
return 0;
|
|
}
|
|
|
|
static inline void arch_spin_unlock(spin_lock_t *lock) {
|
|
*lock = 0;
|
|
}
|
|
|
|
#define ARCH_DEFAULT_SPIN_LOCK_FLAG_INTERRUPTS 0
|
|
|
|
|