arch/sim: Implement malloc_size for the custom heap
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
f240b2e631
commit
8ebf9c92cf
@ -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)
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -31,6 +31,12 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <malloc/malloc.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user