Inverted feature gate macros

This commit is contained in:
Joel Höner 2017-11-23 22:42:25 +01:00
parent 2dadf3f7a1
commit fb452e5b59
3 changed files with 20 additions and 34 deletions

View File

@ -10,7 +10,10 @@ project(Zydis VERSION 2.0)
# Features # Features
option(ZYDIS_FEATURE_DECODER option(ZYDIS_FEATURE_DECODER
"Enable instruction decoding and formtting functionality" "Enable instruction decoding functionality"
ON)
option(ZYDIS_FEATURE_FORMATTER
"Enable instruction formatting functionality"
ON) ON)
#option(ZYDIS_FEATURE_ENCODER #option(ZYDIS_FEATURE_ENCODER
# "Enable instruction encoding functionality" # "Enable instruction encoding functionality"
@ -80,24 +83,18 @@ if (NOT ZYDIS_FEATURE_ENCODER AND NOT ZYDIS_FEATURE_DECODER)
) )
endif () endif ()
if (ZYDIS_FEATURE_EVEX) if (NOT ZYDIS_FEATURE_DECODER)
target_compile_definitions("Zydis" PUBLIC "ZYDIS_ENABLE_FEATURE_EVEX") target_compile_definitions("Zydis" PUBLIC "ZYDIS_DISABLE_DECODER")
endif () endif ()
if (ZYDIS_FEATURE_MVEX) if (NOT ZYDIS_FEATURE_FORMATTER)
target_compile_definitions("Zydis" PUBLIC "ZYDIS_ENABLE_FEATURE_MVEX") target_compile_definitions("Zydis" PUBLIC "ZYDIS_DISABLE_FORMATTER")
endif () endif ()
if (ZYDIS_FEATURE_FLAGS) if (NOT ZYDIS_FEATURE_EVEX)
target_compile_definitions("Zydis" PUBLIC "ZYDIS_ENABLE_FEATURE_FLAGS") target_compile_definitions("Zydis" PUBLIC "ZYDIS_DISABLE_EVEX")
endif () endif ()
if (ZYDIS_FEATURE_CPUID) if (NOT ZYDIS_FEATURE_MVEX)
target_compile_definitions("Zydis" PUBLIC "ZYDIS_ENABLE_FEATURE_CPUID") target_compile_definitions("Zydis" PUBLIC "ZYDIS_DISABLE_MVEX")
endif () endif ()
if (ZYDIS_FEATURE_DECODER)
target_compile_definitions("Zydis" PUBLIC "ZYDIS_ENABLE_FEATURE_DECODER")
endif ()
#if (ZYDIS_FEATURE_ENCODER)
# target_compile_definitions("Zydis" PUBLIC "ZYDIS_ENABLE_FEATURE_ENCODER")
#endif ()
target_sources("Zydis" target_sources("Zydis"
PUBLIC PUBLIC
@ -134,16 +131,6 @@ if (ZYDIS_FEATURE_DECODER)
"src/FormatHelper.c") "src/FormatHelper.c")
endif () endif ()
#if (ZYDIS_FEATURE_ENCODER)
# target_sources("Zydis"
# PUBLIC
# "${CMAKE_CURRENT_LIST_DIR}/include/Zydis/Encoder.h"
# PRIVATE
# "src/EncoderData.h"
# "src/Encoder.c"
# "src/EncoderData.c")
#endif ()
if (BUILD_SHARED_LIBS AND WIN32) if (BUILD_SHARED_LIBS AND WIN32)
target_sources("Zydis" PRIVATE "src/VersionInfo.rc") target_sources("Zydis" PRIVATE "src/VersionInfo.rc")
endif () endif ()

View File

@ -470,10 +470,10 @@ static ZydisStatus ZydisDecodeVEX(ZydisDecoderContext* context,
} }
// Map 0 is only valid for some KNC instructions // Map 0 is only valid for some KNC instructions
#ifdef ZYDIS_ENABLE_FEATURE_MVEX #ifdef ZYDIS_DISABLE_MVEX
if (instruction->raw.vex.m_mmmm > 0x03)
#else
if ((instruction->raw.vex.m_mmmm == 0) || (instruction->raw.vex.m_mmmm > 0x03)) if ((instruction->raw.vex.m_mmmm == 0) || (instruction->raw.vex.m_mmmm > 0x03))
#else
if (instruction->raw.vex.m_mmmm > 0x03)
#endif #endif
{ {
// Invalid according to the intel documentation // Invalid according to the intel documentation

View File

@ -40,33 +40,32 @@ ZydisBool ZydisIsFeatureEnabled(ZydisFeature feature)
switch (feature) switch (feature)
{ {
case ZYDIS_FEATURE_EVEX: case ZYDIS_FEATURE_EVEX:
#ifdef ZYDIS_ENABLE_FEATURE_EVEX #ifndef ZYDIS_DISABLE_EVEX
return ZYDIS_TRUE; return ZYDIS_TRUE;
#else #else
return ZYDIS_FALSE; return ZYDIS_FALSE;
#endif #endif
case ZYDIS_FEATURE_MVEX: case ZYDIS_FEATURE_MVEX:
#ifdef ZYDIS_ENABLE_FEATURE_MVEX #ifndef ZYDIS_DISABLE_MVEX
return ZYDIS_TRUE; return ZYDIS_TRUE;
#else #else
return ZYDIS_FALSE; return ZYDIS_FALSE;
#endif #endif
case ZYDIS_FEATURE_FLAGS: case ZYDIS_FEATURE_FLAGS:
#ifdef ZYDIS_ENABLE_FEATURE_FLAGS #ifndef ZYDIS_DISABLE_FLAGS
return ZYDIS_TRUE; return ZYDIS_TRUE;
#else #else
return ZYDIS_FALSE; return ZYDIS_FALSE;
#endif #endif
case ZYDIS_FEATURE_CPUID: case ZYDIS_FEATURE_CPUID:
#ifdef ZYDIS_ENABLE_FEATURE_CPUID #ifndef ZYDIS_DISABLE_CPUID
return ZYDIS_TRUE; return ZYDIS_TRUE;
#else #else
return ZYDIS_FALSE; return ZYDIS_FALSE;
#endif #endif
default: default:
break;
}
return ZYDIS_FALSE; return ZYDIS_FALSE;
} }
}
/* ============================================================================================== */ /* ============================================================================================== */