From 96e730fd7056ca0e13b36489ce9e6717fef37318 Mon Sep 17 00:00:00 2001 From: John Naylor Date: Sun, 22 Jan 2023 14:37:53 +0700 Subject: [PATCH v21 18/22] Clean up symbols Remove remaming stragglers who weren't named "RT_*" and get rid of the temporary expedient RT_COMMON block in favor of explicit #undefs everywhere. --- src/include/lib/radixtree.h | 91 ++++++++++++++----------- src/include/lib/radixtree_delete_impl.h | 4 +- src/include/lib/radixtree_insert_impl.h | 4 +- src/include/lib/radixtree_iter_impl.h | 4 +- src/include/lib/radixtree_search_impl.h | 4 +- 5 files changed, 58 insertions(+), 49 deletions(-) diff --git a/src/include/lib/radixtree.h b/src/include/lib/radixtree.h index 7c3f3dcf4f..95124696ef 100644 --- a/src/include/lib/radixtree.h +++ b/src/include/lib/radixtree.h @@ -246,14 +246,6 @@ RT_SCOPE void RT_STATS(RT_RADIX_TREE *tree); /* generate implementation of the radix tree */ #ifdef RT_DEFINE -/* macros and types common to all implementations */ -#ifndef RT_COMMON -#define RT_COMMON - -#ifdef RT_DEBUG -#define UINT64_FORMAT_HEX "%" INT64_MODIFIER "X" -#endif - /* The number of bits encoded in one tree level */ #define RT_NODE_SPAN BITS_PER_BYTE @@ -321,8 +313,6 @@ RT_SCOPE void RT_STATS(RT_RADIX_TREE *tree); #define RT_SLAB_BLOCK_SIZE(size) \ Max((SLAB_DEFAULT_BLOCK_SIZE / (size)) * (size), (size) * 32) -#endif /* RT_COMMON */ - /* Common type for all nodes types */ typedef struct RT_NODE { @@ -370,7 +360,7 @@ typedef struct RT_NODE #define RT_INVALID_PTR_ALLOC NULL #endif -#define NODE_IS_LEAF(n) (((RT_PTR_LOCAL) (n))->shift == 0) +#define RT_NODE_IS_LEAF(n) (((RT_PTR_LOCAL) (n))->shift == 0) #define RT_NODE_MUST_GROW(node) \ ((node)->base.n.count == (node)->base.n.fanout) @@ -916,14 +906,14 @@ RT_NODE_125_IS_CHUNK_USED(RT_NODE_BASE_125 *node, uint8 chunk) static inline RT_PTR_ALLOC RT_NODE_INNER_125_GET_CHILD(RT_NODE_INNER_125 *node, uint8 chunk) { - Assert(!NODE_IS_LEAF(node)); + Assert(!RT_NODE_IS_LEAF(node)); return node->children[node->base.slot_idxs[chunk]]; } static inline RT_VALUE_TYPE RT_NODE_LEAF_125_GET_VALUE(RT_NODE_LEAF_125 *node, uint8 chunk) { - Assert(NODE_IS_LEAF(node)); + Assert(RT_NODE_IS_LEAF(node)); Assert(((RT_NODE_BASE_125 *) node)->slot_idxs[chunk] != RT_INVALID_SLOT_IDX); return node->values[node->base.slot_idxs[chunk]]; } @@ -934,7 +924,7 @@ RT_NODE_LEAF_125_GET_VALUE(RT_NODE_LEAF_125 *node, uint8 chunk) static inline bool RT_NODE_INNER_256_IS_CHUNK_USED(RT_NODE_INNER_256 *node, uint8 chunk) { - Assert(!NODE_IS_LEAF(node)); + Assert(!RT_NODE_IS_LEAF(node)); return node->children[chunk] != RT_INVALID_PTR_ALLOC; } @@ -944,14 +934,14 @@ RT_NODE_LEAF_256_IS_CHUNK_USED(RT_NODE_LEAF_256 *node, uint8 chunk) int idx = BM_IDX(chunk); int bitnum = BM_BIT(chunk); - Assert(NODE_IS_LEAF(node)); + Assert(RT_NODE_IS_LEAF(node)); return (node->isset[idx] & ((bitmapword) 1 << bitnum)) != 0; } static inline RT_PTR_ALLOC RT_NODE_INNER_256_GET_CHILD(RT_NODE_INNER_256 *node, uint8 chunk) { - Assert(!NODE_IS_LEAF(node)); + Assert(!RT_NODE_IS_LEAF(node)); Assert(RT_NODE_INNER_256_IS_CHUNK_USED(node, chunk)); return node->children[chunk]; } @@ -959,7 +949,7 @@ RT_NODE_INNER_256_GET_CHILD(RT_NODE_INNER_256 *node, uint8 chunk) static inline RT_VALUE_TYPE RT_NODE_LEAF_256_GET_VALUE(RT_NODE_LEAF_256 *node, uint8 chunk) { - Assert(NODE_IS_LEAF(node)); + Assert(RT_NODE_IS_LEAF(node)); Assert(RT_NODE_LEAF_256_IS_CHUNK_USED(node, chunk)); return node->values[chunk]; } @@ -968,7 +958,7 @@ RT_NODE_LEAF_256_GET_VALUE(RT_NODE_LEAF_256 *node, uint8 chunk) static inline void RT_NODE_INNER_256_SET(RT_NODE_INNER_256 *node, uint8 chunk, RT_PTR_ALLOC child) { - Assert(!NODE_IS_LEAF(node)); + Assert(!RT_NODE_IS_LEAF(node)); node->children[chunk] = child; } @@ -979,7 +969,7 @@ RT_NODE_LEAF_256_SET(RT_NODE_LEAF_256 *node, uint8 chunk, RT_VALUE_TYPE value) int idx = BM_IDX(chunk); int bitnum = BM_BIT(chunk); - Assert(NODE_IS_LEAF(node)); + Assert(RT_NODE_IS_LEAF(node)); node->isset[idx] |= ((bitmapword) 1 << bitnum); node->values[chunk] = value; } @@ -988,7 +978,7 @@ RT_NODE_LEAF_256_SET(RT_NODE_LEAF_256 *node, uint8 chunk, RT_VALUE_TYPE value) static inline void RT_NODE_INNER_256_DELETE(RT_NODE_INNER_256 *node, uint8 chunk) { - Assert(!NODE_IS_LEAF(node)); + Assert(!RT_NODE_IS_LEAF(node)); node->children[chunk] = RT_INVALID_PTR_ALLOC; } @@ -998,7 +988,7 @@ RT_NODE_LEAF_256_DELETE(RT_NODE_LEAF_256 *node, uint8 chunk) int idx = BM_IDX(chunk); int bitnum = BM_BIT(chunk); - Assert(NODE_IS_LEAF(node)); + Assert(RT_NODE_IS_LEAF(node)); node->isset[idx] &= ~((bitmapword) 1 << bitnum); } @@ -1458,7 +1448,7 @@ RT_FREE_RECURSE(RT_RADIX_TREE *tree, RT_PTR_ALLOC ptr) CHECK_FOR_INTERRUPTS(); /* The leaf node doesn't have child pointers */ - if (NODE_IS_LEAF(node)) + if (RT_NODE_IS_LEAF(node)) { dsa_free(tree->dsa, ptr); return; @@ -1587,7 +1577,7 @@ RT_SET(RT_RADIX_TREE *tree, uint64 key, RT_VALUE_TYPE value) child = RT_PTR_GET_LOCAL(tree, stored_child); - if (NODE_IS_LEAF(child)) + if (RT_NODE_IS_LEAF(child)) break; if (!RT_NODE_SEARCH_INNER(child, key, &new_child)) @@ -1637,7 +1627,7 @@ RT_SEARCH(RT_RADIX_TREE *tree, uint64 key, RT_VALUE_TYPE *value_p) { RT_PTR_ALLOC child; - if (NODE_IS_LEAF(node)) + if (RT_NODE_IS_LEAF(node)) break; if (!RT_NODE_SEARCH_INNER(node, key, &child)) @@ -1788,7 +1778,7 @@ RT_UPDATE_ITER_STACK(RT_ITER *iter, RT_PTR_LOCAL from_node, int from) node_iter->current_idx = -1; /* We don't advance the leaf node iterator here */ - if (NODE_IS_LEAF(node)) + if (RT_NODE_IS_LEAF(node)) return; /* Advance to the next slot in the inner node */ @@ -1972,7 +1962,7 @@ RT_VERIFY_NODE(RT_PTR_LOCAL node) } case RT_NODE_KIND_256: { - if (NODE_IS_LEAF(node)) + if (RT_NODE_IS_LEAF(node)) { RT_NODE_LEAF_256 *n256 = (RT_NODE_LEAF_256 *) node; int cnt = 0; @@ -1992,6 +1982,9 @@ RT_VERIFY_NODE(RT_PTR_LOCAL node) /***************** DEBUG FUNCTIONS *****************/ #ifdef RT_DEBUG + +#define RT_UINT64_FORMAT_HEX "%" INT64_MODIFIER "X" + RT_SCOPE void RT_STATS(RT_RADIX_TREE *tree) { @@ -2012,7 +2005,7 @@ RT_DUMP_NODE(RT_PTR_LOCAL node, int level, bool recurse) char space[125] = {0}; fprintf(stderr, "[%s] kind %d, fanout %d, count %u, shift %u:\n", - NODE_IS_LEAF(node) ? "LEAF" : "INNR", + RT_NODE_IS_LEAF(node) ? "LEAF" : "INNR", (node->kind == RT_NODE_KIND_3) ? 3 : (node->kind == RT_NODE_KIND_32) ? 32 : (node->kind == RT_NODE_KIND_125) ? 125 : 256, @@ -2028,11 +2021,11 @@ RT_DUMP_NODE(RT_PTR_LOCAL node, int level, bool recurse) { for (int i = 0; i < node->count; i++) { - if (NODE_IS_LEAF(node)) + if (RT_NODE_IS_LEAF(node)) { RT_NODE_LEAF_3 *n3 = (RT_NODE_LEAF_3 *) node; - fprintf(stderr, "%schunk 0x%X value 0x" UINT64_FORMAT_HEX "\n", + fprintf(stderr, "%schunk 0x%X value 0x" RT_UINT64_FORMAT_HEX "\n", space, n3->base.chunks[i], (uint64) n3->values[i]); } else @@ -2054,11 +2047,11 @@ RT_DUMP_NODE(RT_PTR_LOCAL node, int level, bool recurse) { for (int i = 0; i < node->count; i++) { - if (NODE_IS_LEAF(node)) + if (RT_NODE_IS_LEAF(node)) { RT_NODE_LEAF_32 *n32 = (RT_NODE_LEAF_32 *) node; - fprintf(stderr, "%schunk 0x%X value 0x" UINT64_FORMAT_HEX "\n", + fprintf(stderr, "%schunk 0x%X value 0x" RT_UINT64_FORMAT_HEX "\n", space, n32->base.chunks[i], (uint64) n32->values[i]); } else @@ -2090,14 +2083,14 @@ RT_DUMP_NODE(RT_PTR_LOCAL node, int level, bool recurse) fprintf(stderr, " [%d]=%d, ", i, b125->slot_idxs[i]); } - if (NODE_IS_LEAF(node)) + if (RT_NODE_IS_LEAF(node)) { RT_NODE_LEAF_125 *n = (RT_NODE_LEAF_125 *) node; fprintf(stderr, ", isset-bitmap:"); for (int i = 0; i < BM_IDX(RT_SLOT_IDX_LIMIT); i++) { - fprintf(stderr, UINT64_FORMAT_HEX " ", (uint64) n->base.isset[i]); + fprintf(stderr, RT_UINT64_FORMAT_HEX " ", (uint64) n->base.isset[i]); } fprintf(stderr, "\n"); } @@ -2107,11 +2100,11 @@ RT_DUMP_NODE(RT_PTR_LOCAL node, int level, bool recurse) if (!RT_NODE_125_IS_CHUNK_USED(b125, i)) continue; - if (NODE_IS_LEAF(node)) + if (RT_NODE_IS_LEAF(node)) { RT_NODE_LEAF_125 *n125 = (RT_NODE_LEAF_125 *) b125; - fprintf(stderr, "%schunk 0x%X value 0x" UINT64_FORMAT_HEX "\n", + fprintf(stderr, "%schunk 0x%X value 0x" RT_UINT64_FORMAT_HEX "\n", space, i, (uint64) RT_NODE_LEAF_125_GET_VALUE(n125, i)); } else @@ -2134,14 +2127,14 @@ RT_DUMP_NODE(RT_PTR_LOCAL node, int level, bool recurse) { for (int i = 0; i < RT_NODE_MAX_SLOTS; i++) { - if (NODE_IS_LEAF(node)) + if (RT_NODE_IS_LEAF(node)) { RT_NODE_LEAF_256 *n256 = (RT_NODE_LEAF_256 *) node; if (!RT_NODE_LEAF_256_IS_CHUNK_USED(n256, i)) continue; - fprintf(stderr, "%schunk 0x%X value 0x" UINT64_FORMAT_HEX "\n", + fprintf(stderr, "%schunk 0x%X value 0x" RT_UINT64_FORMAT_HEX "\n", space, i, (uint64) RT_NODE_LEAF_256_GET_VALUE(n256, i)); } else @@ -2174,7 +2167,7 @@ RT_DUMP_SEARCH(RT_RADIX_TREE *tree, uint64 key) int level = 0; elog(NOTICE, "-----------------------------------------------------------"); - elog(NOTICE, "max_val = " UINT64_FORMAT "(0x" UINT64_FORMAT_HEX ")", + elog(NOTICE, "max_val = " UINT64_FORMAT "(0x" RT_UINT64_FORMAT_HEX ")", tree->ctl->max_val, tree->ctl->max_val); if (!tree->ctl->root) @@ -2185,7 +2178,7 @@ RT_DUMP_SEARCH(RT_RADIX_TREE *tree, uint64 key) if (key > tree->ctl->max_val) { - elog(NOTICE, "key " UINT64_FORMAT "(0x" UINT64_FORMAT_HEX ") is larger than max val", + elog(NOTICE, "key " UINT64_FORMAT "(0x" RT_UINT64_FORMAT_HEX ") is larger than max val", key, key); return; } @@ -2198,7 +2191,7 @@ RT_DUMP_SEARCH(RT_RADIX_TREE *tree, uint64 key) RT_DUMP_NODE(node, level, false); - if (NODE_IS_LEAF(node)) + if (RT_NODE_IS_LEAF(node)) { uint64 dummy; @@ -2249,15 +2242,30 @@ RT_DUMP(RT_RADIX_TREE *tree) #undef RT_VALUE_TYPE /* locally declared macros */ -#undef NODE_IS_LEAF +#undef RT_MAKE_PREFIX +#undef RT_MAKE_NAME +#undef RT_MAKE_NAME_ +#undef RT_NODE_SPAN +#undef RT_NODE_MAX_SLOTS +#undef RT_CHUNK_MASK +#undef RT_MAX_SHIFT +#undef RT_MAX_LEVEL +#undef RT_GET_KEY_CHUNK +#undef BM_IDX +#undef BM_BIT +#undef RT_NODE_IS_LEAF #undef RT_NODE_MUST_GROW #undef RT_NODE_KIND_COUNT #undef RT_SIZE_CLASS_COUNT +#undef RT_INVALID_SLOT_IDX +#undef RT_SLAB_BLOCK_SIZE #undef RT_RADIX_TREE_MAGIC +#undef RT_UINT64_FORMAT_HEX /* type declarations */ #undef RT_RADIX_TREE #undef RT_RADIX_TREE_CONTROL +#undef RT_PTR_LOCAL #undef RT_PTR_ALLOC #undef RT_INVALID_PTR_ALLOC #undef RT_HANDLE @@ -2295,6 +2303,7 @@ RT_DUMP(RT_RADIX_TREE *tree) #undef RT_ATTACH #undef RT_DETACH #undef RT_GET_HANDLE +#undef RT_SEARCH #undef RT_SET #undef RT_BEGIN_ITERATE #undef RT_ITERATE_NEXT diff --git a/src/include/lib/radixtree_delete_impl.h b/src/include/lib/radixtree_delete_impl.h index b9f07f4eb5..99c90771b9 100644 --- a/src/include/lib/radixtree_delete_impl.h +++ b/src/include/lib/radixtree_delete_impl.h @@ -17,9 +17,9 @@ uint8 chunk = RT_GET_KEY_CHUNK(key, node->shift); #ifdef RT_NODE_LEVEL_LEAF - Assert(NODE_IS_LEAF(node)); + Assert(RT_NODE_IS_LEAF(node)); #else - Assert(!NODE_IS_LEAF(node)); + Assert(!RT_NODE_IS_LEAF(node)); #endif switch (node->kind) diff --git a/src/include/lib/radixtree_insert_impl.h b/src/include/lib/radixtree_insert_impl.h index e3c3f7a69d..0fcebf1c6b 100644 --- a/src/include/lib/radixtree_insert_impl.h +++ b/src/include/lib/radixtree_insert_impl.h @@ -17,10 +17,10 @@ #ifdef RT_NODE_LEVEL_LEAF const bool inner = false; - Assert(NODE_IS_LEAF(node)); + Assert(RT_NODE_IS_LEAF(node)); #else const bool inner = true; - Assert(!NODE_IS_LEAF(node)); + Assert(!RT_NODE_IS_LEAF(node)); #endif switch (node->kind) diff --git a/src/include/lib/radixtree_iter_impl.h b/src/include/lib/radixtree_iter_impl.h index c428531438..823d7107c4 100644 --- a/src/include/lib/radixtree_iter_impl.h +++ b/src/include/lib/radixtree_iter_impl.h @@ -18,11 +18,11 @@ #ifdef RT_NODE_LEVEL_LEAF RT_VALUE_TYPE value; - Assert(NODE_IS_LEAF(node_iter->node)); + Assert(RT_NODE_IS_LEAF(node_iter->node)); #else RT_PTR_LOCAL child = NULL; - Assert(!NODE_IS_LEAF(node_iter->node)); + Assert(!RT_NODE_IS_LEAF(node_iter->node)); #endif #ifdef RT_SHMEM diff --git a/src/include/lib/radixtree_search_impl.h b/src/include/lib/radixtree_search_impl.h index 31138b6a72..c4352045c8 100644 --- a/src/include/lib/radixtree_search_impl.h +++ b/src/include/lib/radixtree_search_impl.h @@ -17,12 +17,12 @@ #ifdef RT_NODE_LEVEL_LEAF RT_VALUE_TYPE value = 0; - Assert(NODE_IS_LEAF(node)); + Assert(RT_NODE_IS_LEAF(node)); #else #ifndef RT_ACTION_UPDATE RT_PTR_ALLOC child = RT_INVALID_PTR_ALLOC; #endif - Assert(!NODE_IS_LEAF(node)); + Assert(!RT_NODE_IS_LEAF(node)); #endif switch (node->kind) -- 2.39.0