Skip to content

[v4] Add meta-programming macros for ARM64/AArch64 name change to capstone.h #2200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions include/capstone/capstone.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,59 @@ extern "C" {
#define CS_VERSION_MINOR CS_API_MINOR
#define CS_VERSION_EXTRA 2

/// Macro for meta programming.
/// Meant for projects using Capstone and need to support multiple
/// versions of it.
/// These macros replace several instances of the old "ARM64" with
/// the new "AArch64" name depending on the CS version.
#if CS_NEXT_VERSION < 6
#define CS_AARCH64(x) ARM64##x
#else
#define CS_AARCH64(x) AArch64##x
#endif

#if CS_NEXT_VERSION < 6
#define CS_AARCH64pre(x) x##ARM64
#else
#define CS_AARCH64pre(x) x##AARCH64
#endif

#if CS_NEXT_VERSION < 6
#define CS_AARCH64CC(x) ARM64_CC##x
#else
#define CS_AARCH64CC(x) AArch64CC##x
#endif

#if CS_NEXT_VERSION < 6
#define CS_AARCH64_VL_(x) ARM64_VAS_##x
#else
#define CS_AARCH64_VL_(x) AArch64Layout_VL_##x
#endif

#if CS_NEXT_VERSION < 6
#define CS_aarch64(x) arm64##x
#else
#define CS_aarch64(x) aarch64##x
#endif

#if CS_NEXT_VERSION < 6
#define CS_aarch64_op() cs_arm64_op
#define CS_aarch64_reg() arm64_reg
#define CS_aarch64_cc() arm64_cc
#define CS_cs_aarch64() cs_arm64
#define CS_aarch64_extender() arm64_extender
#define CS_aarch64_shifter() arm64_shifter
#define CS_aarch64_vas() arm64_vas
#else
#define CS_aarch64_op() cs_aarch64_op
#define CS_aarch64_reg() aarch64_reg
#define CS_aarch64_cc() AArch64CC_CondCode
#define CS_cs_aarch64() cs_aarch64
#define CS_aarch64_extender() aarch64_extender
#define CS_aarch64_shifter() aarch64_shifter
#define CS_aarch64_vas() AArch64Layout_VectorLayout
#endif

/// Macro to create combined version which can be compared to
/// result of cs_version() API.
#define CS_MAKE_VERSION(major, minor) ((major << 8) + minor)
Expand Down