Project

General

Profile

Bug #10856

add likely and unlikely macros to sys/ccompile.h

Added by Jerry Jelinek about 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2019-04-26
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

There are currently several duplicate definitions of the likely and unlikely macros in the source tree. We should have one common definition in sys/ccompile.h This one from lz4.c is a good example to follow

#if (GCC_VERSION >= 302) || (INTEL_COMPILER >= 800) || defined(_clang)
#define expect(expr, value) (
_builtin_expect((expr), (value)))
#else
#define expect(expr, value) (expr)
#endif

#define likely(expr) expect((expr) != 0, 1)
#define unlikely(expr) expect((expr) != 0, 0)

Also available in: Atom PDF