28 lines
484 B
C
28 lines
484 B
C
|
|
#include <socks/machine/hwlock.h>
|
||
|
|
#include <socks/compiler.h>
|
||
|
|
|
||
|
|
void ml_hwlock_lock(ml_hwlock_t *lck)
|
||
|
|
{
|
||
|
|
volatile int q = 0;
|
||
|
|
while (!__sync_bool_compare_and_swap(lck, 0, 1)) {
|
||
|
|
q++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void ml_hwlock_unlock(ml_hwlock_t *lck)
|
||
|
|
{
|
||
|
|
__sync_lock_release(lck);
|
||
|
|
}
|
||
|
|
|
||
|
|
void ml_hwlock_lock_irqsave(ml_hwlock_t *lck, unsigned long *flags)
|
||
|
|
{
|
||
|
|
(void)flags;
|
||
|
|
ml_hwlock_lock(lck);
|
||
|
|
}
|
||
|
|
|
||
|
|
void ml_hwlock_unlock_irqrestore(ml_hwlock_t *lck, unsigned long flags)
|
||
|
|
{
|
||
|
|
(void)flags;
|
||
|
|
ml_hwlock_unlock(lck);
|
||
|
|
}
|