summaryrefslogtreecommitdiffstats
path: root/lib/libjove/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libjove/memory.c')
-rw-r--r--lib/libjove/memory.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/libjove/memory.c b/lib/libjove/memory.c
new file mode 100644
index 0000000..db76528
--- /dev/null
+++ b/lib/libjove/memory.c
@@ -0,0 +1,23 @@
+#include <jove/memory.h>
+
+JoveError
+jove_mem_ensure_w(uintptr_t start, size_t pages)
+{
+ start &= ~0xFFFULL;
+ for(size_t i = 0; i < pages; i++) {
+ uintptr_t at = start + (i << 12);
+ JoveError e = jove_mem_ensure(at);
+ if(e) return e;
+ }
+ return EJOVE_OK;
+}
+
+JoveError
+jove_mem_ensure_range(uintptr_t start, uintptr_t end)
+{
+ start &= ~0xFFFULL;
+ if(end & 0xFFF)
+ end += 0x1000 - (end & 0xFFF);
+
+ return jove_mem_ensure_w(start, (end - start) >> 12);
+}