cosmetic changes and additions :

* now we have seperate private headers files
  containing private and static or public functions
  in memory-* files.
* there is only one .c file of the same name the library.

Zagor: because now there is only one .c file, you could only have a .o file and use it instead of the .a libfile.

* most structures and codes are now private.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@112 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Alan Korr 2002-04-17 12:13:43 +00:00
parent 87789d7154
commit 08dada2df5
4 changed files with 68 additions and 48 deletions

View file

@ -22,6 +22,6 @@
#ifndef __LIBRARY_MEMORY_CONFIG_H__
# define __LIBRARY_MEMORY_CONFIG_H__
# define PACKAGE_NAME "memory"
# define PACKAGE_VERSION "0.1.0"
# define PACKAGE_VERSION "0.1.1"
# define MEMORY_PAGE_USE_SPLAY_TREE 1
#endif

View file

@ -21,11 +21,71 @@
#endif
# ifndef __LIBRARY_MEMORY_FUNCTIONS_H__
# define __LIBRARY_MEMORY_FUNCTIONS_H__
/////////////////////////////////////////////////////////////////////
// MEMORY :
///////////
extern void memory_copy (void *target,void const *source,unsigned int count);
extern void memory_set (void *target,int byte,unsigned int count);
extern int memory_release_page (void *);
extern void *memory_allocate_page (int);
/////////////////////////////////////////////////////////////////////
// MEMORY PAGE :
////////////////
//
// - memory_allocate_page : allocate a page
// - memory_release_page : release a page
//
extern int memory_release_page (void *address);
extern void *memory_allocate_page (int order);
extern void memory_setup (void);
//
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// MEMORY SLAB :
////////////////
//
// - memory_grow_cache : allocate a new slab for a cache
// - memory_shrink_cache : release free slabs from a cache
// - memory_create_cache : create a new cache of size-fixed blocks
// - memory_destroy_cache : destroy the cache and release all the slabs
// - memory_cache_allocate : allocate a block from the cache
// - memory_cache_release : release a block in the cache
//
extern struct memory_slab *memory_grow_cache (struct memory_cache *cache);
extern int memory_shrink_cache (struct memory_cache *cache,int all);
extern struct memory_cache *memory_create_cache (unsigned int size,int align,int flags);
extern int memory_destroy_cache (struct memory_cache *cache);
extern void *memory_cache_allocate (struct memory_cache *cache);
extern int memory_cache_release (struct memory_cache *cache,void *address);
//
/////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// MEMORY BLOCK :
/////////////////
//
// - memory_allocate_small_block : allocate a small block (no page)
// - memory_release_small_block : release a small block (no page)
// - memory_allocate_block : allocate a block (or a page)
// - memory_release_block : release a block (or a page)
//
extern void *memory_allocate_small_block (int order);
extern int memory_release_small_block (int order,void *address);
extern void *memory_allocate_block (unsigned int size);
extern int memory_release_block (void *address);
//
/////////////////////////////////////////////////////////////////////
# ifdef TEST
void memory_spy_page (void *address);
void memory_dump (int order);

View file

@ -17,7 +17,7 @@
#############################################################################
ARCH = test
PACKAGE = memory
VERSION = 0.1.0
VERSION = 0.1.1
-include ../makefile-vars
-include ../makefile-rules

View file

@ -22,51 +22,11 @@
#ifndef __LIBRARY_MEMORY_TYPES_H__
# define __LIBRARY_MEMORY_TYPES_H__
struct memory_free_page
{
struct memory_free_page
*less,*more;
char
reserved[MEMORY_PAGE_MINIMAL_SIZE - 2*sizeof (struct memory_free_page *)];
};
struct memory_free_block
{
struct memory_free_block
*link;
};
struct memory_free_page;
struct memory_free_block;
struct memory_slab;
struct memory_cache;
struct memory_cache
{
struct memory_cache
*less,*more,*same;
unsigned int
left; // number of free slabs
struct memory_slab
*used;
struct memory_slab
*free;
struct memory_slab
*reap;
unsigned int
size,original_size;
unsigned int
page_size;
unsigned int
blocks_per_slab;
int
page_order;
unsigned int
flags;
};
struct memory_slab
{
struct memory_slab
*less,*more;
unsigned int // left == number of free blocks left
left;
struct memory_free_block
*free;
};
#endif