diff --git a/arch/sim/src/nuttx-names.in b/arch/sim/src/nuttx-names.in index 66b09034ab..9d405fddc2 100644 --- a/arch/sim/src/nuttx-names.in +++ b/arch/sim/src/nuttx-names.in @@ -50,8 +50,8 @@ NXSYMBOLS(ioctl) NXSYMBOLS(longjmp) NXSYMBOLS(lseek) NXSYMBOLS(malloc) -NXSYMBOLS(mallinfo) -NXSYMBOLS(memalign) +NXSYMBOLS(malloc_size) +NXSYMBOLS(malloc_usable_size) NXSYMBOLS(memcpy) NXSYMBOLS(mkdir) NXSYMBOLS(mmap) @@ -60,6 +60,7 @@ NXSYMBOLS(open) NXSYMBOLS(opendir) NXSYMBOLS(perror) NXSYMBOLS(poll) +NXSYMBOLS(posix_memalign) NXSYMBOLS(pthread_cond_destroy) NXSYMBOLS(pthread_cond_init) NXSYMBOLS(pthread_cond_signal) diff --git a/arch/sim/src/sim/up_heap.c b/arch/sim/src/sim/up_heap.c index 1963952bf3..b1ccc1172b 100644 --- a/arch/sim/src/sim/up_heap.c +++ b/arch/sim/src/sim/up_heap.c @@ -446,6 +446,15 @@ void mm_checkcorruption(FAR struct mm_heap_s *heap) #endif /* CONFIG_DEBUG_MM */ +/**************************************************************************** + * Name: malloc_size + ****************************************************************************/ + +size_t malloc_size(FAR void *mem) +{ + return host_malloc_size(mem); +} + /**************************************************************************** * Name: up_allocate_heap * diff --git a/arch/sim/src/sim/up_hostmemory.c b/arch/sim/src/sim/up_hostmemory.c index 88bc3d1eb8..f44401103a 100644 --- a/arch/sim/src/sim/up_hostmemory.c +++ b/arch/sim/src/sim/up_hostmemory.c @@ -31,6 +31,12 @@ #include #include +#ifdef __APPLE__ +#include +#else +#include +#endif + #include "up_internal.h" /**************************************************************************** @@ -118,6 +124,15 @@ void host_free_shmem(void *mem) munmap(mem, 0); } +size_t host_malloc_size(void *mem) +{ +#ifdef __APPLE__ + return malloc_size(mem); +#else + return malloc_usable_size(mem); +#endif +} + void *host_memalign(size_t alignment, size_t size) { void *p; diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h index 4ad4d0f12e..43c8913fd1 100644 --- a/arch/sim/src/sim/up_internal.h +++ b/arch/sim/src/sim/up_internal.h @@ -144,6 +144,7 @@ void *host_alloc_heap(size_t sz); void *host_alloc_shmem(const char *name, size_t size, int master); void host_free_shmem(void *mem); +size_t host_malloc_size(void *mem); void *host_memalign(size_t alignment, size_t size); void host_free(void *mem); void *host_realloc(void *oldmem, size_t size);