[tor-commits] [tor/master] Move MIN and MAX into lib/intmath/cmp.h

nickm at torproject.org nickm at torproject.org
Thu Jun 28 19:21:00 UTC 2018


commit 3d1e99d01bc0142397cd0dd8be41d001f0f66131
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Jun 28 13:19:42 2018 -0400

    Move MIN and MAX into lib/intmath/cmp.h
---
 src/common/compat.h   | 14 +-------------
 src/lib/intmath/cmp.h | 13 +++++++++++++
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/common/compat.h b/src/common/compat.h
index 43e98d906..ec4df1cc5 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -60,6 +60,7 @@
 #include "lib/fs/mmap.h"
 #include "lib/fs/userdb.h"
 #include "lib/wallclock/timeval.h"
+#include "lib/intmath/cmp.h"
 
 #include <stdio.h>
 #include <errno.h>
@@ -92,19 +93,6 @@ typedef unsigned long rlim_t;
 int set_max_file_descriptors(rlim_t limit, int *max);
 MOCK_DECL(int, get_total_system_memory, (size_t *mem_out));
 
-/** Macros for MIN/MAX.  Never use these when the arguments could have
- * side-effects.
- * {With GCC extensions we could probably define a safer MIN/MAX.  But
- * depending on that safety would be dangerous, since not every platform
- * has it.}
- **/
-#ifndef MAX
-#define MAX(a,b) ( ((a)<(b)) ? (b) : (a) )
-#endif
-#ifndef MIN
-#define MIN(a,b) ( ((a)>(b)) ? (b) : (a) )
-#endif
-
 ssize_t tor_getpass(const char *prompt, char *output, size_t buflen);
 
 /* This needs some of the declarations above so we include it here. */
diff --git a/src/lib/intmath/cmp.h b/src/lib/intmath/cmp.h
index 90ea3ca07..627e5d18b 100644
--- a/src/lib/intmath/cmp.h
+++ b/src/lib/intmath/cmp.h
@@ -6,6 +6,19 @@
 #ifndef TOR_INTMATH_CMP_H
 #define TOR_INTMATH_CMP_H
 
+/** Macros for MIN/MAX.  Never use these when the arguments could have
+ * side-effects.
+ * {With GCC extensions we could probably define a safer MIN/MAX.  But
+ * depending on that safety would be dangerous, since not every platform
+ * has it.}
+ **/
+#ifndef MAX
+#define MAX(a,b) ( ((a)<(b)) ? (b) : (a) )
+#endif
+#ifndef MIN
+#define MIN(a,b) ( ((a)>(b)) ? (b) : (a) )
+#endif
+
 /* Return <b>v</b> if it's between <b>min</b> and <b>max</b>.  Otherwise
  * return <b>min</b> if <b>v</b> is smaller than <b>min</b>, or <b>max</b> if
  * <b>b</b> is larger than <b>max</b>.





More information about the tor-commits mailing list