Debian Codegraph @

third-party/zstd/contrib/pzstd/utils/Likely.h

raw
1 /*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 * All rights reserved.
4 *
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
8 */
9
10 /**
11 * Compiler hints to indicate the fast path of an "if" branch: whether
12 * the if condition is likely to be true or false.
13 *
14 * @author Tudor Bosman ([email protected])
15 */
16
17 #pragma once
18
19 #undef LIKELY
20 #undef UNLIKELY
21
22 #if defined(__GNUC__) && __GNUC__ >= 4
23 #define LIKELY(x) (__builtin_expect((x), 1))
24 #define UNLIKELY(x) (__builtin_expect((x), 0))
25 #else
26 #define LIKELY(x) (x)
27 #define UNLIKELY(x) (x)
28 #endif