Skip to content

Commit

Permalink
Remove compatibility headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Sep 9, 2024
1 parent 04df876 commit f58078c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 96 deletions.
36 changes: 1 addition & 35 deletions docs/cs_v6_release_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,39 +168,6 @@ If you want to use the compatibility header and stick with the `ARM64`/`SYSZ` na
// Your code...
```

_Meta programming macros_

The following `sed` commands in a sh script should ease the replacement of `ARM64` with the macros a lot.
These macros are also part of the latest `v4` and `v5` release.

```sh
#!/bin/sh
echo "Replace enum names"

sed -i -E "s/CS_ARCH_ARM64/CS_AARCH64pre(CS_ARCH_)/g" $1
sed -i -E "s/ARM64_INS_(\\w+)/CS_AARCH64(_INS_\\1)/g" $1
sed -i -E "s/ARM64_REG_(\\w+)/CS_AARCH64(_REG_\\1)/g" $1
sed -i -E "s/ARM64_OP_(\\w+)/CS_AARCH64(_OP_\\1)/g" $1
sed -i -E "s/ARM64_EXT_(\\w+)/CS_AARCH64(_EXT_\\1)/g" $1
sed -i -E "s/ARM64_SFT_(\\w+)/CS_AARCH64(_SFT_\\1)/g" $1
sed -i -E "s/ARM64_VAS_(\\w+)/CS_AARCH64_VL_(\\1)/g" $1

sed -i -E "s/ARM64_CC_(\\w+)/CS_AARCH64CC(_\\1)/g" $1

echo "Replace type identifiers"

sed -i -E "s/cs_arm64_op /CS_aarch64_op() /g" $1
sed -i -E "s/arm64_reg /CS_aarch64_reg() /g" $1
sed -i -E "s/arm64_cc /CS_aarch64_cc() /g" $1
sed -i -E "s/cs_arm64 /CS_cs_aarch64() /g" $1
sed -i -E "s/arm64_extender /CS_aarch64_extender() /g" $1
sed -i -E "s/arm64_shifter /CS_aarch64_shifter() /g" $1
sed -i -E "s/arm64_vas /CS_aarch64_vas() /g" $1

echo "Replace detail->arm64"
sed -i -E "s/detail->arm64/detail->CS_aarch64()/g" $1
```

_Example renaming with `sed`_

Simple renaming from `ARM64` to `AArch64`:
Expand Down Expand Up @@ -258,8 +225,7 @@ echo "Replace detail->sysz"
sed -i "s|detail->sysz|detail->systemz|g" $1
```

Write it into `rename_arm64.sh` and run it on files with `sh rename_arm64.sh <src-file>`

Write it into `rename.sh` and run it on files with `sh rename.sh <src-file>`

### Known bugs

Expand Down
61 changes: 0 additions & 61 deletions include/capstone/capstone.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,67 +61,6 @@ 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.
/// 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_ arm64
#else
#define CS_aarch64_ aarch64
#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
#endif // CAPSTONE_AARCH64_COMPAT_HEADER

/// 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

0 comments on commit f58078c

Please sign in to comment.