Adding my_overflow utilities

This commit is contained in:
Anonymus Raccoon
2020-04-29 23:01:47 +02:00
parent 8d091a9575
commit c886bb1567
+5 -7
View File
@@ -28,12 +28,10 @@ void *my_realloc(void *oldptr, size_t oldsize, size_t newsize);
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CLAMP(x, y) (((x) > (y)) ? ((x) = (y)) : (x))
#define NCLAMP(x, y) (((x) < (y)) ? ((x) = (y)) : (x))
#define ABSCLAMP(x, y) (((x) > 0) ? CLAMP((x), (y)) : NCLAMP((x), -(y)))
#define CLAMP(x, min, max) \
((((x) > (max) ? (max) : (x)) < (min)) ? (min) : ((x) > (max) ? (max) : (x)))
#define SIGN(x) (((x) < 0) ? (-1) : ((x == 0 ? 0 : 1)))
#define SET_SIGN(x, s) (x = (x) * (s) > 0 ? (x) : ((x) * (-1)))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define MY_OVERFLOW(x, value) (x = ((x) > (value) ? -(value) : (x)))
#define MY_UNDERFLOW(x, value) (x = ((x) < (value) ? -(value) : (x)))