From: Ondřej Surý Date: Fri, 17 Aug 2018 09:36:33 +0000 (+0200) Subject: Remove check for atomic isc_refcount in dns/rbt.h and always use isc_refcount X-Git-Tag: v9.13.3~28^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b74478c8f91113c2514606bded541ef3e8219df;p=thirdparty%2Fbind9.git Remove check for atomic isc_refcount in dns/rbt.h and always use isc_refcount --- diff --git a/lib/dns/include/dns/rbt.h b/lib/dns/include/dns/rbt.h index cb9afe65ab4..ffd2445bd74 100644 --- a/lib/dns/include/dns/rbt.h +++ b/lib/dns/include/dns/rbt.h @@ -38,12 +38,6 @@ ISC_LANG_BEGINDECLS #define DNS_RBTFIND_NOPREDECESSOR 0x04 /*@}*/ -#ifndef DNS_RBT_USEISCREFCOUNT -#ifdef ISC_REFCOUNT_HAVEATOMIC -#define DNS_RBT_USEISCREFCOUNT 1 -#endif -#endif - #define DNS_RBT_USEMAGIC 1 /* @@ -164,13 +158,8 @@ struct dns_rbtnode { unsigned int dirty:1; unsigned int wild:1; unsigned int locknum:DNS_RBT_LOCKLENGTH; -#ifndef DNS_RBT_USEISCREFCOUNT - unsigned int references:DNS_RBT_REFLENGTH; -#endif unsigned int :0; /* end of bitfields c/o node lock */ -#ifdef DNS_RBT_USEISCREFCOUNT isc_refcount_t references; /* note that this is not in the bitfield */ -#endif /*@}*/ }; @@ -1059,7 +1048,6 @@ dns_rbtnodechain_nextflat(dns_rbtnodechain_t *chain, dns_name_t *name); * The following macros provide a common interface to these operations, * hiding the back-end. The usage is the same as that of isc_refcount_xxx(). */ -#ifdef DNS_RBT_USEISCREFCOUNT #define dns_rbtnode_refinit(node, n) \ do { \ isc_refcount_init(&(node)->references, (n)); \ @@ -1082,58 +1070,6 @@ dns_rbtnodechain_nextflat(dns_rbtnodechain_t *chain, dns_name_t *name); do { \ isc_refcount_decrement(&(node)->references, (refs)); \ } while (0) -#else /* DNS_RBT_USEISCREFCOUNT */ -#define dns_rbtnode_refinit(node, n) ((node)->references = (n)) -#define dns_rbtnode_refdestroy(node) ISC_REQUIRE((node)->references == 0) -#define dns_rbtnode_refcurrent(node) ((node)->references) - -#if (__STDC_VERSION__ + 0) >= 199901L || defined __GNUC__ -static inline void -dns_rbtnode_refincrement0(dns_rbtnode_t *node, unsigned int *refs) { - node->references++; - if (refs != NULL) - *refs = node->references; -} - -static inline void -dns_rbtnode_refincrement(dns_rbtnode_t *node, unsigned int *refs) { - ISC_REQUIRE(node->references > 0); - node->references++; - if (refs != NULL) - *refs = node->references; -} - -static inline void -dns_rbtnode_refdecrement(dns_rbtnode_t *node, unsigned int *refs) { - ISC_REQUIRE(node->references > 0); - node->references--; - if (refs != NULL) - *refs = node->references; -} -#else -#define dns_rbtnode_refincrement0(node, refs) \ - do { \ - unsigned int *_tmp = (unsigned int *)(refs); \ - (node)->references++; \ - if ((_tmp) != NULL) \ - (*_tmp) = (node)->references; \ - } while (0) -#define dns_rbtnode_refincrement(node, refs) \ - do { \ - ISC_REQUIRE((node)->references > 0); \ - (node)->references++; \ - if ((refs) != NULL) \ - (*refs) = (node)->references; \ - } while (0) -#define dns_rbtnode_refdecrement(node, refs) \ - do { \ - ISC_REQUIRE((node)->references > 0); \ - (node)->references--; \ - if ((refs) != NULL) \ - (*refs) = (node)->references; \ - } while (0) -#endif -#endif /* DNS_RBT_USEISCREFCOUNT */ void dns_rbtnode_nodename(dns_rbtnode_t *node, dns_name_t *name); diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index f622d448a36..4a52dfc8fff 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -5489,14 +5489,16 @@ printnode(dns_db_t *db, dns_dbnode_t *node, FILE *out) { dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db; dns_rbtnode_t *rbtnode = node; bool first; + uint32_t refs; REQUIRE(VALID_RBTDB(rbtdb)); NODE_LOCK(&rbtdb->node_locks[rbtnode->locknum].lock, isc_rwlocktype_read); - fprintf(out, "node %p, %u references, locknum = %u\n", - rbtnode, dns_rbtnode_refcurrent(rbtnode), + refs = dns_rbtnode_refcurrent(rbtnode); + fprintf(out, "node %p, %" PRIu32 " references, locknum = %u\n", + rbtnode, refs, rbtnode->locknum); if (rbtnode->data != NULL) { rdatasetheader_t *current, *top_next;