API Reference Manual  1.45.0
ODP COMPILER / OPTIMIZATION

API Description

Macros that check byte order and operations for byte order conversion.

Macros that will give hints to the compiler.

Macros that allow cache line size configuration, check that alignment is a power of two etc.

Macros

#define ODP_ALIGNED(x)   __attribute__((__aligned__(x)))
 Defines type/struct/variable alignment in bytes.
 
#define ODP_PACKED   __attribute__((__packed__))
 Defines type/struct to be packed.
 
#define ODP_OFFSETOF(type, member)   __builtin_offsetof(type, member)
 Returns offset of member in type.
 
#define ODP_FIELD_SIZEOF(type, member)   sizeof(((type *)0)->member)
 Returns sizeof member.
 
#define ODP_PAGE_SIZE   4096
 Page size in bytes.
 
#define ODP_ALIGNED_CACHE   ODP_ALIGNED(ODP_CACHE_LINE_SIZE)
 Defines type/struct/variable to be cache line size aligned.
 
#define ODP_ALIGNED_PAGE   ODP_ALIGNED(ODP_PAGE_SIZE)
 Defines type/struct/variable to be page size aligned.
 
#define ODP_CACHE_LINE_ROUNDUP(x)   ((ODP_CACHE_LINE_SIZE) * (((x) + (ODP_CACHE_LINE_SIZE) - 1) / (ODP_CACHE_LINE_SIZE)))
 Round up to cache line size. More...
 
#define ODP_LITTLE_ENDIAN   1
 Little endian byte order.
 
#define ODP_BIG_ENDIAN   0
 Big endian byte order.
 
#define ODP_BYTE_ORDER   ODP_LITTLE_ENDIAN
 Selected byte order.
 
#define ODP_LITTLE_ENDIAN_BITFIELD   1
 Little endian bit field.
 
#define ODP_BIG_ENDIAN_BITFIELD   0
 Big endian bit field.
 
#define ODP_BITFIELD_ORDER   ODP_LITTLE_ENDIAN_BITFIELD
 Selected bitfield order.
 
#define ODP_NORETURN   __attribute__((__noreturn__))
 Define a function that does not return.
 
#define ODP_WEAK_SYMBOL   __attribute__((__weak__))
 Define a weak symbol This is primarily useful in defining library functions that can be overridden in user code.
 
#define ODP_HOT_CODE   __attribute__((__hot__))
 Hot code section.
 
#define ODP_COLD_CODE   __attribute__((__cold__))
 Cold code section.
 
#define ODP_PRINTF_FORMAT(x, y)   __attribute__((format(printf, (x), (y))))
 Printf format attribute.
 
#define ODP_UNUSED   __attribute__((__unused__))
 Intentionally unused variables of functions.
 
#define odp_likely(x)   __builtin_expect(!!(x), 1)
 Branch likely taken.
 
#define odp_unlikely(x)   __builtin_expect(!!(x), 0)
 Branch unlikely taken.
 

Typedefs

typedef uint16_t odp_u16le_t
 unsigned 16bit little endian
 
typedef uint16_t odp_u16be_t
 unsigned 16bit big endian
 
typedef uint32_t odp_u32le_t
 unsigned 32bit little endian
 
typedef uint32_t odp_u32be_t
 unsigned 32bit big endian
 
typedef uint64_t odp_u64le_t
 unsigned 64bit little endian
 
typedef uint64_t odp_u64be_t
 unsigned 64bit big endian
 
typedef uint16_t odp_u16sum_t
 unsigned 16bit bitwise
 
typedef uint32_t odp_u32sum_t
 unsigned 32bit bitwise
 

Functions

uint16_t odp_be_to_cpu_16 (odp_u16be_t be16)
 Convert 16bit big endian to cpu native uint16_t. More...
 
uint32_t odp_be_to_cpu_32 (odp_u32be_t be32)
 Convert 32bit big endian to cpu native uint32_t. More...
 
uint64_t odp_be_to_cpu_64 (odp_u64be_t be64)
 Convert 64bit big endian to cpu native uint64_t. More...
 
odp_u16be_t odp_cpu_to_be_16 (uint16_t cpu16)
 Convert cpu native uint16_t to 16bit big endian. More...
 
odp_u32be_t odp_cpu_to_be_32 (uint32_t cpu32)
 Convert cpu native uint32_t to 32bit big endian. More...
 
odp_u64be_t odp_cpu_to_be_64 (uint64_t cpu64)
 Convert cpu native uint64_t to 64bit big endian. More...
 
uint16_t odp_le_to_cpu_16 (odp_u16le_t le16)
 Convert 16bit little endian to cpu native uint16_t. More...
 
uint32_t odp_le_to_cpu_32 (odp_u32le_t le32)
 Convert 32bit little endian to cpu native uint32_t. More...
 
uint64_t odp_le_to_cpu_64 (odp_u64le_t le64)
 Convert 64bit little endian to cpu native uint64_t. More...
 
odp_u16le_t odp_cpu_to_le_16 (uint16_t cpu16)
 Convert cpu native uint16_t to 16bit little endian. More...
 
odp_u32le_t odp_cpu_to_le_32 (uint32_t cpu32)
 Convert cpu native uint32_t to 32bit little endian. More...
 
odp_u64le_t odp_cpu_to_le_64 (uint64_t cpu64)
 Convert cpu native uint64_t to 64bit little endian. More...
 

Macro Definition Documentation

◆ ODP_CACHE_LINE_ROUNDUP

#define ODP_CACHE_LINE_ROUNDUP (   x)    ((ODP_CACHE_LINE_SIZE) * (((x) + (ODP_CACHE_LINE_SIZE) - 1) / (ODP_CACHE_LINE_SIZE)))

Round up to cache line size.

Rounds up the passed value to the next multiple of cache line size (ODP_CACHE_LINE_SIZE). Returns the original value if it is already a multiple of cache line size or zero.

Examples
odp_random.c.

Function Documentation

◆ odp_be_to_cpu_16()

uint16_t odp_be_to_cpu_16 ( odp_u16be_t  be16)

Convert 16bit big endian to cpu native uint16_t.

Parameters
be16big endian 16bit
Returns
cpu native uint16_t
Examples
ipsec_crypto/odp_ipsec.c, odp_bench_misc.c, odp_ipsecfwd.c, odp_l3fwd.c, odp_packet_dump.c, and odp_pktio_ordered.c.

◆ odp_be_to_cpu_32()

uint32_t odp_be_to_cpu_32 ( odp_u32be_t  be32)

Convert 32bit big endian to cpu native uint32_t.

Parameters
be32big endian 32bit
Returns
cpu native uint32_t
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_misc.c, odp_ipsecfwd.c, odp_l3fwd.c, odp_packet_gen.c, and odp_pktio_ordered.c.

◆ odp_be_to_cpu_64()

uint64_t odp_be_to_cpu_64 ( odp_u64be_t  be64)

Convert 64bit big endian to cpu native uint64_t.

Parameters
be64big endian 64bit
Returns
cpu native uint64_t
Examples
odp_bench_misc.c.

◆ odp_cpu_to_be_16()

odp_u16be_t odp_cpu_to_be_16 ( uint16_t  cpu16)

Convert cpu native uint16_t to 16bit big endian.

Parameters
cpu16uint16_t in cpu native format
Returns
big endian 16bit
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_misc.c, odp_classifier.c, odp_ipsec.c, odp_ipsecfwd.c, odp_l3fwd.c, odp_packet_gen.c, and odp_pktio_perf.c.

◆ odp_cpu_to_be_32()

odp_u32be_t odp_cpu_to_be_32 ( uint32_t  cpu32)

Convert cpu native uint32_t to 32bit big endian.

Parameters
cpu32uint32_t in cpu native format
Returns
big endian 32bit
Examples
ipsec_crypto/odp_ipsec.c, odp_bench_misc.c, odp_classifier.c, odp_ipsecfwd.c, odp_packet_gen.c, and odp_pktio_perf.c.

◆ odp_cpu_to_be_64()

odp_u64be_t odp_cpu_to_be_64 ( uint64_t  cpu64)

Convert cpu native uint64_t to 64bit big endian.

Parameters
cpu64uint64_t in cpu native format
Returns
big endian 64bit
Examples
odp_bench_misc.c.

◆ odp_le_to_cpu_16()

uint16_t odp_le_to_cpu_16 ( odp_u16le_t  le16)

Convert 16bit little endian to cpu native uint16_t.

Parameters
le16little endian 16bit
Returns
cpu native uint16_t
Examples
odp_bench_misc.c.

◆ odp_le_to_cpu_32()

uint32_t odp_le_to_cpu_32 ( odp_u32le_t  le32)

Convert 32bit little endian to cpu native uint32_t.

Parameters
le32little endian 32bit
Returns
cpu native uint32_t
Examples
odp_bench_misc.c.

◆ odp_le_to_cpu_64()

uint64_t odp_le_to_cpu_64 ( odp_u64le_t  le64)

Convert 64bit little endian to cpu native uint64_t.

Parameters
le64little endian 64bit
Returns
cpu native uint64_t
Examples
odp_bench_misc.c.

◆ odp_cpu_to_le_16()

odp_u16le_t odp_cpu_to_le_16 ( uint16_t  cpu16)

Convert cpu native uint16_t to 16bit little endian.

Parameters
cpu16uint16_t in cpu native format
Returns
little endian 16bit
Examples
odp_bench_misc.c.

◆ odp_cpu_to_le_32()

odp_u32le_t odp_cpu_to_le_32 ( uint32_t  cpu32)

Convert cpu native uint32_t to 32bit little endian.

Parameters
cpu32uint32_t in cpu native format
Returns
little endian 32bit
Examples
odp_bench_misc.c.

◆ odp_cpu_to_le_64()

odp_u64le_t odp_cpu_to_le_64 ( uint64_t  cpu64)

Convert cpu native uint64_t to 64bit little endian.

Parameters
cpu64uint64_t in cpu native format
Returns
little endian 64bit
Examples
odp_bench_misc.c.