File tree Expand file tree Collapse file tree 4 files changed +67
-11
lines changed
components/libc/compilers Expand file tree Collapse file tree 4 files changed +67
-11
lines changed Original file line number Diff line number Diff line change 44 * SPDX-License-Identifier: Apache-2.0
55 *
66 * Change Logs:
7- * 2014-08-03 bernard Add file header.
7+ * Date Author Notes
8+ * 2014-08-03 bernard Add file header
9+ * 2021-11-13 Meco Man implement no-heap warning
810 */
911
1012#include <rtthread.h>
1113#include <stddef.h>
1214
13- #ifdef RT_USING_HEAP
15+ #ifndef RT_USING_HEAP
16+ #define DBG_TAG "armlibc.mem"
17+ #define DBG_LVL DBG_INFO
18+ #include <rtdbg.h>
19+
20+ #define _NO_HEAP_ERROR () do{LOG_E("Please enable RT_USING_HEAP");\
21+ RT_ASSERT(0);\
22+ }while(0)
23+ #endif /* RT_USING_HEAP */
1424
1525#ifdef __CC_ARM
1626/* avoid the heap and heap-using library functions supplied by arm */
1727#pragma import(__use_no_heap)
18- #endif
28+ #endif /* __CC_ARM */
1929
2030void * malloc (size_t n )
2131{
32+ #ifdef RT_USING_HEAP
2233 return rt_malloc (n );
34+ #else
35+ _NO_HEAP_ERROR ();
36+ return RT_NULL ;
37+ #endif
2338}
2439RTM_EXPORT (malloc );
2540
2641void * realloc (void * rmem , size_t newsize )
2742{
43+ #ifdef RT_USING_HEAP
2844 return rt_realloc (rmem , newsize );
45+ #else
46+ _NO_HEAP_ERROR ();
47+ return RT_NULL ;
48+ #endif
2949}
3050RTM_EXPORT (realloc );
3151
3252void * calloc (size_t nelem , size_t elsize )
3353{
54+ #ifdef RT_USING_HEAP
3455 return rt_calloc (nelem , elsize );
56+ #else
57+ _NO_HEAP_ERROR ();
58+ return RT_NULL ;
59+ #endif
3560}
3661RTM_EXPORT (calloc );
3762
3863void free (void * rmem )
3964{
65+ #ifdef RT_USING_HEAP
4066 rt_free (rmem );
67+ #else
68+ _NO_HEAP_ERROR ();
69+ #endif
4170}
4271RTM_EXPORT (free );
43- #endif
Original file line number Diff line number Diff line change 2525#include "libc.h"
2626#endif
2727
28- #define DBG_TAG "Keil. armlibc.syscalls"
28+ #define DBG_TAG "armlibc.syscalls"
2929#define DBG_LVL DBG_INFO
3030#include <rtdbg.h>
3131
Original file line number Diff line number Diff line change 66 * Change Logs:
77 * Date Author Notes
88 * 2015-01-28 Bernard first version
9+ * 2021-11-13 Meco Man implement no-heap warning
910 */
1011#include <rtthread.h>
12+ #include <stddef.h>
1113
12- #ifdef RT_USING_HEAP
13- void * malloc (rt_size_t n )
14+ #ifndef RT_USING_HEAP
15+ #define DBG_TAG "dlib.syscall_mem"
16+ #define DBG_LVL DBG_INFO
17+ #include <rtdbg.h>
18+ #define _NO_HEAP_ERROR () do{LOG_E("Please enable RT_USING_HEAP");\
19+ RT_ASSERT(0);\
20+ }while(0)
21+ #endif /* RT_USING_HEAP */
22+
23+ void * malloc (size_t n )
1424{
25+ #ifdef RT_USING_HEAP
1526 return rt_malloc (n );
27+ #else
28+ _NO_HEAP_ERROR ();
29+ return RT_NULL ;
30+ #endif
1631}
1732
18- void * realloc (void * rmem , rt_size_t newsize )
33+ void * realloc (void * rmem , size_t newsize )
1934{
35+ #ifdef RT_USING_HEAP
2036 return rt_realloc (rmem , newsize );
37+ #else
38+ _NO_HEAP_ERROR ();
39+ return RT_NULL ;
40+ #endif
2141}
2242
23- void * calloc (rt_size_t nelem , rt_size_t elsize )
43+ void * calloc (size_t nelem , size_t elsize )
2444{
45+ #ifdef RT_USING_HEAP
2546 return rt_calloc (nelem , elsize );
47+ #else
48+ _NO_HEAP_ERROR ();
49+ return RT_NULL ;
50+ #endif
2651}
2752
2853void free (void * rmem )
2954{
55+ #ifdef RT_USING_HEAP
3056 rt_free (rmem );
31- }
57+ #else
58+ _NO_HEAP_ERROR ();
3259#endif
60+ }
Original file line number Diff line number Diff line change 1515#include "libc.h"
1616#endif
1717
18- #define DBG_TAG "IAR. dlib.syscall_write"
18+ #define DBG_TAG "dlib.syscall_write"
1919#define DBG_LVL DBG_INFO
2020#include <rtdbg.h>
2121
You can’t perform that action at this time.
0 commit comments