changeset 3879:02cddc7bd568

removed mutek/memory_allocator.h
author Alexandre Becoulet <alexandre.becoulet@free.fr>
date Mon, 09 Apr 2018 11:53:08 +0200
parents 9155ecf8dd07
children f6cd57f38a00
files arch/atmel/arch_init.c arch/bcm283x/arch_init.c arch/cc26xx/ti_init.c arch/emu/arch_init.c arch/ibmpc/arch_init.c arch/nrf5x/arch_init.c arch/pic32/arch_init.c arch/soclib/arch_init.c mutek/include/mutek/mem_alloc.h mutek/include/mutek/mem_region.h mutek/include/mutek/memory_allocator.h mutek/mem_region.c mutek/memory_allocator_simple.c mutek/memory_allocator_smart.c tests/pool/hello/custom_mem_init.c tests/pool/libpthread_cancel_stress/custom_mem_init.c tests/pool/malloc_stress/test
diffstat 17 files changed, 82 insertions(+), 118 deletions(-) [+]
line wrap: on
line diff
--- a/arch/atmel/arch_init.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/arch/atmel/arch_init.c	Mon Apr 09 11:53:08 2018 +0200
@@ -25,7 +25,7 @@
 #include <string.h>
 
 #include <mutek/mem_alloc.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 
 void atmel_mem_init()
 {
--- a/arch/bcm283x/arch_init.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/arch/bcm283x/arch_init.c	Mon Apr 09 11:53:08 2018 +0200
@@ -24,7 +24,7 @@
 /////////////////////////////////////////////////////////////////////
 
 #include <mutek/mem_alloc.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 #include <mutek/startup.h>
 
 void bcm283x_mem_init(void)
--- a/arch/cc26xx/ti_init.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/arch/cc26xx/ti_init.c	Mon Apr 09 11:53:08 2018 +0200
@@ -3,7 +3,7 @@
 #include <string.h>
 
 #include <mutek/mem_alloc.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 
 #include <hexo/iospace.h>
 
--- a/arch/emu/arch_init.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/arch/emu/arch_init.c	Mon Apr 09 11:53:08 2018 +0200
@@ -56,7 +56,7 @@
 
 #include <mutek/mem_alloc.h>
 #include <mutek/mem_region.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 
 void emu_mem_init(void)
 {
--- a/arch/ibmpc/arch_init.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/arch/ibmpc/arch_init.c	Mon Apr 09 11:53:08 2018 +0200
@@ -50,7 +50,7 @@
 
 #include <mutek/mem_alloc.h>
 #include <mutek/mem_region.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 
 void ibmpc_mem_init()
 {
--- a/arch/nrf5x/arch_init.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/arch/nrf5x/arch_init.c	Mon Apr 09 11:53:08 2018 +0200
@@ -23,7 +23,7 @@
 #include <string.h>
 
 #include <mutek/mem_alloc.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 #include <hexo/flash.h>
 
 #include <arch/nrf5x/nvmc.h>
--- a/arch/pic32/arch_init.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/arch/pic32/arch_init.c	Mon Apr 09 11:53:08 2018 +0200
@@ -28,7 +28,7 @@
 #include <hexo/iospace.h>
 
 #include <mutek/mem_alloc.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 #include <mutek/printk.h>
 #include <mutek/startup.h>
 
--- a/arch/soclib/arch_init.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/arch/soclib/arch_init.c	Mon Apr 09 11:53:08 2018 +0200
@@ -88,7 +88,7 @@
 
 #include <mutek/mem_alloc.h>
 #include <mutek/mem_region.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 
 void soclib_mem_init()
 {
--- a/mutek/include/mutek/mem_alloc.h	Fri Apr 06 13:18:25 2018 +0200
+++ b/mutek/include/mutek/mem_alloc.h	Mon Apr 09 11:53:08 2018 +0200
@@ -23,7 +23,7 @@
 /**
  * @file
  * @module {Core::Kernel services}
- * @short High level memory allocation stuff
+ * @short Memory allocation stuff
  */
 
 
@@ -33,7 +33,50 @@
 #include <hexo/types.h>
 #include <hexo/error.h>
 #include <hexo/lock.h>
-#include <mutek/memory_allocator.h>
+
+struct memory_allocator_region_s;
+
+/** @internal */
+extern struct memory_allocator_region_s *default_region;
+
+/** @internal @this initialize a memory region*/
+struct memory_allocator_region_s *
+memory_allocator_init(struct memory_allocator_region_s *container_region, void *start, void *end);
+
+/** @internal @this extend an existing memory region with a new memory space */
+struct memory_allocator_header_s *
+memory_allocator_extend(struct memory_allocator_region_s *region, void *start, size_t size);
+
+/** @internal @this resize the given memory block */
+void *memory_allocator_resize(void *address, size_t size);
+
+/** @internal @this allocate a new memory block in given region */
+void *memory_allocator_pop(struct memory_allocator_region_s *region, size_t size, size_t align);
+
+/** @internal @this free allocated memory block */
+void memory_allocator_push(void *address);
+
+/** @internal @this reserve a memory space in given region */
+void *memory_allocator_reserve(struct memory_allocator_region_s *region, void *start, size_t size);
+
+/** @internal @this return the size of given memory block */
+size_t memory_allocator_getsize(void *ptr);
+
+/** @internal @this return statistic of memory region use */
+error_t memory_allocator_stats(struct memory_allocator_region_s *region,
+			size_t *alloc_blocks,
+			size_t *free_size,
+			size_t *free_blocks);
+
+/** @internal @this make memory region check depending to activated token: guard zone, headers' integrity (crc and size) 
+    and if free space was used */
+void memory_allocator_region_check(struct memory_allocator_region_s *region);
+
+/** @internal @this return the size of given memory region */
+size_t memory_allocator_region_size(struct memory_allocator_region_s *region);
+
+/** @internal @this return the size of given memory region */
+void* memory_allocator_region_address(struct memory_allocator_region_s *region);
 
 #if defined(CONFIG_MUTEK_MEM_REGION)
 #include <mutek/mem_region.h>
@@ -55,18 +98,19 @@
     @see #CONFIG_MUTEK_MEMALLOC_SCRAMBLE
     @see #CONFIG_MUTEK_MEMALLOC_STATS
 */
-ALWAYS_INLINE
-void mem_check(void)
+config_depend_alwaysinline(CONFIG_MUTEK_MEMALLOC,
+void mem_check(void),
 {
   memory_allocator_region_check(default_region);
-}
+});
 
 /** @this allocates a new memory block in given scope with specified
     alignment constraint. 
     @see #CONFIG_MUTEK_MEMALLOC_ALIGN
 */
-inline void *
-mem_alloc_align(size_t size, size_t align, enum mem_scope_e scope)
+config_depend_inline(CONFIG_MUTEK_MEMALLOC,
+void *
+mem_alloc_align(size_t size, size_t align, enum mem_scope_e scope),
 {
   if (size == 0) 
     return NULL;
@@ -95,18 +139,19 @@
 # endif
 
   return ptr;
-}
+});
 
 /** @This allocates a new memory block in given scope. */
-ALWAYS_INLINE
-void *mem_alloc(size_t size, enum mem_scope_e scope)
+config_depend_alwaysinline(CONFIG_MUTEK_MEMALLOC,
+void *mem_alloc(size_t size, enum mem_scope_e scope),
 {
   return mem_alloc_align(size, 1, scope);
-}
+});
 
 /** @This allocate a new memory block for another cpu in given scope*/
-inline void *
-mem_alloc_cpu(size_t size, enum mem_scope_e scope, cpu_id_t cpu_id)
+config_depend_inline(CONFIG_MUTEK_MEMALLOC,
+void *
+mem_alloc_cpu(size_t size, enum mem_scope_e scope, cpu_id_t cpu_id),
 {
   if (size == 0)
     return NULL;
@@ -135,30 +180,30 @@
 # endif
 
   return ptr;
-}
+});
 
 /** @This frees allocated memory block */
-inline
-void mem_free(void *ptr)
+config_depend_inline(CONFIG_MUTEK_MEMALLOC,
+void mem_free(void *ptr),
 {
   memory_allocator_push(ptr);
-}
+});
 
 /** @This returns the size of given memory block */
-ALWAYS_INLINE
-size_t mem_getsize(void *ptr)
+config_depend_alwaysinline(CONFIG_MUTEK_MEMALLOC_SMART,
+size_t mem_getsize(void *ptr),
 {
   return memory_allocator_getsize(ptr);
-}
+});
 
 /** @This resizes the given memory block, return NULL if failed. The
     allocated memory block is not moved; if not enough free memory
     blocks are available next to allocated memory, this function
     fails. */
-ALWAYS_INLINE
-void *mem_resize(void *ptr, size_t size)
+config_depend_alwaysinline(CONFIG_MUTEK_MEMALLOC_SMART,
+void *mem_resize(void *ptr, size_t size),
 {
   return memory_allocator_resize(ptr, size);
-}
+});
 
 #endif
--- a/mutek/include/mutek/mem_region.h	Fri Apr 06 13:18:25 2018 +0200
+++ b/mutek/include/mutek/mem_region.h	Mon Apr 09 11:53:08 2018 +0200
@@ -30,7 +30,7 @@
 #define MEM_REGION_H_
 
 #include <mutek/mem_alloc.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 
 #include <gct_platform.h>
 #include <gct_lock_hexo_lock_irq.h>
--- a/mutek/include/mutek/memory_allocator.h	Fri Apr 06 13:18:25 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
-    This file is part of MutekH.
-    
-    MutekH is free software; you can redistribute it and/or modify it
-    under the terms of the GNU Lesser General Public License as
-    published by the Free Software Foundation; version 2.1 of the
-    License.
-    
-    MutekH is distributed in the hope that it will be useful, but
-    WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-    
-    You should have received a copy of the GNU Lesser General Public
-    License along with MutekH; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-    02110-1301 USA.
-
-    Copyright Alexandre Becoulet <alexandre.becoulet@lip6.fr> (c) 2006
-    Copyright Dimitri Refauvelet <dimitri.refauvelet@lip6.fr> (c) 2009
-*/
-
-/**
- * @file
- * @module {Core::Kernel services}
- * @short Memory allocation stuff
- */
-
-
-#ifndef MEMORY_ALLOCATOR_H_ 
-#define MEMORY_ALLOCATOR_H_
-
-#include <hexo/types.h>
-#include <hexo/error.h>
-#include <hexo/lock.h>
-
-struct memory_allocator_region_s;
-
-extern struct memory_allocator_region_s *default_region;
-
-/** @this initialize a memory region*/
-struct memory_allocator_region_s *
-memory_allocator_init(struct memory_allocator_region_s *container_region, void *start, void *end);
-
-/** @this extend an existing memory region with a new memory space */
-struct memory_allocator_header_s *
-memory_allocator_extend(struct memory_allocator_region_s *region, void *start, size_t size);
-
-/** @this resize the given memory block */
-void *memory_allocator_resize(void *address, size_t size);
-
-/** @this allocate a new memory block in given region */
-void *memory_allocator_pop(struct memory_allocator_region_s *region, size_t size, size_t align);
-
-/** @this free allocated memory block */
-void memory_allocator_push(void *address);
-
-/** @this reserve a memory space in given region */
-void *memory_allocator_reserve(struct memory_allocator_region_s *region, void *start, size_t size);
-
-/** @this return the size of given memory block */
-size_t memory_allocator_getsize(void *ptr);
-
-/** @this return statistic of memory region use */
-error_t memory_allocator_stats(struct memory_allocator_region_s *region,
-			size_t *alloc_blocks,
-			size_t *free_size,
-			size_t *free_blocks);
-
-/** @this make memory region check depending to activated token: guard zone, headers' integrity (crc and size) 
-    and if free space was used */
-void memory_allocator_region_check(struct memory_allocator_region_s *region);
-
-/** @this return the size of given memory region */
-size_t memory_allocator_region_size(struct memory_allocator_region_s *region);
-
-/** @this return the size of given memory region */
-void* memory_allocator_region_address(struct memory_allocator_region_s *region);
-
-#endif
--- a/mutek/mem_region.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/mutek/mem_region.c	Mon Apr 09 11:53:08 2018 +0200
@@ -20,7 +20,7 @@
 */
 
 #include <mutek/mem_alloc.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 #include <mutek/mem_region.h>
 
 #include <mutek/printk.h>
--- a/mutek/memory_allocator_simple.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/mutek/memory_allocator_simple.c	Mon Apr 09 11:53:08 2018 +0200
@@ -20,7 +20,7 @@
               Dimitri Refauvelet <dimitri.refauvelet@lip6.fr> (c) 2009
 */
 
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 #include <string.h>
 #include <hexo/bit.h>
 
--- a/mutek/memory_allocator_smart.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/mutek/memory_allocator_smart.c	Mon Apr 09 11:53:08 2018 +0200
@@ -20,7 +20,7 @@
               Dimitri Refauvelet <dimitri.refauvelet@lip6.fr> (c) 2009
 */
 
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 #include <string.h>
 #include <hexo/types.h>
 #include <hexo/lock.h>
--- a/tests/pool/hello/custom_mem_init.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/tests/pool/hello/custom_mem_init.c	Mon Apr 09 11:53:08 2018 +0200
@@ -1,6 +1,6 @@
 #include <mutek/mem_alloc.h>
 #include <mutek/mem_region.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 
 extern __ldscript_symbol_t __system_uncached_heap_start, __system_uncached_heap_end;
 
--- a/tests/pool/libpthread_cancel_stress/custom_mem_init.c	Fri Apr 06 13:18:25 2018 +0200
+++ b/tests/pool/libpthread_cancel_stress/custom_mem_init.c	Mon Apr 09 11:53:08 2018 +0200
@@ -1,6 +1,6 @@
 #include <mutek/mem_alloc.h>
 #include <mutek/mem_region.h>
-#include <mutek/memory_allocator.h>
+#include <mutek/mem_alloc.h>
 
 extern __ldscript_symbol_t __system_uncached_heap_start, __system_uncached_heap_end;
 
--- a/tests/pool/malloc_stress/test	Fri Apr 06 13:18:25 2018 +0200
+++ b/tests/pool/malloc_stress/test	Mon Apr 09 11:53:08 2018 +0200
@@ -19,7 +19,6 @@
     "mutek/memory_allocator_simple.c",
     "mutek/mem_alloc.c",
     "mutek/include/mutek/mem_alloc.h",
-    "mutek/include/mutek/memory_allocator.h"
 ]
 
 env_list = [