diff --git a/include/Zydis/Defines.h b/include/Zydis/Defines.h index 5394549..f1c166e 100644 --- a/include/Zydis/Defines.h +++ b/include/Zydis/Defines.h @@ -114,11 +114,22 @@ #endif /* ============================================================================================== */ -/* Debugging macros */ +/* Debugging and optimization macros */ /* ============================================================================================== */ #define ZYDIS_ASSERT(condition) assert(condition) -#define ZYDIS_UNREACHABLE assert(0) + +#if defined(ZYDIS_MSVC) && defined(ZYDIS_RELEASE) +# define ZYDIS_UNREACHABLE +#elif defined(ZYDIS_GNUC) && defined(ZYDIS_RELEASE) +# if __has_builtin(__builtin_unreachable) +# define ZYDIS_UNREACHABLE __builtin_unreachable() +# else +# define ZYDIS_UNREACHABLE +# endif +#else +# define ZYDIS_UNREACHABLE assert(0) +#endif /* ============================================================================================== */ /* Utils */ diff --git a/src/InstructionTable.c b/src/InstructionTable.c index d41554d..f93825f 100644 --- a/src/InstructionTable.c +++ b/src/InstructionTable.c @@ -296,7 +296,7 @@ ZydisBool ZydisInstructionTableGetDefinition(const ZydisInstructionTableNode* no break; default: ZYDIS_UNREACHABLE; - return ZYDIS_FALSE; + //return ZYDIS_FALSE; } return ZYDIS_TRUE; }