1#ifndef COMMIT_SLAB_HDR_H2#define COMMIT_SLAB_HDR_H34/* allocate ~512kB at once, allowing for malloc overhead */5#ifndef COMMIT_SLAB_SIZE6#define COMMIT_SLAB_SIZE (512*1024-32)7#endif89#define declare_commit_slab(slabname, elemtype) \10\11struct slabname { \12unsigned slab_size; \13unsigned stride; \14unsigned slab_count; \15elemtype **slab; \16}1718/*19* Statically initialize a commit slab named "var". Note that this20* evaluates "stride" multiple times! Example:21*22* struct indegree indegrees = COMMIT_SLAB_INIT(1, indegrees);23*24*/25#define COMMIT_SLAB_INIT(stride, var) { \26COMMIT_SLAB_SIZE / sizeof(**((var).slab)) / (stride), \27(stride), 0, NULL \28}2930#define declare_commit_slab_prototypes(slabname, elemtype) \31\32void init_ ##slabname## _with_stride(struct slabname *s, unsigned stride); \33void init_ ##slabname(struct slabname *s); \34void clear_ ##slabname(struct slabname *s); \35elemtype *slabname## _at_peek(struct slabname *s, const struct commit *c, int add_if_missing); \36elemtype *slabname## _at(struct slabname *s, const struct commit *c); \37elemtype *slabname## _peek(struct slabname *s, const struct commit *c)3839#define define_shared_commit_slab(slabname, elemtype) \40declare_commit_slab(slabname, elemtype); \41declare_commit_slab_prototypes(slabname, elemtype)4243#endif /* COMMIT_SLAB_HDR_H */