[PATCH 2/4] tools/nolibc: unistd.h: apply __syscall_ret() helper
Zhangjin Wu
falcon at tinylab.org
Sat Jun 3 22:36:20 PDT 2023
get the return type automatically and use __syscall_ret() to shrink 4
code lines.
Signed-off-by: Zhangjin Wu <falcon at tinylab.org>
---
tools/include/nolibc/unistd.h | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h
index 6773e83c16a0..e4e2b4c09771 100644
--- a/tools/include/nolibc/unistd.h
+++ b/tools/include/nolibc/unistd.h
@@ -56,14 +56,10 @@ int tcsetpgrp(int fd, pid_t pid)
return ioctl(fd, TIOCSPGRP, &pid);
}
-#define _syscall(N, ...) \
-({ \
- int _ret = my_syscall##N(__VA_ARGS__); \
- if (_ret < 0) { \
- SET_ERRNO(-_ret); \
- _ret = -1; \
- } \
- _ret; \
+#define _syscall(N, ...) \
+({ \
+ typeof(my_syscall##N(__VA_ARGS__)) _ret = my_syscall##N(__VA_ARGS__); \
+ __syscall_ret(_ret); \
})
#define _sycall_narg(...) __syscall_narg(__VA_ARGS__, 6, 5, 4, 3, 2, 1, 0)
--
2.25.1
More information about the linux-riscv
mailing list