DPDK  21.02.0
Macros
rte_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 RTE

Definition in file rte_branch_prediction.h.

Macro Definition Documentation

#define likely (   x)    __builtin_expect(!!(x), 1)
#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();

Examples:
examples/bbdev_app/main.c, examples/distributor/main.c, examples/flow_classify/flow_classify.c, examples/ioat/ioatfwd.c, examples/ip_fragmentation/main.c, examples/ip_reassembly/main.c, examples/ipsec-secgw/esp.c, examples/ipsec-secgw/ipsec-secgw.c, examples/ipsec-secgw/ipsec.c, examples/ipsec-secgw/ipsec_worker.c, examples/ipv4_multicast/main.c, examples/kni/main.c, examples/l2fwd-cat/l2fwd-cat.c, examples/l2fwd-crypto/main.c, examples/l2fwd-event/l2fwd_poll.c, examples/l2fwd-event/main.c, examples/l2fwd-keepalive/main.c, examples/l2fwd/main.c, examples/l3fwd-acl/main.c, examples/l3fwd-power/main.c, examples/l3fwd/l3fwd_em.c, examples/l3fwd/l3fwd_lpm.c, examples/link_status_interrupt/main.c, examples/multi_process/client_server_mp/mp_server/main.c, examples/ntb/ntb_fwd.c, examples/packet_ordering/main.c, examples/performance-thread/common/lthread_sched.c, examples/performance-thread/l3fwd-thread/main.c, examples/qos_meter/main.c, examples/qos_sched/app_thread.c, examples/rxtx_callbacks/main.c, examples/server_node_efd/node/node.c, examples/server_node_efd/server/main.c, examples/skeleton/basicfwd.c, examples/vhost/main.c, examples/vhost/virtio_net.c, examples/vhost_blk/blk.c, examples/vhost_crypto/main.c, examples/vmdq/main.c, and examples/vmdq_dcb/main.c.

Definition at line 38 of file rte_branch_prediction.h.