aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-06-25 12:22:17 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-06-25 12:22:17 +0200
commit617906db0db8888f5e3889cfc0c474f56a8fb0de (patch)
tree0c041ddb183891de0157f141040abcb28d115c34
parent591bede0899d3dd11f019af07251c32c3dada24b (diff)
Move MIN() and MAX() to common.h
-rw-r--r--src/analyzer.c1
-rw-r--r--src/arena.c1
-rw-r--r--src/common.h11
-rw-r--r--src/lexer-sse4_1.c2
-rw-r--r--src/scratch.c2
5 files changed, 11 insertions, 6 deletions
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 <sys/param.h> 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)
{