]> git.lizzy.rs Git - nothing.git/blobdiff - src/math/extrema.h
Wire up pp to level loop
[nothing.git] / src / math / extrema.h
index f618987927afc8b6ed6c0b75055b251b07858469..d06229422d86b681efa4f8e5a301a5113eff0db8 100644 (file)
@@ -3,19 +3,24 @@
 
 #include <stdint.h>
 
-// WARNING! Any attempts to "generalize" or "improve" this translation
-// unit will result in an instantly closed Pull Request without any
-// further discussion.
-static inline
-int64_t max_int64(int64_t a, int64_t b)
-{
-    return a > b ? a : b;
-}
+#define MAX_INSTANCE(type)                      \
+    static inline                               \
+    type max_##type(type a, type b) {           \
+        return a > b ? a : b;                   \
+    }                                           \
 
-static inline
-size_t max_size_t(size_t a, size_t b)
-{
-    return a > b ? a : b;
-}
+MAX_INSTANCE(int64_t)
+MAX_INSTANCE(size_t)
+#define MAX(type, a, b) max_##type(a, b)
+
+#define MIN_INSTANCE(type)                      \
+    static inline                               \
+    type min_##type(type a, type b) {           \
+        return a < b ? a : b;                   \
+    }                                           \
+
+MIN_INSTANCE(int64_t)
+MIN_INSTANCE(size_t)
+#define MIN(type, a, b) min_##type(a, b)
 
 #endif  // EXTREMA_H_