Message ID | c23a5b2ad7c756c05d8a19af6033462ddbd948a6.1687957589.git.falcon@tinylab.org |
---|---|
State | Accepted |
Commit | 428905da6ec4a02d08dfcc09013035594f666a31 |
Headers | show |
Series | [v5,01/14] tools/nolibc: sys.h: add a syscall return helper | expand |
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 5464f93e863e..097eef88cf7e 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -28,6 +28,16 @@ #include "errno.h" #include "types.h" +/* Syscall return helper, set errno as -ret when ret < 0 */ +static __inline__ __attribute__((unused, always_inline)) +long __sysret(long ret) +{ + if (ret < 0) { + SET_ERRNO(-ret); + ret = -1; + } + return ret; +} /* Functions in this file only describe syscalls. They're declared static so * that the compiler usually decides to inline them while still being allowed