summaryrefslogtreecommitdiff
path: root/handy.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2016-09-21 16:15:08 -0600
committerKarl Williamson <khw@cpan.org>2016-09-25 22:24:20 -0600
commit98fce2a4417fa36585bb48f6ae845bee93cac0fa (patch)
tree1edae7daef33c90d1efe55b587e523e8858bc7c7 /handy.h
parent8bc127bf58304a1e46a3e33d30b0b8b6f21abb07 (diff)
downloadperl-98fce2a4417fa36585bb48f6ae845bee93cac0fa.tar.gz
Centralize definitions of MIN, MAX
Instead of having each file have them, keep them in handy.h, but only for core compilations.
Diffstat (limited to 'handy.h')
-rw-r--r--handy.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/handy.h b/handy.h
index 5428d7c38d..11009d3b89 100644
--- a/handy.h
+++ b/handy.h
@@ -277,6 +277,15 @@ typedef U64TYPE U64;
/* Unused by core; should be deprecated */
#define Ctl(ch) ((ch) & 037)
+#if defined(PERL_CORE) || defined(PERL_EXT)
+# ifndef MIN
+# define MIN(a,b) ((a) < (b) ? (a) : (b))
+# endif
+# ifndef MAX
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
+# endif
+#endif
+
/* This is a helper macro to avoid preprocessor issues, replaced by nothing
* unless under DEBUGGING, where it expands to an assert of its argument,
* followed by a comma (hence the comma operator). If we just used a straight