Browse Source

Merge pull request #4061 from yangjie11/malloc

[src][SConscript] Provide user heap options
Bernard Xiong 4 years ago
parent
commit
4fc7fbbd35
2 changed files with 16 additions and 1 deletions
  1. 13 1
      src/Kconfig
  2. 3 0
      src/SConscript

+ 13 - 1
src/Kconfig

@@ -270,6 +270,18 @@ menu "Memory Management"
         config RT_USING_MEMHEAP_AS_HEAP
         config RT_USING_MEMHEAP_AS_HEAP
             bool "Use all of memheap objects as heap"
             bool "Use all of memheap objects as heap"
         endif
         endif
+
+        config RT_USING_USERHEAP
+            bool "Use user heap"
+            help
+                If this option is selected, please implement these functions:
+                    rt_malloc(), rt_malloc_sethook()
+                    rt_free(),   rt_free_sethook()
+                    rt_calloc(), rt_realloc()
+                    rt_system_heap_init()
+
+                And if FinSH is used at the same time, please implement list_mem()
+
     endchoice
     endchoice
 
 
     if RT_USING_SMALL_MEM
     if RT_USING_SMALL_MEM
@@ -294,7 +306,7 @@ menu "Memory Management"
         default y if RT_USING_SMALL_MEM
         default y if RT_USING_SMALL_MEM
         default y if RT_USING_SLAB
         default y if RT_USING_SLAB
         default y if RT_USING_MEMHEAP_AS_HEAP
         default y if RT_USING_MEMHEAP_AS_HEAP
-
+        default y if RT_USING_USERHEAP
 endmenu
 endmenu
 
 
 menu "Kernel Device Object"
 menu "Kernel Device Object"

+ 3 - 0
src/SConscript

@@ -23,6 +23,9 @@ if GetDepend('RT_USING_MEMHEAP') == False:
     if GetDepend('RT_USING_MEMHEAP_AS_HEAP'):
     if GetDepend('RT_USING_MEMHEAP_AS_HEAP'):
         SrcRemove(src, ['mem.c'])
         SrcRemove(src, ['mem.c'])
 
 
+if GetDepend('RT_USING_USERHEAP'):
+    SrcRemove(src, ['mem.c', 'slab.c'])
+
 if GetDepend('RT_USING_DEVICE') == False:
 if GetDepend('RT_USING_DEVICE') == False:
     SrcRemove(src, ['device.c'])
     SrcRemove(src, ['device.c'])