diff --git a/lib/libimhex/include/hex/helpers/intrinsics.hpp b/lib/libimhex/include/hex/helpers/intrinsics.hpp new file mode 100644 index 000000000..7a2e10fe5 --- /dev/null +++ b/lib/libimhex/include/hex/helpers/intrinsics.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace hex { + + [[noreturn]] void unreachable() { + __builtin_unreachable(); + } + +} \ No newline at end of file diff --git a/lib/libimhex/include/hex/helpers/utils.hpp b/lib/libimhex/include/hex/helpers/utils.hpp index 282d9cf7d..4f13cd859 100644 --- a/lib/libimhex/include/hex/helpers/utils.hpp +++ b/lib/libimhex/include/hex/helpers/utils.hpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -128,7 +129,7 @@ namespace hex { swapped = (u128(__builtin_bswap64(unswapped & 0xFFFF'FFFF'FFFF'FFFF)) << 64) | __builtin_bswap64(u128(unswapped) >> 64); break; default: - __builtin_unreachable(); + hex::unreachable(); } T result; @@ -168,7 +169,7 @@ namespace hex { swapped = (u128(__builtin_bswap64(unswapped & 0xFFFF'FFFF'FFFF'FFFF)) << 64) | __builtin_bswap64(u128(unswapped) >> 64); break; default: - __builtin_unreachable(); + hex::unreachable(); } T result = 0; diff --git a/lib/libimhex/include/hex/pattern_language/parser.hpp b/lib/libimhex/include/hex/pattern_language/parser.hpp index 98238df06..16119bd90 100644 --- a/lib/libimhex/include/hex/pattern_language/parser.hpp +++ b/lib/libimhex/include/hex/pattern_language/parser.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -189,7 +190,7 @@ namespace hex::pl { else if constexpr (S == Not) return false; else - __builtin_unreachable(); + hex::unreachable(); } template @@ -220,7 +221,7 @@ namespace hex::pl { partReset(); return false; } else - __builtin_unreachable(); + hex::unreachable(); } template @@ -235,7 +236,7 @@ namespace hex::pl { else if constexpr (S == Not) return true; else - __builtin_unreachable(); + hex::unreachable(); } template @@ -245,7 +246,7 @@ namespace hex::pl { else if constexpr (S == Not) return sequenceImpl(type, value) && oneOfImpl(args...); else - __builtin_unreachable(); + hex::unreachable(); } template diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index ba2835e0e..ab16f5c02 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -72,7 +73,7 @@ namespace hex::fs { result = NFD::PickFolder(outPath, defaultPath.c_str()); break; default: - __builtin_unreachable(); + hex::unreachable(); } if (result == NFD_OKAY) { @@ -174,7 +175,7 @@ namespace hex::fs { }); break; default: - __builtin_unreachable(); + hex::unreachable(); } #elif defined(OS_MACOS) // Get path to special directories @@ -219,7 +220,7 @@ namespace hex::fs { result.push_back((applicationSupportDir / "logs").string()); break; default: - __builtin_unreachable(); + hex::unreachable(); } #else std::vector configDirs = xdg::ConfigDirs(); @@ -276,7 +277,7 @@ namespace hex::fs { std::transform(dataDirs.begin(), dataDirs.end(), std::back_inserter(result), [](auto p) { return (p / "logs").string(); }); break; default: - __builtin_unreachable(); + hex::unreachable(); } #endif