donstranding

Don Stranding
git clone git://git.kocotian.pl/donstranding.git
Log | Files | Refs | Submodules | README | LICENSE

commit a9ebbc4b16d2444a1dfd08103eb01033fb6d77ae
parent c7da8b1e4ef595748b0e57b2ffd4705a6e9e3d42
Author: kocotian <kocotian@kocotian.pl>
Date:   Sun,  2 May 2021 21:51:12 +0200

conversion

Diffstat:
Minclude/util.h | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/util.h b/include/util.h @@ -3,9 +3,15 @@ #ifndef _UTIL_H #define _UTIL_H -#define MAX(A, B) ((A) > (B) ? (A) : (B)) -#define MIN(A, B) ((A) < (B) ? (A) : (B)) -#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B)) +#define LEN(X) (sizeof (X) / sizeof *(X)) + +#define MAX(A, B) ((signed)(A) > (signed)(B) ? (signed)(A) : (signed)(B)) +#define MIN(A, B) ((signed)(A) < (signed)(B) ? (signed)(A) : (signed)(B)) +#define BETWEEN(X, A, B) ((signed)(A) <= (signed)(X) && (signed)(X) <= (signed)(B)) + +#define UMAX(A, B) ((unsigned)(A) > (unsigned)(B) ? (unsigned)(A) : (unsigned)(B)) +#define UMIN(A, B) ((unsigned)(A) < (unsigned)(B) ? (unsigned)(A) : (unsigned)(B)) +#define UBETWEEN(X, A, B) ((unsigned)(A) <= (unsigned)(X) && (unsigned)(X) <= (unsigned)(B)) void *ecalloc(size_t nmemb, size_t size); void die(const char *fmt, ...);