:: commit 3e9f2e030d2926658cc1217d956f9e858124a068

Mintsuki <mintsuki@protonmail.com> — 2025-03-25 20:39

parents: fe64bba637

lib: Add MIN and MAX macros

diff --git a/common/lib/misc.h b/common/lib/misc.h
index fb6a1044..5ebb124a 100644
--- a/common/lib/misc.h
+++ b/common/lib/misc.h
@@ -60,6 +60,18 @@ int pit_sleep_and_quit_on_keypress(int seconds);
 
 uint64_t strtoui(const char *s, const char **end, int base);
 
+#define MIN(a, b) ({ \
+    __auto_type MIN_a = (a); \
+    __auto_type MIN_b = (b); \
+    MIN_a > MIN_b ? MIN_b : MIN_a; \
+})
+
+#define MAX(a, b) ({ \
+    __auto_type MAX_a = (a); \
+    __auto_type MAX_b = (b); \
+    MAX_a > MAX_b ? MAX_a : MAX_b; \
+})
+
 #define DIV_ROUNDUP(a, b) ({ \
     __auto_type DIV_ROUNDUP_a = (a); \
     __auto_type DIV_ROUNDUP_b = (b); \
tab: 248 wrap: offon