The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions
build.h File Reference

Source control functions. More...

#include <stdint.h>
#include <stddef.h>
#include <string.h>
+ Include dependency graph for build.h:

Go to the source code of this file.

Macros

#define _JOIN(x, y)   x ## y
 Join two values without stringifying. More...
 
#define _VA_NARG(...)   VA_ARG_N(__VA_ARGS__)
 
#define BLANK_FORMAT   " " /* GCC_LINT whines about empty formats */
 
#define CC_ACQUIRE_HANDLE(_tag)
 
#define CC_RELEASE_HANDLE(_tag)
 
#define CC_USE_HANDLE(_tag)
 
#define CMP(_a, _b)   CMP_PREFER_SMALLER(_a, _b)
 Same as CMP_PREFER_SMALLER use when you don't really care about ordering, you just want an ordering. More...
 
#define CMP_PREFER_LARGER(_a, _b)   (((_a) < (_b)) - ((_a) > (_b)))
 Evaluates to -1 for a > b, and +1 for a < b. More...
 
#define CMP_PREFER_SMALLER(_a, _b)   (((_a) > (_b)) - ((_a) < (_b)))
 Evaluates to +1 for a > b, and -1 for a < b. More...
 
#define CMP_RETURN(_a, _b, _field)
 Return if the comparison is not 0 (is unequal) More...
 
#define define   likely(_x) _x
 
#define DIAG_OFF(_x)
 
#define DIAG_ON(_x)
 
#define DIAG_POP()
 
#define DIAG_PUSH()
 
#define DIAG_UNKNOWN_PRAGMAS
 
#define endforeach   }
 
#define F1(_idx, _val)   [_idx] = _val
 Fill macros for array initialisation. More...
 
#define F128(_idx, _val)   F64(_idx, _val), F64(_idx + 64, _val)
 
#define F16(_idx, _val)   F8(_idx, _val), F8(_idx + 8, _val)
 
#define F2(_idx, _val)   F1(_idx, _val), F1(_idx + 1, _val)
 
#define F256(_idx, _val)   F128(_idx, _val), F128(_idx + 128, _val)
 
#define F32(_idx, _val)   F16(_idx, _val), F16(_idx + 16, _val)
 
#define F4(_idx, _val)   F2(_idx, _val), F2(_idx + 2, _val)
 
#define F64(_idx, _val)   F32(_idx, _val), F32(_idx + 32, _val)
 
#define F8(_idx, _val)   F4(_idx, _val), F4(_idx + 4, _val)
 
#define FALL_THROUGH   ((void)0)
 clang 10 doesn't recognised the FALL-THROUGH comment anymore More...
 
#define HEXIFY(b1)   XHEXIFY(b1)
 
#define HEXIFY2(b1, b2)   XHEXIFY2(b1, b2)
 
#define HEXIFY3(b1, b2, b3)   XHEXIFY3(b1, b2, b3)
 
#define HEXIFY4(b1, b2, b3, b4)   XHEXIFY4(b1, b2, b3, b4)
 
#define HIDDEN   )
 
#define IGNORE(_expr, _type)
 
#define IS_COMPATIBLE(_x, _t)   _Generic(_x, _t:1, default: 0)
 Check if two types are compatible (the C11 way) More...
 
#define IS_CONST(_type, _var)
 Check if a given variable is the _const or not. More...
 
#define IS_FIELD_COMPATIBLE(_s, _f, _t)   _Generic(((_s *)0)->_f, _t:1, default: 0)
 Check if a field in a struct is compatible (the C11 way) More...
 
#define IS_TYPE(_type, _var)
 Check if a given variable is the const or unconst version of a type. More...
 
#define JOIN(x, y)   _JOIN(x,y)
 
#define JOINSTR(x, y)   XSTRINGIFY(x ## y)
 
#define L(_str)   { _str, sizeof(_str) - 1 }
 Helper for initialising arrays of string literals. More...
 
#define MEMCMP_RETURN(_a, _b, _field, _len_field)
 Return if the contents of the specified field is not identical between the specified structures. More...
 
#define NDEBUG_LOCATION_ARGS   char const *file, int line,
 Pass caller information to the function. More...
 
#define NDEBUG_LOCATION_EXP   __FILE__, __LINE__,
 
#define NDEBUG_LOCATION_NONNULL(_num)   ((_num) + 2)
 
#define NDEBUG_LOCATION_VALS   file, line,
 
#define NDEBUG_UNUSED
 
#define NEVER_RETURNS   _Noreturn
 Should be placed before the function return type. More...
 
#define NUM_ELEMENTS(_t)   (sizeof((_t)) / sizeof((_t)[0]))
 
#define NUM_PTR_ELEMENTS(_t)   (sizeof((_t)) / sizeof(void *))
 
#define PAD(_x, _y)   (_y - ((_x) % _y))
 Pad _x to the next multiple of _y. More...
 
#define PRAGMA(_x)   _Pragma(#_x)
 
#define RCSID(id)
 
#define RCSIDH(h, id)
 
#define SIZEOF_MEMBER(_t, _m)   sizeof(((_t *)0)->_m)
 
#define static_assert   _Static_assert
 For systems with an old version libc, define static_assert. More...
 
#define STRINGIFY(x)   XSTRINGIFY(x)
 
#define typeof_field(_type, _field)   __typeof__(((_type *)NULL)->_field)
 Typeof field. More...
 
#define UNCONST(_type, _ptr)   ((_type)((uintptr_t)(_ptr)))
 Remove const qualification from a pointer. More...
 
#define unlikely(_x)   _x
 
#define UNUSED
 
#define UNUSED_VAR(_x)   ((void)_x)
 
#define USES_APPLE_DEPRECATED_API
 
#define USES_APPLE_RST
 
#define VA_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, N, ...)   N
 Variadic macro framework. More...
 
#define VA_NARG(...)   _VA_NARG(__VA_ARGS__, VA_RSEQ_N())
 Return the number of variadic arguments up to 64. More...
 
#define VA_RSEQ_N()
 
#define XHEXIFY(b1)   (0x ## b1)
 
#define XHEXIFY2(b1, b2)   (0x ## b1 ## b2)
 
#define XHEXIFY3(b1, b2, b3)   (0x ## b1 ## b2 ## b3)
 
#define XHEXIFY4(b1, b2, b3, b4)   (0x ## b1 ## b2 ## b3 ## b4)
 HEX concatenation macros. More...
 
#define XSTRINGIFY(x)   #x
 The ubiquitous stringify macros. More...
 

Functions

static int8_t memcmp_return (void const *a, void const *b, size_t a_len, size_t b_len)
 memcmp function which has similar behaviour as strncmp More...
 

Detailed Description

Source control functions.

Id
ec00bbc481807132a59ee0540245d6406e5b6328

Definition in file build.h.

Macro Definition Documentation

◆ _JOIN

#define _JOIN (   x,
  y 
)    x ## y

Join two values without stringifying.

Useful for calling different macros based on the output of

Definition at line 202 of file build.h.

◆ _VA_NARG

#define _VA_NARG (   ...)    VA_ARG_N(__VA_ARGS__)

Definition at line 248 of file build.h.

◆ BLANK_FORMAT

#define BLANK_FORMAT   " " /* GCC_LINT whines about empty formats */

Definition at line 329 of file build.h.

◆ CC_ACQUIRE_HANDLE

#define CC_ACQUIRE_HANDLE (   _tag)

Definition at line 394 of file build.h.

◆ CC_RELEASE_HANDLE

#define CC_RELEASE_HANDLE (   _tag)

Definition at line 396 of file build.h.

◆ CC_USE_HANDLE

#define CC_USE_HANDLE (   _tag)

Definition at line 395 of file build.h.

◆ CMP

#define CMP (   _a,
  _b 
)    CMP_PREFER_SMALLER(_a, _b)

Same as CMP_PREFER_SMALLER use when you don't really care about ordering, you just want an ordering.

Definition at line 110 of file build.h.

◆ CMP_PREFER_LARGER

#define CMP_PREFER_LARGER (   _a,
  _b 
)    (((_a) < (_b)) - ((_a) > (_b)))

Evaluates to -1 for a > b, and +1 for a < b.

Definition at line 106 of file build.h.

◆ CMP_PREFER_SMALLER

#define CMP_PREFER_SMALLER (   _a,
  _b 
)    (((_a) > (_b)) - ((_a) < (_b)))

Evaluates to +1 for a > b, and -1 for a < b.

Definition at line 102 of file build.h.

◆ CMP_RETURN

#define CMP_RETURN (   _a,
  _b,
  _field 
)
Value:
do { \
int8_t _ret = CMP((_a)->_field, (_b)->_field); \
if (_ret != 0) return _ret; \
} while (0)
while(1)
Definition: acutest.h:856
#define CMP(_a, _b)
Same as CMP_PREFER_SMALLER use when you don't really care about ordering, you just want an ordering.
Definition: build.h:110
return
Definition: module.c:186

Return if the comparison is not 0 (is unequal)

Parameters
[in]_apointer to first structure.
[in]_bpointer to second structure.
[in]_fieldwithin the structs to compare.
Returns
The result of the comparison.

Definition at line 119 of file build.h.

◆ define

#define define   likely(_x) _x

◆ DIAG_OFF

#define DIAG_OFF (   _x)

Definition at line 418 of file build.h.

◆ DIAG_ON

#define DIAG_ON (   _x)

Definition at line 419 of file build.h.

◆ DIAG_POP

#define DIAG_POP ( )

Definition at line 421 of file build.h.

◆ DIAG_PUSH

#define DIAG_PUSH ( )

Definition at line 420 of file build.h.

◆ DIAG_UNKNOWN_PRAGMAS

#define DIAG_UNKNOWN_PRAGMAS

Definition at line 417 of file build.h.

◆ endforeach

#define endforeach   }

Definition at line 454 of file build.h.

◆ F1

#define F1 (   _idx,
  _val 
)    [_idx] = _val

Fill macros for array initialisation.

Definition at line 211 of file build.h.

◆ F128

#define F128 (   _idx,
  _val 
)    F64(_idx, _val), F64(_idx + 64, _val)

Definition at line 218 of file build.h.

◆ F16

#define F16 (   _idx,
  _val 
)    F8(_idx, _val), F8(_idx + 8, _val)

Definition at line 215 of file build.h.

◆ F2

#define F2 (   _idx,
  _val 
)    F1(_idx, _val), F1(_idx + 1, _val)

Definition at line 212 of file build.h.

◆ F256

#define F256 (   _idx,
  _val 
)    F128(_idx, _val), F128(_idx + 128, _val)

Definition at line 219 of file build.h.

◆ F32

#define F32 (   _idx,
  _val 
)    F16(_idx, _val), F16(_idx + 16, _val)

Definition at line 216 of file build.h.

◆ F4

#define F4 (   _idx,
  _val 
)    F2(_idx, _val), F2(_idx + 2, _val)

Definition at line 213 of file build.h.

◆ F64

#define F64 (   _idx,
  _val 
)    F32(_idx, _val), F32(_idx + 32, _val)

Definition at line 217 of file build.h.

◆ F8

#define F8 (   _idx,
  _val 
)    F4(_idx, _val), F4(_idx + 4, _val)

Definition at line 214 of file build.h.

◆ FALL_THROUGH

#define FALL_THROUGH   ((void)0)

clang 10 doesn't recognised the FALL-THROUGH comment anymore

Definition at line 320 of file build.h.

◆ HEXIFY

#define HEXIFY (   b1)    XHEXIFY(b1)

Definition at line 188 of file build.h.

◆ HEXIFY2

#define HEXIFY2 (   b1,
  b2 
)    XHEXIFY2(b1, b2)

Definition at line 185 of file build.h.

◆ HEXIFY3

#define HEXIFY3 (   b1,
  b2,
  b3 
)    XHEXIFY3(b1, b2, b3)

Definition at line 182 of file build.h.

◆ HEXIFY4

#define HEXIFY4 (   b1,
  b2,
  b3,
  b4 
)    XHEXIFY4(b1, b2, b3, b4)

Definition at line 179 of file build.h.

◆ HIDDEN

#define HIDDEN   )

Definition at line 312 of file build.h.

◆ IGNORE

#define IGNORE (   _expr,
  _type 
)
Value:
do { \
_type ignored UNUSED = (_expr); \
} while (0)
#define UNUSED
Definition: build.h:313

Definition at line 468 of file build.h.

◆ IS_COMPATIBLE

#define IS_COMPATIBLE (   _x,
  _t 
)    _Generic(_x, _t:1, default: 0)

Check if two types are compatible (the C11 way)

Expands to 1 if types are compatible, else 0.

Parameters
[in]_xpointer to check.
[in]_ttype to check compatibility with.

Definition at line 355 of file build.h.

◆ IS_CONST

#define IS_CONST (   _type,
  _var 
)
Value:
_Generic((_var), \
_type: false, \
const _type: true \
)

Check if a given variable is the _const or not.

Parameters
[in]_typeThe base type of the variable (should not be marked const)
[in]_varto check.

Definition at line 277 of file build.h.

◆ IS_FIELD_COMPATIBLE

#define IS_FIELD_COMPATIBLE (   _s,
  _f,
  _t 
)    _Generic(((_s *)0)->_f, _t:1, default: 0)

Check if a field in a struct is compatible (the C11 way)

Expands to 1 if types are compatible, else 0.

Parameters
[in]_sstruct to check.
[in]_ffield in struct.
[in]_ttype to check compatibility with.

Definition at line 365 of file build.h.

◆ IS_TYPE

#define IS_TYPE (   _type,
  _var 
)
Value:
_Generic((_var), \
_type: _var, \
const _type: _var \
)

Check if a given variable is the const or unconst version of a type.

Expands to _var if _var matches type, otherwise throws a compiler error.

Useful for creating typesafe wrapper macros around functions which take void *s.

Parameters
[in]_typeThe base type of the variable (should not be marked const)
[in]_varto check.

Definition at line 293 of file build.h.

◆ JOIN

#define JOIN (   x,
  y 
)    _JOIN(x,y)

Definition at line 203 of file build.h.

◆ JOINSTR

#define JOINSTR (   x,
  y 
)    XSTRINGIFY(x ## y)

Definition at line 196 of file build.h.

◆ L

#define L (   _str)    { _str, sizeof(_str) - 1 }

Helper for initialising arrays of string literals.

Definition at line 207 of file build.h.

◆ MEMCMP_RETURN

#define MEMCMP_RETURN (   _a,
  _b,
  _field,
  _len_field 
)
Value:
do { \
int8_t _ret = memcmp_return((_a)->_field, (_b)->_field, (_a)->_len_field, (_b)->_len_field); \
if (_ret != 0) return _ret; \
} while (0)
static int8_t memcmp_return(void const *a, void const *b, size_t a_len, size_t b_len)
memcmp function which has similar behaviour as strncmp
Definition: build.h:136

Return if the contents of the specified field is not identical between the specified structures.

Parameters
[in]_apointer to first structure.
[in]_bpointer to second structure.
[in]_fieldwithin the structs to compare.
[in]_len_fieldwithin the structs, specifying the length of the data.
Returns
The result of the comparison.

Definition at line 154 of file build.h.

◆ NDEBUG_LOCATION_ARGS

#define NDEBUG_LOCATION_ARGS   char const *file, int line,

Pass caller information to the function.

Definition at line 261 of file build.h.

◆ NDEBUG_LOCATION_EXP

#define NDEBUG_LOCATION_EXP   __FILE__, __LINE__,

Definition at line 263 of file build.h.

◆ NDEBUG_LOCATION_NONNULL

#define NDEBUG_LOCATION_NONNULL (   _num)    ((_num) + 2)

Definition at line 264 of file build.h.

◆ NDEBUG_LOCATION_VALS

#define NDEBUG_LOCATION_VALS   file, line,

Definition at line 262 of file build.h.

◆ NDEBUG_UNUSED

#define NDEBUG_UNUSED

Definition at line 324 of file build.h.

◆ NEVER_RETURNS

#define NEVER_RETURNS   _Noreturn

Should be placed before the function return type.

Definition at line 311 of file build.h.

◆ NUM_ELEMENTS

#define NUM_ELEMENTS (   _t)    (sizeof((_t)) / sizeof((_t)[0]))

Definition at line 335 of file build.h.

◆ NUM_PTR_ELEMENTS

#define NUM_PTR_ELEMENTS (   _t)    (sizeof((_t)) / sizeof(void *))

Definition at line 342 of file build.h.

◆ PAD

#define PAD (   _x,
  _y 
)    (_y - ((_x) % _y))

Pad _x to the next multiple of _y.

Definition at line 306 of file build.h.

◆ PRAGMA

#define PRAGMA (   _x)    _Pragma(#_x)

Definition at line 384 of file build.h.

◆ RCSID

#define RCSID (   id)

Definition at line 444 of file build.h.

◆ RCSIDH

#define RCSIDH (   h,
  id 
)

Definition at line 445 of file build.h.

◆ SIZEOF_MEMBER

#define SIZEOF_MEMBER (   _t,
  _m 
)    sizeof(((_t *)0)->_m)

Definition at line 334 of file build.h.

◆ static_assert

#define static_assert   _Static_assert

For systems with an old version libc, define static_assert.

Definition at line 35 of file build.h.

◆ STRINGIFY

#define STRINGIFY (   x)    XSTRINGIFY(x)

Definition at line 195 of file build.h.

◆ typeof_field

#define typeof_field (   _type,
  _field 
)    __typeof__(((_type *)NULL)->_field)

Typeof field.

Parameters
[in]_typestruct type containing the field.
[in]_fieldto return the type of.

Definition at line 172 of file build.h.

◆ UNCONST

#define UNCONST (   _type,
  _ptr 
)    ((_type)((uintptr_t)(_ptr)))

Remove const qualification from a pointer.

Parameters
[in]_typeThe non-const version of the type.
[in]_ptrto de-const.

Definition at line 165 of file build.h.

◆ unlikely

#define unlikely (   _x)    _x

Definition at line 378 of file build.h.

◆ UNUSED

#define UNUSED

Definition at line 313 of file build.h.

◆ UNUSED_VAR

#define UNUSED_VAR (   _x)    ((void)_x)

Definition at line 301 of file build.h.

◆ USES_APPLE_DEPRECATED_API

#define USES_APPLE_DEPRECATED_API

Definition at line 431 of file build.h.

◆ USES_APPLE_RST

#define USES_APPLE_RST

Definition at line 432 of file build.h.

◆ VA_ARG_N

#define VA_ARG_N (   _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10,
  _11,
  _12,
  _13,
  _14,
  _15,
  _16,
  _17,
  _18,
  _19,
  _20,
  _21,
  _22,
  _23,
  _24,
  _25,
  _26,
  _27,
  _28,
  _29,
  _30,
  _31,
  _32,
  _33,
  _34,
  _35,
  _36,
  _37,
  _38,
  _39,
  _40,
  _41,
  _42,
  _43,
  _44,
  _45,
  _46,
  _47,
  _48,
  _49,
  _50,
  _51,
  _52,
  _53,
  _54,
  _55,
  _56,
  _57,
  _58,
  _59,
  _60,
  _61,
  _62,
  _63,
  N,
  ... 
)    N

Variadic macro framework.

The VA_NARG macro evaluates to the number of arguments that have been passed to it.

Laurent Deniau, "__VA_NARG__," 17 January 2006, <comp.std.c> (29 November 2007).

Definition at line 230 of file build.h.

◆ VA_NARG

#define VA_NARG (   ...)    _VA_NARG(__VA_ARGS__, VA_RSEQ_N())

Return the number of variadic arguments up to 64.

Parameters
[in]...Variadic arguments to count.

Definition at line 254 of file build.h.

◆ VA_RSEQ_N

#define VA_RSEQ_N ( )
Value:
63,62,61,60, \
59,58,57,56,55,54,53,52,51,50, \
49,48,47,46,45,44,43,42,41,40, \
39,38,37,36,35,34,33,32,31,30, \
29,28,27,26,25,24,23,22,21,20, \
19,18,17,16,15,14,13,12,11,10, \
9,8,7,6,5,4,3,2,1,0

Definition at line 239 of file build.h.

◆ XHEXIFY

#define XHEXIFY (   b1)    (0x ## b1)

Definition at line 187 of file build.h.

◆ XHEXIFY2

#define XHEXIFY2 (   b1,
  b2 
)    (0x ## b1 ## b2)

Definition at line 184 of file build.h.

◆ XHEXIFY3

#define XHEXIFY3 (   b1,
  b2,
  b3 
)    (0x ## b1 ## b2 ## b3)

Definition at line 181 of file build.h.

◆ XHEXIFY4

#define XHEXIFY4 (   b1,
  b2,
  b3,
  b4 
)    (0x ## b1 ## b2 ## b3 ## b4)

HEX concatenation macros.

Definition at line 178 of file build.h.

◆ XSTRINGIFY

#define XSTRINGIFY (   x)    #x

The ubiquitous stringify macros.

Definition at line 194 of file build.h.

Function Documentation

◆ memcmp_return()

static int8_t memcmp_return ( void const *  a,
void const *  b,
size_t  a_len,
size_t  b_len 
)
inlinestatic

memcmp function which has similar behaviour as strncmp

Parameters
[in]aFirst thing to compare.
[in]bSecond thing to compare.
[in]a_lenLength of first thing.
[in]b_lenLength of second thing.
Returns
  • +1 if a > b
  • 0 if a == b
  • -1 if a < b

Definition at line 136 of file build.h.