#include "atomics.h"
#include "threading.h"

RT_DLLEXPORT void rtLockSpinlock(rt_spinlock *lock) {
    int prev;
    do {
        prev = rtAtomic32CASAcq(&lock->lock, 1, 0);
    } while (prev != 0);
}

RT_DLLEXPORT void rtUnlockSpinlock(rt_spinlock *lock) {
    rtAtomic32ExchangeRel(&lock->lock, 0);
}
