libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_macro_utils.h File Reference

Go to the source code of this file.

Macros

#define GBL_MIN(a, b)
 
#define GBL_MAX(a, b)
 
#define GBL_CEIL(numerator, denominator)
 
#define GBL_CLAMP(n, min, max)
 
#define GBL_BIT_MASK_2(bits, offset)
 
#define GBL_BIT_MASK_1(bits)
 
#define GBL_BIT_MASK(...)
 
#define GBL_BCD_BYTE_PACK(n)
 
#define GBL_BCD_BYTE_UNPACK(n)
 
#define GBL_CONTAINER_OF(ptr, type, member)
 
#define GBL_COUNT_OF(array)
 
#define GBL_PTR_OFFSET(...)
 
#define GBL_PTR_OFFSET_3(type, ptr, bytes)
 
#define GBL_PTR_OFFSET_2(ptr, bytes)
 
#define GBL_SWITCH_CASE_STRINGIFY(s)
 
#define GBL_LABEL_EMPTY(name)
 
#define GBL_SWAP(x, y)
 
#define GBL_ASSERT(...)
 
#define GBL_BIT_FIELDS(...)
 
#define GBL_META_GENERIC_MACRO_GENERATE(traits, X)
 
#define GBL_META_GENERIC_MACRO_TRAIT_PROPERTY_DEFAULT(defaultFunc, overloads)
 
#define GBL_META_GENERIC_MACRO_NO_DEFAULT
 
#define GBL_SCOPE(begin, end)
 
#define GBL_SCOPE_EXIT
 
#define GBL_APPEND_LINE(a)
 

Detailed Description

Miscellaneous macro utilities and meta generators.

See also
gimbal_macro_composition.h, gimbal_macro_sequences.h
Author
Falco Girgis
2025 Agustín Bellagamba

Definition in file gimbal_macro_utils.h.

Macro Definition Documentation

◆ GBL_MIN

#define GBL_MIN ( a,
b )

Definition at line 23 of file gimbal_macro_utils.h.

◆ GBL_MAX

#define GBL_MAX ( a,
b )

Definition at line 24 of file gimbal_macro_utils.h.

◆ GBL_CEIL

#define GBL_CEIL ( numerator,
denominator )

Definition at line 25 of file gimbal_macro_utils.h.

◆ GBL_CLAMP

#define GBL_CLAMP ( n,
min,
max )

Definition at line 26 of file gimbal_macro_utils.h.

◆ GBL_BIT_MASK_2

#define GBL_BIT_MASK_2 ( bits,
offset )

Definition at line 28 of file gimbal_macro_utils.h.

◆ GBL_BIT_MASK_1

#define GBL_BIT_MASK_1 ( bits)

Definition at line 29 of file gimbal_macro_utils.h.

◆ GBL_BIT_MASK

#define GBL_BIT_MASK ( ...)

Definition at line 30 of file gimbal_macro_utils.h.

◆ GBL_BCD_BYTE_PACK

#define GBL_BCD_BYTE_PACK ( n)

Definition at line 32 of file gimbal_macro_utils.h.

◆ GBL_BCD_BYTE_UNPACK

#define GBL_BCD_BYTE_UNPACK ( n)

Definition at line 33 of file gimbal_macro_utils.h.

◆ GBL_CONTAINER_OF

#define GBL_CONTAINER_OF ( ptr,
type,
member )

Definition at line 35 of file gimbal_macro_utils.h.

◆ GBL_COUNT_OF

#define GBL_COUNT_OF ( array)

Definition at line 36 of file gimbal_macro_utils.h.

◆ GBL_PTR_OFFSET

#define GBL_PTR_OFFSET ( ...)

Definition at line 38 of file gimbal_macro_utils.h.

◆ GBL_PTR_OFFSET_3

#define GBL_PTR_OFFSET_3 ( type,
ptr,
bytes )

Definition at line 39 of file gimbal_macro_utils.h.

◆ GBL_PTR_OFFSET_2

#define GBL_PTR_OFFSET_2 ( ptr,
bytes )

Definition at line 40 of file gimbal_macro_utils.h.

◆ GBL_SWITCH_CASE_STRINGIFY

#define GBL_SWITCH_CASE_STRINGIFY ( s)

Definition at line 42 of file gimbal_macro_utils.h.

◆ GBL_LABEL_EMPTY

#define GBL_LABEL_EMPTY ( name)

Definition at line 44 of file gimbal_macro_utils.h.

◆ GBL_SWAP

#define GBL_SWAP ( x,
y )

Definition at line 46 of file gimbal_macro_utils.h.

46#define GBL_SWAP(x,y) \
47 GBL_STMT_START { \
48 unsigned char swap_temp[sizeof(x) == sizeof(y) ? \
49 (signed)sizeof(x) : -1]; \
50 memcpy(swap_temp, &y, sizeof(x)); \
51 memcpy(&y, &x, sizeof(x)); \
52 memcpy(&x, swap_temp, sizeof(x)); \
53 } GBL_STMT_END

◆ GBL_ASSERT

#define GBL_ASSERT ( ...)

Definition at line 55 of file gimbal_macro_utils.h.

55#define GBL_ASSERT(...) \
56 GBL_VA_OVERLOAD_SELECT(GBL_ASSERT, GBL_VA_OVERLOAD_SUFFIXER_ARGC, __VA_ARGS__)(__VA_ARGS__)

◆ GBL_BIT_FIELDS

#define GBL_BIT_FIELDS ( ...)

Used to declare an endian-independent group of bitfields.

Definition at line 59 of file gimbal_macro_utils.h.

59#define GBL_BIT_FIELDS(...) \
60 GBL_TUPLE_FOREACH(GBL_BIT_FIELDS_ENTRY_, GBL_PHONY, GBL_BIT_FIELDS_ENDIAN_XFORM_ (__VA_ARGS__))

◆ GBL_META_GENERIC_MACRO_GENERATE

#define GBL_META_GENERIC_MACRO_GENERATE ( traits,
X )

Definition at line 63 of file gimbal_macro_utils.h.

63# define GBL_META_GENERIC_MACRO_GENERATE(traits, X) \
64 _Generic((X), \
65 GBL_MAP_TUPLES(GBL_META_GENERIC_MACRO_TRAIT_OVERLOADS_DECLARE_CASE_C_, \
66 GBL_MAP_TUPLES(GBL_EVAL, GBL_META_GENERIC_MACRO_TRAIT_PROPERTY_OVERLOADS_ traits)) \
67 default: GBL_EVAL(GBL_META_GENERIC_MACRO_TRAIT_PROPERTY_DEFAULT traits) \
68 )

◆ GBL_META_GENERIC_MACRO_TRAIT_PROPERTY_DEFAULT

#define GBL_META_GENERIC_MACRO_TRAIT_PROPERTY_DEFAULT ( defaultFunc,
overloads )

Definition at line 82 of file gimbal_macro_utils.h.

◆ GBL_META_GENERIC_MACRO_NO_DEFAULT

#define GBL_META_GENERIC_MACRO_NO_DEFAULT

Definition at line 83 of file gimbal_macro_utils.h.

◆ GBL_SCOPE

#define GBL_SCOPE ( begin,
end )

Definition at line 109 of file gimbal_macro_utils.h.

◆ GBL_SCOPE_EXIT

#define GBL_SCOPE_EXIT

Definition at line 110 of file gimbal_macro_utils.h.

◆ GBL_APPEND_LINE

#define GBL_APPEND_LINE ( a)

Definition at line 112 of file gimbal_macro_utils.h.