diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 04:56:03 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 04:56:03 +0000 |
commit | 0c293cb4bc9a97db3975f3aacd6b537ea50173ae (patch) | |
tree | ebe9c872e416346e4b333e5062da32401c8e0a73 /src/nolibc.c | |
parent | d53db6851ea17b2d219d084e1afc683b8b62b105 (diff) | |
parent | 1d27ff1934c5c4292dc00fba7f7f8ae411ed42f5 (diff) | |
download | liburing-android14-mainline-mediaprovider-release.tar.gz |
Snap for 10453563 from 1d27ff1934c5c4292dc00fba7f7f8ae411ed42f5 to mainline-mediaprovider-releaseaml_mpr_341713020aml_mpr_341614010aml_mpr_341511070aml_mpr_341411070aml_mpr_341313030aml_mpr_341111030aml_mpr_341111020aml_mpr_341015090aml_mpr_341015030aml_mpr_340919000android14-mainline-mediaprovider-release
Change-Id: Idb2d52ac5dc603b1ddc5f365b8a6de9bb348fc3b
Diffstat (limited to 'src/nolibc.c')
-rw-r--r-- | src/nolibc.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/nolibc.c b/src/nolibc.c new file mode 100644 index 0000000..9a04ead --- /dev/null +++ b/src/nolibc.c @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: MIT */ + +#ifndef CONFIG_NOLIBC +#error "This file should only be compiled for no libc build" +#endif + +#include "lib.h" +#include "syscall.h" + +void *memset(void *s, int c, size_t n) +{ + size_t i; + unsigned char *p = s; + + for (i = 0; i < n; i++) + p[i] = (unsigned char) c; + + return s; +} + +struct uring_heap { + size_t len; + char user_p[] __attribute__((__aligned__)); +}; + +void *__uring_malloc(size_t len) +{ + struct uring_heap *heap; + + heap = __sys_mmap(NULL, sizeof(*heap) + len, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (IS_ERR(heap)) + return NULL; + + heap->len = sizeof(*heap) + len; + return heap->user_p; +} + +void __uring_free(void *p) +{ + struct uring_heap *heap; + + if (uring_unlikely(!p)) + return; + + heap = container_of(p, struct uring_heap, user_p); + __sys_munmap(heap, heap->len); +} |