1 /* $NetBSD: likely.h,v 1.1 2024/02/18 20:57:53 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #ifndef ISC_LIKELY_H 17 #define ISC_LIKELY_H 1 18 19 /*% 20 * Performance 21 */ 22 #ifdef CPPCHECK 23 #define ISC_LIKELY(x) (x) 24 #define ISC_UNLIKELY(x) (x) 25 #else /* ifdef CPPCHECK */ 26 #ifdef HAVE_BUILTIN_EXPECT 27 #define ISC_LIKELY(x) __builtin_expect(!!(x), 1) 28 #define ISC_UNLIKELY(x) __builtin_expect(!!(x), 0) 29 #else /* ifdef HAVE_BUILTIN_EXPECT */ 30 #define ISC_LIKELY(x) (x) 31 #define ISC_UNLIKELY(x) (x) 32 #endif /* ifdef HAVE_BUILTIN_EXPECT */ 33 #endif /* ifdef CPPCHECK */ 34 35 #endif /* ISC_LIKELY_H */ 36