summaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorIan McFarlane <i.mcfarlane2002@gmail.com>2025-04-24 15:50:50 -0400
committerIan McFarlane <i.mcfarlane2002@gmail.com>2025-04-24 15:51:29 -0400
commit3c213ce446c6547c79f683f035b191e92b4e914e (patch)
treed05d172ba28e5e6eb0e607b51e1db92d30003508 /kernel/include
parentfix paging free fns (diff)
downloadcomus-3c213ce446c6547c79f683f035b191e92b4e914e.tar.gz
comus-3c213ce446c6547c79f683f035b191e92b4e914e.tar.bz2
comus-3c213ce446c6547c79f683f035b191e92b4e914e.zip
make alloc_pages_at() able to allocate noncontiguous physical pages
Diffstat (limited to 'kernel/include')
-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