aboutsummaryrefslogtreecommitdiff
path: root/sys/vm
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-07-10 17:19:32 -0400
committerIan Moffett <ian@osmora.org>2024-07-10 17:19:32 -0400
commite4c6ae42b3cf769db9525a3fa4d0cfb2db864bbf (patch)
treec661037aeb6a481583a373cf12d80e32acd32e37 /sys/vm
parent7a915a81d23263df634a6ae626e0bc2f6f4b38b5 (diff)
kernel: vm: Add dynalloc_memalign()
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_dynalloc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/vm/vm_dynalloc.c b/sys/vm/vm_dynalloc.c
index 0b8d668..6b64cfd 100644
--- a/sys/vm/vm_dynalloc.c
+++ b/sys/vm/vm_dynalloc.c
@@ -48,6 +48,24 @@ dynalloc(size_t sz)
}
/*
+ * Dynamically allocate aligned memory
+ *
+ * @sz: The amount of bytes to allocate.
+ * @align: Alignment.
+ */
+void *
+dynalloc_memalign(size_t sz, size_t align)
+{
+ struct vm_ctx *vm_ctx = vm_get_ctx();
+ void *tmp;
+
+ spinlock_acquire(&vm_ctx->dynalloc_lock);
+ tmp = tlsf_memalign(vm_ctx->tlsf_ctx, align, sz);
+ spinlock_release(&vm_ctx->dynalloc_lock);
+ return tmp;
+}
+
+/*
* Reallocates memory pool created by `dynalloc()'
*
* @old_ptr: Pointer to old pool.