CNDP  22.08.0
cne_branch_prediction.h File Reference

Go to the source code of this file.

Macros

#define likely(x)   __builtin_expect(!!(x), 1)
 
#define unlikely(x)   __builtin_expect(!!(x), 0)
 

Detailed Description

Branch Prediction Helpers in CNE

Definition in file cne_branch_prediction.h.

Macro Definition Documentation

◆ likely

#define likely (   x)    __builtin_expect(!!(x), 1)

Check if a branch is likely to be taken.

This compiler builtin allows the developer to indicate if a branch is likely to be taken. Example:

if (likely(x > 1)) do_stuff();

Examples
examples/cnet-graph/cnet-graph.c, examples/cnet-quic/cnet-quic.c, and examples/l3fwd-graph/fwd.c.

Definition at line 24 of file cne_branch_prediction.h.

◆ unlikely

#define unlikely (   x)    __builtin_expect(!!(x), 0)

Check if a branch is unlikely to be taken.

This compiler builtin allows the developer to indicate if a branch is unlikely to be taken. Example:

if (unlikely(x < 1)) do_stuff();

Definition at line 38 of file cne_branch_prediction.h.