1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
typedef struct Datum Datum;
typedef struct DBlock DBlock;
typedef struct DMap DMap;
typedef struct DStore DStore;
typedef struct Listcache Listcache;
enum
{
DDirty = 1<<0,
DStoreHdrSize = 8
};
struct Datum
{
void* a;
uint n;
};
struct DBlock
{
u32int addr;
u32int flags;
void* a;
u32int n;
int (*close)(DBlock*);
int (*free)(DBlock*);
int (*flush)(DBlock*);
};
enum
{
DMapCreate = 1<<0,
DMapReplace = 1<<1
};
struct DMap
{
u32int addr;
int (*insert)(DMap*, Datum*, Datum*, int);
int (*lookup)(DMap*, Datum*, Datum*);
int (*delete)(DMap*, Datum*);
int (*deleteall)(DMap*);
int (*walk)(DMap*, void (*)(void*, Datum*, Datum*), void*);
int (*close)(DMap*);
int (*free)(DMap*);
int (*flush)(DMap*);
int (*isempty)(DMap*);
void (*dump)(DMap*, int); /* debugging */
};
struct DStore
{
int hdrsize;
int pagesize;
int (*flush)(DStore*);
int (*close)(DStore*);
DBlock* (*alloc)(DStore*, uint);
DBlock* (*read)(DStore*, u32int);
int (*free)(DStore*);
};
DStore* createdstore(char*, uint);
DStore* opendstore(char*);
int dstoreignorewrites(DStore*);
DMap* dmaplist(DStore*, u32int, uint);
DMap* dmaptree(DStore*, u32int, uint);
int datumcmp(Datum*, Datum*);
Listcache* openlistcache(void);
void flushlistcache(Listcache*);
void closelistcache(Listcache*);
DMap* dmapclist(Listcache*, DStore*, u32int, uint);
#define LONG(p) (((p)[0]<<24)|((p)[1]<<16)|((p)[2]<<8)|((p)[3]))
#define PLONG(p, l) \
(((p)[0]=(l)>>24),((p)[1]=(l)>>16),\
((p)[2]=(l)>>8),((p)[3]=(l)))
#define SHORT(p) (((p)[0]<<8)|(p)[1])
#define PSHORT(p,l) \
(((p)[0]=(l)>>8),((p)[1]=(l)))
|