macros.h (2394B)
1 #ifdef TABLE_STATIC 2 #undef TABLE_STATIC 3 #define TABLE_STATIC static 4 #else 5 #define TABLE_STATIC 6 #endif 7 8 #if (defined(TABLE_DECLS) || defined(TABLE_DEFS)) && !defined(TABLE_METHOD) 9 #error "rcx/table: TABLE_METHOD must be defined" 10 #endif 11 12 #if defined(TABLE_ALLOC) || defined(TABLE_REALLOC) || defined(TABLE_REALLOCZ) 13 #error "rcx/table: invalid allocator option; use TABLE_ALLOCZ" 14 #endif 15 16 #ifndef TABLE_KSIZE 17 #define TABLE_KSIZE r_spec_->ksize 18 #define TABLE_KSIZE_FIELD usize ksize; 19 #define TABLE_USE_SPEC 20 #else 21 #define TABLE_KSIZE_FIELD 22 #endif 23 24 #ifndef TABLE_VSIZE 25 #define TABLE_VSIZE r_spec_->vsize 26 #define TABLE_VSIZE_FIELD usize vsize; 27 #define TABLE_USE_SPEC 28 #else 29 #define TABLE_VSIZE_FIELD 30 #endif 31 32 #ifndef TABLE_EQ 33 #define TABLE_EQ r_spec_->eq 34 #define TABLE_EQ_FIELD RTableEqFunc eq; 35 #define TABLE_USE_SPEC 36 #else 37 #define TABLE_EQ_FIELD 38 #endif 39 40 #ifndef TABLE_HASH 41 #define TABLE_HASH r_spec_->hash 42 #define TABLE_HASH_FIELD RTableHashFunc hash; 43 #define TABLE_USE_SPEC 44 #else 45 #define TABLE_HASH_FIELD 46 #endif 47 48 #ifndef TABLE_ALLOCZ 49 #define TABLE_ALLOCZ r_spec_->allocz 50 #define TABLE_ALLOCZ_FIELD RTableAlloczFunc allocz; 51 #define TABLE_USE_SPEC 52 #else 53 #define TABLE_ALLOCZ_FIELD 54 #endif 55 56 #ifndef TABLE_FREE 57 #define TABLE_FREE r_spec_->free 58 #define TABLE_FREE_FIELD RTableFreeFunc free; 59 #define TABLE_USE_SPEC 60 #else 61 #define TABLE_FREE_FIELD 62 #endif 63 64 #ifdef TABLE_USE_SPEC 65 #ifndef TABLE_SPEC_NAME 66 #error "rcx/table: TABLE_SPEC_NAME must be defined" 67 #endif 68 #define TABLE_SPEC_PARAM , TABLE_SPEC_NAME *r_spec_ 69 #define TABLE_SPEC , r_spec_ 70 #undef TABLE_USE_SPEC 71 #endif 72 73 /* PAGE_LEN_BITS should be chosen such that PAGE_LEN * KSIZE and 74 * PAGE_LEN * VSIZE are both divisible by alignof(K) and by alignof(V). 75 * The default basically guarantees this on 64 bit machines, but one might 76 * experience improved caching performance for large keys or values by 77 * decreasing PAGE_LEN (because lower PAGE_LEN causes corresponding keys and 78 * values to be closer in memory). See defs.h for more details. */ 79 80 #ifndef TABLE_PAGE_LEN_BITS 81 #define TABLE_PAGE_LEN_BITS 3u 82 #endif 83 84 #define TABLE_PAGE_LEN (1u << (TABLE_PAGE_LEN_BITS)) 85 86 /* The dict size doubles when count + ntombs exceeds the proportion of the 87 * dict size indicated by LF_NUM and LF_DEN (which is 3/4 = 75% by default). 88 * See exceeds_lf in defs.h. */ 89 90 #ifndef TABLE_LF_NUM 91 #define TABLE_LF_NUM 3u 92 #endif 93 94 #ifndef TABLE_LF_DEN 95 #define TABLE_LF_DEN 4u 96 #endif