tools/nolibc: clean up mmap() routine
authorZhangjin Wu <falcon@tinylab.org>
Fri, 7 Jul 2023 14:58:20 +0000 (22:58 +0800)
committerWilly Tarreau <w@1wt.eu>
Wed, 23 Aug 2023 02:38:02 +0000 (04:38 +0200)
commit924e9539aeaa89e93268b4a39bac356e4355ab78
tree99bca15e7464dc90320d08cb1cb30655ab2e4cf2
parent6591be4a73feb955a107c70c7e5b621a97a2eb4b
tools/nolibc: clean up mmap() routine

Do several cleanups together:

- Since all supported architectures have my_syscall6() now, remove the
  #ifdef check.

- Move the mmap() related macros to tools/include/nolibc/types.h and
  reuse most of them from <linux/mman.h>

- Apply the new generic __sysret() to convert the calling of sys_map()
  to oneline code

Note, since MAP_FAILED is -1 on Linux, so we can use the generic
__sysret() which returns -1 upon error and still satisfy user land that
checks for MAP_FAILED.

Suggested-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/lkml/20230702192347.GJ16233@1wt.eu/
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
tools/include/nolibc/sys.h
tools/include/nolibc/types.h