summaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2023-08-15 14:44:55 +0300
committerWilly Tarreau <w@1wt.eu>2023-08-23 06:19:22 +0300
commitfb01ff635efd0aba862c843587554167aacc4d2f (patch)
tree6e8923ae374631c40e0fc22c186394304e68b08c /tools/include
parent872dbfa0321796dace602cb7d368f0ec20af8f16 (diff)
downloadlinux-fb01ff635efd0aba862c843587554167aacc4d2f.tar.xz
tools/nolibc: keep brk(), sbrk(), mmap() away from __sysret()
The __sysret() function causes some undesirable casts so we'll revert it. In order to keep it simple it will now only support integer return values like in the past, so we must basically revert the changes that were made to these 3 syscalls which return a pointer so that they simply rely on their own test and the SET_ERRNO() macro. Fixes: 4201cfce15fe ("tools/nolibc: clean up sbrk() routine") Fixes: 924e9539aeaa ("tools/nolibc: clean up mmap() routine") Fixes: d27447bc2e0a ("tools/nolibc: sys.h: apply __sysret() helper") Link: https://lore.kernel.org/lkml/20230806095846.GB10627@1wt.eu/ Link: https://lore.kernel.org/lkml/ZNKOJY+g66nkIyvv@1wt.eu/ Cc: Zhangjin Wu <falcon@tinylab.org> Cc: David Laight <David.Laight@ACULAB.COM> Cc: Thomas Weißschuh <thomas@t-8ch.de> Signed-off-by: Willy Tarreau <w@1wt.eu>
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/nolibc/sys.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 833d6c5e86dc..bfe1647a3a30 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -82,7 +82,13 @@ void *sys_brk(void *addr)
static __attribute__((unused))
int brk(void *addr)
{
- return __sysret(sys_brk(addr) ? 0 : -ENOMEM);
+ void *ret = sys_brk(addr);
+
+ if (!ret) {
+ SET_ERRNO(ENOMEM);
+ return -1;
+ }
+ return 0;
}
static __attribute__((unused))
@@ -94,7 +100,8 @@ void *sbrk(intptr_t inc)
if (ret && sys_brk(ret + inc) == ret + inc)
return ret + inc;
- return (void *)__sysret(-ENOMEM);
+ SET_ERRNO(ENOMEM);
+ return (void *)-1;
}
@@ -682,7 +689,13 @@ void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
static __attribute__((unused))
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
- return (void *)__sysret((unsigned long)sys_mmap(addr, length, prot, flags, fd, offset));
+ void *ret = sys_mmap(addr, length, prot, flags, fd, offset);
+
+ if ((unsigned long)ret >= -4095UL) {
+ SET_ERRNO(-(long)ret);
+ ret = MAP_FAILED;
+ }
+ return ret;
}
static __attribute__((unused))