未验证 提交 daa508f7 编写于 作者: O openharmony_ci 提交者: Gitee

!406 修改musl 解决TDD测试用例失败的问题

Merge pull request !406 from shuxinyiA/OpenHarmony-3.1-Release
...@@ -27,10 +27,10 @@ enum EnumHookMode { ...@@ -27,10 +27,10 @@ enum EnumHookMode {
STEP_HOOK_MODE, STEP_HOOK_MODE,
}; };
#ifdef HOOK_ENABLE
extern void* function_of_shared_lib[]; extern void* function_of_shared_lib[];
extern volatile atomic_llong ohos_malloc_hook_shared_liibrary; extern volatile atomic_llong ohos_malloc_hook_shared_liibrary;
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -39,18 +39,13 @@ extern "C" { ...@@ -39,18 +39,13 @@ extern "C" {
__attribute__((always_inline)) __attribute__((always_inline))
inline bool __get_global_hook_flag() inline bool __get_global_hook_flag()
{ {
#ifdef HOOK_ENABLE
volatile bool g_flag = atomic_load_explicit(&__hook_enable_hook_flag, memory_order_acquire); volatile bool g_flag = atomic_load_explicit(&__hook_enable_hook_flag, memory_order_acquire);
return g_flag; return g_flag;
#else
return false;
#endif
} }
__attribute__((always_inline)) __attribute__((always_inline))
inline bool __get_hook_flag() inline bool __get_hook_flag()
{ {
#ifdef HOOK_ENABLE
volatile void* impl_handle = (void *)atomic_load_explicit(&ohos_malloc_hook_shared_liibrary, memory_order_acquire); volatile void* impl_handle = (void *)atomic_load_explicit(&ohos_malloc_hook_shared_liibrary, memory_order_acquire);
if (impl_handle == NULL) { if (impl_handle == NULL) {
return false; return false;
...@@ -63,15 +58,11 @@ inline bool __get_hook_flag() ...@@ -63,15 +58,11 @@ inline bool __get_hook_flag()
bool flag = get_hook_func_ptr(); bool flag = get_hook_func_ptr();
return flag; return flag;
} }
#else
return false;
#endif
} }
__attribute__((always_inline)) __attribute__((always_inline))
inline bool __set_hook_flag(bool flag) 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); volatile void* impl_handle = (void *)atomic_load_explicit(&ohos_malloc_hook_shared_liibrary, memory_order_acquire);
if (impl_handle == NULL) { if (impl_handle == NULL) {
return false; return false;
...@@ -83,15 +74,11 @@ inline bool __set_hook_flag(bool flag) ...@@ -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]); SetHookFlagType set_hook_func_ptr = (SetHookFlagType)(function_of_shared_lib[SET_HOOK_FLAG_FUNCTION]);
return set_hook_func_ptr(flag); return set_hook_func_ptr(flag);
} }
#else
return false;
#endif
} }
__attribute__((always_inline)) __attribute__((always_inline))
inline volatile const struct MallocDispatchType* get_current_dispatch_table() 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); volatile const struct MallocDispatchType* ret = (struct MallocDispatchType *)atomic_load_explicit(&__musl_libc_globals.current_dispatch_table, memory_order_acquire);
if (ret != NULL) { if (ret != NULL) {
if (!__get_global_hook_flag()) { if (!__get_global_hook_flag()) {
...@@ -102,9 +89,6 @@ inline volatile const struct MallocDispatchType* get_current_dispatch_table() ...@@ -102,9 +89,6 @@ inline volatile const struct MallocDispatchType* get_current_dispatch_table()
} }
} }
return ret; return ret;
#else
return NULL;
#endif
} }
#define MUSL_HOOK_PARAM_NAME "libc.hook_mode" #define MUSL_HOOK_PARAM_NAME "libc.hook_mode"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册