Blender  V3.3
BLI_utildefines.h File Reference
#include "BLI_compiler_compat.h"
#include "BLI_sys_types.h"
#include "BLI_utildefines_variadic.h"
#include "BLI_assert.h"
#include "BLI_compiler_typecheck.h"

Go to the source code of this file.

Macros

Min/Max Macros
#define MIN2(a, b)   ((a) < (b) ? (a) : (b))
 
#define MAX2(a, b)   ((a) > (b) ? (a) : (b))
 
#define MIN3(a, b, c)   (MIN2(MIN2((a), (b)), (c)))
 
#define MIN4(a, b, c, d)   (MIN2(MIN2((a), (b)), MIN2((c), (d))))
 
#define MAX3(a, b, c)   (MAX2(MAX2((a), (b)), (c)))
 
#define MAX4(a, b, c, d)   (MAX2(MAX2((a), (b)), MAX2((c), (d))))
 
#define MAX3_PAIR(cmp_a, cmp_b, cmp_c, ret_a, ret_b, ret_c)    ((cmp_a > cmp_b) ? ((cmp_a > cmp_c) ? ret_a : ret_c) : ((cmp_b > cmp_c) ? ret_b : ret_c))
 
#define MIN3_PAIR(cmp_a, cmp_b, cmp_c, ret_a, ret_b, ret_c)    ((cmp_a < cmp_b) ? ((cmp_a < cmp_c) ? ret_a : ret_c) : ((cmp_b < cmp_c) ? ret_b : ret_c))
 
#define INIT_MINMAX(min, max)
 
#define INIT_MINMAX2(min, max)
 
#define DO_MIN(vec, min)
 
#define DO_MAX(vec, max)
 
#define DO_MINMAX(vec, min, max)
 
#define DO_MINMAX2(vec, min, max)
 
Swap/Shift Macros
#define SWAP(type, a, b)
 
#define SWAP_TVAL(tval, a, b)
 
#define SHIFT3(type, a, b, c)
 
#define SHIFT4(type, a, b, c, d)
 
Equal to Any Element (ELEM) Macro
#define _VA_ELEM2(v, a)   ((v) == (a))
 
#define _VA_ELEM3(v, a, b)    (_VA_ELEM2(v, a) || _VA_ELEM2(v, b))
 
#define _VA_ELEM4(v, a, b, c)    (_VA_ELEM3(v, a, b) || _VA_ELEM2(v, c))
 
#define _VA_ELEM5(v, a, b, c, d)    (_VA_ELEM4(v, a, b, c) || _VA_ELEM2(v, d))
 
#define _VA_ELEM6(v, a, b, c, d, e)    (_VA_ELEM5(v, a, b, c, d) || _VA_ELEM2(v, e))
 
#define _VA_ELEM7(v, a, b, c, d, e, f)    (_VA_ELEM6(v, a, b, c, d, e) || _VA_ELEM2(v, f))
 
#define _VA_ELEM8(v, a, b, c, d, e, f, g)    (_VA_ELEM7(v, a, b, c, d, e, f) || _VA_ELEM2(v, g))
 
#define _VA_ELEM9(v, a, b, c, d, e, f, g, h)    (_VA_ELEM8(v, a, b, c, d, e, f, g) || _VA_ELEM2(v, h))
 
#define _VA_ELEM10(v, a, b, c, d, e, f, g, h, i)    (_VA_ELEM9(v, a, b, c, d, e, f, g, h) || _VA_ELEM2(v, i))
 
#define _VA_ELEM11(v, a, b, c, d, e, f, g, h, i, j)    (_VA_ELEM10(v, a, b, c, d, e, f, g, h, i) || _VA_ELEM2(v, j))
 
#define _VA_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k)    (_VA_ELEM11(v, a, b, c, d, e, f, g, h, i, j) || _VA_ELEM2(v, k))
 
#define _VA_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l)    (_VA_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k) || _VA_ELEM2(v, l))
 
#define _VA_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m)    (_VA_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l) || _VA_ELEM2(v, m))
 
#define _VA_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n)    (_VA_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m) || _VA_ELEM2(v, n))
 
#define _VA_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)    (_VA_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n) || _VA_ELEM2(v, o))
 
#define _VA_ELEM17(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)    (_VA_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) || _VA_ELEM2(v, p))
 
#define ELEM(...)   VA_NARGS_CALL_OVERLOAD(_VA_ELEM, __VA_ARGS__)
 
Simple Math Macros
#define IS_EQ(a, b)
 
#define IS_EQF(a, b)
 
#define IS_EQT(a, b, c)   (((a) > (b)) ? ((((a) - (b)) <= (c))) : (((((b) - (a)) <= (c)))))
 
#define IN_RANGE(a, b, c)   (((b) < (c)) ? (((b) < (a) && (a) < (c))) : (((c) < (a) && (a) < (b))))
 
#define IN_RANGE_INCL(a, b, c)    (((b) < (c)) ? (((b) <= (a) && (a) <= (c))) : (((c) <= (a) && (a) <= (b))))
 
#define DECIMAL_DIGITS_BOUND(t)   (241 * sizeof(t) / 100 + 1)
 
Clamp Macros
#define CLAMPIS(a, b, c)   ((a) < (b) ? (b) : (a) > (c) ? (c) : (a))
 
#define CLAMP(a, b, c)
 
#define CLAMP_MAX(a, c)
 
#define CLAMP_MIN(a, b)
 
#define CLAMP2(vec, b, c)
 
#define CLAMP2_MIN(vec, b)
 
#define CLAMP2_MAX(vec, b)
 
#define CLAMP3(vec, b, c)
 
#define CLAMP3_MIN(vec, b)
 
#define CLAMP3_MAX(vec, b)
 
#define CLAMP4(vec, b, c)
 
#define CLAMP4_MIN(vec, b)
 
#define CLAMP4_MAX(vec, b)
 
Array Unpacking Macros
#define UNPACK2(a)   ((a)[0]), ((a)[1])
 
#define UNPACK3(a)   UNPACK2(a), ((a)[2])
 
#define UNPACK4(a)   UNPACK3(a), ((a)[3])
 
#define UNPACK2_EX(pre, a, post)   (pre((a)[0]) post), (pre((a)[1]) post)
 
#define UNPACK3_EX(pre, a, post)   UNPACK2_EX(pre, a, post), (pre((a)[2]) post)
 
#define UNPACK4_EX(pre, a, post)   UNPACK3_EX(pre, a, post), (pre((a)[3]) post)
 
Array Macros
#define ARRAY_LAST_ITEM(arr_start, arr_dtype, arr_len)    (arr_dtype *)((char *)(arr_start) + (sizeof(*((arr_dtype *)NULL)) * (size_t)(arr_len - 1)))
 
#define ARRAY_HAS_ITEM(arr_item, arr_start, arr_len)
 
#define ARRAY_DELETE(arr, index, delete_len, arr_len)
 
#define ARRAY_DELETE_REORDER_LAST(arr, index, delete_len, arr_len)
 
#define ARRAY_SIZE(arr)   (sizeof(arr) / sizeof(*(arr)))
 
#define _VA_ARRAY_SET_ITEMS2(v, a)   ((v)[0] = (a))
 
#define _VA_ARRAY_SET_ITEMS3(v, a, b)
 
#define _VA_ARRAY_SET_ITEMS4(v, a, b, c)
 
#define _VA_ARRAY_SET_ITEMS5(v, a, b, c, d)
 
#define _VA_ARRAY_SET_ITEMS6(v, a, b, c, d, e)
 
#define _VA_ARRAY_SET_ITEMS7(v, a, b, c, d, e, f)
 
#define _VA_ARRAY_SET_ITEMS8(v, a, b, c, d, e, f, g)
 
#define _VA_ARRAY_SET_ITEMS9(v, a, b, c, d, e, f, g, h)
 
#define _VA_ARRAY_SET_ITEMS10(v, a, b, c, d, e, f, g, h, i)
 
#define _VA_ARRAY_SET_ITEMS11(v, a, b, c, d, e, f, g, h, i, j)
 
#define _VA_ARRAY_SET_ITEMS12(v, a, b, c, d, e, f, g, h, i, j, k)
 
#define _VA_ARRAY_SET_ITEMS13(v, a, b, c, d, e, f, g, h, i, j, k, l)
 
#define _VA_ARRAY_SET_ITEMS14(v, a, b, c, d, e, f, g, h, i, j, k, l, m)
 
#define _VA_ARRAY_SET_ITEMS15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
 
#define _VA_ARRAY_SET_ITEMS16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
 
#define _VA_ARRAY_SET_ITEMS17(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
 
#define ARRAY_SET_ITEMS(...)
 
Pointer Macros
#define POINTER_OFFSET(v, ofs)   ((void *)((char *)(v) + (ofs)))
 
#define POINTER_FROM_INT(i)   ((void *)(intptr_t)(i))
 
#define POINTER_AS_INT(i)   ((void)0, ((int)(intptr_t)(i)))
 
#define POINTER_FROM_UINT(i)   ((void *)(uintptr_t)(i))
 
#define POINTER_AS_UINT(i)   ((void)0, ((unsigned int)(uintptr_t)(i)))
 
String Macros
#define STRINGIFY_ARG(x)   "" #x
 
#define STRINGIFY_APPEND(a, b)   "" a #b
 
#define STRINGIFY(x)   STRINGIFY_APPEND("", x)
 
#define STREQ(a, b)   (strcmp(a, b) == 0)
 
#define STRCASEEQ(a, b)   (strcasecmp(a, b) == 0)
 
#define STREQLEN(a, b, n)   (strncmp(a, b, n) == 0)
 
#define STRCASEEQLEN(a, b, n)   (strncasecmp(a, b, n) == 0)
 
#define STRPREFIX(a, b)   (strncmp((a), (b), strlen(b)) == 0)
 
Unused Function/Argument Macros
#define UNUSED(x)   UNUSED_##x
 
#define UNUSED_FUNCTION(x)   UNUSED_##x
 
#define UNUSED_FUNCTION_WITH_RETURN_TYPE(rtype, x)   rtype UNUSED_##x
 
#define _VA_UNUSED_VARS_1(a0)   ((void)(a0))
 
#define _VA_UNUSED_VARS_2(a0, b0)   ((void)(a0), _VA_UNUSED_VARS_1(b0))
 
#define _VA_UNUSED_VARS_3(a0, b0, c0)   ((void)(a0), _VA_UNUSED_VARS_2(b0, c0))
 
#define _VA_UNUSED_VARS_4(a0, b0, c0, d0)   ((void)(a0), _VA_UNUSED_VARS_3(b0, c0, d0))
 
#define _VA_UNUSED_VARS_5(a0, b0, c0, d0, e0)   ((void)(a0), _VA_UNUSED_VARS_4(b0, c0, d0, e0))
 
#define _VA_UNUSED_VARS_6(a0, b0, c0, d0, e0, f0)    ((void)(a0), _VA_UNUSED_VARS_5(b0, c0, d0, e0, f0))
 
#define _VA_UNUSED_VARS_7(a0, b0, c0, d0, e0, f0, g0)    ((void)(a0), _VA_UNUSED_VARS_6(b0, c0, d0, e0, f0, g0))
 
#define _VA_UNUSED_VARS_8(a0, b0, c0, d0, e0, f0, g0, h0)    ((void)(a0), _VA_UNUSED_VARS_7(b0, c0, d0, e0, f0, g0, h0))
 
#define _VA_UNUSED_VARS_9(a0, b0, c0, d0, e0, f0, g0, h0, i0)    ((void)(a0), _VA_UNUSED_VARS_8(b0, c0, d0, e0, f0, g0, h0, i0))
 
#define _VA_UNUSED_VARS_10(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0)    ((void)(a0), _VA_UNUSED_VARS_9(b0, c0, d0, e0, f0, g0, h0, i0, j0))
 
#define _VA_UNUSED_VARS_11(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0)    ((void)(a0), _VA_UNUSED_VARS_10(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0))
 
#define _VA_UNUSED_VARS_12(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0)    ((void)(a0), _VA_UNUSED_VARS_11(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0))
 
#define _VA_UNUSED_VARS_13(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0)    ((void)(a0), _VA_UNUSED_VARS_12(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0))
 
#define _VA_UNUSED_VARS_14(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0)    ((void)(a0), _VA_UNUSED_VARS_13(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0))
 
#define _VA_UNUSED_VARS_15(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0)    ((void)(a0), _VA_UNUSED_VARS_14(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0))
 
#define _VA_UNUSED_VARS_16(a0, b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0)    ((void)(a0), _VA_UNUSED_VARS_15(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0))
 
#define UNUSED_VARS(...)   VA_NARGS_CALL_OVERLOAD(_VA_UNUSED_VARS_, __VA_ARGS__)
 
#define UNUSED_VARS_NDEBUG(...)
 
Branch Prediction Macros
#define LIKELY(x)   (x)
 
#define UNLIKELY(x)   (x)
 
Flag Macros
#define SET_FLAG_FROM_TEST(value, test, flag)
 
C++ Macros
#define ENUM_OPERATORS(_type, _max)
 
#define CPP_ARG_DEFAULT(default_value)
 
Misc Macros
#define AT   __FILE__ ":" STRINGIFY(__LINE__)
 
#define EXPR_NOP(expr)   (void)(0 ? ((void)(expr), 1) : 0)
 
#define BLI_ENABLE_IF(condition)   typename std::enable_if_t<(condition)> * = nullptr
 
#define BLI_NO_UNIQUE_ADDRESS   [[no_unique_address]]
 

Struct After Macros

Typically used to copy/clear polymorphic structs which have a generic member at the start which needs to be left as-is.

#define OFFSETOF_STRUCT_AFTER(_struct, _member)
 
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
 
#define MEMSET_STRUCT_AFTER(struct_var, value, member)
 
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
 
bool BLI_memory_is_zero (const void *arr, size_t arr_size)
 

Macro Definition Documentation

◆ _VA_ARRAY_SET_ITEMS10

#define _VA_ARRAY_SET_ITEMS10 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
 
)
Value:
_VA_ARRAY_SET_ITEMS9(v, a, b, c, d, e, f, g, h); \
((v)[8] = (i))
#define _VA_ARRAY_SET_ITEMS9(v, a, b, c, d, e, f, g, h)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)

Definition at line 528 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS11

#define _VA_ARRAY_SET_ITEMS11 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
 
)
Value:
_VA_ARRAY_SET_ITEMS10(v, a, b, c, d, e, f, g, h, i); \
((v)[9] = (j))
#define _VA_ARRAY_SET_ITEMS10(v, a, b, c, d, e, f, g, h, i)

Definition at line 531 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS12

#define _VA_ARRAY_SET_ITEMS12 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
 
)
Value:
_VA_ARRAY_SET_ITEMS11(v, a, b, c, d, e, f, g, h, i, j); \
((v)[10] = (k))
#define _VA_ARRAY_SET_ITEMS11(v, a, b, c, d, e, f, g, h, i, j)

Definition at line 534 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS13

#define _VA_ARRAY_SET_ITEMS13 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l 
)
Value:
_VA_ARRAY_SET_ITEMS12(v, a, b, c, d, e, f, g, h, i, j, k); \
((v)[11] = (l))
#define _VA_ARRAY_SET_ITEMS12(v, a, b, c, d, e, f, g, h, i, j, k)
ATTR_WARN_UNUSED_RESULT const BMLoop * l

Definition at line 537 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS14

#define _VA_ARRAY_SET_ITEMS14 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l,
 
)
Value:
_VA_ARRAY_SET_ITEMS13(v, a, b, c, d, e, f, g, h, i, j, k, l); \
((v)[12] = (m))
#define _VA_ARRAY_SET_ITEMS13(v, a, b, c, d, e, f, g, h, i, j, k, l)

Definition at line 540 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS15

#define _VA_ARRAY_SET_ITEMS15 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l,
  m,
 
)
Value:
_VA_ARRAY_SET_ITEMS14(v, a, b, c, d, e, f, g, h, i, j, k, l, m); \
((v)[13] = (n))
#define _VA_ARRAY_SET_ITEMS14(v, a, b, c, d, e, f, g, h, i, j, k, l, m)

Definition at line 543 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS16

#define _VA_ARRAY_SET_ITEMS16 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l,
  m,
  n,
 
)
Value:
_VA_ARRAY_SET_ITEMS15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n); \
((v)[14] = (o))
#define _VA_ARRAY_SET_ITEMS15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n)

Definition at line 546 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS17

#define _VA_ARRAY_SET_ITEMS17 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l,
  m,
  n,
  o,
 
)
Value:
_VA_ARRAY_SET_ITEMS16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o); \
((v)[15] = (p))
#define _VA_ARRAY_SET_ITEMS16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)

Definition at line 549 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS2

#define _VA_ARRAY_SET_ITEMS2 (   v,
 
)    ((v)[0] = (a))

Definition at line 506 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS3

#define _VA_ARRAY_SET_ITEMS3 (   v,
  a,
 
)
Value:
((v)[1] = (b))
#define _VA_ARRAY_SET_ITEMS2(v, a)

Definition at line 507 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS4

#define _VA_ARRAY_SET_ITEMS4 (   v,
  a,
  b,
 
)
Value:
((v)[2] = (c))
#define _VA_ARRAY_SET_ITEMS3(v, a, b)

Definition at line 510 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS5

#define _VA_ARRAY_SET_ITEMS5 (   v,
  a,
  b,
  c,
 
)
Value:
((v)[3] = (d))
#define _VA_ARRAY_SET_ITEMS4(v, a, b, c)

Definition at line 513 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS6

#define _VA_ARRAY_SET_ITEMS6 (   v,
  a,
  b,
  c,
  d,
  e 
)
Value:
((v)[4] = (e))
#define _VA_ARRAY_SET_ITEMS5(v, a, b, c, d)

Definition at line 516 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS7

#define _VA_ARRAY_SET_ITEMS7 (   v,
  a,
  b,
  c,
  d,
  e,
 
)
Value:
_VA_ARRAY_SET_ITEMS6(v, a, b, c, d, e); \
((v)[5] = (f))
#define _VA_ARRAY_SET_ITEMS6(v, a, b, c, d, e)

Definition at line 519 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS8

#define _VA_ARRAY_SET_ITEMS8 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
 
)
Value:
_VA_ARRAY_SET_ITEMS7(v, a, b, c, d, e, f); \
((v)[6] = (g))
#define _VA_ARRAY_SET_ITEMS7(v, a, b, c, d, e, f)

Definition at line 522 of file BLI_utildefines.h.

◆ _VA_ARRAY_SET_ITEMS9

#define _VA_ARRAY_SET_ITEMS9 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
_VA_ARRAY_SET_ITEMS8(v, a, b, c, d, e, f, g); \
((v)[7] = (h))
#define _VA_ARRAY_SET_ITEMS8(v, a, b, c, d, e, f, g)

Definition at line 525 of file BLI_utildefines.h.

◆ _VA_ELEM10

#define _VA_ELEM10 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
 
)     (_VA_ELEM9(v, a, b, c, d, e, f, g, h) || _VA_ELEM2(v, i))

Definition at line 270 of file BLI_utildefines.h.

◆ _VA_ELEM11

#define _VA_ELEM11 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
 
)     (_VA_ELEM10(v, a, b, c, d, e, f, g, h, i) || _VA_ELEM2(v, j))

Definition at line 272 of file BLI_utildefines.h.

◆ _VA_ELEM12

#define _VA_ELEM12 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
 
)     (_VA_ELEM11(v, a, b, c, d, e, f, g, h, i, j) || _VA_ELEM2(v, k))

Definition at line 274 of file BLI_utildefines.h.

◆ _VA_ELEM13

#define _VA_ELEM13 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l 
)     (_VA_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k) || _VA_ELEM2(v, l))

Definition at line 276 of file BLI_utildefines.h.

◆ _VA_ELEM14

#define _VA_ELEM14 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l,
 
)     (_VA_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l) || _VA_ELEM2(v, m))

Definition at line 278 of file BLI_utildefines.h.

◆ _VA_ELEM15

#define _VA_ELEM15 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l,
  m,
 
)     (_VA_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m) || _VA_ELEM2(v, n))

Definition at line 280 of file BLI_utildefines.h.

◆ _VA_ELEM16

#define _VA_ELEM16 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l,
  m,
  n,
 
)     (_VA_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n) || _VA_ELEM2(v, o))

Definition at line 282 of file BLI_utildefines.h.

◆ _VA_ELEM17

#define _VA_ELEM17 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l,
  m,
  n,
  o,
 
)     (_VA_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) || _VA_ELEM2(v, p))

Definition at line 284 of file BLI_utildefines.h.

◆ _VA_ELEM2

#define _VA_ELEM2 (   v,
 
)    ((v) == (a))

Definition at line 255 of file BLI_utildefines.h.

◆ _VA_ELEM3

#define _VA_ELEM3 (   v,
  a,
 
)     (_VA_ELEM2(v, a) || _VA_ELEM2(v, b))

Definition at line 256 of file BLI_utildefines.h.

◆ _VA_ELEM4

#define _VA_ELEM4 (   v,
  a,
  b,
 
)     (_VA_ELEM3(v, a, b) || _VA_ELEM2(v, c))

Definition at line 258 of file BLI_utildefines.h.

◆ _VA_ELEM5

#define _VA_ELEM5 (   v,
  a,
  b,
  c,
 
)     (_VA_ELEM4(v, a, b, c) || _VA_ELEM2(v, d))

Definition at line 260 of file BLI_utildefines.h.

◆ _VA_ELEM6

#define _VA_ELEM6 (   v,
  a,
  b,
  c,
  d,
  e 
)     (_VA_ELEM5(v, a, b, c, d) || _VA_ELEM2(v, e))

Definition at line 262 of file BLI_utildefines.h.

◆ _VA_ELEM7

#define _VA_ELEM7 (   v,
  a,
  b,
  c,
  d,
  e,
 
)     (_VA_ELEM6(v, a, b, c, d, e) || _VA_ELEM2(v, f))

Definition at line 264 of file BLI_utildefines.h.

◆ _VA_ELEM8

#define _VA_ELEM8 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
 
)     (_VA_ELEM7(v, a, b, c, d, e, f) || _VA_ELEM2(v, g))

Definition at line 266 of file BLI_utildefines.h.

◆ _VA_ELEM9

#define _VA_ELEM9 (   v,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)     (_VA_ELEM8(v, a, b, c, d, e, f, g) || _VA_ELEM2(v, h))

Definition at line 268 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_1

#define _VA_UNUSED_VARS_1 (   a0)    ((void)(a0))

UNUSED_VARS#(a, ...): quiet unused warnings

for i in range(16):
args = [(chr(ord('a') + (c % 26)) + (chr(ord('0') + (c // 26)))) for c in range(i + 1)]
print("#define _VA_UNUSED_VARS_%d(%s) \\" % (i + 1, ", ".join(args)))
print("\t((void)(%s)%s)" %
(args[0], ((", _VA_UNUSED_VARS_" + str(i) + "(%s)") if i else "%s") %
", ".join((args[1:]))))
#define str(s)

Definition at line 703 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_10

#define _VA_UNUSED_VARS_10 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0,
  g0,
  h0,
  i0,
  j0 
)     ((void)(a0), _VA_UNUSED_VARS_9(b0, c0, d0, e0, f0, g0, h0, i0, j0))

Definition at line 716 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_11

#define _VA_UNUSED_VARS_11 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0,
  g0,
  h0,
  i0,
  j0,
  k0 
)     ((void)(a0), _VA_UNUSED_VARS_10(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0))

Definition at line 718 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_12

#define _VA_UNUSED_VARS_12 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0,
  g0,
  h0,
  i0,
  j0,
  k0,
  l0 
)     ((void)(a0), _VA_UNUSED_VARS_11(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0))

Definition at line 720 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_13

#define _VA_UNUSED_VARS_13 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0,
  g0,
  h0,
  i0,
  j0,
  k0,
  l0,
  m0 
)     ((void)(a0), _VA_UNUSED_VARS_12(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0))

Definition at line 722 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_14

#define _VA_UNUSED_VARS_14 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0,
  g0,
  h0,
  i0,
  j0,
  k0,
  l0,
  m0,
  n0 
)     ((void)(a0), _VA_UNUSED_VARS_13(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0))

Definition at line 724 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_15

#define _VA_UNUSED_VARS_15 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0,
  g0,
  h0,
  i0,
  j0,
  k0,
  l0,
  m0,
  n0,
  o0 
)     ((void)(a0), _VA_UNUSED_VARS_14(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0))

Definition at line 726 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_16

#define _VA_UNUSED_VARS_16 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0,
  g0,
  h0,
  i0,
  j0,
  k0,
  l0,
  m0,
  n0,
  o0,
  p0 
)     ((void)(a0), _VA_UNUSED_VARS_15(b0, c0, d0, e0, f0, g0, h0, i0, j0, k0, l0, m0, n0, o0, p0))

Definition at line 728 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_2

#define _VA_UNUSED_VARS_2 (   a0,
  b0 
)    ((void)(a0), _VA_UNUSED_VARS_1(b0))

Definition at line 704 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_3

#define _VA_UNUSED_VARS_3 (   a0,
  b0,
  c0 
)    ((void)(a0), _VA_UNUSED_VARS_2(b0, c0))

Definition at line 705 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_4

#define _VA_UNUSED_VARS_4 (   a0,
  b0,
  c0,
  d0 
)    ((void)(a0), _VA_UNUSED_VARS_3(b0, c0, d0))

Definition at line 706 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_5

#define _VA_UNUSED_VARS_5 (   a0,
  b0,
  c0,
  d0,
  e0 
)    ((void)(a0), _VA_UNUSED_VARS_4(b0, c0, d0, e0))

Definition at line 707 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_6

#define _VA_UNUSED_VARS_6 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0 
)     ((void)(a0), _VA_UNUSED_VARS_5(b0, c0, d0, e0, f0))

Definition at line 708 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_7

#define _VA_UNUSED_VARS_7 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0,
  g0 
)     ((void)(a0), _VA_UNUSED_VARS_6(b0, c0, d0, e0, f0, g0))

Definition at line 710 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_8

#define _VA_UNUSED_VARS_8 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0,
  g0,
  h0 
)     ((void)(a0), _VA_UNUSED_VARS_7(b0, c0, d0, e0, f0, g0, h0))

Definition at line 712 of file BLI_utildefines.h.

◆ _VA_UNUSED_VARS_9

#define _VA_UNUSED_VARS_9 (   a0,
  b0,
  c0,
  d0,
  e0,
  f0,
  g0,
  h0,
  i0 
)     ((void)(a0), _VA_UNUSED_VARS_8(b0, c0, d0, e0, f0, g0, h0, i0))

Definition at line 714 of file BLI_utildefines.h.

◆ ARRAY_DELETE

#define ARRAY_DELETE (   arr,
  index,
  delete_len,
  arr_len 
)
Value:
{ \
BLI_assert((&arr[index] >= arr) && ((index) + delete_len <= arr_len)); \
memmove(&(arr)[index], \
&(arr)[(index) + (delete_len)], \
(((arr_len) - (index)) - (delete_len)) * sizeof(*(arr))); \
} \
((void)0)
SyclQueue void void size_t num_bytes void
Note
use faster ARRAY_DELETE_REORDER_LAST when we can re-order.

Definition at line 463 of file BLI_utildefines.h.

◆ ARRAY_DELETE_REORDER_LAST

#define ARRAY_DELETE_REORDER_LAST (   arr,
  index,
  delete_len,
  arr_len 
)
Value:
{ \
BLI_assert((&arr[index] >= arr) && ((index) + delete_len <= arr_len)); \
if ((index) + (delete_len) != (arr_len)) { \
if (((delete_len) == 1) || ((delete_len) <= ((arr_len) - ((index) + (delete_len))))) { \
memcpy(&(arr)[index], &(arr)[(arr_len) - (delete_len)], (delete_len) * sizeof(*(arr))); \
} \
else { \
memcpy(&(arr)[index], \
&(arr)[(arr_len) - ((arr_len) - ((index) + (delete_len)))], \
((arr_len) - ((index) + (delete_len))) * sizeof(*(arr))); \
} \
} \
} \
((void)0)

Re-ordering array removal.

When removing single items this compiles down to: if (index + 1 != arr_len) { arr[index] = arr[arr_len - 1]; } (typical reordering removal), with removing multiple items, overlap is detected to avoid memcpy errors.

Definition at line 479 of file BLI_utildefines.h.

◆ ARRAY_HAS_ITEM

#define ARRAY_HAS_ITEM (   arr_item,
  arr_start,
  arr_len 
)
Value:
(CHECK_TYPE_PAIR_INLINE(arr_start, arr_item), \
((unsigned int)((arr_item) - (arr_start)) < (unsigned int)(arr_len)))
#define CHECK_TYPE_PAIR_INLINE(var_a, var_b)

Definition at line 456 of file BLI_utildefines.h.

◆ ARRAY_LAST_ITEM

#define ARRAY_LAST_ITEM (   arr_start,
  arr_dtype,
  arr_len 
)     (arr_dtype *)((char *)(arr_start) + (sizeof(*((arr_dtype *)NULL)) * (size_t)(arr_len - 1)))

Definition at line 453 of file BLI_utildefines.h.

◆ ARRAY_SET_ITEMS

#define ARRAY_SET_ITEMS (   ...)
Value:
{ \
VA_NARGS_CALL_OVERLOAD(_VA_ARRAY_SET_ITEMS, __VA_ARGS__); \
} \
(void)0

Definition at line 554 of file BLI_utildefines.h.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   arr)    (sizeof(arr) / sizeof(*(arr)))

Definition at line 501 of file BLI_utildefines.h.

◆ AT

#define AT   __FILE__ ":" STRINGIFY(__LINE__)

Useful for debugging.

Definition at line 832 of file BLI_utildefines.h.

◆ BLI_ENABLE_IF

#define BLI_ENABLE_IF (   condition)    typename std::enable_if_t<(condition)> * = nullptr

Utility macro that wraps std::enable_if to make it a bit easier to use and less verbose for SFINAE in common cases.

Note
Often one has to invoke this macro with double parenthesis. That's because the condition often contains a comma and angle brackets are not recognized as parenthesis by the preprocessor.

Definition at line 844 of file BLI_utildefines.h.

◆ BLI_NO_UNIQUE_ADDRESS

#define BLI_NO_UNIQUE_ADDRESS   [[no_unique_address]]

Definition at line 855 of file BLI_utildefines.h.

◆ CLAMP

#define CLAMP (   a,
  b,
 
)
Value:
{ \
if ((a) < (b)) { \
(a) = (b); \
} \
else if ((a) > (c)) { \
(a) = (c); \
} \
} \
(void)0

Definition at line 332 of file BLI_utildefines.h.

◆ CLAMP2

#define CLAMP2 (   vec,
  b,
 
)
Value:
{ \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
} \
(void)0

Definition at line 359 of file BLI_utildefines.h.

◆ CLAMP2_MAX

#define CLAMP2_MAX (   vec,
 
)
Value:
{ \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
} \
(void)0

Definition at line 373 of file BLI_utildefines.h.

◆ CLAMP2_MIN

#define CLAMP2_MIN (   vec,
 
)
Value:
{ \
CLAMP_MIN((vec)[0], b); \
CLAMP_MIN((vec)[1], b); \
} \
(void)0

Definition at line 366 of file BLI_utildefines.h.

◆ CLAMP3

#define CLAMP3 (   vec,
  b,
 
)
Value:
{ \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
CLAMP((vec)[2], b, c); \
} \
(void)0

Definition at line 380 of file BLI_utildefines.h.

◆ CLAMP3_MAX

#define CLAMP3_MAX (   vec,
 
)
Value:
{ \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
CLAMP_MAX((vec)[2], b); \
} \
(void)0

Definition at line 396 of file BLI_utildefines.h.

◆ CLAMP3_MIN

#define CLAMP3_MIN (   vec,
 
)
Value:
{ \
CLAMP_MIN((vec)[0], b); \
CLAMP_MIN((vec)[1], b); \
CLAMP_MIN((vec)[2], b); \
} \
(void)0

Definition at line 388 of file BLI_utildefines.h.

◆ CLAMP4

#define CLAMP4 (   vec,
  b,
 
)
Value:
{ \
CLAMP((vec)[0], b, c); \
CLAMP((vec)[1], b, c); \
CLAMP((vec)[2], b, c); \
CLAMP((vec)[3], b, c); \
} \
(void)0

Definition at line 404 of file BLI_utildefines.h.

◆ CLAMP4_MAX

#define CLAMP4_MAX (   vec,
 
)
Value:
{ \
CLAMP_MAX((vec)[0], b); \
CLAMP_MAX((vec)[1], b); \
CLAMP_MAX((vec)[2], b); \
CLAMP_MAX((vec)[3], b); \
} \
(void)0

Definition at line 422 of file BLI_utildefines.h.

◆ CLAMP4_MIN

#define CLAMP4_MIN (   vec,
 
)
Value:
{ \
CLAMP_MIN((vec)[0], b); \
CLAMP_MIN((vec)[1], b); \
CLAMP_MIN((vec)[2], b); \
CLAMP_MIN((vec)[3], b); \
} \
(void)0

Definition at line 413 of file BLI_utildefines.h.

◆ CLAMP_MAX

#define CLAMP_MAX (   a,
 
)
Value:
{ \
if ((a) > (c)) { \
(a) = (c); \
} \
} \
(void)0

Definition at line 343 of file BLI_utildefines.h.

◆ CLAMP_MIN

#define CLAMP_MIN (   a,
 
)
Value:
{ \
if ((a) < (b)) { \
(a) = (b); \
} \
} \
(void)0

Definition at line 351 of file BLI_utildefines.h.

◆ CLAMPIS

#define CLAMPIS (   a,
  b,
 
)    ((a) < (b) ? (b) : (a) > (c) ? (c) : (a))

Definition at line 330 of file BLI_utildefines.h.

◆ CPP_ARG_DEFAULT

#define CPP_ARG_DEFAULT (   default_value)

Utility so function declarations in C headers can use C++ default arguments. The default is then available when included in a C++ file, otherwise the argument has to be set explicitly.

Definition at line 822 of file BLI_utildefines.h.

◆ DECIMAL_DIGITS_BOUND

#define DECIMAL_DIGITS_BOUND (   t)    (241 * sizeof(t) / 100 + 1)

Expands to an integer constant expression evaluating to a close upper bound on the number the number of decimal digits in a value expressible in the integer type given by the argument (if it is a type name) or the integer type of the argument (if it is an expression). The meaning of the resulting expression is unspecified for other arguments. i.e: DECIMAL_DIGITS_BOUND(uchar) is equal to 3.

Definition at line 322 of file BLI_utildefines.h.

◆ DO_MAX

#define DO_MAX (   vec,
  max 
)
Value:
{ \
if ((max)[0] < (vec)[0]) { \
(max)[0] = (vec)[0]; \
} \
if ((max)[1] < (vec)[1]) { \
(max)[1] = (vec)[1]; \
} \
if ((max)[2] < (vec)[2]) { \
(max)[2] = (vec)[2]; \
} \
} \
(void)0
float max

Definition at line 135 of file BLI_utildefines.h.

◆ DO_MIN

#define DO_MIN (   vec,
  min 
)
Value:
{ \
if ((min)[0] > (vec)[0]) { \
(min)[0] = (vec)[0]; \
} \
if ((min)[1] > (vec)[1]) { \
(min)[1] = (vec)[1]; \
} \
if ((min)[2] > (vec)[2]) { \
(min)[2] = (vec)[2]; \
} \
} \
(void)0
#define min(a, b)
Definition: sort.c:35

Definition at line 122 of file BLI_utildefines.h.

◆ DO_MINMAX

#define DO_MINMAX (   vec,
  min,
  max 
)
Value:
{ \
if ((min)[0] > (vec)[0]) { \
(min)[0] = (vec)[0]; \
} \
if ((min)[1] > (vec)[1]) { \
(min)[1] = (vec)[1]; \
} \
if ((min)[2] > (vec)[2]) { \
(min)[2] = (vec)[2]; \
} \
if ((max)[0] < (vec)[0]) { \
(max)[0] = (vec)[0]; \
} \
if ((max)[1] < (vec)[1]) { \
(max)[1] = (vec)[1]; \
} \
if ((max)[2] < (vec)[2]) { \
(max)[2] = (vec)[2]; \
} \
} \
(void)0

Definition at line 148 of file BLI_utildefines.h.

◆ DO_MINMAX2

#define DO_MINMAX2 (   vec,
  min,
  max 
)
Value:
{ \
if ((min)[0] > (vec)[0]) { \
(min)[0] = (vec)[0]; \
} \
if ((min)[1] > (vec)[1]) { \
(min)[1] = (vec)[1]; \
} \
if ((max)[0] < (vec)[0]) { \
(max)[0] = (vec)[0]; \
} \
if ((max)[1] < (vec)[1]) { \
(max)[1] = (vec)[1]; \
} \
} \
(void)0

Definition at line 170 of file BLI_utildefines.h.

◆ ELEM

#define ELEM (   ...)    VA_NARGS_CALL_OVERLOAD(_VA_ELEM, __VA_ARGS__)

Definition at line 289 of file BLI_utildefines.h.

◆ ENUM_OPERATORS

#define ENUM_OPERATORS (   _type,
  _max 
)

Definition at line 812 of file BLI_utildefines.h.

◆ EXPR_NOP

#define EXPR_NOP (   expr)    (void)(0 ? ((void)(expr), 1) : 0)

No-op for expressions we don't want to instantiate, but must remain valid.

Definition at line 835 of file BLI_utildefines.h.

◆ IN_RANGE

#define IN_RANGE (   a,
  b,
 
)    (((b) < (c)) ? (((b) < (a) && (a) < (c))) : (((c) < (a) && (a) < (b))))

Definition at line 310 of file BLI_utildefines.h.

◆ IN_RANGE_INCL

#define IN_RANGE_INCL (   a,
  b,
 
)     (((b) < (c)) ? (((b) <= (a) && (a) <= (c))) : (((c) <= (a) && (a) <= (b))))

Definition at line 311 of file BLI_utildefines.h.

◆ INIT_MINMAX

#define INIT_MINMAX (   min,
  max 
)
Value:
{ \
(min)[0] = (min)[1] = (min)[2] = 1.0e30f; \
(max)[0] = (max)[1] = (max)[2] = -1.0e30f; \
} \
(void)0

Definition at line 110 of file BLI_utildefines.h.

◆ INIT_MINMAX2

#define INIT_MINMAX2 (   min,
  max 
)
Value:
{ \
(min)[0] = (min)[1] = 1.0e30f; \
(max)[0] = (max)[1] = -1.0e30f; \
} \
(void)0

Definition at line 116 of file BLI_utildefines.h.

◆ IS_EQ

#define IS_EQ (   a,
 
)
Value:
(CHECK_TYPE_INLINE(a, double), \
CHECK_TYPE_INLINE(b, double), \
((fabs((double)((a) - (b))) >= (double)FLT_EPSILON) ? false : true))
#define CHECK_TYPE_INLINE(val, type)
typedef double(DMatrix)[4][4]
ccl_device_inline float2 fabs(const float2 &a)
Definition: math_float2.h:222

Definition at line 299 of file BLI_utildefines.h.

◆ IS_EQF

#define IS_EQF (   a,
 
)
Value:
(CHECK_TYPE_INLINE(a, float), \
CHECK_TYPE_INLINE(b, float), \
((fabsf((float)((a) - (b))) >= (float)FLT_EPSILON) ? false : true))
typedef float(TangentPoint)[2]
#define fabsf(x)
Definition: metal/compat.h:219

Definition at line 304 of file BLI_utildefines.h.

◆ IS_EQT

#define IS_EQT (   a,
  b,
 
)    (((a) > (b)) ? ((((a) - (b)) <= (c))) : (((((b) - (a)) <= (c)))))

Definition at line 309 of file BLI_utildefines.h.

◆ LIKELY

#define LIKELY (   x)    (x)

Definition at line 752 of file BLI_utildefines.h.

◆ MAX2

#define MAX2 (   a,
 
)    ((a) > (b) ? (a) : (b))

Definition at line 94 of file BLI_utildefines.h.

◆ MAX3

#define MAX3 (   a,
  b,
 
)    (MAX2(MAX2((a), (b)), (c)))

Definition at line 99 of file BLI_utildefines.h.

◆ MAX3_PAIR

#define MAX3_PAIR (   cmp_a,
  cmp_b,
  cmp_c,
  ret_a,
  ret_b,
  ret_c 
)     ((cmp_a > cmp_b) ? ((cmp_a > cmp_c) ? ret_a : ret_c) : ((cmp_b > cmp_c) ? ret_b : ret_c))

Definition at line 104 of file BLI_utildefines.h.

◆ MAX4

#define MAX4 (   a,
  b,
  c,
 
)    (MAX2(MAX2((a), (b)), MAX2((c), (d))))

Definition at line 100 of file BLI_utildefines.h.

◆ MEMCMP_STRUCT_AFTER_IS_ZERO

#define MEMCMP_STRUCT_AFTER_IS_ZERO (   struct_var,
  member 
)
Value:
(BLI_memory_is_zero((const char *)(struct_var) + OFFSETOF_STRUCT_AFTER(struct_var, member), \
sizeof(*(struct_var)) - OFFSETOF_STRUCT_AFTER(struct_var, member)))
bool BLI_memory_is_zero(const void *arr, size_t arr_size)
Definition: memory_utils.c:19
#define OFFSETOF_STRUCT_AFTER(_struct, _member)

Definition at line 628 of file BLI_utildefines.h.

◆ MEMCPY_STRUCT_AFTER

#define MEMCPY_STRUCT_AFTER (   struct_dst,
  struct_src,
  member 
)
Value:
{ \
CHECK_TYPE_NONCONST(struct_dst); \
((void)(struct_dst == struct_src), \
memcpy((char *)(struct_dst) + OFFSETOF_STRUCT_AFTER(struct_dst, member), \
(const char *)(struct_src) + OFFSETOF_STRUCT_AFTER(struct_dst, member), \
sizeof(*(struct_dst)) - OFFSETOF_STRUCT_AFTER(struct_dst, member))); \
} \
((void)0)

memcpy helper, skipping the first part of a struct, ensures 'struct_dst' isn't const and the offset can be computed at compile time. This isn't inclusive, the value of member isn't copied.

Definition at line 600 of file BLI_utildefines.h.

◆ MEMSET_STRUCT_AFTER

#define MEMSET_STRUCT_AFTER (   struct_var,
  value,
  member 
)
Value:
{ \
CHECK_TYPE_NONCONST(struct_var); \
memset((char *)(struct_var) + OFFSETOF_STRUCT_AFTER(struct_var, member), \
value, \
sizeof(*(struct_var)) - OFFSETOF_STRUCT_AFTER(struct_var, member)); \
} \
((void)0)

Definition at line 610 of file BLI_utildefines.h.

◆ MIN2

#define MIN2 (   a,
 
)    ((a) < (b) ? (a) : (b))

Definition at line 93 of file BLI_utildefines.h.

◆ MIN3

#define MIN3 (   a,
  b,
 
)    (MIN2(MIN2((a), (b)), (c)))

Definition at line 96 of file BLI_utildefines.h.

◆ MIN3_PAIR

#define MIN3_PAIR (   cmp_a,
  cmp_b,
  cmp_c,
  ret_a,
  ret_b,
  ret_c 
)     ((cmp_a < cmp_b) ? ((cmp_a < cmp_c) ? ret_a : ret_c) : ((cmp_b < cmp_c) ? ret_b : ret_c))

Definition at line 107 of file BLI_utildefines.h.

◆ MIN4

#define MIN4 (   a,
  b,
  c,
 
)    (MIN2(MIN2((a), (b)), MIN2((c), (d))))

Definition at line 97 of file BLI_utildefines.h.

◆ OFFSETOF_STRUCT_AFTER

#define OFFSETOF_STRUCT_AFTER (   _struct,
  _member 
)
Value:
((((const char *)&((_struct)->_member)) - ((const char *)(_struct))) + \
sizeof((_struct)->_member))

Performs offsetof(typeof(data), member) + sizeof((data)->member) for non-gcc compilers.

Definition at line 591 of file BLI_utildefines.h.

◆ POINTER_AS_INT

#define POINTER_AS_INT (   i)    ((void)0, ((int)(intptr_t)(i)))

Definition at line 575 of file BLI_utildefines.h.

◆ POINTER_AS_UINT

#define POINTER_AS_UINT (   i)    ((void)0, ((unsigned int)(uintptr_t)(i)))

Definition at line 578 of file BLI_utildefines.h.

◆ POINTER_FROM_INT

#define POINTER_FROM_INT (   i)    ((void *)(intptr_t)(i))

Definition at line 574 of file BLI_utildefines.h.

◆ POINTER_FROM_UINT

#define POINTER_FROM_UINT (   i)    ((void *)(uintptr_t)(i))

Definition at line 577 of file BLI_utildefines.h.

◆ POINTER_OFFSET

#define POINTER_OFFSET (   v,
  ofs 
)    ((void *)((char *)(v) + (ofs)))

Definition at line 569 of file BLI_utildefines.h.

◆ SET_FLAG_FROM_TEST

#define SET_FLAG_FROM_TEST (   value,
  test,
  flag 
)
Value:
{ \
if (test) { \
(value) |= (flag); \
} \
else { \
(value) &= ~(flag); \
} \
} \
((void)0)

Definition at line 763 of file BLI_utildefines.h.

◆ SHIFT3

#define SHIFT3 (   type,
  a,
  b,
 
)
Value:
{ \
type tmp; \
CHECK_TYPE(a, type); \
CHECK_TYPE(b, type); \
CHECK_TYPE(c, type); \
tmp = a; \
a = c; \
c = b; \
b = tmp; \
} \
(void)0
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type

Definition at line 216 of file BLI_utildefines.h.

◆ SHIFT4

#define SHIFT4 (   type,
  a,
  b,
  c,
 
)
Value:
{ \
type tmp; \
CHECK_TYPE(a, type); \
CHECK_TYPE(b, type); \
CHECK_TYPE(c, type); \
CHECK_TYPE(d, type); \
tmp = a; \
a = d; \
d = c; \
c = b; \
b = tmp; \
} \
(void)0

Definition at line 229 of file BLI_utildefines.h.

◆ STRCASEEQ

#define STRCASEEQ (   a,
 
)    (strcasecmp(a, b) == 0)

Definition at line 655 of file BLI_utildefines.h.

◆ STRCASEEQLEN

#define STRCASEEQLEN (   a,
  b,
 
)    (strncasecmp(a, b, n) == 0)

Definition at line 657 of file BLI_utildefines.h.

◆ STREQ

#define STREQ (   a,
 
)    (strcmp(a, b) == 0)

Definition at line 654 of file BLI_utildefines.h.

◆ STREQLEN

#define STREQLEN (   a,
  b,
 
)    (strncmp(a, b, n) == 0)

Definition at line 656 of file BLI_utildefines.h.

◆ STRINGIFY

#define STRINGIFY (   x)    STRINGIFY_APPEND("", x)

Definition at line 646 of file BLI_utildefines.h.

◆ STRINGIFY_APPEND

#define STRINGIFY_APPEND (   a,
 
)    "" a #b

Definition at line 645 of file BLI_utildefines.h.

◆ STRINGIFY_ARG

#define STRINGIFY_ARG (   x)    "" #x

Definition at line 644 of file BLI_utildefines.h.

◆ STRPREFIX

#define STRPREFIX (   a,
 
)    (strncmp((a), (b), strlen(b)) == 0)

Definition at line 659 of file BLI_utildefines.h.

◆ SWAP

#define SWAP (   type,
  a,
 
)
Value:
{ \
type sw_ap; \
CHECK_TYPE(a, type); \
CHECK_TYPE(b, type); \
sw_ap = (a); \
(a) = (b); \
(b) = sw_ap; \
} \
(void)0

Definition at line 193 of file BLI_utildefines.h.

◆ SWAP_TVAL

#define SWAP_TVAL (   tval,
  a,
 
)
Value:
{ \
CHECK_TYPE_PAIR(tval, a); \
CHECK_TYPE_PAIR(tval, b); \
(tval) = (a); \
(a) = (b); \
(b) = (tval); \
} \
(void)0

Definition at line 205 of file BLI_utildefines.h.

◆ UNLIKELY

#define UNLIKELY (   x)    (x)

Definition at line 753 of file BLI_utildefines.h.

◆ UNPACK2

#define UNPACK2 (   a)    ((a)[0]), ((a)[1])

Definition at line 438 of file BLI_utildefines.h.

◆ UNPACK2_EX

#define UNPACK2_EX (   pre,
  a,
  post 
)    (pre((a)[0]) post), (pre((a)[1]) post)

Definition at line 442 of file BLI_utildefines.h.

◆ UNPACK3

#define UNPACK3 (   a)    UNPACK2(a), ((a)[2])

Definition at line 439 of file BLI_utildefines.h.

◆ UNPACK3_EX

#define UNPACK3_EX (   pre,
  a,
  post 
)    UNPACK2_EX(pre, a, post), (pre((a)[2]) post)

Definition at line 443 of file BLI_utildefines.h.

◆ UNPACK4

#define UNPACK4 (   a)    UNPACK3(a), ((a)[3])

Definition at line 440 of file BLI_utildefines.h.

◆ UNPACK4_EX

#define UNPACK4_EX (   pre,
  a,
  post 
)    UNPACK3_EX(pre, a, post), (pre((a)[3]) post)

Definition at line 444 of file BLI_utildefines.h.

◆ UNUSED

#define UNUSED (   x)    UNUSED_##x

Definition at line 671 of file BLI_utildefines.h.

◆ UNUSED_FUNCTION

#define UNUSED_FUNCTION (   x)    UNUSED_##x

WARNING: this doesn't warn when returning pointer types (because of the placement of *). Use UNUSED_FUNCTION_WITH_RETURN_TYPE instead in this case.

Definition at line 681 of file BLI_utildefines.h.

◆ UNUSED_FUNCTION_WITH_RETURN_TYPE

#define UNUSED_FUNCTION_WITH_RETURN_TYPE (   rtype,
  x 
)    rtype UNUSED_##x

Definition at line 687 of file BLI_utildefines.h.

◆ UNUSED_VARS

#define UNUSED_VARS (   ...)    VA_NARGS_CALL_OVERLOAD(_VA_UNUSED_VARS_, __VA_ARGS__)

Definition at line 732 of file BLI_utildefines.h.

◆ UNUSED_VARS_NDEBUG

#define UNUSED_VARS_NDEBUG (   ...)

Definition at line 736 of file BLI_utildefines.h.

Function Documentation

◆ BLI_memory_is_zero()

bool BLI_memory_is_zero ( const void arr,
size_t  arr_size 
)

Check if memory is zeroed, as with memset(arr, 0, arr_size).

Definition at line 19 of file memory_utils.c.