summaryrefslogtreecommitdiff
path: root/kernel/include/lib/kmath.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/include/lib/kmath.h')
-rw-r--r--kernel/include/lib/kmath.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/kernel/include/lib/kmath.h b/kernel/include/lib/kmath.h
new file mode 100644
index 0000000..3be953d
--- /dev/null
+++ b/kernel/include/lib/kmath.h
@@ -0,0 +1,20 @@
+/**
+ * @file kmath.h
+ *
+ * @author Ian McFarlane <i.mcfarlane2002@gmail.com>
+ *
+ * Kernel math functions
+ */
+
+#ifndef _KMATH_H
+#define _KMATH_H
+
+#include <stddef.h>
+
+// min and max both prefer a over b
+#define MAX(a, b) ((a) >= (b) ? (a) : (b))
+#define MIN(a, b) ((a) <= (b) ? (a) : (b))
+
+#define CLAMP(val, min, max) (MAX((min), MIN((val), (max))))
+
+#endif