mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-07 05:35:02 -05:00
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
This commit is contained in:
parent
464a26d891
commit
223884c4e5
4 changed files with 12 additions and 182 deletions
|
|
@ -16,178 +16,8 @@
|
|||
## This software is provided "as is" without express or implied warranty.
|
||||
#############################################################################
|
||||
ARCH = test
|
||||
|
||||
CC = gcc
|
||||
AS = as
|
||||
LD = ld
|
||||
AR = ar
|
||||
RL = ranlib
|
||||
OC = objcopy
|
||||
GZ = gzip -f
|
||||
|
||||
PREFIX = ~/rockbox/$(ARCH)
|
||||
PACKAGE = memory
|
||||
VERSION = 0.1
|
||||
DEFINES = -DTEST
|
||||
|
||||
#####################################################"
|
||||
# Compiler flags :
|
||||
|
||||
CFLAGS = -g
|
||||
#CFLAGS += -save-temps
|
||||
CFLAGS += -Wall \
|
||||
-W \
|
||||
-Wshadow \
|
||||
-Wpointer-arith \
|
||||
-Waggregate-return \
|
||||
-Wstrict-prototypes \
|
||||
-Wredundant-decls \
|
||||
-Winline \
|
||||
-Wmissing-prototypes \
|
||||
-Werror \
|
||||
-Wsign-compare \
|
||||
-Wmissing-declarations \
|
||||
-Wmissing-noreturns \
|
||||
-Wnested-externs
|
||||
CFLAGS += -pipe -O3
|
||||
CFLAGS += -fomit-frame-pointer \
|
||||
-fschedule-insns
|
||||
CFLAGS += $(EXTRA_CFLAGS)
|
||||
CFLAGS += $(DEFINES)
|
||||
|
||||
#######################################################################
|
||||
## PLEASE CONSIDER THERE IS NOTHING TO CHANGE IN THE FOLLOWING LINES
|
||||
## SINCE THERE ARE COMMON FOR ALL LIBRARY
|
||||
##
|
||||
|
||||
.SUFFIXES : .o .c .s
|
||||
|
||||
INCLUDES = -I. \
|
||||
-I$(PREFIX)/headers
|
||||
|
||||
STATIC_LIBRARY_PATH = $(PREFIX)/libraries
|
||||
|
||||
LIBRARY = lib$(PACKAGE).a
|
||||
|
||||
#######################################################################
|
||||
## PLEASE CHANGE ONLY THE FOLLOWING LINES
|
||||
##
|
||||
|
||||
LIBS =
|
||||
|
||||
HEADERS = $(PACKAGE).h \
|
||||
config.h \
|
||||
defines.h \
|
||||
types.h \
|
||||
return_values.h \
|
||||
inlines.h \
|
||||
functions.h
|
||||
|
||||
SOURCES = $(PACKAGE)-page.c \
|
||||
$(PACKAGE)-slab.c
|
||||
|
||||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
DEPENDENCIES = $(SOURCES:.c=.d)
|
||||
|
||||
HEADER_PATH = $(PREFIX)/headers/$(PACKAGE)/.
|
||||
|
||||
#######################################################################
|
||||
## PLEASE CONSIDER THERE IS NOTHING TO CHANGE IN THE FOLLOWING LINES
|
||||
## SINCE THERE ARE COMMON FOR ALL LIBRARY
|
||||
##
|
||||
|
||||
%.o: %.c
|
||||
@echo "Compiling" $<...
|
||||
@$(CC) -o $(@) $(CFLAGS) $(INCLUDES) -c $<
|
||||
@$(CC) -M $< $(CFLAGS) $(INCLUDES) > $(*F).d
|
||||
|
||||
%.o: %.s
|
||||
@echo "Assembling" $<...
|
||||
@$(CC) -o $(@) $(CFLAGS) $(INCLUDES) -c $<
|
||||
@$(CC) -M $< $(CFLAGS) $(INCLUDES) > $(*F).d
|
||||
|
||||
.PHONY: splash all clean backup restore dist install
|
||||
|
||||
all: splash $(LIBRARY) test
|
||||
|
||||
splash:
|
||||
@echo "<<< " $(PACKAGE) "-" $(VERSION) ">>>"
|
||||
|
||||
####################################################
|
||||
# LIBRAY PART :
|
||||
|
||||
$(LIBRARY): $(OBJECTS)
|
||||
@echo "Creating library" $(LIBRARY)...
|
||||
@$(AR) cru $(@) $(OBJECTS)
|
||||
@$(RL) $(@)
|
||||
|
||||
|
||||
####################################################
|
||||
# TEST PART :
|
||||
|
||||
test: test.tab.o test.lex.o $(LIBRARY)
|
||||
@echo "Creating executable" $@...
|
||||
@$(CC) $(INCLUDES) -g -o $(@) $(+) -lfl -lreadline
|
||||
|
||||
test.tab.o: test.tab.c
|
||||
@echo "Compiling" $<...
|
||||
@$(CC) -I. -g -o $(@) -O3 -fomit-frame-pointer -c test.tab.c
|
||||
|
||||
test.lex.o: test.lex.c
|
||||
@echo "Compiling" $<...
|
||||
@$(CC) -I. -g -o $(@) -O3 -fomit-frame-pointer -c test.lex.c
|
||||
|
||||
test.tab.h: test.tab.c
|
||||
|
||||
test.lex.c: test.l test.tab.h
|
||||
@echo "Flex:" $<
|
||||
@flex -otest.lex.c test.l
|
||||
|
||||
test.tab.c: test.y
|
||||
@echo "Bison:" $<
|
||||
@bison -d test.y
|
||||
|
||||
|
||||
####################################################
|
||||
# MISCELLANOUS PART :
|
||||
|
||||
clean:
|
||||
@rm -f $(LIBRARY)
|
||||
@rm -f $(OBJECTS) test.lex.o test.tab.o
|
||||
@rm -f $(DEPENDENCIES)
|
||||
@rm -f *~ test test.exe
|
||||
@rm -f test.tab.h test.tab.c test.lex.c
|
||||
@rm -f core
|
||||
|
||||
backup:
|
||||
@mkdir -p ./backup
|
||||
@cp -f makefile ./backup
|
||||
@cp -f test.l ./backup
|
||||
@cp -f test.y ./backup
|
||||
@cp -f $(SOURCES:.c=.txt) ./backup
|
||||
@for header in $(HEADERS) ; do cp -f $$header ./backup ; done
|
||||
@for source in $(SOURCES) ; do cp -f $$source ./backup ; done
|
||||
|
||||
restore:
|
||||
@cp -f ./backup/makefile .
|
||||
@cp -f ./backup/test.l .
|
||||
@cp -f ./backup/test.y .
|
||||
@cp -f ./backup/$(SOURCES:.c=.txt)
|
||||
@for header in $(HEADERS) ; do cp -f ./backup/$$header . ; done
|
||||
@for source in $(SOURCES) ; do cp -f ./backup/$$source . ; done
|
||||
|
||||
dist: backup
|
||||
@mv backup $(PACKAGE)
|
||||
@tar czvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)/*
|
||||
@rm -f $(PACKAGE)/*
|
||||
@rmdir $(PACKAGE)
|
||||
|
||||
install: all
|
||||
@mkdir -p $(PREFIX)/libraries
|
||||
@cp $(LIBRARY) $(PREFIX)/libraries
|
||||
@mkdir -p $(PREFIX)/headers/$(PACKAGE)
|
||||
@for header in $(HEADERS) ; do cp $$header $(PREFIX)/headers/$(PACKAGE) ; done
|
||||
|
||||
-include $(DEPENDENCIES)
|
||||
VERSION = 0.1.0
|
||||
-include ../makefile-vars
|
||||
-include ../makefile-rules
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@
|
|||
****************************************************************************/
|
||||
#ifndef __LIBRARY_MEMORY_H__
|
||||
# define __LIBRARY_MEMORY_H__
|
||||
# include <config.h>
|
||||
# include <defines.h>
|
||||
# include <types.h>
|
||||
# include <return_values.h>
|
||||
# include <inlines.h>
|
||||
# include <functions.h>
|
||||
# include <memory/config.h>
|
||||
# include <memory/defines.h>
|
||||
# include <memory/types.h>
|
||||
# include <memory/return_values.h>
|
||||
# include <memory/inlines.h>
|
||||
# include <memory/functions.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
%{
|
||||
#include <memory.h>
|
||||
#include "memory.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
#ifndef __LIBRARY_MEMORY_H__
|
||||
#error "This header file must be included ONLY from memory.h."
|
||||
# error "This header file must be included ONLY from memory.h."
|
||||
#endif
|
||||
#ifndef __LIBRARY_MEMORY_TYPES_H__
|
||||
#define __LIBRARY_MEMORY_TYPES_H__
|
||||
# define __LIBRARY_MEMORY_TYPES_H__
|
||||
|
||||
struct memory_free_page
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue