diff options
| author | Thomas Weißschuh <thomas.weissschuh@linutronix.de> | 2025-04-28 14:40:05 +0200 |
|---|---|---|
| committer | Thomas Weißschuh <linux@weissschuh.net> | 2025-05-21 15:32:03 +0200 |
| commit | 55175d8659d22bfde30d4a1277328f090d8c0c2f (patch) | |
| tree | 3d8e726b1d41541d0e26b077d4cbc03931b12839 /tools/include | |
| parent | 2337d39f7233fc3fb9d90489f0d48904eb129a2e (diff) | |
tools/nolibc: add mremap()
This is used in various selftests and will be handy when integrating
those with nolibc.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-4-3c043eeab06c@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Diffstat (limited to 'tools/include')
| -rw-r--r-- | tools/include/nolibc/sys/mman.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/include/nolibc/sys/mman.h b/tools/include/nolibc/sys/mman.h index 41c7bf45e427..5228751b458c 100644 --- a/tools/include/nolibc/sys/mman.h +++ b/tools/include/nolibc/sys/mman.h @@ -49,6 +49,25 @@ void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) } static __attribute__((unused)) +void *sys_mremap(void *old_address, size_t old_size, size_t new_size, int flags, void *new_address) +{ + return (void *)my_syscall5(__NR_mremap, old_address, old_size, + new_size, flags, new_address); +} + +static __attribute__((unused)) +void *mremap(void *old_address, size_t old_size, size_t new_size, int flags, void *new_address) +{ + void *ret = sys_mremap(old_address, old_size, new_size, flags, new_address); + + if ((unsigned long)ret >= -4095UL) { + SET_ERRNO(-(long)ret); + ret = MAP_FAILED; + } + return ret; +} + +static __attribute__((unused)) int sys_munmap(void *addr, size_t length) { return my_syscall2(__NR_munmap, addr, length); |
