mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-12 20:51:21 +00:00
nuttx: Use text heap for executable memory (#1181)
Based on nuttx patch "Add up_textheap_heapmember": https://github.com/apache/incubator-nuttx/pull/6306
This commit is contained in:
parent
69c23aa2d4
commit
723a808106
|
@ -6,6 +6,10 @@
|
||||||
#include "platform_api_extension.h"
|
#include "platform_api_extension.h"
|
||||||
#include "platform_api_vmcore.h"
|
#include "platform_api_vmcore.h"
|
||||||
|
|
||||||
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
bh_platform_init()
|
bh_platform_init()
|
||||||
{
|
{
|
||||||
|
@ -37,6 +41,12 @@ os_free(void *ptr)
|
||||||
void *
|
void *
|
||||||
os_mmap(void *hint, size_t size, int prot, int flags)
|
os_mmap(void *hint, size_t size, int prot, int flags)
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
|
if ((prot & MMAP_PROT_EXEC) != 0) {
|
||||||
|
return up_textheap_memalign(sizeof(void *), size);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((uint64)size >= UINT32_MAX)
|
if ((uint64)size >= UINT32_MAX)
|
||||||
return NULL;
|
return NULL;
|
||||||
return malloc((uint32)size);
|
return malloc((uint32)size);
|
||||||
|
@ -45,6 +55,12 @@ os_mmap(void *hint, size_t size, int prot, int flags)
|
||||||
void
|
void
|
||||||
os_munmap(void *addr, size_t size)
|
os_munmap(void *addr, size_t size)
|
||||||
{
|
{
|
||||||
|
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
|
||||||
|
if (up_textheap_heapmember(addr)) {
|
||||||
|
up_textheap_free(addr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return free(addr);
|
return free(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user