From bd5969fc876a10b18613302db7087ef3c40f18e1 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:00 -0500 Subject: lib: Add mlibc Signed-off-by: Ian Moffett --- lib/mlibc/sysdeps/managarm/generic/memory.cpp | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/mlibc/sysdeps/managarm/generic/memory.cpp (limited to 'lib/mlibc/sysdeps/managarm/generic/memory.cpp') diff --git a/lib/mlibc/sysdeps/managarm/generic/memory.cpp b/lib/mlibc/sysdeps/managarm/generic/memory.cpp new file mode 100644 index 0000000..91e47af --- /dev/null +++ b/lib/mlibc/sysdeps/managarm/generic/memory.cpp @@ -0,0 +1,30 @@ + +#include + +#include +#include +#include +#include + +#include +#include + +namespace mlibc { + +int sys_anon_allocate(size_t size, void **pointer) { + // This implementation is inherently signal-safe. + __ensure(!(size & 0xFFF)); + HelWord out; + HEL_CHECK(helSyscall1_1(kHelCallSuper + posix::superAnonAllocate, size, &out)); + *pointer = reinterpret_cast(out); + return 0; +} + +int sys_anon_free(void *pointer, size_t size) { + // This implementation is inherently signal-safe. + HEL_CHECK(helSyscall2(kHelCallSuper + posix::superAnonDeallocate, (HelWord)pointer, size)); + return 0; +} + +} //namespace mlibc + -- cgit v1.2.3