mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-05-06 19:01:18 +03:00
37 lines
1.9 KiB
C
37 lines
1.9 KiB
C
#ifndef T1M_UTIL_H
|
|
#define T1M_UTIL_H
|
|
|
|
#define SQUARE(A) ((A) * (A))
|
|
#ifndef ABS
|
|
#define ABS(x) (((x) < 0) ? (-(x)) : (x))
|
|
#define MIN(x, y) ((x) <= (y) ? (x) : (y))
|
|
#define MAX(x, y) ((x) >= (y) ? (x) : (y))
|
|
#endif
|
|
#define CHK_ALL(a, b) (((a) & (b)) == (b))
|
|
#define CHK_ANY(a, b) (((a) & (b)) != 0)
|
|
|
|
#define CLAMPL(a, b) \
|
|
do { \
|
|
if ((a) < (b)) \
|
|
(a) = (b); \
|
|
} while (0)
|
|
#define CLAMPG(a, b) \
|
|
do { \
|
|
if ((a) > (b)) \
|
|
(a) = (b); \
|
|
} while (0)
|
|
#define CLAMP(a, b, c) \
|
|
do { \
|
|
if ((a) < (b)) \
|
|
(a) = (b); \
|
|
else if ((a) > (c)) \
|
|
(a) = (c); \
|
|
} while (0)
|
|
#define SWAP(a, b, c) \
|
|
do { \
|
|
(c) = (a); \
|
|
(a) = (b); \
|
|
(b) = (c); \
|
|
} while (0)
|
|
|
|
#endif
|