FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
clib.h File Reference
+ Include dependency graph for clib.h:

Go to the source code of this file.

Macros

#define CLIB_UNIX
 
#define BITS(x)   (8*sizeof(x))
 
#define ARRAY_LEN(x)   (sizeof (x)/sizeof (x[0]))
 
#define STRUCT_OFFSET_OF(t, f)   offsetof(t, f)
 
#define STRUCT_BIT_OFFSET_OF(t, f)   (BITS(u8) * STRUCT_OFFSET_OF (t, f))
 
#define STRUCT_SIZE_OF(t, f)   (sizeof (_STRUCT_FIELD (t, f)))
 
#define STRUCT_BITS_OF(t, f)   (BITS (_STRUCT_FIELD (t, f)))
 
#define STRUCT_ARRAY_LEN(t, f)   ARRAY_LEN (_STRUCT_FIELD (t, f))
 
#define STRUCT_MARK(mark)   u8 mark[0]
 
#define STRUCT_MARK_PTR(v, f)   &(v)->f
 
#define STRUCT_STRIDE_OF(t, f)
 
#define STRUCT_OFFSET_OF_VAR(v, f)   ((uword) (&(v)->f) - (uword) (v))
 
#define CLIB_PACKED(x)   x __attribute__ ((packed))
 
#define CLIB_UNUSED(x)   x __attribute__ ((unused))
 
#define CLIB_ALIGN_MARK(name, alignment)   u8 name[0] __attribute__((aligned(alignment)))
 
#define CLIB_STRING_MACRO(x)   #x
 
#define never_inline   __attribute__ ((__noinline__))
 
#define always_inline   static inline
 
#define static_always_inline   static inline
 
#define u8   pad_from[(to) - (from)] u8 pad_##from[(to) - (from)]
 Padding. More...
 
#define PREDICT_FALSE(x)   __builtin_expect((x),0)
 
#define PREDICT_TRUE(x)   __builtin_expect((x),1)
 
#define COMPILE_TIME_CONST(x)   __builtin_constant_p (x)
 
#define CLIB_COMPILER_BARRIER()   asm volatile ("":::"memory")
 
#define CLIB_MEMORY_BARRIER()   __sync_synchronize ()
 
#define CLIB_MEMORY_STORE_BARRIER()   __builtin_ia32_sfence ()
 
#define INIT_FUNCTION(decl)
 
#define EXIT_FUNCTION(decl)
 
#define count_leading_zeros(x)   __builtin_clzl (x)
 
#define count_trailing_zeros(x)   __builtin_ctzl (x)
 
#define clib_max(x, y)
 
#define clib_min(x, y)
 
#define clib_clamp(x, lo, hi)
 
#define clib_abs(x)
 

Functions

static uword clear_lowest_set_bit (uword x)
 
static uword min_log2 (uword x)
 
static uword max_log2 (uword x)
 
static u64 min_log2_u64 (u64 x)
 
static uword pow2_mask (uword x)
 
static uword max_pow2 (uword x)
 
static uword is_pow2 (uword x)
 
static uword round_down_pow2 (uword x, uword pow2)
 
static uword round_pow2 (uword x, uword pow2)
 
static u64 round_pow2_u64 (u64 x, u64 pow2)
 
static uword first_set (uword x)
 
static uword log2_first_set (uword x)
 
static f64 flt_round_down (f64 x)
 
static word flt_round_nearest (f64 x)
 
static f64 flt_round_to_multiple (f64 x, f64 f)
 
static uword extract_bits (uword x, int start, int count)
 
uword clib_backtrace (uword *callers, uword max_callers, uword n_frames_to_skip)
 

Macro Definition Documentation

◆ always_inline

#define always_inline   static inline

Definition at line 111 of file clib.h.

◆ ARRAY_LEN

#define ARRAY_LEN (   x)    (sizeof (x)/sizeof (x[0]))

Definition at line 70 of file clib.h.

◆ BITS

#define BITS (   x)    (8*sizeof(x))

Definition at line 69 of file clib.h.

◆ clib_abs

#define clib_abs (   x)
Value:
({ \
__typeof__ (x) _x = (x); \
_x < 0 ? -_x : _x; \
})

Definition at line 357 of file clib.h.

◆ CLIB_ALIGN_MARK

#define CLIB_ALIGN_MARK (   name,
  alignment 
)    u8 name[0] __attribute__((aligned(alignment)))

Definition at line 93 of file clib.h.

◆ clib_clamp

#define clib_clamp (   x,
  lo,
  hi 
)
Value:
({ \
__typeof__ (x) _x = (x); \
__typeof__ (lo) _lo = (lo); \
__typeof__ (hi) _hi = (hi); \
_x < _lo ? _lo : (_x > _hi ? _hi : _x); \
})

Definition at line 349 of file clib.h.

◆ CLIB_COMPILER_BARRIER

#define CLIB_COMPILER_BARRIER ( )    asm volatile ("":::"memory")

Definition at line 134 of file clib.h.

◆ clib_max

#define clib_max (   x,
 
)
Value:
({ \
__typeof__ (x) _x = (x); \
__typeof__ (y) _y = (y); \
_x > _y ? _x : _y; \
})

Definition at line 335 of file clib.h.

◆ CLIB_MEMORY_BARRIER

#define CLIB_MEMORY_BARRIER ( )    __sync_synchronize ()

Definition at line 137 of file clib.h.

◆ CLIB_MEMORY_STORE_BARRIER

#define CLIB_MEMORY_STORE_BARRIER ( )    __builtin_ia32_sfence ()

Definition at line 140 of file clib.h.

◆ clib_min

#define clib_min (   x,
 
)
Value:
({ \
__typeof__ (x) _x = (x); \
__typeof__ (y) _y = (y); \
_x < _y ? _x : _y; \
})

Definition at line 342 of file clib.h.

◆ CLIB_PACKED

#define CLIB_PACKED (   x)    x __attribute__ ((packed))

Definition at line 89 of file clib.h.

◆ CLIB_STRING_MACRO

#define CLIB_STRING_MACRO (   x)    #x

Definition at line 96 of file clib.h.

◆ CLIB_UNIX

#define CLIB_UNIX

Definition at line 53 of file clib.h.

◆ CLIB_UNUSED

#define CLIB_UNUSED (   x)    x __attribute__ ((unused))

Definition at line 90 of file clib.h.

◆ COMPILE_TIME_CONST

#define COMPILE_TIME_CONST (   x)    __builtin_constant_p (x)

Definition at line 126 of file clib.h.

◆ count_leading_zeros

#define count_leading_zeros (   x)    __builtin_clzl (x)

Definition at line 160 of file clib.h.

◆ count_trailing_zeros

#define count_trailing_zeros (   x)    __builtin_ctzl (x)

Definition at line 161 of file clib.h.

◆ EXIT_FUNCTION

#define EXIT_FUNCTION (   decl)
Value:
decl __attribute ((destructor)); \
decl

Definition at line 151 of file clib.h.

◆ INIT_FUNCTION

#define INIT_FUNCTION (   decl)
Value:
decl __attribute ((constructor)); \
decl

Definition at line 146 of file clib.h.

◆ never_inline

#define never_inline   __attribute__ ((__noinline__))

Definition at line 108 of file clib.h.

◆ PREDICT_FALSE

#define PREDICT_FALSE (   x)    __builtin_expect((x),0)

Definition at line 124 of file clib.h.

◆ PREDICT_TRUE

#define PREDICT_TRUE (   x)    __builtin_expect((x),1)

Definition at line 125 of file clib.h.

◆ static_always_inline

#define static_always_inline   static inline

Definition at line 112 of file clib.h.

◆ STRUCT_ARRAY_LEN

#define STRUCT_ARRAY_LEN (   t,
  f 
)    ARRAY_LEN (_STRUCT_FIELD (t, f))

Definition at line 77 of file clib.h.

◆ STRUCT_BIT_OFFSET_OF

#define STRUCT_BIT_OFFSET_OF (   t,
  f 
)    (BITS(u8) * STRUCT_OFFSET_OF (t, f))

Definition at line 74 of file clib.h.

◆ STRUCT_BITS_OF

#define STRUCT_BITS_OF (   t,
  f 
)    (BITS (_STRUCT_FIELD (t, f)))

Definition at line 76 of file clib.h.

◆ STRUCT_MARK

#define STRUCT_MARK (   mark)    u8 mark[0]

Definition at line 78 of file clib.h.

◆ STRUCT_MARK_PTR

#define STRUCT_MARK_PTR (   v,
  f 
)    &(v)->f

Definition at line 79 of file clib.h.

◆ STRUCT_OFFSET_OF

#define STRUCT_OFFSET_OF (   t,
  f 
)    offsetof(t, f)

Definition at line 73 of file clib.h.

◆ STRUCT_OFFSET_OF_VAR

#define STRUCT_OFFSET_OF_VAR (   v,
  f 
)    ((uword) (&(v)->f) - (uword) (v))

Definition at line 86 of file clib.h.

◆ STRUCT_SIZE_OF

#define STRUCT_SIZE_OF (   t,
  f 
)    (sizeof (_STRUCT_FIELD (t, f)))

Definition at line 75 of file clib.h.

◆ STRUCT_STRIDE_OF

#define STRUCT_STRIDE_OF (   t,
  f 
)
Value:
( ((uword) & (((t *) 0)[1].f)) \
- ((uword) & (((t *) 0)[0].f)))

Definition at line 82 of file clib.h.

◆ u8

epi32 epi32 u8   pad_from[(to) - (from)] u8 pad_##from[(to) - (from)]

Padding.

Definition at line 121 of file clib.h.

Function Documentation

◆ clear_lowest_set_bit()

static uword clear_lowest_set_bit ( uword  x)
inlinestatic

Definition at line 166 of file clib.h.

+ Here is the caller graph for this function:

◆ clib_backtrace()

uword clib_backtrace ( uword callers,
uword  max_callers,
uword  n_frames_to_skip 
)

Definition at line 226 of file backtrace.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_bits()

static uword extract_bits ( uword  x,
int  start,
int  count 
)
inlinestatic

Definition at line 327 of file clib.h.

+ Here is the call graph for this function:

◆ first_set()

static uword first_set ( uword  x)
inlinestatic

Definition at line 291 of file clib.h.

+ Here is the caller graph for this function:

◆ flt_round_down()

static f64 flt_round_down ( f64  x)
inlinestatic

Definition at line 309 of file clib.h.

◆ flt_round_nearest()

static word flt_round_nearest ( f64  x)
inlinestatic

Definition at line 315 of file clib.h.

+ Here is the caller graph for this function:

◆ flt_round_to_multiple()

static f64 flt_round_to_multiple ( f64  x,
f64  f 
)
inlinestatic

Definition at line 321 of file clib.h.

+ Here is the call graph for this function:

◆ is_pow2()

static uword is_pow2 ( uword  x)
inlinestatic

Definition at line 267 of file clib.h.

+ Here is the caller graph for this function:

◆ log2_first_set()

static uword log2_first_set ( uword  x)
inlinestatic

Definition at line 297 of file clib.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ max_log2()

static uword max_log2 ( uword  x)
inlinestatic

Definition at line 223 of file clib.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ max_pow2()

static uword max_pow2 ( uword  x)
inlinestatic

Definition at line 258 of file clib.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ min_log2()

static uword min_log2 ( uword  x)
inlinestatic

Definition at line 176 of file clib.h.

+ Here is the caller graph for this function:

◆ min_log2_u64()

static u64 min_log2_u64 ( u64  x)
inlinestatic

Definition at line 232 of file clib.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pow2_mask()

static uword pow2_mask ( uword  x)
inlinestatic

Definition at line 252 of file clib.h.

+ Here is the caller graph for this function:

◆ round_down_pow2()

static uword round_down_pow2 ( uword  x,
uword  pow2 
)
inlinestatic

Definition at line 273 of file clib.h.

+ Here is the caller graph for this function:

◆ round_pow2()

static uword round_pow2 ( uword  x,
uword  pow2 
)
inlinestatic

Definition at line 279 of file clib.h.

+ Here is the caller graph for this function:

◆ round_pow2_u64()

static u64 round_pow2_u64 ( u64  x,
u64  pow2 
)
inlinestatic

Definition at line 285 of file clib.h.

+ Here is the caller graph for this function:
f
vlib_frame_t * f
Definition: interface_output.c:1080
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
uword
u64 uword
Definition: types.h:112
lo
lo
Definition: vector_altivec.h:95