summaryrefslogtreecommitdiff
path: root/firmware/test/memory/memory-block.c
diff options
context:
space:
mode:
authorAlan Korr <alkorr@rockbox.org>2002-04-17 15:00:28 +0000
committerAlan Korr <alkorr@rockbox.org>2002-04-17 15:00:28 +0000
commitc25510f944553681d7898e5b9d8e132f6e3c431b (patch)
tree5665e58628f634374dada65da74b5b854a6e70b4 /firmware/test/memory/memory-block.c
parent454be44f8d0c7cc1a6f77c0e694c8a32f2cd6099 (diff)
downloadrockbox-c25510f944553681d7898e5b9d8e132f6e3c431b.tar.gz
rockbox-c25510f944553681d7898e5b9d8e132f6e3c431b.zip
Now memory-page and memory-misc compile fine (others are in stage-development)
Conventions : * Public headers : memory.h,config.h,defines.h,inlines.h,types.h,functions.h * Private headers : memory-page.h,memory-slab.h (here you can find prototypes functions or structures we want to share only between memory-page.c, memory-slab.c, memory-block.c, memory-misc.c). * Public or private codes in : memory-page.c,memory-slab.c,memory-block.c,memory-misc.c git-svn-id: svn://svn.rockbox.org/rockbox/trunk@126 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/test/memory/memory-block.c')
-rw-r--r--firmware/test/memory/memory-block.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/firmware/test/memory/memory-block.c b/firmware/test/memory/memory-block.c
index e4ffbfaf73..c5cf3ce9f8 100644
--- a/firmware/test/memory/memory-block.c
+++ b/firmware/test/memory/memory-block.c
@@ -16,13 +16,12 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19#ifndef __LIBRARY_MEMORY_C__ 19#if 0
20# error "This header file must be included ONLY from memory.c." 20#include <memory.h>
21#endif 21#include "memory-page.h"
22#ifndef __LIBRARY_MEMORY_BLOCK_H__ 22#include "memory-slab.h"
23# define __LIBRARY_MEMORY_BLOCK_H__
24 23
25static struct memory_cache *free_block_cache[MEMORY_PAGE_MINIMAL_ORDER - 2]; 24static struct memory_cache *__memory_free_block_cache[MEMORY_PAGE_MINIMAL_ORDER - 2];
26 25
27/////////////////////////////////////////////////////////////////////////////// 26///////////////////////////////////////////////////////////////////////////////
28// MEMORY BLOCK : 27// MEMORY BLOCK :
@@ -32,15 +31,15 @@ static struct memory_cache *free_block_cache[MEMORY_PAGE_MINIMAL_ORDER - 2];
32// - memory_release_block : release a power-of-2-sized block (or a page) 31// - memory_release_block : release a power-of-2-sized block (or a page)
33// 32//
34 33
35static inline void *allocate_small_block (int order) 34static inline void *__memory_allocate_block (int order)
36 { 35 {
37 struct memory_cache *cache = free_block_cache[order - 2]; 36 struct memory_cache *cache = __memory_free_block_cache[order - 2];
38 do 37 do
39 { 38 {
40 if (cache) 39 if (cache)
41 return memory_cache_allocate (cache); 40 return memory_cache_allocate (cache);
42 } 41 }
43 while ((free_block_cache[order] = cache = memory_create_cache (size,0,0))); 42 while ((__memory_free_block_cache[order] = cache = memory_create_cache (size,0,0)));
44 return MEMORY_RETURN_FAILURE; 43 return MEMORY_RETURN_FAILURE;
45 } 44 }
46 45
@@ -49,15 +48,15 @@ void *memory_allocate_block (int order)
49 if (order < 2) 48 if (order < 2)
50 order = 2; 49 order = 2;
51 if (order < MEMORY_PAGE_MINIMAL_ORDER) 50 if (order < MEMORY_PAGE_MINIMAL_ORDER)
52 return allocate_small_block (order); 51 return __memory_allocate_block (order);
53 if (order < MEMORY_PAGE_MAXIMAL_ORDER) 52 if (order < MEMORY_PAGE_MAXIMAL_ORDER)
54 return memory_allocate_page (order); 53 return memory_allocate_page (order);
55 return MEMORY_RETURN_FAILURE; 54 return MEMORY_RETURN_FAILURE;
56 } 55 }
57 56
58static inline int release_block (int order,void *address) 57static inline int __memory_release_block (int order,void *address)
59 { 58 {
60 struct memory_cache *cache = free_block_cache[order - 2]; 59 struct memory_cache *cache = __memory_free_block_cache[order - 2];
61 if (cache) 60 if (cache)
62 return memory_cache_release (cache,address); 61 return memory_cache_release (cache,address);
63 return MEMORY_RETURN_FAILURE; 62 return MEMORY_RETURN_FAILURE;
@@ -68,7 +67,7 @@ int memory_release_block (int order,void *address)
68 if (order < 2) 67 if (order < 2)
69 order = 2; 68 order = 2;
70 if (order < MEMORY_PAGE_MINIMAL_ORDER) 69 if (order < MEMORY_PAGE_MINIMAL_ORDER)
71 return release_block (order); 70 return __memory_release_block (order);
72 if (order < MEMORY_PAGE_MAXIMAL_ORDER) 71 if (order < MEMORY_PAGE_MAXIMAL_ORDER)
73 return memory_release_page (address); 72 return memory_release_page (address);
74 return MEMORY_RETURN_FAILURE; 73 return MEMORY_RETURN_FAILURE;