synth/arm/lock.h

23 lines
439 B
C
Raw Permalink Normal View History

2022-05-17 03:56:25 +00:00
#pragma once
#ifndef __x86_64__
2022-05-17 03:56:25 +00:00
#include "aum1_cm1.h"
struct InterruptLock {
2022-06-19 07:46:30 +00:00
uint32_t old_primask;
2022-05-17 03:56:25 +00:00
2022-06-19 07:46:30 +00:00
InterruptLock() : old_primask(__get_PRIMASK()) { __disable_irq(); }
2022-05-17 03:56:25 +00:00
~InterruptLock() {
2022-06-19 07:46:30 +00:00
__set_PRIMASK(old_primask);
2022-05-17 03:56:25 +00:00
}
};
#else // __x86_64__
#include <mutex>
struct InterruptLock {
static std::recursive_mutex m;
InterruptLock() { m.lock(); }
~InterruptLock() { m.unlock(); }
};
#endif // __x86_64__