XenevaOS
Loading...
Searching...
No Matches
Macros
minmax.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define min(a, b)   (((a) < (b)) ? (a) : (b))
 
#define max(a, b)   (((a) > (b)) ? (a) : (b))
 
#define min_t(type, a, b)   ((type)(a) < (type)(b) ? (type)(a) : (type)(b))
 
#define max_t(type, a, b)   ((type)(a) > (type)(b) ? (type)(a) : (type)(b))
 
#define MAX_T(type, a, b)   max_t(type, a, b)
 
#define MIN_T(type, a, b)   min_t(type, a, b)
 
#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
 
#define clamp(val, lo, hi)   ((val) < (lo) ? (lo) : ((val) > (hi) ? (hi) : (val)))
 
#define clamp_val(val, lo, hi)   clamp((val), (lo), (hi))
 
#define ARRAY_SIZE(a)   (sizeof(a) / sizeof((a)[0]))
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE (   a)    (sizeof(a) / sizeof((a)[0]))

◆ clamp

#define clamp (   val,
  lo,
  hi 
)    ((val) < (lo) ? (lo) : ((val) > (hi) ? (hi) : (val)))

◆ clamp_val

#define clamp_val (   val,
  lo,
  hi 
)    clamp((val), (lo), (hi))

◆ max

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

◆ max_t

#define max_t (   type,
  a,
  b 
)    ((type)(a) > (type)(b) ? (type)(a) : (type)(b))

◆ MAX_T

#define MAX_T (   type,
  a,
  b 
)    max_t(type, a, b)

◆ min

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

◆ min_t

#define min_t (   type,
  a,
  b 
)    ((type)(a) < (type)(b) ? (type)(a) : (type)(b))

◆ MIN_T

#define MIN_T (   type,
  a,
  b 
)    min_t(type, a, b)

◆ swap

#define swap (   a,
  b 
)     do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)