riscv-os/include/atomic_helpers.h
2025-04-26 22:43:28 +12:00

17 lines
1 KiB
C

#ifndef ATOMIC_HELPERS_H
#define ATOMIC_HELPERS_H
#define csrr(reg) \
({ \
long temp; \
__asm__ volatile("csrr %0, " #reg : "=r"(temp)); \
temp; \
})
#define csrw(reg, val) \
({ \
long temp = (long)val; \
__asm__ volatile("csrw " #reg ", %0" ::"r"(temp)); \
})
#endif