summaryrefslogtreecommitdiff
path: root/lib/zebra.h
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2016-09-21 18:20:49 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-09-23 12:12:17 -0400
commit6b143a68d3a44be42f2370b9d91409eceb14cebd (patch)
tree312fc83c79fec8f86ddfd909aedc09678eda49f9 /lib/zebra.h
parent518acd6fd802dbb5ab30db7d12b9995f582b824f (diff)
lib: force local MIN/MAX macros
Linux/glibc sys/param.h has definitions of MIN/MAX that result in multiple evaluations of its parameters. Force local definitions. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/zebra.h')
-rw-r--r--lib/zebra.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/zebra.h b/lib/zebra.h
index da069d1dfa..8763abd766 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -352,18 +352,21 @@ struct in_pktinfo
#endif /* ndef BYTE_ORDER */
/* MAX / MIN are not commonly defined, but useful */
-#ifndef MAX
+/* note: glibc sys/param.h has #define MIN(a,b) (((a)<(b))?(a):(b)) */
+#ifdef MAX
+#undef MAX
+#endif
#define MAX(a, b) \
({ typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; })
+#ifdef MIN
+#undef MIN
#endif
-#ifndef MIN
#define MIN(a, b) \
({ typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a < _b ? _a : _b; })
-#endif
#define ZEBRA_NUM_OF(x) (sizeof (x) / sizeof (x[0]))