reldb 0.1.0
Recreational SQLite
Loading...
Searching...
No Matches
Utility Math & Helpers

Quality-of-life macros. Uses type-safe GCC/Clang extensions when available. More...

Macros

#define INT_FROM_PTR(ptr)
 Safely casts a pointer to an integer of pointer size.
#define PTR_FROM_INT(type, val)
 Safely casts a pointer-sized integer back to a specific pointer type.
#define ARRAY_SIZE(arr)
 Calculates the number of elements in a static array.
#define MIN(a, b)
#define MAX(a, b)
#define CLAMP(val, min, max)
#define SWAP(type, a, b)

Detailed Description

Quality-of-life macros. Uses type-safe GCC/Clang extensions when available.

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE ( arr)
Value:
(sizeof(arr) / sizeof((arr)[0]))

Calculates the number of elements in a static array.

Definition at line 180 of file macros.h.

◆ CLAMP

#define CLAMP ( val,
min,
max )
Value:
(((val) < (min)) ? (min) : ((val) > (max)) ? (max) : (val))

Definition at line 228 of file macros.h.

◆ INT_FROM_PTR

#define INT_FROM_PTR ( ptr)
Value:
((uintptr_t)(ptr))
void * ptr
Definition types.h:82

Safely casts a pointer to an integer of pointer size.

Definition at line 175 of file macros.h.

◆ MAX

#define MAX ( a,
b )
Value:
(((a) > (b)) ? (a) : (b))

Definition at line 227 of file macros.h.

◆ MIN

#define MIN ( a,
b )
Value:
(((a) < (b)) ? (a) : (b))

Definition at line 226 of file macros.h.

◆ PTR_FROM_INT

#define PTR_FROM_INT ( type,
val )
Value:
((type *)(uintptr_t)(val))

Safely casts a pointer-sized integer back to a specific pointer type.

Definition at line 177 of file macros.h.

◆ SWAP

#define SWAP ( type,
a,
b )
Value:
do { \
type _tmp = (a); \
(a) = (b); \
(b) = _tmp; \
} while (0)

Definition at line 229 of file macros.h.