From e43852ffc738b27cbb84d0aea85b677bd5d98f82 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 28 Mar 2024 01:36:33 -0400 Subject: kernel: vm_dynalloc: Add dynalloc_memalign() Signed-off-by: Ian Moffett --- sys/include/vm/dynalloc.h | 1 + sys/vm/vm_dynalloc.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) (limited to 'sys') diff --git a/sys/include/vm/dynalloc.h b/sys/include/vm/dynalloc.h index 1a30d3d..44d2f5a 100644 --- a/sys/include/vm/dynalloc.h +++ b/sys/include/vm/dynalloc.h @@ -37,6 +37,7 @@ #include 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..dea4460 100644 --- a/sys/vm/vm_dynalloc.c +++ b/sys/vm/vm_dynalloc.c @@ -47,6 +47,18 @@ dynalloc(size_t sz) return tmp; } +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