summaryrefslogtreecommitdiff
path: root/firmware/test
diff options
context:
space:
mode:
authorAlan Korr <alkorr@rockbox.org>2002-04-16 18:37:44 +0000
committerAlan Korr <alkorr@rockbox.org>2002-04-16 18:37:44 +0000
commit223884c4e5f14c6ed1fc2f536bd9250984a6a0d6 (patch)
tree0ab00dfa4e6a6a80b57272545c79d83780377912 /firmware/test
parent464a26d8913ba43d8bc6f71c1fbb9d9971628457 (diff)
downloadrockbox-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')
-rw-r--r--firmware/test/memory/makefile176
-rw-r--r--firmware/test/memory/memory.h12
-rw-r--r--firmware/test/memory/test.y2
-rw-r--r--firmware/test/memory/types.h4
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#############################################################################
18ARCH = test 18ARCH = test
19
20CC = gcc
21AS = as
22LD = ld
23AR = ar
24RL = ranlib
25OC = objcopy
26GZ = gzip -f
27
28PREFIX = ~/rockbox/$(ARCH)
29PACKAGE = memory 19PACKAGE = memory
30VERSION = 0.1 20VERSION = 0.1.0
31DEFINES = -DTEST 21-include ../makefile-vars
32 22-include ../makefile-rules
33#####################################################"
34# Compiler flags :
35
36CFLAGS = -g
37#CFLAGS += -save-temps
38CFLAGS += -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
52CFLAGS += -pipe -O3
53CFLAGS += -fomit-frame-pointer \
54 -fschedule-insns
55CFLAGS += $(EXTRA_CFLAGS)
56CFLAGS += $(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
65INCLUDES = -I. \
66 -I$(PREFIX)/headers
67
68STATIC_LIBRARY_PATH = $(PREFIX)/libraries
69
70LIBRARY = lib$(PACKAGE).a
71
72#######################################################################
73## PLEASE CHANGE ONLY THE FOLLOWING LINES
74##
75
76LIBS =
77
78HEADERS = $(PACKAGE).h \
79 config.h \
80 defines.h \
81 types.h \
82 return_values.h \
83 inlines.h \
84 functions.h
85
86SOURCES = $(PACKAGE)-page.c \
87 $(PACKAGE)-slab.c
88
89OBJECTS = $(SOURCES:.c=.o)
90
91DEPENDENCIES = $(SOURCES:.c=.d)
92
93HEADER_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
112all: splash $(LIBRARY) test
113
114splash:
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
129test: test.tab.o test.lex.o $(LIBRARY)
130 @echo "Creating executable" $@...
131 @$(CC) $(INCLUDES) -g -o $(@) $(+) -lfl -lreadline
132
133test.tab.o: test.tab.c
134 @echo "Compiling" $<...
135 @$(CC) -I. -g -o $(@) -O3 -fomit-frame-pointer -c test.tab.c
136
137test.lex.o: test.lex.c
138 @echo "Compiling" $<...
139 @$(CC) -I. -g -o $(@) -O3 -fomit-frame-pointer -c test.lex.c
140
141test.tab.h: test.tab.c
142
143test.lex.c: test.l test.tab.h
144 @echo "Flex:" $<
145 @flex -otest.lex.c test.l
146
147test.tab.c: test.y
148 @echo "Bison:" $<
149 @bison -d test.y
150
151
152####################################################
153# MISCELLANOUS PART :
154
155clean:
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
163backup:
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
172restore:
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
180dist: backup
181 @mv backup $(PACKAGE)
182 @tar czvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)/*
183 @rm -f $(PACKAGE)/*
184 @rmdir $(PACKAGE)
185
186install: 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
25struct memory_free_page 25struct memory_free_page
26 { 26 {