From e4c6ae42b3cf769db9525a3fa4d0cfb2db864bbf Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 10 Jul 2024 17:19:32 -0400 Subject: kernel: vm: Add dynalloc_memalign() Signed-off-by: Ian Moffett --- sys/vm/vm_dynalloc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'sys/vm') 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 @@ -47,6 +47,24 @@ dynalloc(size_t sz) return tmp; } +/* + * 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()' * -- cgit v1.2.3