]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Add INLINE_SYSCALL_RETURN/INLINE_SYSCALL_ERROR_RETURN
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 21 Aug 2015 11:46:39 +0000 (04:46 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 21 Aug 2015 11:46:53 +0000 (04:46 -0700)
For ia32 PIC, the first thing of many syscalls does is to call
__x86.get_pc_thunk.reg to load PC into reg in case there is an error,
which is required for setting errno.  In most cases, there are no
errors.  But we still call __x86.get_pc_thunk.reg.  This patch adds
INLINE_SYSCALL_RETURN and INLINE_SYSCALL_ERROR_RETURN so that i386
can optimize setting errno by branching to the internal __syscall_error
without PLT.

INLINE_SYSCALL_ERROR_RETURN is designed to take the negative error
number returned from the majority of Linux kernels for which negating
is a no-op with INTERNAL_SYSCALL_ERRNO.

With i386 INLINE_SYSCALL_RETURN, INLINE_SYSCALL_ERROR_RETURN and
i386 syscall inlining optimization for GCC 5, for
sysdeps/unix/sysv/linux/fchmodat.c with -O2 -march=i686
-mtune=generic, GCC 5.2 now generates:

<fchmodat>:
   0: push   %ebx
   1: mov    0x14(%esp),%eax
   5: mov    0x8(%esp),%ebx
   9: mov    0xc(%esp),%ecx
   d: mov    0x10(%esp),%edx
  11: test   $0xfffffeff,%eax
  16: jne    38 <fchmodat+0x38>
  18: test   $0x1,%ah
  1b: jne    48 <fchmodat+0x48>
  1d: mov    $0x132,%eax
  22: call   *%gs:0x10
  29: cmp    $0xfffff000,%eax
  2e: ja     58 <fchmodat+0x58>
  30: pop    %ebx
  31: ret
  32: lea    0x0(%esi),%esi
  38: pop    %ebx
  39: mov    $0xffffffea,%eax
  3e: jmp    3f <fchmodat+0x3f> 3f: R_386_PC32 __syscall_error
  43: nop
  44: lea    0x0(%esi,%eiz,1),%esi
  48: pop    %ebx
  49: mov    $0xffffffa1,%eax
  4e: jmp    4f <fchmodat+0x4f> 4f: R_386_PC32 __syscall_error
  53: nop
  54: lea    0x0(%esi,%eiz,1),%esi
  58: pop    %ebx
  59: jmp    5a <fchmodat+0x5a> 5a: R_386_PC32 __syscall_error

instead of

<fchmodat>:
   0: sub    $0x8,%esp
   3: mov    0x18(%esp),%eax
   7: mov    %ebx,(%esp)
   a: call   b <fchmodat+0xb> b: R_386_PC32 __x86.get_pc_thunk.bx
   f: add    $0x2,%ebx 11: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
  15: mov    %edi,0x4(%esp)
  19: test   $0xfffffeff,%eax
  1e: jne    70 <fchmodat+0x70>
  20: test   $0x1,%ah
  23: jne    88 <fchmodat+0x88>
  25: mov    0x14(%esp),%edx
  29: mov    0x10(%esp),%ecx
  2d: mov    0xc(%esp),%edi
  31: xchg   %ebx,%edi
  33: mov    $0x132,%eax
  38: call   *%gs:0x10
  3f: xchg   %edi,%ebx
  41: cmp    $0xfffff000,%eax
  46: ja     58 <fchmodat+0x58>
  48: mov    (%esp),%ebx
  4b: mov    0x4(%esp),%edi
  4f: add    $0x8,%esp
  52: ret
  53: nop
  54: lea    0x0(%esi,%eiz,1),%esi
  58: mov    0x0(%ebx),%edx 5a: R_386_TLS_GOTIE __libc_errno
  5e: neg    %eax
  60: mov    %eax,%gs:(%edx)
  63: mov    $0xffffffff,%eax
  68: jmp    48 <fchmodat+0x48>
  6a: lea    0x0(%esi),%esi
  70: mov    0x0(%ebx),%eax 72: R_386_TLS_GOTIE __libc_errno
  76: movl   $0x16,%gs:(%eax)
  7d: mov    $0xffffffff,%eax
  82: jmp    48 <fchmodat+0x48>
  84: lea    0x0(%esi,%eiz,1),%esi
  88: mov    0x0(%ebx),%eax 8a: R_386_TLS_GOTIE __libc_errno
  8e: movl   $0x5f,%gs:(%eax)
  95: mov    $0xffffffff,%eax
  9a: jmp    48 <fchmodat+0x48>

* sysdeps/unix/sysdep.h (INLINE_SYSCALL_RETURN): New.
(INLINE_SYSCALL_ERROR_RETURN): Likewise.
* sysdeps/unix/sysv/linux/adjtime.c (ADJTIME): Use
INLINE_SYSCALL_RETURN and INLINE_SYSCALL_ERROR_RETURN.
* sysdeps/unix/sysv/linux/aio_sigqueue.c (__aio_sigqueue):
Likewise.
* sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise.
* sysdeps/unix/sysv/linux/eventfd.c (eventfd): Likewise.
* sysdeps/unix/sysv/linux/faccessat.c (faccessat): Likewise.
* sysdeps/unix/sysv/linux/fchmodat.c (fchmodat): Likewise.
* sysdeps/unix/sysv/linux/fcntl.c (do_fcntl): Likewise.
* sysdeps/unix/sysv/linux/fstatfs64.c (__fstatfs64): Likewise.
* sysdeps/unix/sysv/linux/ftruncate64.c (__ftruncate64): Likewise.
* sysdeps/unix/sysv/linux/futimens.c (futimens): Likewise.
* sysdeps/unix/sysv/linux/futimes.c (__futimes): Likewise.
* sysdeps/unix/sysv/linux/futimesat.c (futimesat): Likewise.
* sysdeps/unix/sysv/linux/fxstat.c (__fxstat): Likewise.
* sysdeps/unix/sysv/linux/fxstat64.c (___fxstat64): Likewise.
* sysdeps/unix/sysv/linux/fxstatat.c (__fxstatat): Likewise.
* sysdeps/unix/sysv/linux/fxstatat64.c (__fxstatat64): Likewise.
* sysdeps/unix/sysv/linux/gai_sigqueue.c (__gai_sigqueue):
Likewise.
* sysdeps/unix/sysv/linux/getpriority.c (__getpriority): Likewise.
* sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Likewise.
* sysdeps/unix/sysv/linux/llseek.c (__llseek): Likewise.
* sysdeps/unix/sysv/linux/lutimes.c (lutimes): Likewise.
* sysdeps/unix/sysv/linux/lxstat.c (__lxstat): Likewise.
* sysdeps/unix/sysv/linux/lxstat64.c (___lxstat64): Likewise.
* sysdeps/unix/sysv/linux/mmap64.c (__mmap64): Likewise.
* sysdeps/unix/sysv/linux/mq_close.c (mq_close): Likewise.
* sysdeps/unix/sysv/linux/mq_open.c (__mq_open): Likewise.
* sysdeps/unix/sysv/linux/mq_unlink.c (mq_unlink): Likewise.
* sysdeps/unix/sysv/linux/msgget.c (msgget): Likewise.
* sysdeps/unix/sysv/linux/prlimit.c (prlimit): Likewise.
* sysdeps/unix/sysv/linux/pt-raise.c (raise): Likewise.
* sysdeps/unix/sysv/linux/raise.c (raise): Likewise.
* sysdeps/unix/sysv/linux/readahead.c (__readahead): Likewise.
* sysdeps/unix/sysv/linux/reboot.c (reboot): Likewise.
* sysdeps/unix/sysv/linux/semget.c (semget): Likewise.
* sysdeps/unix/sysv/linux/semop.c (semop): Likewise.
* sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Likewise.
* sysdeps/unix/sysv/linux/setrlimit64.c (setrlimit64): Likewise.
* sysdeps/unix/sysv/linux/shmat.c (shmat): Likewise.
* sysdeps/unix/sysv/linux/shmdt.c (shmdt): Likewise.
* sysdeps/unix/sysv/linux/shmget.c (shmget): Likewise.
* sysdeps/unix/sysv/linux/signalfd.c (signalfd): Likewise.
* sysdeps/unix/sysv/linux/sigpending.c (sigpending): Likewise.
* sysdeps/unix/sysv/linux/sigprocmask.c ( __sigprocmask): Likewise.
* sysdeps/unix/sysv/linux/sigqueue.c (__sigqueue): Likewise.
* sysdeps/unix/sysv/linux/speed.c (cfsetospeed): Likewise.
* sysdeps/unix/sysv/linux/statfs64.c (__statfs64): Likewise.
* sysdeps/unix/sysv/linux/sysctl.c (__sysctl): Likewise.
* sysdeps/unix/sysv/linux/tcsendbrk.c (tcsendbreak): Likewise.
* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
* sysdeps/unix/sysv/linux/timer_getoverr.c (timer_getoverrun):
Likewise.
* sysdeps/unix/sysv/linux/timer_gettime.c (timer_gettime):
Likewise.
* sysdeps/unix/sysv/linux/timer_settime.c (timer_settime):
Likewise.
* sysdeps/unix/sysv/linux/truncate64.c (truncate64): Likewise.
* sysdeps/unix/sysv/linux/ustat.c (ustat): Likewise.
* sysdeps/unix/sysv/linux/utimensat.c (utimensat): Likewise.
* sysdeps/unix/sysv/linux/utimes.c (__utimes): Likewise.
* sysdeps/unix/sysv/linux/xmknod.c (__xmknod): Likewise.
* sysdeps/unix/sysv/linux/xmknodat.c (__xmknodat): Likewise.
* sysdeps/unix/sysv/linux/xstat.c (__xstat): Likewise.
* sysdeps/unix/sysv/linux/xstat64.c (___xstat64): Likewise.
* sysdeps/unix/sysv/linux/xstatconv.c (__xstat_conv): Likewise.
(__xstat64_conv): Likewise.
(__xstat32_conv): Likewise.
* sysdeps/unix/sysv/linux/sched_getaffinity.c
(__sched_getaffinity_new): Add libc_hidden_proto and
libc_hidden_def.  Use INLINE_SYSCALL_ERROR_RETURN.

64 files changed:
ChangeLog
sysdeps/unix/sysdep.h
sysdeps/unix/sysv/linux/adjtime.c
sysdeps/unix/sysv/linux/aio_sigqueue.c
sysdeps/unix/sysv/linux/dl-openat64.c
sysdeps/unix/sysv/linux/eventfd.c
sysdeps/unix/sysv/linux/faccessat.c
sysdeps/unix/sysv/linux/fchmodat.c
sysdeps/unix/sysv/linux/fcntl.c
sysdeps/unix/sysv/linux/fstatfs64.c
sysdeps/unix/sysv/linux/ftruncate64.c
sysdeps/unix/sysv/linux/futimens.c
sysdeps/unix/sysv/linux/futimes.c
sysdeps/unix/sysv/linux/futimesat.c
sysdeps/unix/sysv/linux/fxstat.c
sysdeps/unix/sysv/linux/fxstat64.c
sysdeps/unix/sysv/linux/fxstatat.c
sysdeps/unix/sysv/linux/fxstatat64.c
sysdeps/unix/sysv/linux/gai_sigqueue.c
sysdeps/unix/sysv/linux/getpriority.c
sysdeps/unix/sysv/linux/getrlimit64.c
sysdeps/unix/sysv/linux/llseek.c
sysdeps/unix/sysv/linux/lutimes.c
sysdeps/unix/sysv/linux/lxstat.c
sysdeps/unix/sysv/linux/lxstat64.c
sysdeps/unix/sysv/linux/mmap64.c
sysdeps/unix/sysv/linux/mq_close.c
sysdeps/unix/sysv/linux/mq_open.c
sysdeps/unix/sysv/linux/mq_unlink.c
sysdeps/unix/sysv/linux/msgget.c
sysdeps/unix/sysv/linux/prlimit.c
sysdeps/unix/sysv/linux/pt-raise.c
sysdeps/unix/sysv/linux/raise.c
sysdeps/unix/sysv/linux/readahead.c
sysdeps/unix/sysv/linux/reboot.c
sysdeps/unix/sysv/linux/sched_getaffinity.c
sysdeps/unix/sysv/linux/semget.c
sysdeps/unix/sysv/linux/semop.c
sysdeps/unix/sysv/linux/semtimedop.c
sysdeps/unix/sysv/linux/setrlimit64.c
sysdeps/unix/sysv/linux/shmat.c
sysdeps/unix/sysv/linux/shmdt.c
sysdeps/unix/sysv/linux/shmget.c
sysdeps/unix/sysv/linux/signalfd.c
sysdeps/unix/sysv/linux/sigpending.c
sysdeps/unix/sysv/linux/sigprocmask.c
sysdeps/unix/sysv/linux/sigqueue.c
sysdeps/unix/sysv/linux/speed.c
sysdeps/unix/sysv/linux/statfs64.c
sysdeps/unix/sysv/linux/sysctl.c
sysdeps/unix/sysv/linux/tcsendbrk.c
sysdeps/unix/sysv/linux/tcsetattr.c
sysdeps/unix/sysv/linux/timer_getoverr.c
sysdeps/unix/sysv/linux/timer_gettime.c
sysdeps/unix/sysv/linux/timer_settime.c
sysdeps/unix/sysv/linux/truncate64.c
sysdeps/unix/sysv/linux/ustat.c
sysdeps/unix/sysv/linux/utimensat.c
sysdeps/unix/sysv/linux/utimes.c
sysdeps/unix/sysv/linux/xmknod.c
sysdeps/unix/sysv/linux/xmknodat.c
sysdeps/unix/sysv/linux/xstat.c
sysdeps/unix/sysv/linux/xstat64.c
sysdeps/unix/sysv/linux/xstatconv.c

index c5e70b17ba4d6e46382400578f5c3cc091c8865f..8fc12f4c532bbddbb81b6ea835c4596bbc406160 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,80 @@
+2015-08-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * sysdeps/unix/sysdep.h (INLINE_SYSCALL_RETURN): New.
+       (INLINE_SYSCALL_ERROR_RETURN): Likewise.
+       * sysdeps/unix/sysv/linux/adjtime.c (ADJTIME): Use
+       INLINE_SYSCALL_RETURN and INLINE_SYSCALL_ERROR_RETURN.
+       * sysdeps/unix/sysv/linux/aio_sigqueue.c (__aio_sigqueue):
+       Likewise.
+       * sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise.
+       * sysdeps/unix/sysv/linux/eventfd.c (eventfd): Likewise.
+       * sysdeps/unix/sysv/linux/faccessat.c (faccessat): Likewise.
+       * sysdeps/unix/sysv/linux/fchmodat.c (fchmodat): Likewise.
+       * sysdeps/unix/sysv/linux/fcntl.c (do_fcntl): Likewise.
+       * sysdeps/unix/sysv/linux/fstatfs64.c (__fstatfs64): Likewise.
+       * sysdeps/unix/sysv/linux/ftruncate64.c (__ftruncate64): Likewise.
+       * sysdeps/unix/sysv/linux/futimens.c (futimens): Likewise.
+       * sysdeps/unix/sysv/linux/futimes.c (__futimes): Likewise.
+       * sysdeps/unix/sysv/linux/futimesat.c (futimesat): Likewise.
+       * sysdeps/unix/sysv/linux/fxstat.c (__fxstat): Likewise.
+       * sysdeps/unix/sysv/linux/fxstat64.c (___fxstat64): Likewise.
+       * sysdeps/unix/sysv/linux/fxstatat.c (__fxstatat): Likewise.
+       * sysdeps/unix/sysv/linux/fxstatat64.c (__fxstatat64): Likewise.
+       * sysdeps/unix/sysv/linux/gai_sigqueue.c (__gai_sigqueue):
+       Likewise.
+       * sysdeps/unix/sysv/linux/getpriority.c (__getpriority): Likewise.
+       * sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Likewise.
+       * sysdeps/unix/sysv/linux/llseek.c (__llseek): Likewise.
+       * sysdeps/unix/sysv/linux/lutimes.c (lutimes): Likewise.
+       * sysdeps/unix/sysv/linux/lxstat.c (__lxstat): Likewise.
+       * sysdeps/unix/sysv/linux/lxstat64.c (___lxstat64): Likewise.
+       * sysdeps/unix/sysv/linux/mmap64.c (__mmap64): Likewise.
+       * sysdeps/unix/sysv/linux/mq_close.c (mq_close): Likewise.
+       * sysdeps/unix/sysv/linux/mq_open.c (__mq_open): Likewise.
+       * sysdeps/unix/sysv/linux/mq_unlink.c (mq_unlink): Likewise.
+       * sysdeps/unix/sysv/linux/msgget.c (msgget): Likewise.
+       * sysdeps/unix/sysv/linux/prlimit.c (prlimit): Likewise.
+       * sysdeps/unix/sysv/linux/pt-raise.c (raise): Likewise.
+       * sysdeps/unix/sysv/linux/raise.c (raise): Likewise.
+       * sysdeps/unix/sysv/linux/readahead.c (__readahead): Likewise.
+       * sysdeps/unix/sysv/linux/reboot.c (reboot): Likewise.
+       * sysdeps/unix/sysv/linux/semget.c (semget): Likewise.
+       * sysdeps/unix/sysv/linux/semop.c (semop): Likewise.
+       * sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Likewise.
+       * sysdeps/unix/sysv/linux/setrlimit64.c (setrlimit64): Likewise.
+       * sysdeps/unix/sysv/linux/shmat.c (shmat): Likewise.
+       * sysdeps/unix/sysv/linux/shmdt.c (shmdt): Likewise.
+       * sysdeps/unix/sysv/linux/shmget.c (shmget): Likewise.
+       * sysdeps/unix/sysv/linux/signalfd.c (signalfd): Likewise.
+       * sysdeps/unix/sysv/linux/sigpending.c (sigpending): Likewise.
+       * sysdeps/unix/sysv/linux/sigprocmask.c ( __sigprocmask): Likewise.
+       * sysdeps/unix/sysv/linux/sigqueue.c (__sigqueue): Likewise.
+       * sysdeps/unix/sysv/linux/speed.c (cfsetospeed): Likewise.
+       * sysdeps/unix/sysv/linux/statfs64.c (__statfs64): Likewise.
+       * sysdeps/unix/sysv/linux/sysctl.c (__sysctl): Likewise.
+       * sysdeps/unix/sysv/linux/tcsendbrk.c (tcsendbreak): Likewise.
+       * sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
+       * sysdeps/unix/sysv/linux/timer_getoverr.c (timer_getoverrun):
+       Likewise.
+       * sysdeps/unix/sysv/linux/timer_gettime.c (timer_gettime):
+       Likewise.
+       * sysdeps/unix/sysv/linux/timer_settime.c (timer_settime):
+       Likewise.
+       * sysdeps/unix/sysv/linux/truncate64.c (truncate64): Likewise.
+       * sysdeps/unix/sysv/linux/ustat.c (ustat): Likewise.
+       * sysdeps/unix/sysv/linux/utimensat.c (utimensat): Likewise.
+       * sysdeps/unix/sysv/linux/utimes.c (__utimes): Likewise.
+       * sysdeps/unix/sysv/linux/xmknod.c (__xmknod): Likewise.
+       * sysdeps/unix/sysv/linux/xmknodat.c (__xmknodat): Likewise.
+       * sysdeps/unix/sysv/linux/xstat.c (__xstat): Likewise.
+       * sysdeps/unix/sysv/linux/xstat64.c (___xstat64): Likewise.
+       * sysdeps/unix/sysv/linux/xstatconv.c (__xstat_conv): Likewise.
+       (__xstat64_conv): Likewise.
+       (__xstat32_conv): Likewise.
+       * sysdeps/unix/sysv/linux/sched_getaffinity.c
+       (__sched_getaffinity_new): Add libc_hidden_proto and
+       libc_hidden_def.  Use INLINE_SYSCALL_ERROR_RETURN.
+
 2015-08-20  Joseph Myers  <joseph@codesourcery.com>
 
        * timezone/Makefile (CFLAGS-zdump.c): Remove
index 52dad582ce406af4dd728b75a9ac90baa8fdfa9d..c4316db4bcb51e6a0158240c15786c861bb3c7eb 100644 (file)
 #ifndef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...) __syscall_##name (args)
 #endif
+
+/* Similar to INLINE_SYSCALL, but with return type.  It should only be
+   used with function return.  */
+#ifndef INLINE_SYSCALL_RETURN
+#define INLINE_SYSCALL_RETURN(name, nr, type, args...) \
+  INLINE_SYSCALL (name, nr, args)
+#endif
+
+/* Set error number and return value.  It should only be used with
+   function return.  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);                                                \
+    (type) (value);                                            \
+  })
+#endif
index b6fb7cf5db839faa7651123391017d8775c38e2a..ad54cf8ff87dc89911352d66e2ed9205f5d22121 100644 (file)
@@ -61,10 +61,7 @@ ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv)
       tmp.tv_sec = itv->tv_sec + itv->tv_usec / 1000000L;
       tmp.tv_usec = itv->tv_usec % 1000000L;
       if (tmp.tv_sec > MAX_SEC || tmp.tv_sec < MIN_SEC)
-       {
-         __set_errno (EINVAL);
-         return -1;
-       }
+       return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
       tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L;
       tntx.modes = ADJ_OFFSET_SINGLESHOT;
     }
index 6a48e6251b707d6828165070a7c302cbfe3dada8..c56b94f911dc3b47c42951fa18b187dd90969f82 100644 (file)
@@ -47,7 +47,8 @@ __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);
+  return INLINE_SYSCALL_RETURN (rt_sigqueueinfo, 3, int, info.si_pid,
+                               sig, &info);
 }
 #else
 # include <rt/aio_sigqueue.c>
index 732097dd92cdbcf447dc55f6a030c52b60333619..ffb13f3acb6538d2986ecf3d60a031e5bda7fb03 100644 (file)
@@ -31,9 +31,9 @@ openat64 (dfd, file, oflag)
   assert (!__OPEN_NEEDS_MODE (oflag));
 
 #ifdef __NR_openat
-  return INLINE_SYSCALL (openat, 3, dfd, file, oflag | O_LARGEFILE);
+  return INLINE_SYSCALL_RETURN (openat, 3, int, dfd, file,
+                               oflag | O_LARGEFILE);
 #else
-  __set_errno (ENOSYS);
-  return -1;
+  return INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1);
 #endif
 }
index d4ffb3cedcd41be1ae9e0c2faeac831f476783fe..1496a0e651c79d5996656a01de5581db37acea7e 100644 (file)
@@ -25,11 +25,14 @@ int
 eventfd (unsigned int count, int flags)
 {
 #ifdef __NR_eventfd2
-  int res = INLINE_SYSCALL (eventfd2, 2, count, flags);
 # ifndef __ASSUME_EVENTFD2
-  if (res != -1 || errno != ENOSYS)
-# endif
+  INTERNAL_SYSCALL_DECL (err);
+  int res = INTERNAL_SYSCALL (eventfd2, err, 2, count, flags);
+  if (!__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))
+      || INTERNAL_SYSCALL_ERRNO (res, err) != ENOSYS)
     return res;
+# endif
+  return INLINE_SYSCALL_RETURN (eventfd2, 2, int, count, flags);
 #endif
 
 #ifndef __ASSUME_EVENTFD2
@@ -38,16 +41,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;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1)
 
 # ifdef __NR_eventfd
-  return INLINE_SYSCALL (eventfd, 1, count);
+  return INLINE_SYSCALL_RETURN (eventfd, 1, int, count)
 # else
-  __set_errno (ENOSYS);
-  return -1;
+  return INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1)
 # endif
 #elif !defined __NR_eventfd2
 # error "__ASSUME_EVENTFD2 defined but not __NR_eventfd2"
index 1bb544fd4d57c00642ef97d67aeaf3c489ddede2..6a0b1b7018b701ed06d6f236b8054c0830fb58ad 100644 (file)
@@ -35,13 +35,10 @@ faccessat (fd, file, mode, flag)
      int flag;
 {
   if (flag & ~(AT_SYMLINK_NOFOLLOW | AT_EACCESS))
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
   if ((flag == 0 || ((flag & ~AT_EACCESS) == 0 && ! __libc_enable_secure)))
-    return INLINE_SYSCALL (faccessat, 3, fd, file, mode);
+    return INLINE_SYSCALL_RETURN (faccessat, 3, int, fd, file, mode);
 
   struct stat64 stats;
   if (__fxstatat64 (_STAT_VER, fd, file, &stats, flag & AT_SYMLINK_NOFOLLOW))
@@ -74,6 +71,5 @@ faccessat (fd, file, mode, flag)
   if (granted == mode)
     return 0;
 
-  __set_errno (EACCES);
-  return -1;
+  return INLINE_SYSCALL_ERROR_RETURN (-EACCES, int, -1);
 }
index e278426de1e0047e73cad10b5c319f9ada07e84e..025634b2788bd3c837be6446551a73de1435b5dc 100644 (file)
@@ -34,17 +34,11 @@ fchmodat (fd, file, mode, flag)
      int flag;
 {
   if (flag & ~AT_SYMLINK_NOFOLLOW)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return 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;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-ENOTSUP, int, -1);
 #endif
 
-  return INLINE_SYSCALL (fchmodat, 3, fd, file, mode);
+  return INLINE_SYSCALL_RETURN (fchmodat, 3, int, fd, file, mode);
 }
index fa184db7fe00d5355ed972174dd6293da9afc544..a9a6b6548b50d0389fc8bae3bf37045a3ec7043e 100644 (file)
@@ -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);
+    return 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;
+  return INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (res, err),
+                                     int, -1);
 }
 
 
index af8383010f198a4e836cc15db6d37cf8c4217840..bba99186b5ab5352f4e796dcde5007e1069dd481 100644 (file)
@@ -35,12 +35,17 @@ __fstatfs64 (int fd, struct statfs64 *buf)
   if (! __no_statfs64)
 # endif
     {
-      int result = INLINE_SYSCALL (fstatfs64, 3, fd, sizeof (*buf), buf);
-
 # if __ASSUME_STATFS64 == 0
-      if (result == 0 || errno != ENOSYS)
-# endif
+      INTERNAL_SYSCALL_DECL (err);
+      int result = INTERNAL_SYSCALL (fstatfs64, err, 3, fd,
+                                    sizeof (*buf), buf);
+      if (!__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))
+         || INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS)
        return result;
+# else
+      return INLINE_SYSCALL_RETURN (fstatfs64, 3, int, fd,
+                                   sizeof (*buf), buf);
+# endif
 
 # if __ASSUME_STATFS64 == 0
       __no_statfs64 = 1;
index cc3c43c74b9d834276676324ccedf284d9176080..b466229aa655844254aef36b7cfc967f734889a3 100644 (file)
@@ -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;
+  return INLINE_SYSCALL_RETURN (ftruncate64, 3, int, fd,
+                               __LONG_LONG_PAIR (high, low));
 }
 weak_alias (__ftruncate64, ftruncate64)
index 5f2b8a56cd7fd554f0cce278b56685270fdcf9c0..dfc21c0139b1c78766cf1d4719947272b75ccfb1 100644 (file)
@@ -33,15 +33,11 @@ futimens (int fd, const struct timespec tsp[2])
 {
 #ifdef __NR_utimensat
   if (fd < 0)
-    {
-      __set_errno (EBADF);
-      return -1;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EBADF, int, -1);
   /* Avoid implicit array coercion in syscall macros.  */
-  return INLINE_SYSCALL (utimensat, 4, fd, NULL, &tsp[0], 0);
+  return INLINE_SYSCALL_RETURN (utimensat, 4, int, fd, NULL, &tsp[0], 0);
 #else
-  __set_errno (ENOSYS);
-  return -1;
+  return INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1);
 #endif
 }
 #ifndef __NR_utimensat
index 69ddfe1531f2ae8453205598a0ad1bb443f252f7..72094b6f11f244e64839c49ad0114abd905a7e39 100644 (file)
@@ -40,15 +40,13 @@ __futimes (int fd, const struct timeval tvp[2])
     {
       if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000
           || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000)
-       {
-         __set_errno (EINVAL);
-         return -1;
-       }
+       return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
       TIMEVAL_TO_TIMESPEC (&tvp[0], &ts[0]);
       TIMEVAL_TO_TIMESPEC (&tvp[1], &ts[1]);
     }
 
-  return INLINE_SYSCALL (utimensat, 4, fd, NULL, tvp ? &ts : NULL, 0);
+  return INLINE_SYSCALL_RETURN (utimensat, 4, int, fd, NULL,
+                               tvp ? &ts : NULL, 0);
 }
 weak_alias (__futimes, futimes)
index 27d68702e1d1a813c617837742c23c16648b3eae..76ccec7a66848ee961bd97de97aaf81e92c67419 100644 (file)
@@ -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]);
+  return INLINE_SYSCALL_RETURN (futimesat, 3, int, fd, file, &tvp[0]);
 }
index 8d8c4e182a440018701ff3e56206116b2725a6a3..e81dc3f2b459d994059994d3d5335f5f9692022d 100644 (file)
@@ -36,20 +36,21 @@ int
 __fxstat (int vers, int fd, struct stat *buf)
 {
   if (vers == _STAT_VER_KERNEL)
-    return INLINE_SYSCALL (fstat, 2, fd, (struct kernel_stat *) buf);
+    return INLINE_SYSCALL_RETURN (fstat, 2, fd,
+                                 (struct kernel_stat *) buf);
 
 #ifdef STAT_IS_KERNEL_STAT
-  errno = EINVAL;
-  return -1;
+  return 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)))
+    return INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result,
+                                                                err),
+                                       int, -1);
+  else
+    return __xstat_conv (vers, &kbuf, buf);
 #endif
 }
 
index 7a0168d5b7fca825a35a496d01c0543fa6c9e648..97b06a81f642d1e846798b5b3bba7098eb321622 100644 (file)
 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)))
+    return 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;
index c88bcecbd2f1a57fb24a948f6a5b9b4fd591868e..5259931df4888623bc114bda6e18027a6b3fd35a 100644 (file)
@@ -45,7 +45,11 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 #endif
 
   result = INTERNAL_SYSCALL (newfstatat, err, 4, fd, file, &kst, flag);
-  if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
+    return INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result,
+                                                                err),
+                                       int, -1);
+  else
     {
 #ifdef STAT_IS_KERNEL_STAT
       return 0;
@@ -53,11 +57,6 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
       return __xstat_conv (vers, &kst, st);
 #endif
     }
-  else
-    {
-      __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
-      return -1;
-    }
 }
 libc_hidden_def (__fxstatat)
 #ifdef XSTAT_IS_XSTAT64
index a55cf1d1554dd72867fa281b30e5f9dd03b08d69..f4cd094ecacb4835936ae2b1421f48104351ba91 100644 (file)
@@ -32,21 +32,17 @@ int
 __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 {
   if (__glibc_unlikely (vers != _STAT_VER_LINUX))
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
   int result;
   INTERNAL_SYSCALL_DECL (err);
 
   result = INTERNAL_SYSCALL (fstatat64, err, 4, fd, file, st, flag);
-  if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
-    return 0;
+  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err)))
+    return INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result,
+                                                                err),
+                                       int, -1);
   else
-    {
-      __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
-      return -1;
-    }
+    return 0;
 }
 libc_hidden_def (__fxstatat64)
index 404dd68fa9a2fbfda299096a132f0ab65aa559a7..fe4f36f37b85fed1e02af25026338e57f6fba717 100644 (file)
@@ -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);
+  return INLINE_SYSCALL_RETURN (rt_sigqueueinfo, 3, int, info.si_pid,
+                               sig, &info);
 }
 #else
 # include <resolv/gai_sigqueue.c>
index 9c691bb387a981ce6c9ed62beb8cd5a5df535fe0..444995e0e33207de0914ba3c4889641b1f64fecb 100644 (file)
 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)))
+    return INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (res,
+                                                                err),
+                                       int, -1);
+  else
+    return PZERO - res;
 }
 libc_hidden_def (__getpriority)
 weak_alias (__getpriority, getpriority)
index 100ba623e227c35e6e3f0bbf73c31eb8b970d201..b0c85337b3d539c3e7465a10239948f1a567305a 100644 (file)
@@ -27,11 +27,15 @@ int
 __getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
 {
 #ifdef __ASSUME_PRLIMIT64
-  return INLINE_SYSCALL (prlimit64, 4, 0, resource, NULL, rlimits);
+  return INLINE_SYSCALL_RETURN (prlimit64, 4, int, 0, resource,
+                               NULL, rlimits);
 #else
 # ifdef __NR_prlimit64
-  int res = INLINE_SYSCALL (prlimit64, 4, 0, resource, NULL, rlimits);
-  if (res == 0 || errno != ENOSYS)
+  INTERNAL_SYSCALL_DECL (err);
+  int res = INTERNAL_SYSCALL (prlimit64, err, 4, 0, resource, NULL,
+                             rlimits);
+  if (!__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))
+      || INTERNAL_SYSCALL_ERRNO (res, err) != ENOSYS)
     return res;
 # endif
   struct rlimit rlimits32;
index 80ac5e690b60fd0cd60baee5b70d27e804a306d5..116e55b9f787f70f539378f4c11a60a8c4699ac9 100644 (file)
@@ -29,10 +29,17 @@ 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)))
+    return INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result,
+                                                                err),
+                                       loff_t, -1);
+  else
+    return retval;
 }
 weak_alias (__llseek, llseek)
 strong_alias (__llseek, __libc_lseek64)
index 9e51305b9bbf9d9dfa2def5243554824fc54e934..3597c18cfc60d8437c0680c02435b73f4de336a4 100644 (file)
@@ -34,20 +34,16 @@ lutimes (const char *file, const struct timeval tvp[2])
     {
       if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000
           || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000)
-       {
-         __set_errno (EINVAL);
-         return -1;
-       }
+       return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
       TIMEVAL_TO_TIMESPEC (&tvp[0], &ts[0]);
       TIMEVAL_TO_TIMESPEC (&tvp[1], &ts[1]);
     }
 
-  return INLINE_SYSCALL (utimensat, 4, AT_FDCWD, file, tvp ? ts : NULL,
-                        AT_SYMLINK_NOFOLLOW);
+  return INLINE_SYSCALL_RETURN (utimensat, 4, int, AT_FDCWD, file,
+                               tvp ? ts : NULL, AT_SYMLINK_NOFOLLOW);
 #else
-  __set_errno (ENOSYS);
-  return -1;
+  return INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1);
 #endif
 }
 
index 948665c27afe494e4e8cacaedd00f9e0c3ddf961..ae3f33cb7fd1d01a7f188e9f0722038f3a73aa72 100644 (file)
@@ -35,20 +35,21 @@ 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);
+    return INLINE_SYSCALL_ERROR_RETURN (lstat, 2, int, name,
+                                       (struct kernel_stat *) buf);
 
 #ifdef STAT_IS_KERNEL_STAT
-  errno = EINVAL;
-  return -1;
+  return 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)))
+    return INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result,
+                                                                err),
+                                       int, -1)
+  else
+    return __xstat_conv (vers, &kbuf, buf);
 #endif
 }
 
index 5d0c051aa12af3ffa95de064b950b525b2fdb0a4..5b4d806731b389b1f4e53e554aff0e06cc2a0cef 100644 (file)
 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)))
+    return 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;
index 0b160b6f6b07db3429d9a2a07ec68293dd93aa55..4dbe28b9c4033b46374e37a1e9ae3c489a7e9c50 100644 (file)
@@ -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;
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, void *, MAP_FAILED);
+  return INLINE_SYSCALL_RETURN (mmap2, 6, void *, addr,
+                               len, prot, flags, fd,
+                               (off_t) (offset >> page_shift));
 }
 weak_alias (__mmap64, mmap64)
index 58d5aea6994a7131548780e7f3078c4f3742bf2e..1d5b664b3a82c7c91fde4c163efea5066a3887a9 100644 (file)
@@ -26,7 +26,7 @@
 int
 mq_close (mqd_t mqdes)
 {
-  return INLINE_SYSCALL (close, 1, mqdes);
+  return INLINE_SYSCALL_RETURN (close, 1, int, mqdes);
 }
 
 #else
index 46c0cc871c32f3d269fc2ff9bc6f48c5cda97210..ecadd08544a814c45eab1a57cd05c742eadb8252 100644 (file)
@@ -35,10 +35,7 @@ mqd_t
 __mq_open (const char *name, int oflag, ...)
 {
   if (name[0] != '/')
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
   mode_t mode = 0;
   struct mq_attr *attr = NULL;
@@ -52,7 +49,8 @@ __mq_open (const char *name, int oflag, ...)
       va_end (ap);
     }
 
-  return INLINE_SYSCALL (mq_open, 4, name + 1, oflag, mode, attr);
+  return INLINE_SYSCALL_RETURN (mq_open, 4, int, name + 1, oflag, mode,
+                               attr);
 }
 strong_alias (__mq_open, mq_open);
 
index a876c3c3ca5978ce00d8f5af0b1a81ead37c02cb..0b133d1425a74e1903324e5417386b1582833314 100644 (file)
@@ -26,10 +26,7 @@ int
 mq_unlink (const char *name)
 {
   if (name[0] != '/')
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
   INTERNAL_SYSCALL_DECL (err);
   int ret = INTERNAL_SYSCALL (mq_unlink, err, 1, name + 1);
@@ -41,8 +38,7 @@ mq_unlink (const char *name)
       ret = INTERNAL_SYSCALL_ERRNO (ret, err);
       if (ret == EPERM)
        ret = EACCES;
-      __set_errno (ret);
-      ret = -1;
+      return INLINE_SYSCALL_ERROR_RETURN (-ret, int, -1);
     }
 
   return ret;
index ca8932ca8ad6f265bc273b33dca59ef0ae2d305c..fdc4796361dacd798a55f09f784f5262c605969d 100644 (file)
@@ -32,5 +32,6 @@ msgget (key, msgflg)
      key_t key;
      int msgflg;
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgget, key, msgflg, 0, NULL);
+  return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_msgget, key, msgflg,
+                               0, NULL);
 }
index db88ba893c2335070be14963943925c5d50f372c..ad164c4b2cba73042ec14d76aba0c343018d9c09 100644 (file)
@@ -44,10 +44,15 @@ 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)))
+    return 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 +64,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;
-           }
+           return 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;
-           }
+           return INLINE_SYSCALL_ERROR_RETURN (-EOVERFLOW, int, -1);
          old_rlimit->rlim_max = RLIM_INFINITY;
        }
     }
@@ -84,8 +83,7 @@ int
 prlimit (__pid_t pid, enum __rlimit_resource resource,
         const struct rlimit *new_rlimit, struct rlimit *old_rlimit)
 {
-  __set_errno (ENOSYS);
-  return -1;
+  return INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1);
 }
 stub_warning (prlimit)
 #endif
index 307b9dca08368fa76fc4c488df933d178bb947a5..1e1443918b8e796823d6dd5f7b8acb58a6210a56 100644 (file)
@@ -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);
+  return INLINE_SYSCALL_RETURN (tgkill, 3, int, pid,
+                               THREAD_GETMEM (THREAD_SELF, tid), sig);
 }
index e2810634d6002faab360b760fc0b1babefc408f0..2e6bb6b46a4ed6fa8529fc11346a75b53506d556 100644 (file)
@@ -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);
+  return INLINE_SYSCALL_RETURN (tgkill, 3, int, pid, selftid, sig);
 }
 libc_hidden_def (raise)
 weak_alias (raise, gsignal)
index c47df0d5defcebd0c8de80b7ae244825f1053fc0..0c3e58574b2355ea101b4eaa02b21088f461dcd9 100644 (file)
 ssize_t
 __readahead (int fd, off64_t offset, size_t count)
 {
-  return INLINE_SYSCALL (readahead, 4, fd,
-                        __LONG_LONG_PAIR ((off_t) (offset >> 32),
-                                          (off_t) (offset & 0xffffffff)),
-                        count);
+  return INLINE_SYSCALL_RETURN (readahead, 4, int, fd,
+                               __LONG_LONG_PAIR ((off_t) (offset >> 32),
+                                                 (off_t) (offset & 0xffffffff)),
+                             count);
 }
 #else
 ssize_t
 __readahead (int fd, off64_t offset, size_t count)
 {
-  __set_errno (ENOSYS);
-  return -1;
+  return INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1);
 }
 stub_warning (readahead)
 #endif
index a016321ee7bcf267bf2079a4f3ca257986121cb5..e5252456abd52349f4df9576d223109391f7538b 100644 (file)
@@ -25,5 +25,6 @@
 int
 reboot (int howto)
 {
-  return INLINE_SYSCALL (reboot, 3, (int) 0xfee1dead, 672274793, howto);
+  return INLINE_SYSCALL_RETURN (reboot, 3, int, (int) 0xfee1dead,
+                               672274793, howto);
 }
index 985080629896b152762eaaf68c22e5d91c34c9fe..d66b6faa55abfe4918fc73cf59286d318bec00f7 100644 (file)
 
 
 #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)))
+    return 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 +54,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)
index 7221ff22d86f86b51f65d64f5496d17541a978cb..c75835df1545a3c25f4b38a3c691259755f78a37 100644 (file)
@@ -33,5 +33,6 @@ semget (key, nsems, semflg)
      int nsems;
      int semflg;
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semget, key, nsems, semflg, NULL);
+  return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_semget, key, nsems,
+                               semflg, NULL);
 }
index dc936be856c41259723ff0980c7e5ab8056941be..b40014c89766ce5ec8b21e9b4b0efb73dbae5a1f 100644 (file)
@@ -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);
+  return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_semop, semid,
+                               (int) nsops, 0, sops);
 }
index 02df07e7045c006819f6a8b98a5146691fa740b6..57e7485946ad4e5a58f2733db26314add5a5322d 100644 (file)
@@ -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);
+  return INLINE_SYSCALL_RETURN (ipc, 6, int, IPCOP_semtimedop, semid,
+                               (int) nsops, 0, sops, timeout);
 }
index 17f95cbdfc2530525bbcfcd7020eedc34c42053b..1989af6fd5bffa57b4c5bad80ba5efb04b038192 100644 (file)
@@ -30,11 +30,15 @@ setrlimit64 (resource, rlimits)
      const struct rlimit64 *rlimits;
 {
 #ifdef __ASSUME_PRLIMIT64
-  return INLINE_SYSCALL (prlimit64, 4, 0, resource, rlimits, NULL);
+  return INLINE_SYSCALL_RETURN (prlimit64, 4, int, 0, resource,
+                               rlimits, NULL);
 #else
 # ifdef __NR_prlimit64
-  int res = INLINE_SYSCALL (prlimit64, 4, 0, resource, rlimits, NULL);
-  if (res == 0 || errno != ENOSYS)
+  INTERNAL_SYSCALL_DECL (err);
+  int res = INTERNAL_SYSCALL (prlimit64, err, 4, 0, resource, rlimits,
+                             NULL);
+  if (!__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))
+      || INTERNAL_SYSCALL_ERRNO (res, err) != ENOSYS)
     return res;
 # endif
   struct rlimit rlimits32;
index 94d18d3f66f53e3359ea0bfc9da46f3b005f2ac0..45ebd1177c766ff633c153ffe93ff6351d16fd38 100644 (file)
@@ -42,11 +42,10 @@ shmat (shmid, shmaddr, shmflg)
                                shmid, shmflg,
                                (long int) &raddr,
                                (void *) shmaddr);
-  if (INTERNAL_SYSCALL_ERROR_P (resultvar, err))
-    {
-      __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err));
-      return (void *) -1l;
-    }
-
-  return raddr;
+  if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, err)))
+    return INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (resultvar,
+                                                                err),
+                                       void *, -1l);
+  else
+    return raddr;
 }
index 51bad719c043936a17094b1f6d9951ad43cdb4cb..0bb637081bc80cb8eb70127d316d46d4d22f514a 100644 (file)
@@ -30,5 +30,6 @@ int
 shmdt (shmaddr)
      const void *shmaddr;
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmdt, 0, 0, 0, (void *) shmaddr);
+  return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_shmdt, 0, 0, 0,
+                               (void *) shmaddr);
 }
index b3d74e69e50217d09d17e278b54bf1df5f874065..c9720f4c4b8662fdf56ef08f4d4388e9400b271e 100644 (file)
@@ -33,5 +33,6 @@ shmget (key, size, shmflg)
      size_t size;
      int shmflg;
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmget, key, size, shmflg, NULL);
+  return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_shmget, key, size,
+                               shmflg, NULL);
 }
index f3ae8c19475c59e568a5f69513a6b199fa5043c9..e07b56cf06dd182119b7262531f3f77d5e9b3d77 100644 (file)
@@ -26,11 +26,17 @@ 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
-  if (res != -1 || errno != ENOSYS)
-# endif
+  INTERNAL_SYSCALL_DECL (err);
+  int res = INTERNAL_SYSCALL (signalfd4, err, 4, fd, mask, _NSIG / 8,
+                             flags);
+  if (!__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (res, err))
+      || INTERNAL_SYSCALL_ERRNO (res, err) != ENOSYS)
     return res;
+# else
+  return INLINE_SYSCALL_RETURN (signalfd4, 4, int, fd, mask, _NSIG / 8,
+                               flags);
+# endif
 #endif
 
 #ifndef __ASSUME_SIGNALFD4
@@ -39,16 +45,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;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
 # ifdef __NR_signalfd
-  return INLINE_SYSCALL (signalfd, 3, fd, mask, _NSIG / 8);
+  return INLINE_SYSCALL_RETURN (signalfd, 3, int, fd, mask, _NSIG / 8);
 # else
-  __set_errno (ENOSYS);
-  return -1;
+  return INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1);
 # endif
 #elif !defined __NR_signalfd4
 # error "__ASSUME_SIGNALFD4 defined but not __NR_signalfd4"
index c8f3a8e395d46e285a2ea3786b1a3712bb9c4a6b..4ad098295a9d2e416c558a172be7c37dc3b70a0e 100644 (file)
@@ -29,5 +29,5 @@ int
 sigpending (set)
      sigset_t *set;
 {
-  return INLINE_SYSCALL (rt_sigpending, 2, set, _NSIG / 8);
+  return INLINE_SYSCALL_RETURN (rt_sigpending, 2, int, set, _NSIG / 8);
 }
index 574f0d22323b31fc8602c1e397a8f3cc92d39e94..452f8a168d6098631fb5f997f9a81818108d562d 100644 (file)
@@ -54,6 +54,7 @@ __sigprocmask (how, set, oset)
     }
 #endif
 
-  return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8);
+  return INLINE_SYSCALL_RETURN (rt_sigprocmask, 4, int, how, set, oset,
+                               _NSIG / 8);
 }
 weak_alias (__sigprocmask, sigprocmask)
index 7970a7c9979cbcad34a9fbd9122adc2faa382272..9009174ed6f496347e10d5945ee66f78f224cae2 100644 (file)
@@ -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);
+  return INLINE_SYSCALL_RETURN (rt_sigqueueinfo, 3, int, pid, sig, &info);
 }
 weak_alias (__sigqueue, sigqueue)
 #else
index 3ac0640b659d55df5c6596d59881f8e843a8d270..2ed9f15da3f1ea6584ce2b38dc407e5c8ea8563d 100644 (file)
@@ -60,10 +60,7 @@ cfsetospeed  (termios_p, speed)
 {
   if ((speed & ~CBAUD) != 0
       && (speed < B57600 || speed > __MAX_BAUD))
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
 #ifdef _HAVE_STRUCT_TERMIOS_C_OSPEED
   termios_p->c_ospeed = speed;
@@ -87,10 +84,7 @@ cfsetispeed (termios_p, speed)
 {
   if ((speed & ~CBAUD) != 0
       && (speed < B57600 || speed > __MAX_BAUD))
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
 #ifdef _HAVE_STRUCT_TERMIOS_C_ISPEED
   termios_p->c_ispeed = speed;
index ac5c33fbf00a6ae96eac12eb32584c452f04ca47..0d9e16c7bcc09129a178092a6feb7baf16bd42f6 100644 (file)
@@ -37,12 +37,18 @@ __statfs64 (const char *file, struct statfs64 *buf)
   if (! __no_statfs64)
 # endif
     {
-      int result = INLINE_SYSCALL (statfs64, 3, file, sizeof (*buf), buf);
-
 # if __ASSUME_STATFS64 == 0
-      if (result == 0 || errno != ENOSYS)
-# endif
+      INTERNAL_SYSCALL_DECL (err);
+      int result = INTERNAL_SYSCALL (statfs64, err, 3, file,
+                                    sizeof (*buf), buf);
+
+      if (!__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, err))
+         || INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS)
        return result;
+# else
+      return INLINE_SYSCALL_RETURN (statfs64, 3, int, file,
+                                   sizeof (*buf), buf);
+# endif
 
 # if __ASSUME_STATFS64 == 0
       __no_statfs64 = 1;
index 2d4eb1dd85a6827e9dccc894c5d31a6585f6ee6d..d0fe55c76cdbdc93541aa1afcbcf9a7537a9e47f 100644 (file)
@@ -37,7 +37,7 @@ __sysctl (int *name, int nlen, void *oldval, size_t *oldlenp,
     .newlen = newlen
   };
 
-  return INLINE_SYSCALL (_sysctl, 1, &args);
+  return INLINE_SYSCALL_RETURN (_sysctl, 1, int, &args);
 }
 libc_hidden_def (__sysctl)
 weak_alias (__sysctl, sysctl)
index 4a43209a0e36a1505ee7e165ae21f3b8637fc2dc..508efbbaabca31b30bac5402b5b85ff988822d65 100644 (file)
@@ -39,7 +39,6 @@ tcsendbreak (int fd, int duration)
   /* ioctl can't send a break of any other duration for us.
      This could be changed to use trickery (e.g. lower speed and
      send a '\0') to send the break, but for now just return an error.  */
-  __set_errno (EINVAL);
-  return -1;
+  return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 #endif
 }
index d7afc636a0b0247678b1fd4832b87520d5bebc97..96f728790bd612ee9a572de4b2bc230de6d921ac 100644 (file)
@@ -61,8 +61,7 @@ tcsetattr (fd, optional_actions, termios_p)
       cmd = TCSETSF;
       break;
     default:
-      __set_errno (EINVAL);
-      return -1;
+      return 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);
+  return INLINE_SYSCALL_RETURN (ioctl, 3, int, fd, cmd, &k_termios);
 }
 libc_hidden_def (tcsetattr)
index 8f0019228721a612ef0254042b2f2a66a975aafe..2bcac7993d260ff0ec23838d9b14ce8616dfffc3 100644 (file)
@@ -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;
+  return INLINE_SYSCALL_RETURN (timer_getoverrun, 1, int, kt->ktimerid);
 }
index 79705cf5e8b10c0107d1c1385f6038ceb0819ecd..e9ca59a47eecb5e3b5e63e8fa3ea299f6629dd06 100644 (file)
@@ -37,7 +37,6 @@ 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;
+  return INLINE_SYSCALL_RETURN (timer_gettime, 2, int, kt->ktimerid,
+                               value);
 }
index 87c65194ea9f82e864081206925e6fe11b723549..d8687fdd9feaade4e87a4c7bbf8389f8404f2a21 100644 (file)
@@ -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;
+  return INLINE_SYSCALL_RETURN (timer_settime, 4, int, kt->ktimerid,
+                               flags, value, ovalue);
 }
index 0002247142c90ef3c9fffb596a2bd1659afdd327..d4500b1c17f6041d0f77824d7ef076048e369d37 100644 (file)
@@ -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;
+  return INLINE_SYSCALL_RETURN (truncate64, 3, int, path,
+                               __LONG_LONG_PAIR (high, low));
 }
index 8d495ca8ce6c2eb98bbf9316f4f4c29ca53535eb..1d78c20a2926a176aa69c1e9711e909ef9e91ebd 100644 (file)
@@ -31,10 +31,8 @@ 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;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
-  return INLINE_SYSCALL (ustat, 2, (unsigned int) k_dev, ubuf);
+  return INLINE_SYSCALL_RETURN (ustat, 2, int, (unsigned int) k_dev,
+                               ubuf);
 }
index 81b565f2ea2bcd4df558cbd1ce6734dfbcb5ce05..9b645a10e6a1e51b6c8f703b9f52d0174b191313 100644 (file)
@@ -30,16 +30,13 @@ utimensat (int fd, const char *file, const struct timespec tsp[2],
           int flags)
 {
   if (file == NULL)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
+    return 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);
+  return INLINE_SYSCALL_RETURN (utimensat, 4, int, fd, file, &tsp[0],
+                               flags);
 #else
-  __set_errno (ENOSYS);
-  return -1;
+  return INLINE_SYSCALL_ERROR_RETURN (-ENOSYS, int, -1);
 #endif
 }
 #ifndef __NR_utimensat
index 2a1f2f90a10fa6d0c19ba1d6c92f4cb417127549..10b5593d79f297d5ff185bb49ef149948cfcf498 100644 (file)
@@ -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]);
+  return INLINE_SYSCALL_RETURN (utimes, 2, int, file, &tvp[0]);
 }
 
 weak_alias (__utimes, utimes)
index b940273058ce020de17d582c30a0c8b43b6fe667..92f714d5b183a24ebca353c919f9502204b81d61 100644 (file)
@@ -33,20 +33,15 @@ __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;
-    }
+    return 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;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
-  return INLINE_SYSCALL (mknod, 3, path, mode, (unsigned int) k_dev);
+  return INLINE_SYSCALL_RETURN (mknod, 3, int, path, mode,
+                               (unsigned int) k_dev);
 }
 
 weak_alias (__xmknod, _xmknod)
index f30b9b30729648bea7552c1d662b58cae312a150..04ad458b1b65749a9bc0970b0c988834ce796587 100644 (file)
@@ -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;
-    }
+    return 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;
-    }
+    return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
 
-  return INLINE_SYSCALL (mknodat, 4, fd, file, mode, (unsigned int) k_dev);
+  return INLINE_SYSCALL_RETURN (mknodat, 4, int, fd, file, mode,
+                               (unsigned int) k_dev);
 }
 
 libc_hidden_def (__xmknodat)
index 62189637662819e82990a902d40209d4fa680d28..8734e0b93339b1b430540f973f57ece949d3c88b 100644 (file)
@@ -35,20 +35,22 @@ 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);
+    return 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)))
+    return INLINE_SYSCALL_ERROR_RETURN (-INTERNAL_SYSCALL_ERRNO (result,
+                                                                err),
+                                       int, -1);
+  else
+    return __xstat_conv (vers, &kbuf, buf);
 #endif
 }
 hidden_def (__xstat)
index c909b5672c4b57fffa7f400cb14daabbb8d8a257..55ff8a1c637d07b35aec82722a5b8f1321a3d0d2 100644 (file)
 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)))
+    return 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;
index 6504414e1e108555ec474da8a9b28de873933eb9..5aae78e0d584275c4657d7fb3d8dd9614177c987 100644 (file)
@@ -96,8 +96,7 @@ __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
       break;
 
     default:
-      __set_errno (EINVAL);
-      return -1;
+      return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
     }
 
   return 0;
@@ -170,8 +169,7 @@ __xstat64_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
         _STAT_VER_KERNEL does not make sense.  */
     case _STAT_VER_KERNEL:
     default:
-      __set_errno (EINVAL);
-      return -1;
+      return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
     }
 
   return 0;
@@ -201,19 +199,13 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf)
            buf->st_ino = kbuf->st_ino;
            if (sizeof (buf->st_ino) != sizeof (kbuf->st_ino)
                && buf->st_ino != kbuf->st_ino)
-             {
-               __set_errno (EOVERFLOW);
-               return -1;
-             }
+             return INLINE_SYSCALL_ERROR_RETURN (-EOVERFLOW, int, -1);
          }
 #else
        buf->st_ino = kbuf->st_ino;
        if (sizeof (buf->st_ino) != sizeof (kbuf->st_ino)
            && buf->st_ino != kbuf->st_ino)
-         {
-           __set_errno (EOVERFLOW);
-           return -1;
-         }
+         return INLINE_SYSCALL_ERROR_RETURN (-EOVERFLOW, int, -1);
 #endif
        buf->st_mode = kbuf->st_mode;
        buf->st_nlink = kbuf->st_nlink;
@@ -227,19 +219,13 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf)
        /* Check for overflow.  */
        if (sizeof (buf->st_size) != sizeof (kbuf->st_size)
            && buf->st_size != kbuf->st_size)
-         {
-           __set_errno (EOVERFLOW);
-           return -1;
-         }
+         return INLINE_SYSCALL_ERROR_RETURN (-EOVERFLOW, int, -1);
        buf->st_blksize = kbuf->st_blksize;
        buf->st_blocks = kbuf->st_blocks;
        /* Check for overflow.  */
        if (sizeof (buf->st_blocks) != sizeof (kbuf->st_blocks)
            && buf->st_blocks != kbuf->st_blocks)
-         {
-           __set_errno (EOVERFLOW);
-           return -1;
-         }
+         return INLINE_SYSCALL_ERROR_RETURN (-EOVERFLOW, int, -1);
 #ifdef _HAVE_STAT_NSEC
        buf->st_atim.tv_sec = kbuf->st_atim.tv_sec;
        buf->st_atim.tv_nsec = kbuf->st_atim.tv_nsec;
@@ -275,8 +261,7 @@ __xstat32_conv (int vers, struct stat64 *kbuf, struct stat *buf)
         _STAT_VER_KERNEL does not make sense.  */
     case _STAT_VER_KERNEL:
     default:
-      __set_errno (EINVAL);
-      return -1;
+      return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
     }
 
   return 0;