prefix cs_ to global variables to avoid link problems (#1108)
* prefix cs_ to global variables to avoid link problems * force Capstone to be build using MT * fix identation
This commit is contained in:
parent
3a6ccaffb1
commit
5c3021250d
|
@ -52,6 +52,11 @@ option(CAPSTONE_X86_REDUCE "x86 with reduce instruction sets to minimize library
|
|||
option(CAPSTONE_X86_ATT_DISABLE "Disable x86 AT&T syntax" OFF)
|
||||
option(CAPSTONE_OSXKERNEL_SUPPORT "Support to embed Capstone into OS X Kernel extensions" OFF)
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
endif ()
|
||||
|
||||
enable_testing()
|
||||
|
||||
if (CAPSTONE_BUILD_DIET)
|
||||
|
|
|
@ -47,8 +47,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void AArch64_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_ARM64] = init;
|
||||
arch_option[CS_ARCH_ARM64] = option;
|
||||
cs_arch_init[CS_ARCH_ARM64] = init;
|
||||
cs_arch_option[CS_ARCH_ARM64] = option;
|
||||
|
||||
// support this arch
|
||||
all_arch |= (1 << CS_ARCH_ARM64);
|
||||
|
|
|
@ -68,8 +68,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void ARM_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_ARM] = init;
|
||||
arch_option[CS_ARCH_ARM] = option;
|
||||
cs_arch_init[CS_ARCH_ARM] = init;
|
||||
cs_arch_option[CS_ARCH_ARM] = option;
|
||||
|
||||
// support this arch
|
||||
all_arch |= (1 << CS_ARCH_ARM);
|
||||
|
|
|
@ -74,8 +74,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void M680X_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_M680X] = init;
|
||||
arch_option[CS_ARCH_M680X] = option;
|
||||
cs_arch_init[CS_ARCH_M680X] = init;
|
||||
cs_arch_option[CS_ARCH_M680X] = option;
|
||||
|
||||
// support this arch
|
||||
all_arch |= (1 << CS_ARCH_M680X);
|
||||
|
|
|
@ -39,8 +39,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void M68K_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_M68K] = init;
|
||||
arch_option[CS_ARCH_M68K] = option;
|
||||
cs_arch_init[CS_ARCH_M68K] = init;
|
||||
cs_arch_option[CS_ARCH_M68K] = option;
|
||||
|
||||
// support this arch
|
||||
all_arch |= (1 << CS_ARCH_M68K);
|
||||
|
|
|
@ -49,8 +49,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void Mips_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_MIPS] = init;
|
||||
arch_option[CS_ARCH_MIPS] = option;
|
||||
cs_arch_init[CS_ARCH_MIPS] = init;
|
||||
cs_arch_option[CS_ARCH_MIPS] = option;
|
||||
|
||||
// support this arch
|
||||
all_arch |= (1 << CS_ARCH_MIPS);
|
||||
|
|
|
@ -49,8 +49,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void PPC_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_PPC] = init;
|
||||
arch_option[CS_ARCH_PPC] = option;
|
||||
cs_arch_init[CS_ARCH_PPC] = init;
|
||||
cs_arch_option[CS_ARCH_PPC] = option;
|
||||
|
||||
// support this arch
|
||||
all_arch |= (1 << CS_ARCH_PPC);
|
||||
|
|
|
@ -48,8 +48,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void Sparc_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_SPARC] = init;
|
||||
arch_option[CS_ARCH_SPARC] = option;
|
||||
cs_arch_init[CS_ARCH_SPARC] = init;
|
||||
cs_arch_option[CS_ARCH_SPARC] = option;
|
||||
|
||||
// support this arch
|
||||
all_arch |= (1 << CS_ARCH_SPARC);
|
||||
|
|
|
@ -40,8 +40,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void SystemZ_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_SYSZ] = init;
|
||||
arch_option[CS_ARCH_SYSZ] = option;
|
||||
cs_arch_init[CS_ARCH_SYSZ] = init;
|
||||
cs_arch_option[CS_ARCH_SYSZ] = option;
|
||||
|
||||
// support this arch
|
||||
all_arch |= (1 << CS_ARCH_SYSZ);
|
||||
|
|
|
@ -37,8 +37,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void TMS320C64x_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_TMS320C64X] = init;
|
||||
arch_option[CS_ARCH_TMS320C64X] = option;
|
||||
cs_arch_init[CS_ARCH_TMS320C64X] = init;
|
||||
cs_arch_option[CS_ARCH_TMS320C64X] = option;
|
||||
|
||||
all_arch |= (1 << CS_ARCH_TMS320C64X);
|
||||
}
|
||||
|
|
|
@ -97,8 +97,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void X86_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_X86] = init;
|
||||
arch_option[CS_ARCH_X86] = option;
|
||||
cs_arch_init[CS_ARCH_X86] = init;
|
||||
cs_arch_option[CS_ARCH_X86] = option;
|
||||
|
||||
// support this arch
|
||||
all_arch |= (1 << CS_ARCH_X86);
|
||||
|
|
|
@ -37,8 +37,8 @@ static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
|||
|
||||
void XCore_enable(void)
|
||||
{
|
||||
arch_init[CS_ARCH_XCORE] = init;
|
||||
arch_option[CS_ARCH_XCORE] = option;
|
||||
cs_arch_init[CS_ARCH_XCORE] = init;
|
||||
cs_arch_option[CS_ARCH_XCORE] = option;
|
||||
|
||||
// support this arch
|
||||
all_arch |= (1 << CS_ARCH_XCORE);
|
||||
|
|
12
cs.c
12
cs.c
|
@ -51,9 +51,9 @@
|
|||
#define SKIPDATA_MNEM NULL
|
||||
#endif
|
||||
|
||||
cs_err (*arch_init[MAX_ARCH])(cs_struct *) = { NULL };
|
||||
cs_err (*arch_option[MAX_ARCH]) (cs_struct *, cs_opt_type, size_t value) = { NULL };
|
||||
void (*arch_destroy[MAX_ARCH]) (cs_struct *) = { NULL };
|
||||
cs_err (*cs_arch_init[MAX_ARCH])(cs_struct *) = { NULL };
|
||||
cs_err (*cs_arch_option[MAX_ARCH]) (cs_struct *, cs_opt_type, size_t value) = { NULL };
|
||||
void (*cs_arch_destroy[MAX_ARCH]) (cs_struct *) = { NULL };
|
||||
|
||||
extern void ARM_enable(void);
|
||||
extern void AArch64_enable(void);
|
||||
|
@ -275,7 +275,7 @@ cs_err CAPSTONE_API cs_open(cs_arch arch, cs_mode mode, csh *handle)
|
|||
|
||||
archs_enable();
|
||||
|
||||
if (arch < CS_ARCH_MAX && arch_init[arch]) {
|
||||
if (arch < CS_ARCH_MAX && cs_arch_init[arch]) {
|
||||
ud = cs_mem_calloc(1, sizeof(*ud));
|
||||
if (!ud) {
|
||||
// memory insufficient
|
||||
|
@ -292,7 +292,7 @@ cs_err CAPSTONE_API cs_open(cs_arch arch, cs_mode mode, csh *handle)
|
|||
// default skipdata setup
|
||||
ud->skipdata_setup.mnemonic = SKIPDATA_MNEM;
|
||||
|
||||
err = arch_init[ud->arch](ud);
|
||||
err = cs_arch_init[ud->arch](ud);
|
||||
if (err) {
|
||||
cs_mem_free(ud);
|
||||
*handle = 0;
|
||||
|
@ -560,7 +560,7 @@ cs_err CAPSTONE_API cs_option(csh ud, cs_opt_type type, size_t value)
|
|||
return CS_ERR_OK;
|
||||
}
|
||||
|
||||
return arch_option[handle->arch](handle, type, value);
|
||||
return cs_arch_option[handle->arch](handle, type, value);
|
||||
}
|
||||
|
||||
// generate @op_str for data instruction of SKIPDATA
|
||||
|
|
|
@ -79,10 +79,10 @@ struct cs_struct {
|
|||
#define MAX_ARCH CS_ARCH_MAX
|
||||
|
||||
// constructor initialization for all archs
|
||||
extern cs_err (*arch_init[MAX_ARCH]) (cs_struct *);
|
||||
extern cs_err (*cs_arch_init[MAX_ARCH]) (cs_struct *);
|
||||
|
||||
// support cs_option() for all archs
|
||||
extern cs_err (*arch_option[MAX_ARCH]) (cs_struct*, cs_opt_type, size_t value);
|
||||
extern cs_err (*cs_arch_option[MAX_ARCH]) (cs_struct*, cs_opt_type, size_t value);
|
||||
|
||||
extern unsigned int all_arch;
|
||||
|
||||
|
|
Loading…
Reference in New Issue