From 40dd29b87606375794cf173c9171d8b5b19fe843 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 16 May 2026 16:58:49 +0300 Subject: [PATCH] LibC: Cleanup syscall macros --- userspace/libraries/LibC/include/unistd.h | 9 +++++---- userspace/libraries/LibC/unistd.cpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/userspace/libraries/LibC/include/unistd.h b/userspace/libraries/LibC/include/unistd.h index 2acc98f7..1c3e6e4e 100644 --- a/userspace/libraries/LibC/include/unistd.h +++ b/userspace/libraries/LibC/include/unistd.h @@ -612,16 +612,17 @@ long syscall(long syscall, ...); #include #include #define _syscall(...) ({ \ - long _ret = -ERESTART; \ - while (_ret == -ERESTART) \ + long _ret; \ + do { \ _ret = _kas_syscall(__VA_ARGS__); \ - if (_ret < 0) { \ + } while (__builtin_expect(_ret == -ERESTART, 0)); \ + if (__builtin_expect(_ret < 0, 0)) { \ errno = -_ret; \ _ret = -1; \ } \ _ret; \ }) -#define syscall _syscall +#define syscall(...) _syscall(__VA_ARGS__) #endif extern char** environ; diff --git a/userspace/libraries/LibC/unistd.cpp b/userspace/libraries/LibC/unistd.cpp index c7700919..1a62e7db 100644 --- a/userspace/libraries/LibC/unistd.cpp +++ b/userspace/libraries/LibC/unistd.cpp @@ -270,7 +270,7 @@ long syscall(long syscall, ...) return _syscall(syscall, arg1, arg2, arg3, arg4, arg5); } -#define syscall _syscall +#define syscall(...) _syscall(__VA_ARGS__) int close(int fd) {