Loading...
Searching...
No Matches
Go to the documentation of this file.
14#define DEFINE_CLAMP(type, name) \
15[[gnu::always_inline]] \
16static inline type clamp_##name(type input, type lower, type upper) { \
17 if (input < lower) return lower; \
18 if (input > upper) return upper; \
23DEFINE_CLAMP(
unsigned int, uint)
24DEFINE_CLAMP(
long,
long)
25DEFINE_CLAMP(
unsigned long, ulong)
26DEFINE_CLAMP(
float,
float)
28#define CLAMP(input, lower_bound, upper_bound) \
29 _Generic((input) + (lower_bound) + (upper_bound), \
31 unsigned int: clamp_uint, \
33 unsigned long: clamp_ulong, \
35)(input, lower_bound, upper_bound)