It check the resulting value from INTERNAL_SYSCALL_CALL and sets the
errno accordingly.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
sysdeps/unix/sysv/linux/fstatat.c | 2 +-
sysdeps/unix/sysv/linux/fstatat64.c | 2 +-
sysdeps/unix/sysv/linux/mq_unlink.c | 11 +++--------
sysdeps/unix/sysv/linux/sysdep-vdso.h | 26 +++++--------------------
sysdeps/unix/sysv/linux/sysdep.h | 28 +++++++++++++--------------
5 files changed, 23 insertions(+), 46 deletions(-)
@@ -80,7 +80,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag)
# endif /* __nr_fstatat64 */
# endif /* STAT_IS_KERNEL_STAT */
- return r == 0 ? 0 : INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ return syscall_ret (r);
}
weak_alias (__fstatat, fstatat)
@@ -102,7 +102,7 @@ __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf,
# endif
#endif
- return r == 0 ? 0 : INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ return syscall_ret (r);
}
#if __TIMESIZE != 64
hidden_def (__fstatat64_time64)
@@ -30,12 +30,7 @@ mq_unlink (const char *name)
/* While unlink can return either EPERM or EACCES, mq_unlink should
return just EACCES. */
- if (ret < 0)
- {
- if (ret == -EPERM)
- ret = -EACCES;
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (-ret);
- }
-
- return ret;
+ if (ret == -EPERM)
+ ret = -EACCES;
+ return syscall_ret (ret);
}
@@ -28,29 +28,13 @@
#define INLINE_VSYSCALL(name, nr, args...) \
({ \
- __label__ out; \
- __label__ iserr; \
- long int sc_ret; \
- \
+ long int sc_ret = -ENOSYS; \
__typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name); \
if (vdsop != NULL) \
- { \
- sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \
- if (sc_ret == 0) \
- goto out; \
- if (sc_ret != -ENOSYS) \
- goto iserr; \
- } \
- \
- sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \
- if (sc_ret < 0) \
- { \
- iserr: \
- __set_errno (-sc_ret); \
- sc_ret = -1L; \
- } \
- out: \
- sc_ret; \
+ sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, nr, ##args); \
+ if (sc_ret == -ENOSYS) \
+ sc_ret = INTERNAL_SYSCALL_CALL (name, ##args); \
+ syscall_ret (sc_ret); \
})
#endif /* SYSDEP_VDSO_LINUX_H */
@@ -23,26 +23,24 @@
#include <endian.h>
#include <errno.h>
-#ifndef SYSCALL_ERROR_LABEL
-# define SYSCALL_ERROR_LABEL(sc_err) \
- ({ \
- __set_errno (sc_err); \
- -1L; \
- })
-#endif
-
#ifndef __ASSEMBLER__
+static inline long int
+syscall_ret (unsigned long int val)
+{
+ if (val > -4096UL)
+ {
+ __set_errno (-val);
+ return -1;
+ }
+ return val;
+}
+
/* Define a macro which expands into the inline wrapper code for a system
call. It sets the errno and returns -1 on a failure, or the syscall
return value otherwise. */
#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) \
- ({ \
- long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
- __glibc_unlikely (sc_ret > -4096UL) \
- ? SYSCALL_ERROR_LABEL (-sc_ret) \
- : sc_ret; \
- })
+#define INLINE_SYSCALL(...) \
+ syscall_ret (INTERNAL_SYSCALL (__VA_ARGS__))
#endif
/* Set error number and return -1. A target may choose to return the