From 1f71b9576db536af84155363e14fc49e92de2eef Mon Sep 17 00:00:00 2001 From: Brett Weiland Date: Sun, 29 Aug 2021 02:52:48 -0500 Subject: backup 8.29.21 --- src/include/smp_sync.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/include/smp_sync.h (limited to 'src/include/smp_sync.h') diff --git a/src/include/smp_sync.h b/src/include/smp_sync.h new file mode 100644 index 0000000..92784b8 --- /dev/null +++ b/src/include/smp_sync.h @@ -0,0 +1,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 -- cgit v1.2.3