aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti/fns.h
blob: 4503d539a2a0fe711f6fbf6e859f53a430df13c6 (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
 * sorted by 4,/^$/|sort -bd +1
 */
int		addarena(Arena *name);
ZBlock		*alloczblock(u32int size, int zeroed);
Arena		*amapitoa(Index *index, u64int a, u64int *aa);
u64int		arenadirsize(Arena *arena, u32int clumps);
void		arenaupdate(Arena *arena, u32int size, u8int *score);
void		backsumarena(Arena *arena);
u32int		buildbucket(Index *ix, IEStream *ies, IBucket *ib);
void		checkdcache(void);
void		checklumpcache(void);
int		clumpinfoeq(ClumpInfo *c, ClumpInfo *d);
int		clumpinfoeq(ClumpInfo *c, ClumpInfo *d);
u32int		clumpmagic(Arena *arena, u64int aa);
int		delarena(Arena *arena);
void		*emalloc(ulong);
void		*erealloc(void *, ulong);
char		*estrdup(char*);
void		*ezmalloc(ulong);
Arena		*findarena(char *name);
ISect		*findisect(Index *ix, u32int buck);
int		flushciblocks(Arena *arena);
void		fmtzbinit(Fmt *f, ZBlock *b);
void		freearena(Arena *arena);
void		freearenapart(ArenaPart *ap, int freearenas);
void		freeiestream(IEStream *ies);
void		freeifile(IFile *f);
void		freeisect(ISect *is);
void		freeindex(Index *index);
void		freepart(Part *part);
void		freezblock(ZBlock *b);
DBlock		*getdblock(Part *part, u64int addr, int read);
u32int		hashbits(u8int *score, int nbits);
int		httpdinit(char *address);
int		iaddrcmp(IAddr *ia1, IAddr *ia2);
int		ientrycmp(const void *vie1, const void *vie2);
char		*ifileline(IFile *f);
int		ifilename(IFile *f, char *dst);
int		ifileu32int(IFile *f, u32int *r);
int		indexsect(Index *ix, u8int *score);
Arena		*initarena(Part *part, u64int base, u64int size, u32int blocksize);
ArenaPart	*initarenapart(Part *part);
int		initarenasum(void);
void		initdcache(u32int mem);
void		initicache(int bits, int depth);
IEStream	*initiestream(Part *part, u64int off, u64int clumps, u32int size);
ISect		*initisect(Part *part);
Index		*initindex(char *name, ISect **sects, int n);
void		initlumpcache(u32int size, u32int nblocks);
int		initlumpqueues(int nq);
Part*		initpart(char *name, int writable);
int		initventi(char *config);
void		insertlump(Lump *lump, Packet *p);
int		insertscore(u8int *score, IAddr *ia, int write);
ZBlock		*loadclump(Arena *arena, u64int aa, int blocks, Clump *cl, u8int *score, int verify);
int		loadientry(Index *index, u8int *score, int type, IEntry *ie);
void		logerr(int severity, char *fmt, ...);
Lump		*lookuplump(u8int *score, int type);
int		lookupscore(u8int *score, int type, IAddr *ia, int *rac);
int		maparenas(AMap *am, Arena **arenas, int n, char *what);
int		namecmp(char *s, char *t);
void		namecp(char *dst, char *src);
int		nameok(char *name);
Arena		*newarena(Part *part, char *name, u64int base, u64int size, u32int blocksize);
ArenaPart	*newarenapart(Part *part, u32int blocksize, u32int tabsize);
ISect		*newisect(Part *part, char *name, u32int blocksize, u32int tabsize);
Index		*newindex(char *name, ISect **sects, int n);
u32int		now(void);
int		okamap(AMap *am, int n, u64int start, u64int stop, char *what);
int		outputamap(Fmt *f, AMap *am, int n);
int		outputindex(Fmt *f, Index *ix);
int		packarena(Arena *arena, u8int *buf);
int		packarenahead(ArenaHead *head, u8int *buf);
int		packarenapart(ArenaPart *as, u8int *buf);
int		packclump(Clump *c, u8int *buf);
void		packclumpinfo(ClumpInfo *ci, u8int *buf);
void		packibucket(IBucket *b, u8int *buf);
void		packientry(IEntry *i, u8int *buf);
int		packisect(ISect *is, u8int *buf);
void		packmagic(u32int magic, u8int *buf);
ZBlock		*packet2zblock(Packet *p, u32int size);
int		parseamap(IFile *f, AMapN *amn);
int		parseindex(IFile *f, Index *ix);
void		partblocksize(Part *part, u32int blocksize);
int		partifile(IFile *f, Part *part, u64int start, u32int size);
void		printarenapart(int fd, ArenaPart *ap);
void		printarena(int fd, Arena *arena);
void		printindex(int fd, Index *ix);
void		printstats(void);
void		putdblock(DBlock *b);
void		putlump(Lump *b);
void		queueflush(void);
int		queuewrite(Lump *b, Packet *p, int creator);
u32int		readarena(Arena *arena, u64int aa, u8int *buf, long n);
int		readarenamap(AMapN *amn, Part *part, u64int base, u32int size);
int		readclumpinfo(Arena *arena, int clump, ClumpInfo *ci);
int		readclumpinfos(Arena *arena, int clump, ClumpInfo *cis, int n);
ZBlock		*readfile(char *name);
int		readifile(IFile *f, char *name);
Packet		*readlump(u8int *score, int type, u32int size);
int		readpart(Part *part, u64int addr, u8int *buf, u32int n);
int		runconfig(char *config, Config*);
int		scorecmp(u8int *, u8int *);
void		scoremem(u8int *score, u8int *buf, int size);
void		seterr(int severity, char *fmt, ...);
u64int		sortrawientries(Index *ix, Part *tmp, u64int *tmpoff);
void		statsinit(void);
int		storeclump(Index *index, ZBlock *b, u8int *score, int type, u32int creator, IAddr *ia);
int		storeientry(Index *index, IEntry *m);
int		strscore(char *s, u8int *score);
int		stru32int(char *s, u32int *r);
int		stru64int(char *s, u64int *r);
void		sumarena(Arena *arena);
int		syncarena(Arena *arena, u32int n, int zok, int fix);
int		syncarenaindex(Index *ix, Arena *arena, u32int clump, u64int a, int fix);
int		syncindex(Index *ix, int fix);
int		u64log2(u64int v);
u64int		unittoull(char *s);
int		unpackarena(Arena *arena, u8int *buf);
int		unpackarenahead(ArenaHead *head, u8int *buf);
int		unpackarenapart(ArenaPart *as, u8int *buf);
int		unpackclump(Clump *c, u8int *buf);
void		unpackclumpinfo(ClumpInfo *ci, u8int *buf);
void		unpackibucket(IBucket *b, u8int *buf);
void		unpackientry(IEntry *i, u8int *buf);
int		unpackisect(ISect *is, u8int *buf);
u32int		unpackmagic(u8int *buf);
int		vtproc(void(*)(void*), void*);
int		vttypevalid(int type);
int		wbarena(Arena *arena);
int		wbarenahead(Arena *arena);
int		wbarenamap(AMap *am, int n, Part *part, u64int base, u64int size);
int		wbarenapart(ArenaPart *ap);
int		wbisect(ISect *is);
int		wbindex(Index *ix);
int		whackblock(u8int *dst, u8int *src, int ssize);
u64int		writeaclump(Arena *a, Clump *c, u8int *clbuf);
u32int		writearena(Arena *arena, u64int aa, u8int *clbuf, u32int n);
int		writeclumpinfo(Arena *arean, int clump, ClumpInfo *ci);
u64int		writeiclump(Index *ix, Clump *c, u8int *clbuf);
int		writelump(Packet *p, u8int *score, int type, u32int creator);
int		writepart(Part *part, u64int addr, u8int *buf, u32int n);
int		writeqlump(Lump *u, Packet *p, int creator);
Packet		*zblock2packet(ZBlock *zb, u32int size);
void		zeropart(Part *part, int blocksize);

/*
#pragma	varargck	argpos	sysfatal		1
#pragma	varargck	argpos	logerr		2
#pragma	varargck	argpos	SetErr		2
*/

#define scorecmp(h1,h2)		memcmp((h1),(h2),VtScoreSize)
#define scorecp(h1,h2)		memmove((h1),(h2),VtScoreSize)

#define MK(t)			((t*)emalloc(sizeof(t)))
#define MKZ(t)			((t*)ezmalloc(sizeof(t)))
#define MKN(t,n)		((t*)emalloc((n)*sizeof(t)))
#define MKNZ(t,n)		((t*)ezmalloc((n)*sizeof(t)))
#define MKNA(t,at,n)		((t*)emalloc(sizeof(t) + (n)*sizeof(at)))