]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove check for atomic isc_refcount in dns/rbt.h and always use isc_refcount
authorOndřej Surý <ondrej@sury.org>
Fri, 17 Aug 2018 09:36:33 +0000 (11:36 +0200)
committerOndřej Surý <ondrej@sury.org>
Tue, 28 Aug 2018 10:15:39 +0000 (12:15 +0200)
lib/dns/include/dns/rbt.h
lib/dns/rbtdb.c

index cb9afe65ab49c797186eb892406e185197223b2f..ffd2445bd74649b21846eda534dd6dcb70885dfe 100644 (file)
@@ -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);
index f622d448a3699847993469704192eb19175322cc..4a52dfc8fff294de62eef6618d3c331a653df662 100644 (file)
@@ -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;