From 617906db0db8888f5e3889cfc0c474f56a8fb0de Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 25 Jun 2024 12:22:17 +0200 Subject: Move MIN() and MAX() to common.h --- src/analyzer.c | 1 - src/arena.c | 1 - src/common.h | 11 +++++++++++ src/lexer-sse4_1.c | 2 -- src/scratch.c | 2 -- 5 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/analyzer.c b/src/analyzer.c index 4b2034b..5f4262a 100644 --- a/src/analyzer.c +++ b/src/analyzer.c @@ -21,7 +21,6 @@ #define LOG2_10 (3.321928) #define MP_BITCNT_MAX ((mp_bitcnt_t)-1) -#define MIN(x, y) ((x) < (y) ? (x) : (y)) /* In debug builds we want to actually alloc a new mpq_t so that it’s easier to free memory without doing a double free */ diff --git a/src/arena.c b/src/arena.c index 23d374e..f88b8cb 100644 --- a/src/arena.c +++ b/src/arena.c @@ -16,7 +16,6 @@ # error "System not supported (missing MAP_ANON)" #endif -#define MAX(x, y) ((x) > (y) ? (x) : (y)) #define IS_POW_2(n) ((n) != 0 && ((n) & ((n)-1)) == 0) struct _arena { diff --git a/src/common.h b/src/common.h index 7030e4b..2dffe2a 100644 --- a/src/common.h +++ b/src/common.h @@ -19,4 +19,15 @@ #define MPQ_IS_INIT(x) (mpq_denref(x)->_mp_d != NULL) +/* Some headers like may define these */ +#ifdef MIN +# undef MIN +#endif +#ifdef MAX +# undef MAX +#endif + +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#define MAX(x, y) ((x) > (y) ? (x) : (y)) + #endif /* !ORYX_COMMON_H */ diff --git a/src/lexer-sse4_1.c b/src/lexer-sse4_1.c index 16df370..888ead0 100644 --- a/src/lexer-sse4_1.c +++ b/src/lexer-sse4_1.c @@ -5,8 +5,6 @@ #include "common.h" #include "types.h" -#define MIN(x, y) ((x) < (y) ? (x) : (y)) - bool skpcmnt(const uchar **ptr, const uchar *end) { diff --git a/src/scratch.c b/src/scratch.c index ae48ff6..df3707f 100644 --- a/src/scratch.c +++ b/src/scratch.c @@ -18,8 +18,6 @@ # define TMP_DFLT_BUFSZ (1 * 1024) #endif -#define MAX(x, y) ((x) > (y) ? (x) : (y)) - void * tmpalloc(scratch_t *s, size_t nmemb, size_t size) { -- cgit v1.2.3