changeset 2445:6ae04ddf9b8e

* cdl/memalloc.cdl: Added option CYGBLD_MEMALLOC_MALLOC_EXTERNAL_JOIN_H to let applications implement a way to pick the pool to allocate memory from based on an application specific heuristic. * src/malloc.cxx: Use it.
author jlarmour
date Mon, 05 Nov 2007 12:38:19 +0000
parents b717ff319fe2
children a72554718436
files packages/services/memalloc/common/current/ChangeLog packages/services/memalloc/common/current/cdl/memalloc.cdl packages/services/memalloc/common/current/src/malloc.cxx
diffstat 3 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/packages/services/memalloc/common/current/ChangeLog
+++ b/packages/services/memalloc/common/current/ChangeLog
@@ -1,3 +1,10 @@
+2007-11-05  Oyvind Harboe <oyvind.harboe@zylin.com>
+	
+	* cdl/memalloc.cdl: Added option CYGBLD_MEMALLOC_MALLOC_EXTERNAL_JOIN_H
+	to let applications implement a way to pick the pool to allocate memory
+	from based on an application specific heuristic.
+	* src/malloc.cxx: Use it.
+	
 2007-10-24  Oyvind Harboe <oyvind.harboe@zylin.com>
 2007-10-24  Jonathan Larmour  <jifl@eCosCentric.com>
 
--- a/packages/services/memalloc/common/current/cdl/memalloc.cdl
+++ b/packages/services/memalloc/common/current/cdl/memalloc.cdl
@@ -305,6 +305,20 @@ cdl_package CYGPKG_MEMALLOC {
                            be set to a header which provides the equivalent
                            definitions to <pkgconf/heaps.hxx>."
         }
+        
+        cdl_component CYGBLD_MEMALLOC_MALLOC_EXTERNAL_JOIN_H {
+            display       "Use external implementation of joining multiple heaps"
+            flavor        booldata
+            default_value 0
+            description   "The default implementation of joining multiple heaps
+                           is fine for the case where there are multiple disjoint
+                           memory regions of the same type. However, in a system
+                           there might be e.g. a small amount of internal SRAM and
+                           a large amount of external DRAM. The SRAM is faster and
+                           the DRAM is slower. An application can implement some 
+                           heuristic to choose which pool to allocate from. This
+                           heuristic can be highly application specific."
+        }
 
         cdl_interface CYGINT_MEMALLOC_MALLOC_ALLOCATORS {
             display       "malloc() allocator implementations"
--- a/packages/services/memalloc/common/current/src/malloc.cxx
+++ b/packages/services/memalloc/common/current/src/malloc.cxx
@@ -99,8 +99,11 @@ CYGCLS_MEMALLOC_MALLOC_IMPL cyg_memalloc
 
 #else 
 // multiple heaps
-
+#ifdef CYGBLD_MEMALLOC_MALLOC_EXTERNAL_JOIN_H
+# include CYGBLD_MEMALLOC_MALLOC_EXTERNAL_JOIN_H
+#else
 # include <cyg/memalloc/memjoin.hxx>
+#endif
 
 Cyg_Mempool_Joined<CYGCLS_MEMALLOC_MALLOC_IMPL> cyg_memalloc_mallocpool
    CYGBLD_ATTRIB_INIT_PRI( CYG_INIT_MEMALLOC ) =