diff --git a/porting/linux/user/src/hook/musl_preinit_common.h b/porting/linux/user/src/hook/musl_preinit_common.h index 06af2bf08a2aecb0be540f0c858445364e523629..63703338631b9f296ec8c99eae7d46d6381d4b90 100755 --- a/porting/linux/user/src/hook/musl_preinit_common.h +++ b/porting/linux/user/src/hook/musl_preinit_common.h @@ -27,10 +27,10 @@ enum EnumHookMode { STEP_HOOK_MODE, }; -#ifdef HOOK_ENABLE + extern void* function_of_shared_lib[]; extern volatile atomic_llong ohos_malloc_hook_shared_liibrary; -#endif + #ifdef __cplusplus extern "C" { @@ -39,18 +39,13 @@ extern "C" { __attribute__((always_inline)) inline bool __get_global_hook_flag() { -#ifdef HOOK_ENABLE volatile bool g_flag = atomic_load_explicit(&__hook_enable_hook_flag, memory_order_acquire); return g_flag; -#else - return false; -#endif } __attribute__((always_inline)) inline bool __get_hook_flag() { -#ifdef HOOK_ENABLE volatile void* impl_handle = (void *)atomic_load_explicit(&ohos_malloc_hook_shared_liibrary, memory_order_acquire); if (impl_handle == NULL) { return false; @@ -63,15 +58,11 @@ inline bool __get_hook_flag() bool flag = get_hook_func_ptr(); return flag; } -#else - return false; -#endif } __attribute__((always_inline)) inline bool __set_hook_flag(bool flag) { -#ifdef HOOK_ENABLE volatile void* impl_handle = (void *)atomic_load_explicit(&ohos_malloc_hook_shared_liibrary, memory_order_acquire); if (impl_handle == NULL) { return false; @@ -83,15 +74,11 @@ inline bool __set_hook_flag(bool flag) SetHookFlagType set_hook_func_ptr = (SetHookFlagType)(function_of_shared_lib[SET_HOOK_FLAG_FUNCTION]); return set_hook_func_ptr(flag); } -#else - return false; -#endif } __attribute__((always_inline)) inline volatile const struct MallocDispatchType* get_current_dispatch_table() { -#ifdef HOOK_ENABLE volatile const struct MallocDispatchType* ret = (struct MallocDispatchType *)atomic_load_explicit(&__musl_libc_globals.current_dispatch_table, memory_order_acquire); if (ret != NULL) { if (!__get_global_hook_flag()) { @@ -102,9 +89,6 @@ inline volatile const struct MallocDispatchType* get_current_dispatch_table() } } return ret; -#else - return NULL; -#endif } #define MUSL_HOOK_PARAM_NAME "libc.hook_mode"