Skip to content

Commit

Permalink
utils: Add likely/unlikely macros
Browse files Browse the repository at this point in the history
Signed-off-by: Siddharth Chandrasekaran <[email protected]>
  • Loading branch information
sidcha committed Feb 21, 2024
1 parent a096d8d commit 3de34d6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,15 @@ extern "C" {
#define __noreturn
#define __weak
#define __unreachable()
#define likely(p) (p)
#define unlikely(p) (p)
#else
#define __format_printf(x, y) __attribute__((format(printf, x, y)))
#define __noreturn __attribute__((noreturn))
#define __weak __attribute__((weak))
#define __unreachable() __builtin_unreachable()
#define likely(p) __builtin_expect(!!(p), 1)
#define unlikely(p) __builtin_expect(!!(p), 0)
#endif

/**
Expand Down

0 comments on commit 3de34d6

Please sign in to comment.