mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
bd43bd6f1a
This is intended for the secrmem pool in the kernel, but could also be used for temporary pools to recover the memory used by the arenas.
59 lines
1.4 KiB
C
59 lines
1.4 KiB
C
typedef struct Pool Pool;
|
|
struct Pool {
|
|
char* name;
|
|
uintptr maxsize;
|
|
|
|
uintptr cursize;
|
|
uintptr curfree;
|
|
uintptr curalloc;
|
|
|
|
ulong minarena; /* smallest size of new arena */
|
|
ulong quantum; /* allocated blocks should be multiple of */
|
|
ulong minblock; /* smallest newly allocated block */
|
|
|
|
void* freeroot; /* actually Free* */
|
|
void* arenalist; /* actually Arena* */
|
|
|
|
void* (*alloc)(ulong);
|
|
int (*merge)(void*, void*);
|
|
void (*move)(void* from, void* to);
|
|
void (*free)(void*, ulong);
|
|
|
|
int flags;
|
|
int nfree;
|
|
int lastcompact;
|
|
|
|
void (*lock)(Pool*);
|
|
void (*unlock)(Pool*);
|
|
void (*print)(Pool*, char*, ...);
|
|
void (*panic)(Pool*, char*, ...);
|
|
void (*logstack)(Pool*);
|
|
|
|
void* private;
|
|
};
|
|
|
|
extern void* poolalloc(Pool*, ulong);
|
|
extern void* poolallocalign(Pool*, ulong, ulong, long, ulong);
|
|
extern void poolfree(Pool*, void*);
|
|
extern ulong poolmsize(Pool*, void*);
|
|
extern int poolisoverlap(Pool*, void*, ulong);
|
|
extern void poolreset(Pool*);
|
|
extern void* poolrealloc(Pool*, void*, ulong);
|
|
extern void poolcheck(Pool*);
|
|
extern int poolcompact(Pool*);
|
|
extern void poolblockcheck(Pool*, void*);
|
|
extern void pooldump(Pool*);
|
|
|
|
extern Pool* mainmem;
|
|
extern Pool* imagmem;
|
|
extern Pool* secrmem;
|
|
|
|
enum { /* flags */
|
|
POOL_ANTAGONISM = 1<<0,
|
|
POOL_PARANOIA = 1<<1,
|
|
POOL_VERBOSITY = 1<<2,
|
|
POOL_DEBUGGING = 1<<3,
|
|
POOL_LOGGING = 1<<4,
|
|
POOL_TOLERANCE = 1<<5,
|
|
POOL_NOREUSE = 1<<6,
|
|
};
|