summaryrefslogtreecommitdiff
path: root/kernel/include/lib
diff options
context:
space:
mode:
authorGalen Sagarin <gps5307@rit.edu>2025-04-29 14:18:40 -0400
committerGalen Sagarin <gps5307@rit.edu>2025-04-29 14:18:40 -0400
commitae2cdd83ba4a0cae161db0b29031d5591005fa34 (patch)
tree82fbdfcbb1fe4e3b5e232db195c8c331d69489fd /kernel/include/lib
parentStarted writing fat.c (diff)
parentfs header changes (diff)
downloadcomus-ae2cdd83ba4a0cae161db0b29031d5591005fa34.tar.gz
comus-ae2cdd83ba4a0cae161db0b29031d5591005fa34.tar.bz2
comus-ae2cdd83ba4a0cae161db0b29031d5591005fa34.zip
Merge branch 'main' of https://github.com/kenshineto/kern into fat32
Merging main into here
Diffstat (limited to '')
-rw-r--r--kernel/include/lib.h1
-rw-r--r--kernel/include/lib/kmath.h20
2 files changed, 21 insertions, 0 deletions
diff --git a/kernel/include/lib.h b/kernel/include/lib.h
index be4e739..edfbeb4 100644
--- a/kernel/include/lib.h
+++ b/kernel/include/lib.h
@@ -15,6 +15,7 @@
#include <lib/kctype.h>
#include <lib/kio.h>
#include <lib/klib.h>
+#include <lib/kmath.h>
#include <lib/kstring.h>
#endif /* lib.h */
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