@@ -73,3 +73,23 @@
#ifndef INLINE_SYSCALL
#define INLINE_SYSCALL(name, nr, args...) __syscall_##name (args)
#endif
+
+/* Define a macro which expands inline into the wrapper code for a system
+ call and return. */
+#ifndef INLINE_SYSCALL_RETURN
+#define INLINE_SYSCALL_RETURN(name, nr, type, args...) \
+ { \
+ return (type) INLINE_SYSCALL (name, nr, args); \
+ }
+#endif
+
+/* Define a macro to return for a system call error. ERR is the
+ negative error number returned from the majority of Linux kernels
+ for which -ERR is no-op with INTERNAL_SYSCALL_ERRNO. */
+#ifndef INLINE_SYSCALL_ERROR_RETURN
+#define INLINE_SYSCALL_ERROR_RETURN(err, type, value) \
+ { \
+ __set_errno (-err); \
+ return (type) (value); \
+ }
+#endif
@@ -47,7 +47,7 @@ __aio_sigqueue (sig, val, caller_pid)
info.si_uid = getuid ();
info.si_value = val;
- return INLINE_SYSCALL (rt_sigqueueinfo, 3, info.si_pid, sig, &info);
+ INLINE_SYSCALL_RETURN (rt_sigqueueinfo, 3, int, info.si_pid, sig, &info);
}
#else
# include <rt/aio_sigqueue.c>
@@ -31,9 +31,8 @@ openat64 (dfd, file, oflag)
assert (!__OPEN_NEEDS_MODE (oflag));
#ifdef __NR_openat
- return INLINE_SYSCALL (openat, 3, dfd, file, oflag | O_LARGEFILE);
+ INLINE_SYSCALL_RETURN (openat, 3, int, dfd, file, oflag | O_LARGEFILE)
#else
- __set_errno (ENOSYS);
- return -1;
+ INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1)
#endif
}
@@ -25,11 +25,12 @@ int
eventfd (unsigned int count, int flags)
{
#ifdef __NR_eventfd2
- int res = INLINE_SYSCALL (eventfd2, 2, count, flags);
# ifndef __ASSUME_EVENTFD2
+ int res = INLINE_SYSCALL (eventfd2, 2, count, flags);
if (res != -1 || errno != ENOSYS)
-# endif
return res;
+# endif
+ INLINE_SYSCALL_RETURN (eventfd2, 2, int, count, flags)
#endif
#ifndef __ASSUME_EVENTFD2
@@ -38,16 +39,12 @@ eventfd (unsigned int count, int flags)
kernel (sys_indirect) before implementing setting flags like
O_NONBLOCK etc. */
if (flags != 0)
- {
- __set_errno (EINVAL);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
# ifdef __NR_eventfd
- return INLINE_SYSCALL (eventfd, 1, count);
+ INLINE_SYSCALL_RETURN (eventfd, 1, int, count)
# else
- __set_errno (ENOSYS);
- return -1;
+ INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1)
# endif
#elif !defined __NR_eventfd2
# error "__ASSUME_EVENTFD2 defined but not __NR_eventfd2"
@@ -34,17 +34,11 @@ fchmodat (fd, file, mode, flag)
int flag;
{
if (flag & ~AT_SYMLINK_NOFOLLOW)
- {
- __set_errno (EINVAL);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
#ifndef __NR_lchmod /* Linux so far has no lchmod syscall. */
if (flag & AT_SYMLINK_NOFOLLOW)
- {
- __set_errno (ENOTSUP);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-ENOTSUP, int, -1)
#endif
- return INLINE_SYSCALL (fchmodat, 3, fd, file, mode);
+ INLINE_SYSCALL_RETURN (fchmodat, 3, int, fd, file, mode)
}
@@ -28,7 +28,7 @@ static int
do_fcntl (int fd, int cmd, void *arg)
{
if (cmd != F_GETOWN)
- return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
+ INLINE_SYSCALL_RETURN (fcntl, 3, int, fd, cmd, arg)
INTERNAL_SYSCALL_DECL (err);
struct f_owner_ex fex;
@@ -36,8 +36,8 @@ do_fcntl (int fd, int cmd, void *arg)
if (!INTERNAL_SYSCALL_ERROR_P (res, err))
return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
- __set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
- return -1;
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (res, err),
+ int, -1)
}
@@ -35,12 +35,14 @@ __fstatfs64 (int fd, struct statfs64 *buf)
if (! __no_statfs64)
# endif
{
+# if __ASSUME_STATFS64 == 0
int result = INLINE_SYSCALL (fstatfs64, 3, fd, sizeof (*buf), buf);
-# if __ASSUME_STATFS64 == 0
if (result == 0 || errno != ENOSYS)
-# endif
return result;
+# else
+ INLINE_SYSCALL_RETURN (fstatfs64, 3, int, fd, sizeof (*buf), buf)
+# endif
# if __ASSUME_STATFS64 == 0
__no_statfs64 = 1;
@@ -29,8 +29,7 @@ __ftruncate64 (int fd, off64_t length)
{
unsigned int low = length & 0xffffffff;
unsigned int high = length >> 32;
- int result = INLINE_SYSCALL (ftruncate64, 3, fd,
- __LONG_LONG_PAIR (high, low));
- return result;
+ INLINE_SYSCALL_RETURN (ftruncate64, 3, int, fd,
+ __LONG_LONG_PAIR (high, low))
}
weak_alias (__ftruncate64, ftruncate64)
@@ -33,15 +33,11 @@ futimens (int fd, const struct timespec tsp[2])
{
#ifdef __NR_utimensat
if (fd < 0)
- {
- __set_errno (EBADF);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EBADF, int, -1)
/* Avoid implicit array coercion in syscall macros. */
- return INLINE_SYSCALL (utimensat, 4, fd, NULL, &tsp[0], 0);
+ INLINE_SYSCALL_RETURN (utimensat, 4, int, fd, NULL, &tsp[0], 0)
#else
- __set_errno (ENOSYS);
- return -1;
+ INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1)
#endif
}
#ifndef __NR_utimensat
@@ -49,6 +49,6 @@ __futimes (int fd, const struct timeval tvp[2])
TIMEVAL_TO_TIMESPEC (&tvp[1], &ts[1]);
}
- return INLINE_SYSCALL (utimensat, 4, fd, NULL, tvp ? &ts : NULL, 0);
+ INLINE_SYSCALL_RETURN (utimensat, 4, int, fd, NULL, tvp ? &ts : NULL, 0)
}
weak_alias (__futimes, futimes)
@@ -34,5 +34,5 @@ futimesat (int fd, const char *file, const struct timeval tvp[2])
return __futimes (fd, tvp);
/* Avoid implicit array coercion in syscall macros. */
- return INLINE_SYSCALL (futimesat, 3, fd, file, &tvp[0]);
+ INLINE_SYSCALL_RETURN (futimesat, 3, int, fd, file, &tvp[0])
}
@@ -36,20 +36,19 @@ int
__fxstat (int vers, int fd, struct stat *buf)
{
if (vers == _STAT_VER_KERNEL)
- return INLINE_SYSCALL (fstat, 2, fd, (struct kernel_stat *) buf);
+ INLINE_SYSCALL_RETURN (fstat, 2, fd, (struct kernel_stat *) buf);
#ifdef STAT_IS_KERNEL_STAT
- errno = EINVAL;
- return -1;
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
#else
struct kernel_stat kbuf;
- int result;
-
- result = INLINE_SYSCALL (fstat, 2, fd, &kbuf);
- if (result == 0)
- result = __xstat_conv (vers, &kbuf, buf);
-
- return result;
+ INTERNAL_SYSCALL_DECL (err);
+ int result = INTERNAL_SYSCALL (fstat, err, 2, fd, &kbuf);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result, err),
+ int, -1)
+ else
+ return __xstat_conv (vers, &kbuf, buf);
#endif
}
@@ -31,8 +31,11 @@
int
___fxstat64 (int vers, int fd, struct stat64 *buf)
{
- int result;
- result = INLINE_SYSCALL (fstat64, 2, fd, buf);
+ INTERNAL_SYSCALL_DECL (err);
+ int result = INTERNAL_SYSCALL (fstat64, err, 2, fd, buf);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result, err),
+ int, -1)
#if defined _HAVE_STAT64___ST_INO && __ASSUME_ST_INO_64_BIT == 0
if (__builtin_expect (!result, 1) && buf->__st_ino != (__ino_t) buf->st_ino)
buf->st_ino = buf->__st_ino;
@@ -47,7 +47,8 @@ __gai_sigqueue (sig, val, caller_pid)
info.si_uid = __getuid ();
info.si_value = val;
- return INLINE_SYSCALL (rt_sigqueueinfo, 3, info.si_pid, sig, &info);
+ INLINE_SYSCALL_RETURN (rt_sigqueueinfo, 3, int, info.si_pid, sig,
+ &info)
}
#else
# include <resolv/gai_sigqueue.c>
@@ -34,12 +34,13 @@
int
__getpriority (enum __priority_which which, id_t who)
{
- int res;
-
- res = INLINE_SYSCALL (getpriority, 2, (int) which, who);
- if (res >= 0)
- res = PZERO - res;
- return res;
+ INTERNAL_SYSCALL_DECL (err);
+ int res = INTERNAL_SYSCALL (getpriority, err, 2, (int) which, who);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err)))
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (res, err),
+ int, -1)
+ else
+ return PZERO - res;
}
libc_hidden_def (__getpriority)
weak_alias (__getpriority, getpriority)
@@ -27,7 +27,7 @@ int
__getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
{
#ifdef __ASSUME_PRLIMIT64
- return INLINE_SYSCALL (prlimit64, 4, 0, resource, NULL, rlimits);
+ INLINE_SYSCALL_RETURN (prlimit64, 4, int, 0, resource, NULL, rlimits)
#else
# ifdef __NR_prlimit64
int res = INLINE_SYSCALL (prlimit64, 4, 0, resource, NULL, rlimits);
@@ -29,10 +29,16 @@ loff_t
__llseek (int fd, loff_t offset, int whence)
{
loff_t retval;
-
- return (loff_t) (INLINE_SYSCALL (_llseek, 5, fd, (off_t) (offset >> 32),
- (off_t) (offset & 0xffffffff),
- &retval, whence) ?: retval);
+ INTERNAL_SYSCALL_DECL (err);
+ int result = INTERNAL_SYSCALL (_llseek, err, 5, fd,
+ (off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff),
+ &retval, whence);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result, err),
+ loff_t, -1)
+ else
+ return retval;
}
weak_alias (__llseek, llseek)
strong_alias (__llseek, __libc_lseek64)
@@ -43,11 +43,10 @@ lutimes (const char *file, const struct timeval tvp[2])
TIMEVAL_TO_TIMESPEC (&tvp[1], &ts[1]);
}
- return INLINE_SYSCALL (utimensat, 4, AT_FDCWD, file, tvp ? ts : NULL,
- AT_SYMLINK_NOFOLLOW);
+ INLINE_SYSCALL_RETURN (utimensat, 4, int, AT_FDCWD, file,
+ tvp ? ts : NULL, AT_SYMLINK_NOFOLLOW)
#else
- __set_errno (ENOSYS);
- return -1;
+ INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1)
#endif
}
@@ -35,20 +35,20 @@ int
__lxstat (int vers, const char *name, struct stat *buf)
{
if (vers == _STAT_VER_KERNEL)
- return INLINE_SYSCALL (lstat, 2, name, (struct kernel_stat *) buf);
+ INLINE_SYSCALL_ERROR_RETURN (lstat, 2, int, name,
+ (struct kernel_stat *) buf);
#ifdef STAT_IS_KERNEL_STAT
- errno = EINVAL;
- return -1;
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
#else
struct kernel_stat kbuf;
- int result;
-
- result = INLINE_SYSCALL (lstat, 2, name, &kbuf);
- if (result == 0)
- result = __xstat_conv (vers, &kbuf, buf);
-
- return result;
+ INTERNAL_SYSCALL_DECL (err);
+ int result = INTERNAL_SYSCALL (lstat, err, 2, name, &kbuf);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result, err),
+ int, -1)
+ else
+ return __xstat_conv (vers, &kbuf, buf);
#endif
}
@@ -30,8 +30,11 @@
int
___lxstat64 (int vers, const char *name, struct stat64 *buf)
{
- int result;
- result = INLINE_SYSCALL (lstat64, 2, name, buf);
+ INTERNAL_SYSCALL_DECL (err);
+ int result = INTERNAL_SYSCALL (lstat64, err, 2, name, buf);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result, err),
+ int, -1)
#if defined _HAVE_STAT64___ST_INO && __ASSUME_ST_INO_64_BIT == 0
if (__builtin_expect (!result, 1) && buf->__st_ino != (__ino_t) buf->st_ino)
buf->st_ino = buf->__st_ino;
@@ -46,15 +46,9 @@ __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset)
}
#endif
if (offset & ((1 << page_shift) - 1))
- {
- __set_errno (EINVAL);
- return MAP_FAILED;
- }
- void *result;
- result = (void *)
- INLINE_SYSCALL (mmap2, 6, addr,
- len, prot, flags, fd,
- (off_t) (offset >> page_shift));
- return result;
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, void *, MAP_FAILED)
+ INLINE_SYSCALL_RETURN (mmap2, 6, void *, addr,
+ len, prot, flags, fd,
+ (off_t) (offset >> page_shift));
}
weak_alias (__mmap64, mmap64)
@@ -26,7 +26,7 @@
int
mq_close (mqd_t mqdes)
{
- return INLINE_SYSCALL (close, 1, mqdes);
+ INLINE_SYSCALL_RETURN (close, 1, int, mqdes)
}
#else
@@ -52,7 +52,7 @@ __mq_open (const char *name, int oflag, ...)
va_end (ap);
}
- return INLINE_SYSCALL (mq_open, 4, name + 1, oflag, mode, attr);
+ INLINE_SYSCALL_RETURN (mq_open, 4, int, name + 1, oflag, mode, attr)
}
strong_alias (__mq_open, mq_open);
@@ -32,5 +32,5 @@ msgget (key, msgflg)
key_t key;
int msgflg;
{
- return INLINE_SYSCALL (ipc, 5, IPCOP_msgget, key, msgflg, 0, NULL);
+ INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_msgget, key, msgflg, 0, NULL)
}
@@ -44,10 +44,14 @@ prlimit (__pid_t pid, enum __rlimit_resource resource,
new_rlimit64 = &new_rlimit64_mem;
}
- int res = INLINE_SYSCALL (prlimit64, 4, pid, resource, new_rlimit64,
- old_rlimit64);
+ INTERNAL_SYSCALL_DECL (err);
+ int res = INTERNAL_SYSCALL (prlimit64, err, 4, pid, resource,
+ new_rlimit64, old_rlimit64);
- if (res == 0 && old_rlimit != NULL)
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err)))
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (res, err),
+ int, -1)
+ else if (old_rlimit != NULL)
{
/* The prlimit64 syscall is ill-designed for 32-bit machines.
We have to provide a 32-bit variant since otherwise the LFS
@@ -59,20 +63,14 @@ prlimit (__pid_t pid, enum __rlimit_resource resource,
if (old_rlimit->rlim_cur != old_rlimit64_mem.rlim_cur)
{
if (new_rlimit == NULL)
- {
- __set_errno (EOVERFLOW);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EOVERFLOW, int, -1)
old_rlimit->rlim_cur = RLIM_INFINITY;
}
old_rlimit->rlim_max = old_rlimit64_mem.rlim_max;
if (old_rlimit->rlim_max != old_rlimit64_mem.rlim_max)
{
if (new_rlimit == NULL)
- {
- __set_errno (EOVERFLOW);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EOVERFLOW, int, -1)
old_rlimit->rlim_max = RLIM_INFINITY;
}
}
@@ -33,6 +33,6 @@ raise (sig)
if (__glibc_unlikely (pid < 0))
pid = -pid;
- return INLINE_SYSCALL (tgkill, 3, pid, THREAD_GETMEM (THREAD_SELF, tid),
- sig);
+ INLINE_SYSCALL_RETURN (tgkill, 3, int, pid,
+ THREAD_GETMEM (THREAD_SELF, tid), sig);
}
@@ -52,7 +52,7 @@ raise (sig)
if (__glibc_unlikely (pid <= 0))
pid = (pid & INT_MAX) == 0 ? selftid : -pid;
- return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
+ INLINE_SYSCALL_RETURN (tgkill, 3, int, pid, selftid, sig)
}
libc_hidden_def (raise)
weak_alias (raise, gsignal)
@@ -29,10 +29,10 @@
ssize_t
__readahead (int fd, off64_t offset, size_t count)
{
- return INLINE_SYSCALL (readahead, 4, fd,
+ INLINE_SYSCALL_RETURN (readahead, 4, int, fd,
__LONG_LONG_PAIR ((off_t) (offset >> 32),
(off_t) (offset & 0xffffffff)),
- count);
+ count)
}
#else
ssize_t
@@ -25,5 +25,6 @@
int
reboot (int howto)
{
- return INLINE_SYSCALL (reboot, 3, (int) 0xfee1dead, 672274793, howto);
+ INLINE_SYSCALL_RETURN (reboot, 3, int, (int) 0xfee1dead, 672274793,
+ howto)
}
@@ -25,12 +25,21 @@
#ifdef __NR_sched_getaffinity
+# if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4)
+extern int __sched_getaffinity_new (pid_t, size_t, cpu_set_t *);
+libc_hidden_proto (__sched_getaffinity_new)
+# endif
+
int
__sched_getaffinity_new (pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
{
- int res = INLINE_SYSCALL (sched_getaffinity, 3, pid,
- MIN (INT_MAX, cpusetsize), cpuset);
- if (res != -1)
+ INTERNAL_SYSCALL_DECL (err);
+ int res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, pid,
+ MIN (INT_MAX, cpusetsize), cpuset);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err)))
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (res, err),
+ int, -1)
+ else
{
/* Clean the rest of the memory the kernel didn't do. */
memset ((char *) cpuset + res, '\0', cpusetsize - res);
@@ -44,6 +53,8 @@ versioned_symbol (libc, __sched_getaffinity_new, sched_getaffinity,
# if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4)
+libc_hidden_def (__sched_getaffinity_new)
+
int
attribute_compat_text_section
__sched_getaffinity_old (pid_t pid, cpu_set_t *cpuset)
@@ -33,5 +33,6 @@ semget (key, nsems, semflg)
int nsems;
int semflg;
{
- return INLINE_SYSCALL (ipc, 5, IPCOP_semget, key, nsems, semflg, NULL);
+ INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_semget, key, nsems, semflg,
+ NULL)
}
@@ -31,5 +31,6 @@ semop (semid, sops, nsops)
struct sembuf *sops;
size_t nsops;
{
- return INLINE_SYSCALL (ipc, 5, IPCOP_semop, semid, (int) nsops, 0, sops);
+ INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_semop, semid, (int) nsops, 0,
+ sops)
}
@@ -32,7 +32,6 @@ semtimedop (semid, sops, nsops, timeout)
size_t nsops;
const struct timespec *timeout;
{
- return INLINE_SYSCALL (ipc, 6, IPCOP_semtimedop,
- semid, (int) nsops, 0, sops,
- timeout);
+ INLINE_SYSCALL_RETURN (ipc, 6, int, IPCOP_semtimedop, semid,
+ (int) nsops, 0, sops, timeout)
}
@@ -30,7 +30,7 @@ setrlimit64 (resource, rlimits)
const struct rlimit64 *rlimits;
{
#ifdef __ASSUME_PRLIMIT64
- return INLINE_SYSCALL (prlimit64, 4, 0, resource, rlimits, NULL);
+ INLINE_SYSCALL_RETURN (prlimit64, 4, int, 0, resource, rlimits, NULL)
#else
# ifdef __NR_prlimit64
int res = INLINE_SYSCALL (prlimit64, 4, 0, resource, rlimits, NULL);
@@ -30,5 +30,6 @@ int
shmdt (shmaddr)
const void *shmaddr;
{
- return INLINE_SYSCALL (ipc, 5, IPCOP_shmdt, 0, 0, 0, (void *) shmaddr);
+ INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_shmdt, 0, 0, 0,
+ (void *) shmaddr)
}
@@ -33,5 +33,6 @@ shmget (key, size, shmflg)
size_t size;
int shmflg;
{
- return INLINE_SYSCALL (ipc, 5, IPCOP_shmget, key, size, shmflg, NULL);
+ INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_shmget, key, size, shmflg,
+ NULL)
}
@@ -26,11 +26,13 @@ int
signalfd (int fd, const sigset_t *mask, int flags)
{
#ifdef __NR_signalfd4
- int res = INLINE_SYSCALL (signalfd4, 4, fd, mask, _NSIG / 8, flags);
# ifndef __ASSUME_SIGNALFD4
+ int res = INLINE_SYSCALL (signalfd4, 4, fd, mask, _NSIG / 8, flags);
if (res != -1 || errno != ENOSYS)
-# endif
return res;
+# else
+ INLINE_SYSCALL_RETURN (signalfd4, 4, int, fd, mask, _NSIG / 8, flags)
+# endif
#endif
#ifndef __ASSUME_SIGNALFD4
@@ -39,16 +41,12 @@ signalfd (int fd, const sigset_t *mask, int flags)
kernel (sys_indirect) before implementing setting flags like
O_NONBLOCK etc. */
if (flags != 0)
- {
- __set_errno (EINVAL);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
# ifdef __NR_signalfd
- return INLINE_SYSCALL (signalfd, 3, fd, mask, _NSIG / 8);
+ INLINE_SYSCALL_RETURN (signalfd, 3, int, fd, mask, _NSIG / 8)
# else
- __set_errno (ENOSYS);
- return -1;
+ INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1)
# endif
#elif !defined __NR_signalfd4
# error "__ASSUME_SIGNALFD4 defined but not __NR_signalfd4"
@@ -29,5 +29,5 @@ int
sigpending (set)
sigset_t *set;
{
- return INLINE_SYSCALL (rt_sigpending, 2, set, _NSIG / 8);
+ INLINE_SYSCALL_RETURN (rt_sigpending, 2, int, set, _NSIG / 8)
}
@@ -54,6 +54,7 @@ __sigprocmask (how, set, oset)
}
#endif
- return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8);
+ INLINE_SYSCALL_RETURN (rt_sigprocmask, 4, int, how, set, oset,
+ _NSIG / 8)
}
weak_alias (__sigprocmask, sigprocmask)
@@ -43,7 +43,7 @@ __sigqueue (pid, sig, val)
info.si_uid = __getuid ();
info.si_value = val;
- return INLINE_SYSCALL (rt_sigqueueinfo, 3, pid, sig, &info);
+ INLINE_SYSCALL_RETURN (rt_sigqueueinfo, 3, int, pid, sig, &info)
}
weak_alias (__sigqueue, sigqueue)
#else
@@ -37,12 +37,14 @@ __statfs64 (const char *file, struct statfs64 *buf)
if (! __no_statfs64)
# endif
{
+# if __ASSUME_STATFS64 == 0
int result = INLINE_SYSCALL (statfs64, 3, file, sizeof (*buf), buf);
-# if __ASSUME_STATFS64 == 0
if (result == 0 || errno != ENOSYS)
-# endif
return result;
+# else
+ INLINE_SYSCALL_RETURN (statfs64, 3, int, file, sizeof (*buf), buf)
+# endif
# if __ASSUME_STATFS64 == 0
__no_statfs64 = 1;
@@ -37,7 +37,7 @@ __sysctl (int *name, int nlen, void *oldval, size_t *oldlenp,
.newlen = newlen
};
- return INLINE_SYSCALL (_sysctl, 1, &args);
+ INLINE_SYSCALL_RETURN (_sysctl, 1, int, &args)
}
libc_hidden_def (__sysctl)
weak_alias (__sysctl, sysctl)
@@ -61,8 +61,7 @@ tcsetattr (fd, optional_actions, termios_p)
cmd = TCSETSF;
break;
default:
- __set_errno (EINVAL);
- return -1;
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
}
k_termios.c_iflag = termios_p->c_iflag & ~IBAUD0;
@@ -79,6 +78,6 @@ tcsetattr (fd, optional_actions, termios_p)
memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0],
__KERNEL_NCCS * sizeof (cc_t));
- return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
+ INLINE_SYSCALL_RETURN (ioctl, 3, int, fd, cmd, &k_termios)
}
libc_hidden_def (tcsetattr)
@@ -35,7 +35,5 @@ timer_getoverrun (timerid)
struct timer *kt = (struct timer *) timerid;
/* Get the information from the kernel. */
- int res = INLINE_SYSCALL (timer_getoverrun, 1, kt->ktimerid);
-
- return res;
+ INLINE_SYSCALL_RETURN (timer_getoverrun, 1, int, kt->ktimerid)
}
@@ -37,7 +37,5 @@ timer_gettime (timerid, value)
struct timer *kt = (struct timer *) timerid;
/* Delete the kernel timer object. */
- int res = INLINE_SYSCALL (timer_gettime, 2, kt->ktimerid, value);
-
- return res;
+ INLINE_SYSCALL_RETURN (timer_gettime, 2, int, kt->ktimerid, value)
}
@@ -39,8 +39,6 @@ timer_settime (timerid, flags, value, ovalue)
struct timer *kt = (struct timer *) timerid;
/* Delete the kernel timer object. */
- int res = INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags,
- value, ovalue);
-
- return res;
+ INLINE_SYSCALL_RETURN (timer_settime, 4, int, kt->ktimerid, flags,
+ value, ovalue)
}
@@ -29,7 +29,6 @@ truncate64 (const char *path, off64_t length)
{
unsigned int low = length & 0xffffffff;
unsigned int high = length >> 32;
- int result = INLINE_SYSCALL (truncate64, 3, path,
- __LONG_LONG_PAIR (high, low));
- return result;
+ INLINE_SYSCALL_RETURN (truncate64, 3, int, path,
+ __LONG_LONG_PAIR (high, low))
}
@@ -31,10 +31,7 @@ ustat (dev_t dev, struct ustat *ubuf)
/* We must convert the value to dev_t type used by the kernel. */
k_dev = dev & ((1ULL << 32) - 1);
if (k_dev != dev)
- {
- __set_errno (EINVAL);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
- return INLINE_SYSCALL (ustat, 2, (unsigned int) k_dev, ubuf);
+ INLINE_SYSCALL_RETURN (ustat, 2, int, (unsigned int) k_dev, ubuf)
}
@@ -30,16 +30,12 @@ utimensat (int fd, const char *file, const struct timespec tsp[2],
int flags)
{
if (file == NULL)
- {
- __set_errno (EINVAL);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
#ifdef __NR_utimensat
/* Avoid implicit array coercion in syscall macros. */
- return INLINE_SYSCALL (utimensat, 4, fd, file, &tsp[0], flags);
+ INLINE_SYSCALL_RETURN (utimensat, 4, int, fd, file, &tsp[0], flags)
#else
- __set_errno (ENOSYS);
- return -1;
+ INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1)
#endif
}
#ifndef __NR_utimensat
@@ -30,7 +30,7 @@ int
__utimes (const char *file, const struct timeval tvp[2])
{
/* Avoid implicit array coercion in syscall macros. */
- return INLINE_SYSCALL (utimes, 2, file, &tvp[0]);
+ INLINE_SYSCALL_RETURN (utimes, 2, int, file, &tvp[0])
}
weak_alias (__utimes, utimes)
@@ -33,20 +33,14 @@ __xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
unsigned long long int k_dev;
if (vers != _MKNOD_VER)
- {
- __set_errno (EINVAL);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
/* We must convert the value to dev_t type used by the kernel. */
k_dev = (*dev) & ((1ULL << 32) - 1);
if (k_dev != *dev)
- {
- __set_errno (EINVAL);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
- return INLINE_SYSCALL (mknod, 3, path, mode, (unsigned int) k_dev);
+ INLINE_SYSCALL_RETURN (mknod, 3, int, path, mode, (unsigned int) k_dev)
}
weak_alias (__xmknod, _xmknod)
@@ -34,20 +34,15 @@ int
__xmknodat (int vers, int fd, const char *file, mode_t mode, dev_t *dev)
{
if (vers != _MKNOD_VER)
- {
- __set_errno (EINVAL);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
/* We must convert the value to dev_t type used by the kernel. */
unsigned long long int k_dev = (*dev) & ((1ULL << 32) - 1);
if (k_dev != *dev)
- {
- __set_errno (EINVAL);
- return -1;
- }
+ INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
- return INLINE_SYSCALL (mknodat, 4, fd, file, mode, (unsigned int) k_dev);
+ INLINE_SYSCALL_RETURN (mknodat, 4, int, fd, file, mode,
+ (unsigned int) k_dev)
}
libc_hidden_def (__xmknodat)
@@ -35,20 +35,20 @@ int
__xstat (int vers, const char *name, struct stat *buf)
{
if (vers == _STAT_VER_KERNEL)
- return INLINE_SYSCALL (stat, 2, name, (struct kernel_stat *) buf);
+ INLINE_SYSCALL_RETURN (stat, 2, int, name, (struct kernel_stat *) buf)
#ifdef STAT_IS_KERNEL_STAT
errno = EINVAL;
return -1;
#else
struct kernel_stat kbuf;
- int result;
-
- result = INLINE_SYSCALL (stat, 2, name, &kbuf);
- if (result == 0)
- result = __xstat_conv (vers, &kbuf, buf);
-
- return result;
+ INTERNAL_SYSCALL_DECL (err);
+ int result = INTERNAL_SYSCALL (stat, err, 2, name, &kbuf);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result, err),
+ int, -1)
+ else
+ return __xstat_conv (vers, &kbuf, buf);
#endif
}
hidden_def (__xstat)
@@ -31,8 +31,11 @@
int
___xstat64 (int vers, const char *name, struct stat64 *buf)
{
- int result;
- result = INLINE_SYSCALL (stat64, 2, name, buf);
+ INTERNAL_SYSCALL_DECL (err);
+ int result = INTERNAL_SYSCALL (stat64, err, 2, name, buf);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
+ INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result, err),
+ int, -1)
#if defined _HAVE_STAT64___ST_INO && __ASSUME_ST_INO_64_BIT == 0
if (__builtin_expect (!result, 1) && buf->__st_ino != (__ino_t) buf->st_ino)
buf->st_ino = buf->__st_ino;