Skip to content

Commit

Permalink
Add CAPSTONE_AARCH64_COMPAT_HEADER toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Apr 20, 2024
1 parent 1fe84c6 commit 3db02b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ set(HEADERS_ENGINE

set(HEADERS_COMMON
include/capstone/aarch64.h
include/capstone/arm64.h
include/capstone/arm.h
include/capstone/capstone.h
include/capstone/cs_operand.h
Expand Down
21 changes: 19 additions & 2 deletions include/capstone/capstone.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ extern "C" {
#define CS_VERSION_MINOR CS_API_MINOR
#define CS_VERSION_EXTRA 0

#ifndef CAPSTONE_AARCH64_COMPAT_HEADER
/// Macro for meta programming.
/// Meant for projects using Capstone and need to support multiple
/// versions of it.
Expand Down Expand Up @@ -119,6 +120,7 @@ extern "C" {
#define CS_aarch64_shifter() aarch64_shifter
#define CS_aarch64_vas() AArch64Layout_VectorLayout
#endif
#endif // CAPSTONE_AARCH64_COMPAT_HEADER

/// Macro to create combined version which can be compared to
/// result of cs_version() API.
Expand All @@ -133,7 +135,11 @@ typedef size_t csh;
/// Architecture type
typedef enum cs_arch {
CS_ARCH_ARM = 0, ///< ARM architecture (including Thumb, Thumb-2)
CS_ARCH_AARCH64, ///< AArch64
#ifdef CAPSTONE_AARCH64_COMPAT_HEADER
CS_ARCH_ARM64 = 1, ///< ARM64
#else
CS_ARCH_AARCH64 = 1, ///< AArch64
#endif
CS_ARCH_MIPS, ///< Mips architecture
CS_ARCH_X86, ///< X86 architecture (including x86 & x86-64)
CS_ARCH_PPC, ///< PowerPC architecture
Expand Down Expand Up @@ -354,7 +360,11 @@ typedef struct cs_opt_skipdata {


#include "arm.h"
#ifdef CAPSTONE_AARCH64_COMPAT_HEADER
#include "arm64.h"
#else
#include "aarch64.h"
#endif
#include "m68k.h"
#include "mips.h"
#include "ppc.h"
Expand Down Expand Up @@ -399,7 +409,11 @@ typedef struct cs_detail {
/// Architecture-specific instruction info
union {
cs_x86 x86; ///< X86 architecture, including 16-bit, 32-bit & 64-bit mode
cs_aarch64 aarch64; ///< AARCH64 architecture (aka AArch64)
#ifdef CAPSTONE_AARCH64_COMPAT_HEADER
cs_arm64 arm64;
#else
cs_aarch64 aarch64; ///< AArch6464 architecture (aka ARM64)
#endif
cs_arm arm; ///< ARM architecture (including Thumb/Thumb2)
cs_m68k m68k; ///< M68K architecture
cs_mips mips; ///< MIPS architecture
Expand Down Expand Up @@ -526,6 +540,9 @@ CAPSTONE_EXPORT
void CAPSTONE_API cs_arch_register_arm(void);
CAPSTONE_EXPORT
void CAPSTONE_API cs_arch_register_aarch64(void);
#ifdef CAPSTONE_AARCH64_COMPAT_HEADER
#define cs_arch_register_aarch64 cs_arch_register_arm64
#endif
CAPSTONE_EXPORT
void CAPSTONE_API cs_arch_register_mips(void);
CAPSTONE_EXPORT
Expand Down

0 comments on commit 3db02b1

Please sign in to comment.