diff options
author | Alan Korr <alkorr@rockbox.org> | 2002-04-16 18:37:44 +0000 |
---|---|---|
committer | Alan Korr <alkorr@rockbox.org> | 2002-04-16 18:37:44 +0000 |
commit | 223884c4e5f14c6ed1fc2f536bd9250984a6a0d6 (patch) | |
tree | 0ab00dfa4e6a6a80b57272545c79d83780377912 /firmware/test/memory | |
parent | 464a26d8913ba43d8bc6f71c1fbb9d9971628457 (diff) | |
download | rockbox-223884c4e5f14c6ed1fc2f536bd9250984a6a0d6.tar.gz rockbox-223884c4e5f14c6ed1fc2f536bd9250984a6a0d6.zip |
There is two part in this module :
* memory-page :
It is a page allocator using bins. Each bin is a list (or a splay tree)
of the same power-of-2 pages. If no page left in a bin, it tries to
allocate a large page to split into two pages. Page size are :
512 B, 1 KB, 2 KB, 4 KB, 8 KB, 16 KB, 32 KB, 64 KB, 128 KB,
256 KB, 512 KB, 1 MB and 2 MB. Alignment of a page is the same
value than for its size.
* memory-slab :
using slab for smaller blocks, but much simpler than Linux' slab.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@106 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/test/memory')
-rw-r--r-- | firmware/test/memory/makefile | 176 | ||||
-rw-r--r-- | firmware/test/memory/memory.h | 12 | ||||
-rw-r--r-- | firmware/test/memory/test.y | 2 | ||||
-rw-r--r-- | firmware/test/memory/types.h | 4 |
4 files changed, 12 insertions, 182 deletions
diff --git a/firmware/test/memory/makefile b/firmware/test/memory/makefile index 2259cdfce7..2c14b7d0bd 100644 --- a/firmware/test/memory/makefile +++ b/firmware/test/memory/makefile | |||
@@ -16,178 +16,8 @@ | |||
16 | ## This software is provided "as is" without express or implied warranty. | 16 | ## This software is provided "as is" without express or implied warranty. |
17 | ############################################################################# | 17 | ############################################################################# |
18 | ARCH = test | 18 | ARCH = test |
19 | |||
20 | CC = gcc | ||
21 | AS = as | ||
22 | LD = ld | ||
23 | AR = ar | ||
24 | RL = ranlib | ||
25 | OC = objcopy | ||
26 | GZ = gzip -f | ||
27 | |||
28 | PREFIX = ~/rockbox/$(ARCH) | ||
29 | PACKAGE = memory | 19 | PACKAGE = memory |
30 | VERSION = 0.1 | 20 | VERSION = 0.1.0 |
31 | DEFINES = -DTEST | 21 | -include ../makefile-vars |
32 | 22 | -include ../makefile-rules | |
33 | #####################################################" | ||
34 | # Compiler flags : | ||
35 | |||
36 | CFLAGS = -g | ||
37 | #CFLAGS += -save-temps | ||
38 | CFLAGS += -Wall \ | ||
39 | -W \ | ||
40 | -Wshadow \ | ||
41 | -Wpointer-arith \ | ||
42 | -Waggregate-return \ | ||
43 | -Wstrict-prototypes \ | ||
44 | -Wredundant-decls \ | ||
45 | -Winline \ | ||
46 | -Wmissing-prototypes \ | ||
47 | -Werror \ | ||
48 | -Wsign-compare \ | ||
49 | -Wmissing-declarations \ | ||
50 | -Wmissing-noreturns \ | ||
51 | -Wnested-externs | ||
52 | CFLAGS += -pipe -O3 | ||
53 | CFLAGS += -fomit-frame-pointer \ | ||
54 | -fschedule-insns | ||
55 | CFLAGS += $(EXTRA_CFLAGS) | ||
56 | CFLAGS += $(DEFINES) | ||
57 | |||
58 | ####################################################################### | ||
59 | ## PLEASE CONSIDER THERE IS NOTHING TO CHANGE IN THE FOLLOWING LINES | ||
60 | ## SINCE THERE ARE COMMON FOR ALL LIBRARY | ||
61 | ## | ||
62 | |||
63 | .SUFFIXES : .o .c .s | ||
64 | |||
65 | INCLUDES = -I. \ | ||
66 | -I$(PREFIX)/headers | ||
67 | |||
68 | STATIC_LIBRARY_PATH = $(PREFIX)/libraries | ||
69 | |||
70 | LIBRARY = lib$(PACKAGE).a | ||
71 | |||
72 | ####################################################################### | ||
73 | ## PLEASE CHANGE ONLY THE FOLLOWING LINES | ||
74 | ## | ||
75 | |||
76 | LIBS = | ||
77 | |||
78 | HEADERS = $(PACKAGE).h \ | ||
79 | config.h \ | ||
80 | defines.h \ | ||
81 | types.h \ | ||
82 | return_values.h \ | ||
83 | inlines.h \ | ||
84 | functions.h | ||
85 | |||
86 | SOURCES = $(PACKAGE)-page.c \ | ||
87 | $(PACKAGE)-slab.c | ||
88 | |||
89 | OBJECTS = $(SOURCES:.c=.o) | ||
90 | |||
91 | DEPENDENCIES = $(SOURCES:.c=.d) | ||
92 | |||
93 | HEADER_PATH = $(PREFIX)/headers/$(PACKAGE)/. | ||
94 | |||
95 | ####################################################################### | ||
96 | ## PLEASE CONSIDER THERE IS NOTHING TO CHANGE IN THE FOLLOWING LINES | ||
97 | ## SINCE THERE ARE COMMON FOR ALL LIBRARY | ||
98 | ## | ||
99 | |||
100 | %.o: %.c | ||
101 | @echo "Compiling" $<... | ||
102 | @$(CC) -o $(@) $(CFLAGS) $(INCLUDES) -c $< | ||
103 | @$(CC) -M $< $(CFLAGS) $(INCLUDES) > $(*F).d | ||
104 | |||
105 | %.o: %.s | ||
106 | @echo "Assembling" $<... | ||
107 | @$(CC) -o $(@) $(CFLAGS) $(INCLUDES) -c $< | ||
108 | @$(CC) -M $< $(CFLAGS) $(INCLUDES) > $(*F).d | ||
109 | |||
110 | .PHONY: splash all clean backup restore dist install | ||
111 | |||
112 | all: splash $(LIBRARY) test | ||
113 | |||
114 | splash: | ||
115 | @echo "<<< " $(PACKAGE) "-" $(VERSION) ">>>" | ||
116 | |||
117 | #################################################### | ||
118 | # LIBRAY PART : | ||
119 | |||
120 | $(LIBRARY): $(OBJECTS) | ||
121 | @echo "Creating library" $(LIBRARY)... | ||
122 | @$(AR) cru $(@) $(OBJECTS) | ||
123 | @$(RL) $(@) | ||
124 | |||
125 | |||
126 | #################################################### | ||
127 | # TEST PART : | ||
128 | |||
129 | test: test.tab.o test.lex.o $(LIBRARY) | ||
130 | @echo "Creating executable" $@... | ||
131 | @$(CC) $(INCLUDES) -g -o $(@) $(+) -lfl -lreadline | ||
132 | |||
133 | test.tab.o: test.tab.c | ||
134 | @echo "Compiling" $<... | ||
135 | @$(CC) -I. -g -o $(@) -O3 -fomit-frame-pointer -c test.tab.c | ||
136 | |||
137 | test.lex.o: test.lex.c | ||
138 | @echo "Compiling" $<... | ||
139 | @$(CC) -I. -g -o $(@) -O3 -fomit-frame-pointer -c test.lex.c | ||
140 | |||
141 | test.tab.h: test.tab.c | ||
142 | |||
143 | test.lex.c: test.l test.tab.h | ||
144 | @echo "Flex:" $< | ||
145 | @flex -otest.lex.c test.l | ||
146 | |||
147 | test.tab.c: test.y | ||
148 | @echo "Bison:" $< | ||
149 | @bison -d test.y | ||
150 | |||
151 | |||
152 | #################################################### | ||
153 | # MISCELLANOUS PART : | ||
154 | |||
155 | clean: | ||
156 | @rm -f $(LIBRARY) | ||
157 | @rm -f $(OBJECTS) test.lex.o test.tab.o | ||
158 | @rm -f $(DEPENDENCIES) | ||
159 | @rm -f *~ test test.exe | ||
160 | @rm -f test.tab.h test.tab.c test.lex.c | ||
161 | @rm -f core | ||
162 | |||
163 | backup: | ||
164 | @mkdir -p ./backup | ||
165 | @cp -f makefile ./backup | ||
166 | @cp -f test.l ./backup | ||
167 | @cp -f test.y ./backup | ||
168 | @cp -f $(SOURCES:.c=.txt) ./backup | ||
169 | @for header in $(HEADERS) ; do cp -f $$header ./backup ; done | ||
170 | @for source in $(SOURCES) ; do cp -f $$source ./backup ; done | ||
171 | |||
172 | restore: | ||
173 | @cp -f ./backup/makefile . | ||
174 | @cp -f ./backup/test.l . | ||
175 | @cp -f ./backup/test.y . | ||
176 | @cp -f ./backup/$(SOURCES:.c=.txt) | ||
177 | @for header in $(HEADERS) ; do cp -f ./backup/$$header . ; done | ||
178 | @for source in $(SOURCES) ; do cp -f ./backup/$$source . ; done | ||
179 | |||
180 | dist: backup | ||
181 | @mv backup $(PACKAGE) | ||
182 | @tar czvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)/* | ||
183 | @rm -f $(PACKAGE)/* | ||
184 | @rmdir $(PACKAGE) | ||
185 | |||
186 | install: all | ||
187 | @mkdir -p $(PREFIX)/libraries | ||
188 | @cp $(LIBRARY) $(PREFIX)/libraries | ||
189 | @mkdir -p $(PREFIX)/headers/$(PACKAGE) | ||
190 | @for header in $(HEADERS) ; do cp $$header $(PREFIX)/headers/$(PACKAGE) ; done | ||
191 | |||
192 | -include $(DEPENDENCIES) | ||
193 | 23 | ||
diff --git a/firmware/test/memory/memory.h b/firmware/test/memory/memory.h index 881cb509bc..fde6ac3ad1 100644 --- a/firmware/test/memory/memory.h +++ b/firmware/test/memory/memory.h | |||
@@ -18,10 +18,10 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #ifndef __LIBRARY_MEMORY_H__ | 19 | #ifndef __LIBRARY_MEMORY_H__ |
20 | # define __LIBRARY_MEMORY_H__ | 20 | # define __LIBRARY_MEMORY_H__ |
21 | # include <config.h> | 21 | # include <memory/config.h> |
22 | # include <defines.h> | 22 | # include <memory/defines.h> |
23 | # include <types.h> | 23 | # include <memory/types.h> |
24 | # include <return_values.h> | 24 | # include <memory/return_values.h> |
25 | # include <inlines.h> | 25 | # include <memory/inlines.h> |
26 | # include <functions.h> | 26 | # include <memory/functions.h> |
27 | #endif | 27 | #endif |
diff --git a/firmware/test/memory/test.y b/firmware/test/memory/test.y index 1c368a1ebb..481339b31b 100644 --- a/firmware/test/memory/test.y +++ b/firmware/test/memory/test.y | |||
@@ -1,5 +1,5 @@ | |||
1 | %{ | 1 | %{ |
2 | #include <memory.h> | 2 | #include "memory.h" |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <stdio.h> | 4 | #include <stdio.h> |
5 | #include <string.h> | 5 | #include <string.h> |
diff --git a/firmware/test/memory/types.h b/firmware/test/memory/types.h index 05e97b6b26..09e38682f7 100644 --- a/firmware/test/memory/types.h +++ b/firmware/test/memory/types.h | |||
@@ -17,10 +17,10 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #ifndef __LIBRARY_MEMORY_H__ | 19 | #ifndef __LIBRARY_MEMORY_H__ |
20 | #error "This header file must be included ONLY from memory.h." | 20 | # error "This header file must be included ONLY from memory.h." |
21 | #endif | 21 | #endif |
22 | #ifndef __LIBRARY_MEMORY_TYPES_H__ | 22 | #ifndef __LIBRARY_MEMORY_TYPES_H__ |
23 | #define __LIBRARY_MEMORY_TYPES_H__ | 23 | # define __LIBRARY_MEMORY_TYPES_H__ |
24 | 24 | ||
25 | struct memory_free_page | 25 | struct memory_free_page |
26 | { | 26 | { |