| 1 | #ifndef _DTHDR_H |
| 2 | #define _DTHDR_H 1 |
| 3 | |
| 4 | /* Internal definitions for libcdt. |
| 5 | ** Written by Kiem-Phong Vo (5/25/96) |
| 6 | */ |
| 7 | |
| 8 | #include <stdlib.h> |
| 9 | |
| 10 | #include <cdt.h> |
| 11 | |
| 12 | /* short-hand notations */ |
| 13 | #define NIL(t) ((t)0) |
| 14 | #define reg register |
| 15 | #define uint unsigned int |
| 16 | #define left hl._left |
| 17 | #define hash hl._hash |
| 18 | #define htab hh._htab |
| 19 | #define head hh._head |
| 20 | |
| 21 | /* this must be disjoint from DT_METHODS */ |
| 22 | #define DT_FLATTEN 010000 /* dictionary already flattened */ |
| 23 | #define DT_WALK 020000 /* hash table being walked */ |
| 24 | |
| 25 | /* how the Dt_t handle was allocated */ |
| 26 | #define DT_MALLOC 0 |
| 27 | #define DT_MEMORYF 1 |
| 28 | |
| 29 | /* max search length before splaying */ |
| 30 | #define DT_MINP (sizeof(size_t)*8 - 2) |
| 31 | |
| 32 | /* hash start size and load factor */ |
| 33 | #define HSLOT (256) |
| 34 | #define HRESIZE(n) ((n) << 1) |
| 35 | #define HLOAD(s) ((s) << 1) |
| 36 | #define HINDEX(n,h) ((h)&((n)-1)) |
| 37 | |
| 38 | #define UNFLATTEN(dt) \ |
| 39 | ((dt->data->type&DT_FLATTEN) ? dtrestore(dt,NIL(Dtlink_t*)) : 0) |
| 40 | |
| 41 | /* tree rotation/linking functions */ |
| 42 | #define rrotate(x,y) ((x)->left = (y)->right, (y)->right = (x)) |
| 43 | #define lrotate(x,y) ((x)->right = (y)->left, (y)->left = (x)) |
| 44 | #define rlink(r,x) ((r) = (r)->left = (x) ) |
| 45 | #define llink(l,x) ((l) = (l)->right = (x) ) |
| 46 | |
| 47 | #define RROTATE(x,y) (rrotate(x,y), (x) = (y)) |
| 48 | #define LROTATE(x,y) (lrotate(x,y), (x) = (y)) |
| 49 | |
| 50 | #endif /* _DTHDR_H */ |
| 51 | |