dns_message_create(...);
- CHECK(..., V);
-@@
-expression V;
-statement S;
-@@
-
-- V =
- dns_message_create(...);
-- if (ISC_UNLIKELY(V != ISC_R_SUCCESS)) S
-
@@
expression V;
@@
isc_buffer_allocate(...);
- CHECK(..., V);
-@@
-expression V;
-statement S;
-@@
-
-- V =
- isc_buffer_allocate(...);
-- if (ISC_UNLIKELY(V != ISC_R_SUCCESS)) S
-
@@
expression V;
@@
REQUIRE(dns_name_isabsolute(name));
REQUIRE(offset != NULL);
- if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) {
+ if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) {
return (false);
}
*/
ch = p[1];
i = tableindex[ch];
- if (ISC_LIKELY((cctx->allowed & DNS_COMPRESS_CASESENSITIVE) !=
- 0)) {
+ if ((cctx->allowed & DNS_COMPRESS_CASESENSITIVE) != 0) {
for (node = cctx->table[i]; node != NULL;
node = node->next) {
- if (ISC_UNLIKELY(node->name.length != length)) {
+ if (node->name.length != length) {
continue;
}
- if (ISC_LIKELY(memcmp(node->name.ndata, p,
- length) == 0)) {
+ if (memcmp(node->name.ndata, p, length) == 0) {
goto found;
}
}
unsigned char c;
unsigned char *label1, *label2;
- if (ISC_UNLIKELY(node->name.length != length)) {
+ if (node->name.length != length) {
continue;
}
l = labels - n;
- if (ISC_UNLIKELY(node->name.labels != l)) {
+ if (node->name.labels != l) {
continue;
}
label1 = node->name.ndata;
label2 = p;
- while (ISC_LIKELY(l-- > 0)) {
+ while (l-- > 0) {
count = *label1++;
if (count != *label2++) {
goto cont1;
INSIST(count <= 63);
/* Loop unrolled for performance */
- while (ISC_LIKELY(count > 3)) {
+ while (count > 3) {
c = maptolower[label1[0]];
if (c != maptolower[label2[0]])
{
label1 += 4;
label2 += 4;
}
- while (ISC_LIKELY(count-- > 0)) {
+ while (count-- > 0) {
c = maptolower[*label1++];
if (c != maptolower[*label2++])
{
REQUIRE(VALID_CCTX(cctx));
REQUIRE(dns_name_isabsolute(name));
- if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) {
+ if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) {
return;
}
REQUIRE(VALID_CCTX(cctx));
- if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) {
+ if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) {
return;
}
curr = ISC_LIST_PREV(curr, link))
{
if (curr->type == type && curr->covers == covers) {
- if (ISC_UNLIKELY(rdataset != NULL)) {
+ if (rdataset != NULL) {
*rdataset = curr;
}
return (ISC_R_SUCCESS);
/*
* And now look for the type.
*/
- if (ISC_UNLIKELY(type == dns_rdatatype_any)) {
+ if (type == dns_rdatatype_any) {
return (ISC_R_SUCCESS);
}
REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) ==
(name2->attributes & DNS_NAMEATTR_ABSOLUTE));
- if (ISC_UNLIKELY(name1 == name2)) {
+ if (name1 == name2) {
*orderp = 0;
*nlabelsp = name1->labels;
return (dns_namereln_equal);
offsets1 += l1;
offsets2 += l2;
- while (ISC_LIKELY(l > 0)) {
+ while (l > 0) {
l--;
offsets1--;
offsets2--;
}
/* Loop unrolled for performance */
- while (ISC_LIKELY(count > 3)) {
+ while (count > 3) {
chdiff = (int)maptolower[label1[0]] -
(int)maptolower[label2[0]];
if (chdiff != 0) {
label1 += 4;
label2 += 4;
}
- while (ISC_LIKELY(count-- > 0)) {
+ while (count-- > 0) {
chdiff = (int)maptolower[*label1++] -
(int)maptolower[*label2++];
if (chdiff != 0) {
REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) ==
(name2->attributes & DNS_NAMEATTR_ABSOLUTE));
- if (ISC_UNLIKELY(name1 == name2)) {
+ if (name1 == name2) {
return (true);
}
label1 = name1->ndata;
label2 = name2->ndata;
- while (ISC_LIKELY(l-- > 0)) {
+ while (l-- > 0) {
count = *label1++;
if (count != *label2++) {
return (false);
INSIST(count <= 63); /* no bitstring support */
/* Loop unrolled for performance */
- while (ISC_LIKELY(count > 3)) {
+ while (count > 3) {
c = maptolower[label1[0]];
if (c != maptolower[label2[0]]) {
return (false);
label1 += 4;
label2 += 4;
}
- while (ISC_LIKELY(count-- > 0)) {
+ while (count-- > 0) {
c = maptolower[*label1++];
if (c != maptolower[*label2++]) {
return (false);
REQUIRE(BINDABLE(target));
p = source->ndata;
- if (ISC_UNLIKELY(first == source->labels)) {
+ if (first == source->labels) {
firstoffset = source->length;
} else {
for (i = 0; i < first; i++) {
firstoffset = (unsigned int)(p - source->ndata);
}
- if (ISC_LIKELY(first + n == source->labels)) {
+ if (first + n == source->labels) {
endoffset = source->length;
} else {
for (i = 0; i < n; i++) {
offset = 0;
nlabels = 0;
absolute = false;
- while (ISC_LIKELY(offset != length)) {
+ while (offset != length) {
INSIST(nlabels < 128);
offsets[nlabels++] = offset;
count = *ndata;
offset += count + 1;
ndata += count + 1;
INSIST(offset <= length);
- if (ISC_UNLIKELY(count == 0)) {
+ if (count == 0) {
absolute = true;
break;
}
(name->attributes & DNS_NAMEATTR_NOCOMPRESS) == 0 &&
(methods & DNS_COMPRESS_GLOBAL14) != 0)
{
- if (ISC_UNLIKELY(target->length - target->used < 2)) {
+ if (target->length - target->used < 2) {
return (ISC_R_NOSPACE);
}
offset = *comp_offsetp;
* If the offset is too high for 14 bit global compression, we're
* out of luck.
*/
- if (gf && ISC_UNLIKELY(go >= 0x4000)) {
+ if (gf && go >= 0x4000) {
gf = false;
}
}
if (gf) {
- if (ISC_UNLIKELY(target->length - target->used < gp.length)) {
+ if (target->length - target->used < gp.length) {
return (ISC_R_NOSPACE);
}
if (gp.length != 0) {
(size_t)gp.length);
}
isc_buffer_add(target, gp.length);
- if (ISC_UNLIKELY(target->length - target->used < 2)) {
+ if (target->length - target->used < 2) {
return (ISC_R_NOSPACE);
}
isc_buffer_putuint16(target, go | 0xc000);
*comp_offsetp = go;
}
} else {
- if (ISC_UNLIKELY(target->length - target->used < name->length))
- {
+ if (target->length - target->used < name->length) {
return (ISC_R_NOSPACE);
}
if (name->length != 0) {
static inline bool
rehashing_in_progress(dns_rbt_t *rbt);
-#define TRY_NEXTTABLE(hindex, rbt) \
- (ISC_LIKELY(hindex == rbt->hindex) && \
- ISC_UNLIKELY(rehashing_in_progress(rbt)))
+#define TRY_NEXTTABLE(hindex, rbt) \
+ (hindex == rbt->hindex && rehashing_in_progress(rbt))
static inline void
rotate_left(dns_rbtnode_t *node, dns_rbtnode_t **rootp);
INSIST(add_name != NULL);
dns_name_clone(name, add_name);
- if (ISC_UNLIKELY(rbt->root == NULL)) {
+ if (rbt->root == NULL) {
result = create_node(rbt->mctx, add_name, &new_current);
if (result == ISC_R_SUCCESS) {
rbt->nodecount++;
}
}
}
- } while (ISC_LIKELY(child != NULL));
+ } while (child != NULL);
- if (ISC_LIKELY(result == ISC_R_SUCCESS)) {
+ if (result == ISC_R_SUCCESS) {
result = create_node(rbt->mctx, add_name, &new_current);
}
- if (ISC_LIKELY(result == ISC_R_SUCCESS)) {
+ if (result == ISC_R_SUCCESS) {
if (*root == NULL) {
UPPERNODE(new_current) = current;
} else {
dns_rbtnodechain_reset(chain);
}
- if (ISC_UNLIKELY(rbt->root == NULL)) {
+ if (rbt->root == NULL) {
return (ISC_R_NOTFOUND);
}
saved_result = ISC_R_SUCCESS;
current = rbt->root;
- while (ISC_LIKELY(current != NULL)) {
+ while (current != NULL) {
NODENAME(current, ¤t_name);
compared = dns_name_fullcompare(search_name, ¤t_name,
&order, &common_labels);
{
dns_name_t hnode_name;
- if (ISC_LIKELY(hashval != HASHVAL(hnode))) {
+ if (hashval != HASHVAL(hnode)) {
continue;
}
/*
* that we don't match a labelsequence from some
* other subdomain.
*/
- if (ISC_LIKELY(get_upper_node(hnode) !=
- up_current)) {
+ if (get_upper_node(hnode) != up_current) {
continue;
}
dns_name_init(&hnode_name, NULL);
NODENAME(hnode, &hnode_name);
- if (ISC_LIKELY(dns_name_equal(&hnode_name,
- &hash_name))) {
+ if (dns_name_equal(&hnode_name, &hash_name)) {
break;
}
}
hash_node(dns_rbt_t *rbt, dns_rbtnode_t *node, const dns_name_t *name) {
REQUIRE(DNS_RBTNODE_VALID(node));
- if (ISC_UNLIKELY(rehashing_in_progress(rbt))) {
+ if (rehashing_in_progress(rbt)) {
/* Rehash in progress */
hashtable_rehash_one(rbt);
- } else if (ISC_UNLIKELY(hashtable_is_overcommited(rbt))) {
+ } else if (hashtable_is_overcommited(rbt)) {
/* Rehash requested */
maybe_rehash(rbt, rbt->nodecount);
}
}
}
RDATASET_ATTR_SET(header, RDATASET_ATTR_CASESET);
- if (ISC_LIKELY(fully_lower)) {
+ if (fully_lower) {
RDATASET_ATTR_SET(header, RDATASET_ATTR_CASEFULLYLOWER);
}
}
goto unlock;
}
- if (ISC_LIKELY(CASEFULLYLOWER(header))) {
+ if (CASEFULLYLOWER(header)) {
for (size_t i = 0; i < name->length; i++) {
name->ndata[i] = tolower(name->ndata[i]);
}
maybe_rehash_gluetable(rbtdb_version_t *version) {
size_t overcommit = HASHSIZE(version->glue_table_bits) *
RBTDB_GLUE_TABLE_OVERCOMMIT;
- if (ISC_LIKELY(version->glue_table_nodecount < overcommit)) {
+ if (version->glue_table_nodecount < overcommit) {
return;
}
dns_name_t *gluename = dns_fixedname_name(&ge->fixedname);
result = dns_message_gettempname(msg, &name);
- if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
+ if (result != ISC_R_SUCCESS) {
goto no_glue;
}
if (dns_rdataset_isassociated(&ge->rdataset_a)) {
result = dns_message_gettemprdataset(msg, &rdataset_a);
- if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
+ if (result != ISC_R_SUCCESS) {
dns_message_puttempname(msg, &name);
goto no_glue;
}
if (dns_rdataset_isassociated(&ge->sigrdataset_a)) {
result = dns_message_gettemprdataset(msg,
&sigrdataset_a);
- if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
+ if (result != ISC_R_SUCCESS) {
if (rdataset_a != NULL) {
dns_message_puttemprdataset(
msg, &rdataset_a);
if (dns_rdataset_isassociated(&ge->rdataset_aaaa)) {
result = dns_message_gettemprdataset(msg,
&rdataset_aaaa);
- if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
+ if (result != ISC_R_SUCCESS) {
dns_message_puttempname(msg, &name);
if (rdataset_a != NULL) {
dns_message_puttemprdataset(
if (dns_rdataset_isassociated(&ge->sigrdataset_aaaa)) {
result = dns_message_gettemprdataset(msg,
&sigrdataset_aaaa);
- if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) {
+ if (result != ISC_R_SUCCESS) {
dns_message_puttempname(msg, &name);
if (rdataset_a != NULL) {
dns_message_puttemprdataset(
}
}
- if (ISC_LIKELY(rdataset_a != NULL)) {
+ if (rdataset_a != NULL) {
dns_rdataset_clone(&ge->rdataset_a, rdataset_a);
ISC_LIST_APPEND(name->list, rdataset_a, link);
}
}
INSIST(i == count);
- if (ISC_LIKELY(want_random)) {
+ if (want_random) {
seed = isc_random32();
}
- if (ISC_UNLIKELY(want_cyclic) &&
- (rdataset->count != DNS_RDATASET_COUNT_UNDEFINED))
- {
+ if (want_cyclic &&
+ (rdataset->count != DNS_RDATASET_COUNT_UNDEFINED)) {
j = rdataset->count % count;
}
for (i = 0; i < count; i++) {
- if (ISC_LIKELY(want_random)) {
+ if (want_random) {
swap_rdata(in, j, j + seed % (count - j));
}
/*
* XXXRTH Currently we support only one question.
*/
- if (ISC_UNLIKELY(message->counts[DNS_SECTION_QUESTION] == 0)) {
+ if (message->counts[DNS_SECTION_QUESTION] == 0) {
if ((message->flags & DNS_MESSAGEFLAG_TC) != 0) {
/*
* If TC=1 and the question section is empty, we
log_formerr(fctx, "empty question section");
return (DNS_R_FORMERR);
}
- } else if (ISC_UNLIKELY(message->counts[DNS_SECTION_QUESTION] > 1)) {
+ } else if (message->counts[DNS_SECTION_QUESTION] > 1) {
log_formerr(fctx, "too many questions");
return (DNS_R_FORMERR);
}
*/
for (i = 0; bit < maxbit; i++, bit += DNS_RPZ_CIDR_WORD_BITS) {
delta = key1->w[i] ^ key2->w[i];
- if (ISC_UNLIKELY(delta != 0)) {
+ if (delta != 0) {
#ifdef HAVE_BUILTIN_CLZ
bit += __builtin_clz(delta);
#else /* ifdef HAVE_BUILTIN_CLZ */
include/isc/iterated_hash.h \
include/isc/lang.h \
include/isc/lex.h \
- include/isc/likely.h \
include/isc/list.h \
include/isc/log.h \
include/isc/magic.h \
isc__buffer_putuint8(isc_buffer_t *b, uint8_t val) {
isc_result_t result;
REQUIRE(ISC_BUFFER_VALID(b));
- if (ISC_UNLIKELY(b->autore)) {
+ if (b->autore) {
result = isc_buffer_reserve(&b, 1);
REQUIRE(result == ISC_R_SUCCESS);
}
isc__buffer_putuint16(isc_buffer_t *b, uint16_t val) {
isc_result_t result;
REQUIRE(ISC_BUFFER_VALID(b));
- if (ISC_UNLIKELY(b->autore)) {
+ if (b->autore) {
result = isc_buffer_reserve(&b, 2);
REQUIRE(result == ISC_R_SUCCESS);
}
isc__buffer_putuint24(isc_buffer_t *b, uint32_t val) {
isc_result_t result;
REQUIRE(ISC_BUFFER_VALID(b));
- if (ISC_UNLIKELY(b->autore)) {
+ if (b->autore) {
result = isc_buffer_reserve(&b, 3);
REQUIRE(result == ISC_R_SUCCESS);
}
isc__buffer_putuint32(isc_buffer_t *b, uint32_t val) {
isc_result_t result;
REQUIRE(ISC_BUFFER_VALID(b));
- if (ISC_UNLIKELY(b->autore)) {
+ if (b->autore) {
result = isc_buffer_reserve(&b, 4);
REQUIRE(result == ISC_R_SUCCESS);
}
uint32_t vallo;
REQUIRE(ISC_BUFFER_VALID(b));
- if (ISC_UNLIKELY(b->autore)) {
+ if (b->autore) {
result = isc_buffer_reserve(&b, 6);
REQUIRE(result == ISC_R_SUCCESS);
}
unsigned int length) {
isc_result_t result;
REQUIRE(ISC_BUFFER_VALID(b));
- if (ISC_UNLIKELY(b->autore)) {
+ if (b->autore) {
result = isc_buffer_reserve(&b, length);
REQUIRE(result == ISC_R_SUCCESS);
}
* Do not use ISC__BUFFER_PUTSTR(), so strlen is only done once.
*/
l = strlen(source);
- if (ISC_UNLIKELY(b->autore)) {
+ if (b->autore) {
result = isc_buffer_reserve(&b, l);
REQUIRE(result == ISC_R_SUCCESS);
}
/* xxxwpk do it more low-level way ? */
l = snprintf(buf, 21, "%" PRId64, v);
RUNTIME_CHECK(l <= 21);
- if (ISC_UNLIKELY(b->autore)) {
+ if (b->autore) {
result = isc_buffer_reserve(&b, l);
REQUIRE(result == ISC_R_SUCCESS);
}
REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(r != NULL);
- if (ISC_UNLIKELY(b->autore)) {
+ if (b->autore) {
result = isc_buffer_reserve(&b, r->length);
if (result != ISC_R_SUCCESS) {
return (result);
return (ISC_R_FAILURE);
}
- if (ISC_UNLIKELY(b->autore)) {
+ if (b->autore) {
result = isc_buffer_reserve(&b, n + 1);
if (result != ISC_R_SUCCESS) {
return (result);
#include "entropy_private.h"
#include "isc/hash.h" /* IWYU pragma: keep */
-#include "isc/likely.h"
#include "isc/once.h"
#include "isc/random.h"
#include "isc/result.h"
const void *
isc_hash_get_initializer(void) {
- if (ISC_UNLIKELY(!hash_initialized)) {
+ if (!hash_initialized) {
RUNTIME_CHECK(
isc_once_do(&isc_hash_once, isc_hash_initialize) ==
ISC_R_SUCCESS);
* Ensure that isc_hash_initialize() is not called after
* isc_hash_set_initializer() is called.
*/
- if (ISC_UNLIKELY(!hash_initialized)) {
+ if (!hash_initialized) {
RUNTIME_CHECK(
isc_once_do(&isc_hash_once, isc_hash_initialize) ==
ISC_R_SUCCESS);
void
isc_hmac_free(isc_hmac_t *hmac) {
- if (ISC_UNLIKELY(hmac == NULL)) {
+ if (hmac == NULL) {
return;
}
isc_hmac_update(isc_hmac_t *hmac, const unsigned char *buf, const size_t len) {
REQUIRE(hmac != NULL);
- if (ISC_UNLIKELY(buf == NULL || len == 0)) {
+ if (buf == NULL || len == 0) {
return (ISC_R_SUCCESS);
}
#include <isc/attributes.h>
#include <isc/lang.h>
-#include <isc/likely.h>
ISC_LANG_BEGINDECLS
isc_assertion_typetotext(isc_assertiontype_t type);
#define ISC_REQUIRE(cond) \
- ((void)(ISC_LIKELY(cond) || \
+ ((void)((cond) || \
((isc_assertion_failed)(__FILE__, __LINE__, \
isc_assertiontype_require, #cond), \
0)))
#define ISC_ENSURE(cond) \
- ((void)(ISC_LIKELY(cond) || \
+ ((void)((cond) || \
((isc_assertion_failed)(__FILE__, __LINE__, \
isc_assertiontype_ensure, #cond), \
0)))
#define ISC_INSIST(cond) \
- ((void)(ISC_LIKELY(cond) || \
+ ((void)((cond) || \
((isc_assertion_failed)(__FILE__, __LINE__, \
isc_assertiontype_insist, #cond), \
0)))
#define ISC_INVARIANT(cond) \
- ((void)(ISC_LIKELY(cond) || \
+ ((void)((cond) || \
((isc_assertion_failed)(__FILE__, __LINE__, \
isc_assertiontype_invariant, #cond), \
0)))
#include <isc/assertions.h>
#include <isc/formatcheck.h>
#include <isc/lang.h>
-#include <isc/likely.h>
#include <isc/magic.h>
#include <isc/types.h>
#define ISC__BUFFER_PUTMEM(_b, _base, _length) \
do { \
- if (ISC_UNLIKELY((_b)->autore)) { \
+ if ((_b)->autore) { \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, _length) == \
ISC_R_SUCCESS); \
unsigned int _length; \
unsigned char *_cp; \
_length = (unsigned int)strlen(_source); \
- if (ISC_UNLIKELY((_b)->autore)) { \
+ if ((_b)->autore) { \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, _length) == \
ISC_R_SUCCESS); \
unsigned char *_cp; \
/* evaluate (_val) only once */ \
uint8_t _val2 = (_val); \
- if (ISC_UNLIKELY((_b)->autore)) { \
+ if ((_b)->autore) { \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, 1) == \
ISC_R_SUCCESS); \
unsigned char *_cp; \
/* evaluate (_val) only once */ \
uint16_t _val2 = (_val); \
- if (ISC_UNLIKELY((_b)->autore)) { \
+ if ((_b)->autore) { \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, 2) == \
ISC_R_SUCCESS); \
unsigned char *_cp; \
/* evaluate (_val) only once */ \
uint32_t _val2 = (_val); \
- if (ISC_UNLIKELY((_b)->autore)) { \
+ if ((_b)->autore) { \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, 3) == \
ISC_R_SUCCESS); \
unsigned char *_cp; \
/* evaluate (_val) only once */ \
uint32_t _val2 = (_val); \
- if (ISC_UNLIKELY((_b)->autore)) { \
+ if ((_b)->autore) { \
isc_buffer_t *_tmp = _b; \
ISC_REQUIRE(isc_buffer_reserve(&_tmp, 4) == \
ISC_R_SUCCESS); \
#include <isc/attributes.h>
#include <isc/formatcheck.h>
#include <isc/lang.h>
-#include <isc/likely.h>
ISC_LANG_BEGINDECLS
isc_error_runtimecheck(const char *, int, const char *);
#define ISC_ERROR_RUNTIMECHECK(cond) \
- ((void)(ISC_LIKELY(cond) || \
+ ((void)((cond) || \
((isc_error_runtimecheck)(__FILE__, __LINE__, #cond), 0)))
ISC_LANG_ENDDECLS
+++ /dev/null
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-#pragma once
-
-/*%
- * Performance
- */
-#ifdef CPPCHECK
-#define ISC_LIKELY(x) (x)
-#define ISC_UNLIKELY(x) (x)
-#else /* ifdef CPPCHECK */
-#ifdef HAVE_BUILTIN_EXPECT
-#define ISC_LIKELY(x) __builtin_expect(!!(x), 1)
-#define ISC_UNLIKELY(x) __builtin_expect(!!(x), 0)
-#else /* ifdef HAVE_BUILTIN_EXPECT */
-#define ISC_LIKELY(x) (x)
-#define ISC_UNLIKELY(x) (x)
-#endif /* ifdef HAVE_BUILTIN_EXPECT */
-#endif /* ifdef CPPCHECK */
#pragma once
-#include <isc/likely.h>
-
/*! \file isc/magic.h */
typedef struct {
* The intent of this is to allow magic numbers to be checked even though
* the object is otherwise opaque.
*/
-#define ISC_MAGIC_VALID(a, b) \
- (ISC_LIKELY((a) != NULL) && \
- ISC_LIKELY(((const isc__magic_t *)(a))->magic == (b)))
+#define ISC_MAGIC_VALID(a, b) \
+ ((a) != NULL && ((const isc__magic_t *)(a))->magic == (b))
#define ISC_MAGIC(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
/*%
* Performance
*/
-#include <isc/likely.h>
#ifdef HAVE_BUILTIN_UNREACHABLE
#define ISC_UNREACHABLE() __builtin_unreachable();
void
isc_md_free(isc_md_t *md) {
- if (ISC_UNLIKELY(md == NULL)) {
+ if (md == NULL) {
return;
}
isc_md_update(isc_md_t *md, const unsigned char *buf, const size_t len) {
REQUIRE(md != NULL);
- if (ISC_UNLIKELY(buf == NULL || len == 0)) {
+ if (buf == NULL || len == 0) {
return (ISC_R_SUCCESS);
}
#else /* if !ISC_MEM_TRACKLINES */
#define TRACE_OR_RECORD (ISC_MEM_DEBUGTRACE | ISC_MEM_DEBUGRECORD)
-#define SHOULD_TRACE_OR_RECORD(ptr) \
- (ISC_UNLIKELY((isc_mem_debugging & TRACE_OR_RECORD) != 0) && \
- ptr != NULL)
+#define SHOULD_TRACE_OR_RECORD(ptr) \
+ ((isc_mem_debugging & TRACE_OR_RECORD) != 0 && ptr != NULL)
#define ADD_TRACE(a, b, c, d, e) \
if (SHOULD_TRACE_OR_RECORD(b)) { \
idx = hash % DEBUG_TABLE_COUNT;
dl = ISC_LIST_HEAD(mctx->debuglist[idx]);
- while (ISC_LIKELY(dl != NULL)) {
- if (ISC_UNLIKELY(dl->ptr == ptr)) {
+ while (dl != NULL) {
+ if (dl->ptr == ptr) {
ISC_LIST_UNLINK(mctx->debuglist[idx], dl, link);
decrement_malloced(mctx, sizeof(*dl));
sdallocx(dl, sizeof(*dl), 0);
#endif /* ISC_MEM_TRACKLINES */
#define ADJUST_ZERO_ALLOCATION_SIZE(s) \
- if (ISC_UNLIKELY(s == 0)) { \
+ if (s == 0) { \
s = ZERO_ALLOCATION_SIZE; \
}
ret = mallocx(size, 0);
INSIST(ret != NULL);
- if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) {
+ if ((ctx->flags & ISC_MEMFLAG_FILL) != 0) {
memset(ret, 0xbe, size); /* Mnemonic for "beef". */
}
mem_put(isc_mem_t *ctx, void *mem, size_t size) {
ADJUST_ZERO_ALLOCATION_SIZE(size);
- if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) {
+ if ((ctx->flags & ISC_MEMFLAG_FILL) != 0) {
memset(mem, 0xde, size); /* Mnemonic for "dead". */
}
sdallocx(mem, size, 0);
new_ptr = rallocx(old_ptr, new_size, 0);
INSIST(new_ptr != NULL);
- if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) {
+ if ((ctx->flags & ISC_MEMFLAG_FILL) != 0) {
ssize_t diff_size = new_size - old_size;
void *diff_ptr = (uint8_t *)new_ptr + old_size;
if (diff_size > 0) {
ISC_LIST_INIT(ctx->pools);
#if ISC_MEM_TRACKLINES
- if (ISC_UNLIKELY((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0)) {
+ if ((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0) {
unsigned int i;
ctx->debuglist =
INSIST(ISC_LIST_EMPTY(ctx->pools));
#if ISC_MEM_TRACKLINES
- if (ISC_UNLIKELY(ctx->debuglist != NULL)) {
+ if (ctx->debuglist != NULL) {
debuglink_t *dl;
for (i = 0; i < DEBUG_TABLE_COUNT; i++) {
for (dl = ISC_LIST_HEAD(ctx->debuglist[i]); dl != NULL;
size_t new_size FLARG) {
void *new_ptr = NULL;
- if (ISC_UNLIKELY(old_ptr == NULL)) {
+ if (old_ptr == NULL) {
REQUIRE(old_size == 0);
new_ptr = isc__mem_get(ctx, new_size FLARG_PASS);
- } else if (ISC_UNLIKELY(new_size == 0)) {
+ } else if (new_size == 0) {
isc__mem_put(ctx, old_ptr, old_size FLARG_PASS);
} else {
DELETE_TRACE(ctx, old_ptr, old_size, file, line);
REQUIRE(VALID_CONTEXT(ctx));
- if (ISC_UNLIKELY(old_ptr == NULL)) {
+ if (old_ptr == NULL) {
new_ptr = isc__mem_allocate(ctx, new_size FLARG_PASS);
- } else if (ISC_UNLIKELY(new_size == 0)) {
+ } else if (new_size == 0) {
isc__mem_free(ctx, old_ptr FLARG_PASS);
} else {
size_t old_size = sallocx(old_ptr, 0);
mpctx->allocated++;
- if (ISC_UNLIKELY(mpctx->items == NULL)) {
+ if (mpctx->items == NULL) {
isc_mem_t *mctx = mpctx->mctx;
const size_t fillcount = mpctx->fillcount;
/*
LOCK(&contextslock);
if (!ISC_LIST_EMPTY(contexts)) {
#if ISC_MEM_TRACKLINES
- if (ISC_UNLIKELY((isc_mem_debugging & TRACE_OR_RECORD) != 0)) {
+ if ((isc_mem_debugging & TRACE_OR_RECORD) != 0) {
print_contexts(file);
}
#endif /* if ISC_MEM_TRACKLINES */
/* We are tying to avoid a memory allocation for small write
* requests. See the mirroring code in the tls_send_outgoing()
* function. */
- if (ISC_UNLIKELY(send_req->data.length > sizeof(send_req->smallbuf))) {
+ if (send_req->data.length > sizeof(send_req->smallbuf)) {
isc_mem_put(handle->sock->mgr->mctx, send_req->data.base,
send_req->data.length);
} else {
.data.length = pending };
/* Let's try to avoid a memory allocation for small write requests */
- if (ISC_UNLIKELY((size_t)pending > sizeof(send_req->smallbuf))) {
+ if ((size_t)pending > sizeof(send_req->smallbuf)) {
send_req->data.base = isc_mem_get(sock->mgr->mctx, pending);
} else {
send_req->data.base = &send_req->smallbuf[0];
* If # zone labels < # name labels, try to find an even better match
* Only try if DLZ drivers are loaded for this view
*/
- if (ISC_UNLIKELY(zonelabels < namelabels &&
- !ISC_LIST_EMPTY(client->view->dlz_searched)))
- {
+ if (zonelabels < namelabels &&
+ !ISC_LIST_EMPTY(client->view->dlz_searched)) {
dns_clientinfomethods_t cm;
dns_clientinfo_t ci;
dns_db_t *tdbp;
result = query_getdb(qctx->client, qctx->client->query.qname,
qctx->qtype, qctx->options, &qctx->zone, &qctx->db,
&qctx->version, &qctx->is_zone);
- if (ISC_UNLIKELY((result != ISC_R_SUCCESS || !qctx->is_zone) &&
- qctx->qtype == dns_rdatatype_ds &&
- !RECURSIONOK(qctx->client) &&
- (qctx->options & DNS_GETDB_NOEXACT) != 0))
+ if ((result != ISC_R_SUCCESS || !qctx->is_zone) &&
+ qctx->qtype == dns_rdatatype_ds && !RECURSIONOK(qctx->client) &&
+ (qctx->options & DNS_GETDB_NOEXACT) != 0)
{
/*
* This is a non-recursive QTYPE=DS query with QNAME whose
REQUIRE(buffer != NULL);
qctx->dbuf = ns_client_getnamebuf(qctx->client);
- if (ISC_UNLIKELY(qctx->dbuf == NULL)) {
+ if (qctx->dbuf == NULL) {
CCTRACE(ISC_LOG_ERROR,
"qctx_prepare_buffers: ns_client_getnamebuf "
"failed");
}
qctx->fname = ns_client_newname(qctx->client, qctx->dbuf, buffer);
- if (ISC_UNLIKELY(qctx->fname == NULL)) {
+ if (qctx->fname == NULL) {
CCTRACE(ISC_LOG_ERROR,
"qctx_prepare_buffers: ns_client_newname failed");
}
qctx->rdataset = ns_client_newrdataset(qctx->client);
- if (ISC_UNLIKELY(qctx->rdataset == NULL)) {
+ if (qctx->rdataset == NULL) {
CCTRACE(ISC_LOG_ERROR,
"qctx_prepare_buffers: ns_client_newrdataset failed");
goto error;
./lib/isc/include/isc/iterated_hash.h C 2008,2014,2016,2018,2019,2020,2021
./lib/isc/include/isc/lang.h C 1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020,2021
./lib/isc/include/isc/lex.h C 1998,1999,2000,2001,2002,2004,2005,2007,2008,2015,2016,2017,2018,2019,2020,2021
-./lib/isc/include/isc/likely.h C 2017,2018,2019,2020,2021
./lib/isc/include/isc/list.h C 1997,1998,1999,2000,2001,2002,2004,2006,2007,2011,2012,2013,2016,2018,2019,2020,2021
./lib/isc/include/isc/log.h C 1999,2000,2001,2002,2004,2005,2006,2007,2009,2014,2016,2017,2018,2019,2020,2021
./lib/isc/include/isc/magic.h C 1999,2000,2001,2004,2005,2006,2007,2016,2017,2018,2019,2020,2021