summaryrefslogtreecommitdiff
path: root/components/libc/compilers/dlib/syscall_mem.c
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2021-11-15 23:27:27 +0800
committerGitHub <[email protected]>2021-11-15 23:27:27 +0800
commit0bcab2892a81960ceb394b5cde4bc78eed3326eb (patch)
tree2f6cf7554548f407edb8a51136c76a7a7658a375 /components/libc/compilers/dlib/syscall_mem.c
parentef05ecf7c47a8265de19ce8367583de690fb1860 (diff)
parent4fe93881b071ea664b9a5b89c073ad46b9d3e312 (diff)
Merge pull request #5268 from mysterywolf/SYSCALL
[libc]重新梳理read write桩函数实现
Diffstat (limited to 'components/libc/compilers/dlib/syscall_mem.c')
-rw-r--r--components/libc/compilers/dlib/syscall_mem.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/components/libc/compilers/dlib/syscall_mem.c b/components/libc/compilers/dlib/syscall_mem.c
index 9c6de64455..74b960f0b9 100644
--- a/components/libc/compilers/dlib/syscall_mem.c
+++ b/components/libc/compilers/dlib/syscall_mem.c
@@ -6,27 +6,55 @@
* Change Logs:
* Date Author Notes
* 2015-01-28 Bernard first version
+ * 2021-11-13 Meco Man implement no-heap warning
*/
#include <rtthread.h>
+#include <stddef.h>
-#ifdef RT_USING_HEAP
-void *malloc(rt_size_t n)
+#ifndef RT_USING_HEAP
+#define DBG_TAG "dlib.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 */
+
+void *malloc(size_t n)
{
+#ifdef RT_USING_HEAP
return rt_malloc(n);
+#else
+ _NO_HEAP_ERROR();
+ return RT_NULL;
+#endif
}
-void *realloc(void *rmem, rt_size_t newsize)
+void *realloc(void *rmem, size_t newsize)
{
+#ifdef RT_USING_HEAP
return rt_realloc(rmem, newsize);
+#else
+ _NO_HEAP_ERROR();
+ return RT_NULL;
+#endif
}
-void *calloc(rt_size_t nelem, rt_size_t elsize)
+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
}
void free(void *rmem)
{
+#ifdef RT_USING_HEAP
rt_free(rmem);
-}
+#else
+ _NO_HEAP_ERROR();
#endif
+}