forked from M-Labs/nac3
1
0
Fork 0
nac3/nac3core/irrt/irrt_utils.hpp

37 lines
904 B
C++
Raw Normal View History

2024-07-10 11:56:31 +08:00
#pragma once
#include "irrt_typedefs.hpp"
namespace {
template <typename T>
T max(T a, T b) {
return a > b ? a : b;
}
template <typename T>
T min(T a, T b) {
return a > b ? b : a;
}
2024-07-10 14:05:08 +08:00
template <typename T>
bool arrays_match(int len, T *as, T *bs) {
for (int i = 0; i < len; i++) {
if (as[i] != bs[i]) return false;
2024-07-10 11:56:31 +08:00
}
2024-07-10 14:05:08 +08:00
return true;
}
void irrt_panic() {
// Crash the program for now.
// TODO: Don't crash the program
// ... or at least produce a good message when doing testing IRRT
uint8_t* death = nullptr;
*death = 0; // TODO: address 0 on hardware might be writable?
}
2024-07-10 17:05:01 +08:00
// TODO: Make this a macro and allow it to be toggled on/off (e.g., debug vs release)
2024-07-10 14:05:08 +08:00
void irrt_assert(bool condition) {
if (!condition) irrt_panic();
2024-07-10 11:56:31 +08:00
}
}