File syn_spinlock.h¶
File List > src > syntropic > util > syn_spinlock.h
Go to the documentation of this file
#ifndef SYN_SPINLOCK_H
#define SYN_SPINLOCK_H
#if __has_include("syn_config.h")
#include "syn_config.h"
#endif
#if defined(SYN_USE_MULTICORE) && SYN_USE_MULTICORE
#include "../port/syn_port_spinlock.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ── Well-known spinlock IDs ───────────────────────────────────────────── */
#ifndef SYN_SPINLOCK_UART
#define SYN_SPINLOCK_UART 0
#endif
#ifndef SYN_SPINLOCK_FLASH
#define SYN_SPINLOCK_FLASH 1
#endif
#ifndef SYN_SPINLOCK_USER0
#define SYN_SPINLOCK_USER0 2
#endif
#ifndef SYN_SPINLOCK_USER1
#define SYN_SPINLOCK_USER1 3
#endif
/* ── Scoped lock macro ─────────────────────────────────────────────────── */
#define SYN_SPINLOCK_GUARD(id) \
for (int _sl_once = (syn_port_spinlock_acquire(id), 0); !_sl_once; \
_sl_once = 1, syn_port_spinlock_release(id))
#ifdef __cplusplus
}
#endif
#endif /* SYN_USE_MULTICORE */
#endif /* SYN_SPINLOCK_H */