rt-thread-official/components/libc/compilers/armlibc/syscall_mem.c

72 lines
1.3 KiB
C
Raw Normal View History

/*
2021-03-08 18:19:04 +08:00
* Copyright (c) 2006-2021, RT-Thread Development Team
*
2018-10-14 19:28:18 +08:00
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2014-08-03 bernard Add file header
* 2021-11-13 Meco Man implement no-heap warning
*/
2021-09-11 20:40:07 +08:00
#include <rtthread.h>
#include <stddef.h>
#ifndef RT_USING_HEAP
2021-12-26 22:41:24 +08:00
#define DBG_TAG "armlibc.syscall.mem"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#define _NO_HEAP_ERROR() do{LOG_E("Please enable RT_USING_HEAP");\
RT_ASSERT(0);\
}while(0)
#endif /* RT_USING_HEAP */
2018-09-23 12:08:44 +08:00
#ifdef __CC_ARM
2022-07-25 10:21:18 +08:00
/* avoid the heap and heap-using library functions supplied by arm */
#pragma import(__use_no_heap)
#endif /* __CC_ARM */
void *malloc(size_t n)
{
#ifdef RT_USING_HEAP
return rt_malloc(n);
#else
_NO_HEAP_ERROR();
return RT_NULL;
#endif
}
2015-10-11 15:37:34 +08:00
RTM_EXPORT(malloc);
void *realloc(void *rmem, size_t newsize)
{
#ifdef RT_USING_HEAP
return rt_realloc(rmem, newsize);
#else
_NO_HEAP_ERROR();
return RT_NULL;
#endif
}
2015-10-11 15:37:34 +08:00
RTM_EXPORT(realloc);
void *calloc(size_t nelem, size_t elsize)
{
#ifdef RT_USING_HEAP
return rt_calloc(nelem, elsize);
#else
_NO_HEAP_ERROR();
return RT_NULL;
#endif
}
2015-10-11 15:37:34 +08:00
RTM_EXPORT(calloc);
void free(void *rmem)
{
#ifdef RT_USING_HEAP
rt_free(rmem);
#else
_NO_HEAP_ERROR();
#endif
}
2015-10-11 15:37:34 +08:00
RTM_EXPORT(free);