diff options
Diffstat (limited to 'firmware/test/memory/memory-block.c')
-rw-r--r-- | firmware/test/memory/memory-block.c | 25 |
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 | ||
25 | static struct memory_cache *free_block_cache[MEMORY_PAGE_MINIMAL_ORDER - 2]; | 24 | static 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 | ||
35 | static inline void *allocate_small_block (int order) | 34 | static 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 | ||
58 | static inline int release_block (int order,void *address) | 57 | static 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; |