summaryrefslogtreecommitdiff
path: root/src/include/smp_sync.h
blob: 92784b83bd2d56c879e9adb3bbb5e6b6d65835b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifndef SMP_SYNC_INCLUDED
#define SMP_SYNC_INCLUDED

static inline void lock(uint8_t *lock) {
  asm("mov al, 1\n"
      "spinlock:\n"
      "lock xchgb [%0], al\n"
      "test al, al\n"
      "jnz spinlock\n"
      ::"r"(lock):"al");
} 

static inline void unlock(uint8_t *lock) {
  asm("lock andb [%0], 0"::"r"(lock));
}

#endif