Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed Jun 21, 2018
1 parent 853a287 commit 0b874b2
Show file tree
Hide file tree
Showing 18 changed files with 7 additions and 101 deletions.
4 changes: 0 additions & 4 deletions arch/AArch64/AArch64Module.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,4 @@ cs_err AArch64_option(cs_struct *handle, cs_opt_type type, size_t value)
return CS_ERR_OK;
}

void AArch64_destroy(cs_struct *handle)
{
}

#endif
1 change: 0 additions & 1 deletion arch/AArch64/AArch64Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

cs_err AArch64_global_init(cs_struct *ud);
cs_err AArch64_option(cs_struct *handle, cs_opt_type type, size_t value);
void AArch64_destroy(cs_struct *handle);

#endif
4 changes: 0 additions & 4 deletions arch/ARM/ARMModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,4 @@ cs_err ARM_option(cs_struct *handle, cs_opt_type type, size_t value)
return CS_ERR_OK;
}

void ARM_destroy(cs_struct *handle)
{
}

#endif
1 change: 0 additions & 1 deletion arch/ARM/ARMModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

cs_err ARM_global_init(cs_struct *ud);
cs_err ARM_option(cs_struct *handle, cs_opt_type type, size_t value);
void ARM_destroy(cs_struct *handle);

#endif
4 changes: 0 additions & 4 deletions arch/Mips/MipsModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,4 @@ cs_err Mips_option(cs_struct *handle, cs_opt_type type, size_t value)
return CS_ERR_OK;
}

void Mips_destroy(cs_struct *handle)
{
}

#endif
1 change: 0 additions & 1 deletion arch/Mips/MipsModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

cs_err Mips_global_init(cs_struct *ud);
cs_err Mips_option(cs_struct *handle, cs_opt_type type, size_t value);
void Mips_destroy(cs_struct *handle);

#endif
4 changes: 0 additions & 4 deletions arch/PowerPC/PPCModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,4 @@ cs_err PPC_option(cs_struct *handle, cs_opt_type type, size_t value)
return CS_ERR_OK;
}

void PPC_destroy(cs_struct *handle)
{
}

#endif
1 change: 0 additions & 1 deletion arch/PowerPC/PPCModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

cs_err PPC_global_init(cs_struct *ud);
cs_err PPC_option(cs_struct *handle, cs_opt_type type, size_t value);
void PPC_destroy(cs_struct *handle);

#endif
4 changes: 0 additions & 4 deletions arch/Sparc/SparcModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,4 @@ cs_err Sparc_option(cs_struct *handle, cs_opt_type type, size_t value)
return CS_ERR_OK;
}

void Sparc_destroy(cs_struct *handle)
{
}

#endif
1 change: 0 additions & 1 deletion arch/Sparc/SparcModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

cs_err Sparc_global_init(cs_struct *ud);
cs_err Sparc_option(cs_struct *handle, cs_opt_type type, size_t value);
void Sparc_destroy(cs_struct *handle);

#endif
4 changes: 0 additions & 4 deletions arch/SystemZ/SystemZModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,4 @@ cs_err SystemZ_option(cs_struct *handle, cs_opt_type type, size_t value)
return CS_ERR_OK;
}

void SystemZ_destroy(cs_struct *handle)
{
}

#endif
1 change: 0 additions & 1 deletion arch/SystemZ/SystemZModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

cs_err SystemZ_global_init(cs_struct *ud);
cs_err SystemZ_option(cs_struct *handle, cs_opt_type type, size_t value);
void SystemZ_destroy(cs_struct *handle);

#endif
4 changes: 0 additions & 4 deletions arch/X86/X86Module.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,4 @@ cs_err X86_option(cs_struct *handle, cs_opt_type type, size_t value)
return CS_ERR_OK;
}

void X86_destroy(cs_struct *handle)
{
}

#endif
1 change: 0 additions & 1 deletion arch/X86/X86Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

cs_err X86_global_init(cs_struct *ud);
cs_err X86_option(cs_struct *handle, cs_opt_type type, size_t value);
void X86_destroy(cs_struct *handle);

#endif
4 changes: 0 additions & 4 deletions arch/XCore/XCoreModule.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,4 @@ cs_err XCore_option(cs_struct *handle, cs_opt_type type, size_t value)
return CS_ERR_OK;
}

void XCore_destroy(cs_struct *handle)
{
}

#endif
1 change: 0 additions & 1 deletion arch/XCore/XCoreModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

cs_err XCore_global_init(cs_struct *ud);
cs_err XCore_option(cs_struct *handle, cs_opt_type type, size_t value);
void XCore_destroy(cs_struct *handle);

#endif
53 changes: 7 additions & 46 deletions cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
#include "arch/XCore/XCoreModule.h"


cs_err (*cs_arch_init[MAX_ARCH])(cs_struct *) = {
// constructor initialization for all archs
static cs_err (*cs_arch_init[MAX_ARCH])(cs_struct *) = {
#ifdef CAPSTONE_HAS_ARM
ARM_global_init,
#else
Expand Down Expand Up @@ -105,7 +106,8 @@ cs_err (*cs_arch_init[MAX_ARCH])(cs_struct *) = {
#endif
};

cs_err (*cs_arch_option[MAX_ARCH]) (cs_struct *, cs_opt_type, size_t value) = {
// support cs_option() for all archs
static cs_err (*cs_arch_option[MAX_ARCH]) (cs_struct *, cs_opt_type, size_t value) = {
#ifdef CAPSTONE_HAS_ARM
ARM_option,
#else
Expand Down Expand Up @@ -148,49 +150,8 @@ cs_err (*cs_arch_option[MAX_ARCH]) (cs_struct *, cs_opt_type, size_t value) = {
#endif
};

void (*cs_arch_destroy[MAX_ARCH]) (cs_struct *) = {
#ifdef CAPSTONE_HAS_ARM
ARM_destroy,
#else
NULL,
#endif
#ifdef CAPSTONE_HAS_ARM64
AArch64_destroy,
#else
NULL,
#endif
#ifdef CAPSTONE_HAS_MIPS
Mips_destroy,
#else
NULL,
#endif
#ifdef CAPSTONE_HAS_X86
X86_destroy,
#else
NULL,
#endif
#ifdef CAPSTONE_HAS_POWERPC
PPC_destroy,
#else
NULL,
#endif
#ifdef CAPSTONE_HAS_SPARC
Sparc_destroy,
#else
NULL,
#endif
#ifdef CAPSTONE_HAS_SYSZ
SystemZ_destroy,
#else
NULL,
#endif
#ifdef CAPSTONE_HAS_XCORE
XCore_destroy,
#else
NULL,
#endif
};

// bitmask for finding disallowed modes for an arch:
// to be called in cs_open()/cs_option()
cs_mode cs_arch_disallowed_mode_mask[MAX_ARCH] = {
#ifdef CAPSTONE_HAS_ARM
~(CS_MODE_LITTLE_ENDIAN | CS_MODE_ARM | CS_MODE_V8 | CS_MODE_MCLASS | CS_MODE_THUMB | CS_MODE_BIG_ENDIAN),
Expand Down Expand Up @@ -235,7 +196,7 @@ cs_mode cs_arch_disallowed_mode_mask[MAX_ARCH] = {
#endif
};

unsigned int all_arch =
static unsigned int all_arch =
#ifdef CAPSTONE_HAS_ARM
(1 << CS_ARCH_ARM)
#else
Expand Down
15 changes: 0 additions & 15 deletions cs_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,6 @@ struct cs_struct {
// Returns a bool (0 or 1) whether big endian is enabled for a mode
#define MODE_IS_BIG_ENDIAN(mode) (((mode) & CS_MODE_BIG_ENDIAN) != 0)

// constructor initialization for all archs
extern cs_err (*cs_arch_init[MAX_ARCH]) (cs_struct *);

// support cs_option() for all archs
extern cs_err (*cs_arch_option[MAX_ARCH]) (cs_struct*, cs_opt_type, size_t value);

// deinitialized functions: to be called when cs_close() is called
extern void (*cs_arch_destroy[MAX_ARCH]) (cs_struct*);

// bitmask for finding disallowed modes for an arch:
// to be called in cs_open()/cs_option()
extern cs_mode cs_arch_disallowed_mode_mask[MAX_ARCH];

extern unsigned int all_arch;

extern cs_malloc_t cs_mem_malloc;
extern cs_calloc_t cs_mem_calloc;
extern cs_realloc_t cs_mem_realloc;
Expand Down

0 comments on commit 0b874b2

Please sign in to comment.