vmap: Use {map,unmap}_segment() helpers
[akaros.git] / kern / arch / riscv / atomic.h
index b3cbfa9..e57815d 100644 (file)
@@ -1,5 +1,4 @@
-#ifndef ROS_KERN_ARCH_ATOMIC_H
-#define ROS_KERN_ARCH_ATOMIC_H
+#pragma once
 
 #include <ros/common.h>
 #include <arch/arch.h>
@@ -129,9 +128,9 @@ static inline bool spin_locked(spinlock_t* lock)
        return lock->rlock;
 }
 
-static inline uint32_t spin_trylock(spinlock_t* lock)
+static inline bool __spin_trylock(spinlock_t *lock)
 {
-       return __sync_fetch_and_or(&lock->rlock, 1);
+       return !__sync_fetch_and_or(&lock->rlock, 1);
 }
 
 static inline void __spin_lock(spinlock_t *lock)
@@ -140,7 +139,7 @@ static inline void __spin_lock(spinlock_t *lock)
        {
                while (lock->rlock)
                        ;
-       } while (spin_trylock(lock));
+       } while (!__spin_trylock(lock));
        mb();
 }
 
@@ -154,9 +153,3 @@ static inline void __spinlock_init(spinlock_t *lock)
 {
        lock->rlock = 0;
 }
-
-static inline void spinlock_debug(spinlock_t* lock)
-{
-}
-
-#endif /* ROS_KERN_ARCH_ATOMIC_H */