#pragma once

#ifndef __x86_64__
#include "hal/interrupts.h"

struct InterruptLock {
    bool was_on;

    InterruptLock() : was_on(EnableInterrupts(false)) {}

    ~InterruptLock() { EnableInterrupts(was_on); }
};
#else  // __x86_64__
#include <mutex>

struct InterruptLock {
    static std::recursive_mutex m;
    InterruptLock() { m.lock(); }
    ~InterruptLock() { m.unlock(); }
};
#endif  // __x86_64__
