aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/include/vm/dynalloc.h2
-rw-r--r--sys/vm/vm_dynalloc.c18
2 files changed, 20 insertions, 0 deletions
diff --git a/sys/include/vm/dynalloc.h b/sys/include/vm/dynalloc.h
index 11d8f31..071ee3a 100644
--- a/sys/include/vm/dynalloc.h
+++ b/sys/include/vm/dynalloc.h
@@ -33,6 +33,8 @@
#include <sys/types.h>
void *dynalloc(size_t sz);
+void *dynalloc_memalign(size_t sz, size_t align);
+
void *dynrealloc(void *old_ptr, size_t newsize);
void dynfree(void *ptr);
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.