| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#define L2BDIM 6 |
| 11 |
#define BDIM (1 << (L2BDIM)) |
| 12 |
#define L2BSIZE (2 * (L2BDIM)) |
| 13 |
#define BSIZE (1 << (L2BSIZE)) |
| 14 |
#define HI(i) ((i) >> (L2BDIM)) |
| 15 |
#define LO(i) ((i) & ((BDIM) - 1)) |
| 16 |
|
| 17 |
typedef DCELL block[BDIM][BDIM]; |
| 18 |
|
| 19 |
struct cache { |
| 20 |
int fd; |
| 21 |
int stride; |
| 22 |
int nblocks; |
| 23 |
block **grid; |
| 24 |
block *blocks; |
| 25 |
int *refs; |
| 26 |
}; |
| 27 |
|
| 28 |
typedef void (*func)(struct cache *, void *, int, double *, double *, |
| 29 |
struct Cell_head *); |
| 30 |
|
| 31 |
#define BKIDX(c, y, x) ((y) * (c)->stride + (x)) |
| 32 |
#define BKPTR(c, y, x) ((c)->grid[BKIDX((c), (y), (x))]) |
| 33 |
#define BLOCK(c, y, x) \ |
| 34 |
(BKPTR((c), (y), (x)) ? BKPTR((c), (y), (x)) \ |
| 35 |
: get_block((c), BKIDX((c), (y), (x)))) |
| 36 |
#define CPTR(c, y, x) (&(*BLOCK((c), HI((y)), HI((x))))[LO((y))][LO((x))]) |
| 37 |
|
| 38 |
struct menu { |
| 39 |
func method; |
| 40 |
char *name; |
| 41 |
char *text; |
| 42 |
}; |