shared-platform: Remove dependency on shared-utils' bh_memory_remap_slow (#3153)
As an original design rule, the code in `core/shared/platform` should not rely on the code in `core/share/utils`. In the current implementation, platform layer calls function `bh_memory_remap_slow` in utils layer. This PR adds inline function `os_mremap_slow` in platform_api_vmcore.h, and lets os_remap call it if mremap fails. And remove bh_memutils.h/c as as they are unused. And resolve the compilation warning in wamrc: ```bash core/shared/platform/common/posix/posix_memmap.c:255:16: warning: implicit declaration of function ‘bh_memory_remap_slow’ 255 | return bh_memory_remap_slow(old_addr, old_size, new_size); ```
This commit is contained in:
@ -3,10 +3,10 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "bh_memutils.h"
|
||||
#include "platform_api_vmcore.h"
|
||||
|
||||
void *
|
||||
os_mremap(void *old_addr, size_t old_size, size_t new_size)
|
||||
{
|
||||
return bh_memory_remap_slow(old_addr, old_size, new_size);
|
||||
return os_mremap_slow(old_addr, old_size, new_size);
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ list (REMOVE_AT CMAKE_REQUIRED_DEFINITIONS 0)
|
||||
|
||||
if(MREMAP_EXISTS)
|
||||
add_definitions (-DWASM_HAVE_MREMAP=1)
|
||||
add_definitions (-D_GNU_SOURCE)
|
||||
else()
|
||||
add_definitions (-DWASM_HAVE_MREMAP=0)
|
||||
include (${CMAKE_CURRENT_LIST_DIR}/../memory/platform_api_memory.cmake)
|
||||
|
||||
@ -3,12 +3,6 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#if !defined(_GNU_SOURCE) && WASM_HAVE_MREMAP != 0
|
||||
/* Enable mremap */
|
||||
#define _GNU_SOURCE
|
||||
#include "bh_memutils.h"
|
||||
#endif
|
||||
|
||||
#include "platform_api_vmcore.h"
|
||||
|
||||
#if defined(__APPLE__) || defined(__MACH__)
|
||||
@ -252,7 +246,7 @@ os_mremap(void *old_addr, size_t old_size, size_t new_size)
|
||||
#if BH_ENABLE_TRACE_MMAP != 0
|
||||
os_printf("mremap failed: %d\n", errno);
|
||||
#endif
|
||||
return bh_memory_remap_slow(old_addr, old_size, new_size);
|
||||
return os_mremap_slow(old_addr, old_size, new_size);
|
||||
}
|
||||
|
||||
return ptr;
|
||||
|
||||
Reference in New Issue
Block a user