From 3c213ce446c6547c79f683f035b191e92b4e914e Mon Sep 17 00:00:00 2001 From: Ian McFarlane Date: Thu, 24 Apr 2025 15:50:50 -0400 Subject: make alloc_pages_at() able to allocate noncontiguous physical pages --- kernel/include/lib/kmath.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 kernel/include/lib/kmath.h (limited to 'kernel/include/lib/kmath.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 + * + * Kernel math functions + */ + +#ifndef _KMATH_H +#define _KMATH_H + +#include + +// 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 -- cgit v1.2.3-freya