s/REQUIRE/ISC_REQUIRE/; include <isc/assertions.h> if ISC_REQUIRE is used; include <isc/likely.h> if ISC_{UN}LIKELY is used

(cherry picked from commit 0fab171196)
This commit is contained in:
Mark Andrews 2017-10-19 16:39:53 +11:00
parent b093b684a6
commit 659b66eb54
4 changed files with 28 additions and 23 deletions

View file

@ -13,6 +13,7 @@
/*! \file dns/rbt.h */
#include <isc/assertions.h>
#include <isc/crc64.h>
#include <isc/lang.h>
#include <isc/magic.h>
@ -1076,7 +1077,7 @@ dns_rbtnodechain_nextflat(dns_rbtnodechain_t *chain, dns_name_t *name);
} while (0)
#else /* DNS_RBT_USEISCREFCOUNT */
#define dns_rbtnode_refinit(node, n) ((node)->references = (n))
#define dns_rbtnode_refdestroy(node) REQUIRE((node)->references == 0)
#define dns_rbtnode_refdestroy(node) ISC_REQUIRE((node)->references == 0)
#define dns_rbtnode_refcurrent(node) ((node)->references)
#if (__STDC_VERSION__ + 0) >= 199901L || defined __GNUC__
@ -1089,7 +1090,7 @@ dns_rbtnode_refincrement0(dns_rbtnode_t *node, unsigned int *refs) {
static inline void
dns_rbtnode_refincrement(dns_rbtnode_t *node, unsigned int *refs) {
REQUIRE(node->references > 0);
ISC_REQUIRE(node->references > 0);
node->references++;
if (refs != NULL)
*refs = node->references;
@ -1097,7 +1098,7 @@ dns_rbtnode_refincrement(dns_rbtnode_t *node, unsigned int *refs) {
static inline void
dns_rbtnode_refdecrement(dns_rbtnode_t *node, unsigned int *refs) {
REQUIRE(node->references > 0);
ISC_REQUIRE(node->references > 0);
node->references--;
if (refs != NULL)
*refs = node->references;
@ -1112,14 +1113,14 @@ dns_rbtnode_refdecrement(dns_rbtnode_t *node, unsigned int *refs) {
} while (0)
#define dns_rbtnode_refincrement(node, refs) \
do { \
REQUIRE((node)->references > 0); \
ISC_REQUIRE((node)->references > 0); \
(node)->references++; \
if ((refs) != NULL) \
(*refs) = (node)->references; \
} while (0)
#define dns_rbtnode_refdecrement(node, refs) \
do { \
REQUIRE((node)->references > 0); \
ISC_REQUIRE((node)->references > 0); \
(node)->references--; \
if ((refs) != NULL) \
(*refs) = (node)->references; \

View file

@ -16,6 +16,7 @@
#define ISC_ASSERTIONS_H 1
#include <isc/lang.h>
#include <isc/likely.h>
#include <isc/platform.h>
ISC_LANG_BEGINDECLS

View file

@ -96,8 +96,10 @@
*** Imports
***/
#include <isc/assertions.h>
#include <isc/formatcheck.h>
#include <isc/lang.h>
#include <isc/likely.h>
#include <isc/magic.h>
#include <isc/types.h>
@ -878,11 +880,11 @@ ISC_LANG_ENDDECLS
#define ISC__BUFFER_PUTMEM(_b, _base, _length) \
do { \
if (ISC_UNLIKELY((_b)->autore)) { \
isc_buffer_t *tmpbuf = _b; \
REQUIRE(isc_buffer_reserve(&tmpbuf, _length) \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, _length) \
== ISC_R_SUCCESS); \
} \
REQUIRE(isc_buffer_availablelength(_b) >= (unsigned int) _length); \
ISC_REQUIRE(isc_buffer_availablelength(_b) >= (unsigned int) _length); \
memmove(isc_buffer_used(_b), (_base), (_length)); \
(_b)->used += (_length); \
} while (0)
@ -893,11 +895,11 @@ ISC_LANG_ENDDECLS
unsigned char *_cp; \
_length = strlen(_source); \
if (ISC_UNLIKELY((_b)->autore)) { \
isc_buffer_t *tmpbuf = _b; \
REQUIRE(isc_buffer_reserve(&tmpbuf, _length) \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, _length) \
== ISC_R_SUCCESS); \
} \
REQUIRE(isc_buffer_availablelength(_b) >= (unsigned int) _length); \
ISC_REQUIRE(isc_buffer_availablelength(_b) >= (unsigned int) _length); \
_cp = isc_buffer_used(_b); \
memmove(_cp, (_source), _length); \
(_b)->used += (_length); \
@ -908,11 +910,11 @@ ISC_LANG_ENDDECLS
unsigned char *_cp; \
isc_uint8_t _val2 = (_val); \
if (ISC_UNLIKELY((_b)->autore)) { \
isc_buffer_t *tmpbuf = _b; \
REQUIRE(isc_buffer_reserve(&tmpbuf, 1) \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, 1) \
== ISC_R_SUCCESS); \
} \
REQUIRE(isc_buffer_availablelength(_b) >= 1U); \
ISC_REQUIRE(isc_buffer_availablelength(_b) >= 1U); \
_cp = isc_buffer_used(_b); \
(_b)->used++; \
_cp[0] = _val2 & 0x00ff; \
@ -923,11 +925,11 @@ ISC_LANG_ENDDECLS
unsigned char *_cp; \
isc_uint16_t _val2 = (_val); \
if (ISC_UNLIKELY((_b)->autore)) { \
isc_buffer_t *tmpbuf = _b; \
REQUIRE(isc_buffer_reserve(&tmpbuf, 2) \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, 2) \
== ISC_R_SUCCESS); \
} \
REQUIRE(isc_buffer_availablelength(_b) >= 2U); \
ISC_REQUIRE(isc_buffer_availablelength(_b) >= 2U); \
_cp = isc_buffer_used(_b); \
(_b)->used += 2; \
_cp[0] = (unsigned char)((_val2 & 0xff00U) >> 8); \
@ -939,11 +941,11 @@ ISC_LANG_ENDDECLS
unsigned char *_cp; \
isc_uint32_t _val2 = (_val); \
if (ISC_UNLIKELY((_b)->autore)) { \
isc_buffer_t *tmpbuf = _b; \
REQUIRE(isc_buffer_reserve(&tmpbuf, 3) \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, 3) \
== ISC_R_SUCCESS); \
} \
REQUIRE(isc_buffer_availablelength(_b) >= 3U); \
ISC_REQUIRE(isc_buffer_availablelength(_b) >= 3U); \
_cp = isc_buffer_used(_b); \
(_b)->used += 3; \
_cp[0] = (unsigned char)((_val2 & 0xff0000U) >> 16); \
@ -956,11 +958,11 @@ ISC_LANG_ENDDECLS
unsigned char *_cp; \
isc_uint32_t _val2 = (_val); \
if (ISC_UNLIKELY((_b)->autore)) { \
isc_buffer_t *tmpbuf = _b; \
REQUIRE(isc_buffer_reserve(&tmpbuf, 4) \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, 4) \
== ISC_R_SUCCESS); \
} \
REQUIRE(isc_buffer_availablelength(_b) >= 4U); \
ISC_REQUIRE(isc_buffer_availablelength(_b) >= 4U); \
_cp = isc_buffer_used(_b); \
(_b)->used += 4; \
_cp[0] = (unsigned char)((_val2 & 0xff000000) >> 24); \

View file

@ -17,6 +17,7 @@
#include <isc/formatcheck.h>
#include <isc/lang.h>
#include <isc/likely.h>
#include <isc/platform.h>
ISC_LANG_BEGINDECLS