This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch hjl/i486/master created. glibc-2.22-117-g643ba8c
- From: hjl at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 10 Sep 2015 11:33:54 -0000
- Subject: GNU C Library master sources branch hjl/i486/master created. glibc-2.22-117-g643ba8c
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/i486/master has been created
at 643ba8c180110b46097ae98e59b4deb7f5520650 (commit)
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=643ba8c180110b46097ae98e59b4deb7f5520650
commit 643ba8c180110b46097ae98e59b4deb7f5520650
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Aug 12 12:10:06 2015 -0700
i386: Remove syscall assembly codes with 6 arguments
This patch removes i386 assembly implementation for epoll_wait, mmap,
mmap64, semtimeop now that i386 have 6 argument syscall support from
C code and GCC 5 can inline syscalls with 6 argument. We also compile
epoll_pwait.c, mmap.c, mmap64.c and semtimedop.c with -fomit-frame-pointer
since %ebp may be used to pass the 6th argument to syscall.
Fo sysdeps/unix/sysv/linux/i386/mmap.c, with -O2 -march=i686
-mtune=generic, GCC 5.2 now generates:
<__mmap>:
0: sub $0x10,%esp
3: mov 0x28(%esp),%eax
7: mov %ebx,(%esp)
a: mov 0x18(%esp),%ecx
e: mov %esi,0x4(%esp)
12: mov 0x14(%esp),%ebx
16: mov %edi,0x8(%esp)
1a: mov 0x1c(%esp),%edx
1e: test $0xfff,%eax
23: mov 0x20(%esp),%esi
27: mov %ebp,0xc(%esp)
2b: mov 0x24(%esp),%edi
2f: jne 60 <__mmap+0x60>
31: sar $0xc,%eax
34: mov %eax,%ebp
36: mov $0xc0,%eax
3b: call *%gs:0x10
42: cmp $0xfffff000,%eax
47: ja 65 <__mmap+0x65>
49: mov (%esp),%ebx
4c: mov 0x4(%esp),%esi
50: mov 0x8(%esp),%edi
54: mov 0xc(%esp),%ebp
58: add $0x10,%esp
5b: ret
5c: lea 0x0(%esi,%eiz,1),%esi
60: mov $0xffffffea,%eax
65: mov (%esp),%ebx
68: mov 0x4(%esp),%esi
6c: mov 0x8(%esp),%edi
70: mov 0xc(%esp),%ebp
74: add $0x10,%esp
77: jmp 78 <__mmap+0x78> 78: R_386_PC32 __syscall_error
vs sysdeps/unix/sysv/linux/i386/mmap.S:
<__mmap>:
0: push %ebp
1: push %ebx
2: push %esi
3: push %edi
4: mov 0x14(%esp),%ebx
8: mov 0x18(%esp),%ecx
c: mov 0x1c(%esp),%edx
10: mov 0x20(%esp),%esi
14: mov 0x24(%esp),%edi
18: mov 0x28(%esp),%ebp
1c: test $0xfff,%ebp
22: mov $0xffffffea,%eax
27: jne 38 <__mmap+0x38>
29: shr $0xc,%ebp
2c: mov $0xc0,%eax
31: call *%gs:0x10
38: pop %edi
39: pop %esi
3a: pop %ebx
3b: pop %ebp
3c: cmp $0xfffff000,%eax
41: ja 44 <__mmap+0x44>
43: ret
44: call 45 <__mmap+0x45> 45: R_386_PC32 __x86.get_pc_thunk.cx
49: add $0x2,%ecx 4b: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
4f: mov 0x0(%ecx),%ecx 51: R_386_TLS_GOTIE __libc_errno
55: neg %eax
57: mov %eax,%gs:(%ecx)
5a: or $0xffffffff,%eax
5d: ret
The C version has:
3: mov 0x28(%esp),%eax
...
1e: test $0xfff,%eax
...
31: sar $0xc,%eax
34: mov %eax,%ebp
is due to missing $ebx register constraint for inline asm. We have
to use "r" constraint with
register unsigned int _a6 asm ("ebp") = (unsigned int) (arg6);
and compiler chose %eax for offset (arg6) in
if (offset & ((1 << MMAP_PAGE_SHIFT) - 1))
* sysdeps/unix/sysv/linux/i386/Makefile (CFLAGS-epoll_pwait.c):
Add -fomit-frame-pointer.
(CFLAGS-mmap.c): Likewise.
(CFLAGS-mmap64.c): Likewise.
(CFLAGS-semtimedop.c): Likewise.
* sysdeps/unix/sysv/linux/i386/mmap.c: New file.
* sysdeps/unix/sysv/linux/i386/epoll_pwait.S: Remove file.
* sysdeps/unix/sysv/linux/i386/mmap.S: Likewise.
* sysdeps/unix/sysv/linux/i386/mmap64.S: Likewise.
* sysdeps/unix/sysv/linux/i386/semtimedop.S: Likewise.
diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile
index e10d133..b484217 100644
--- a/sysdeps/unix/sysv/linux/i386/Makefile
+++ b/sysdeps/unix/sysv/linux/i386/Makefile
@@ -3,6 +3,15 @@ default-abi := 32
ifeq ($(subdir),misc)
sysdep_routines += ioperm iopl vm86
+# %ebp may be used to pass the 6th argument to syscall.
+CFLAGS-epoll_pwait.c += -fomit-frame-pointer
+CFLAGS-mmap.c += -fomit-frame-pointer
+CFLAGS-mmap64.c += -fomit-frame-pointer
+endif
+
+ifeq ($(subdir),sysvipc)
+# %ebp may be used to pass the 6th argument to syscall.
+CFLAGS-semtimedop.c += -fomit-frame-pointer
endif
ifeq ($(subdir),elf)
diff --git a/sysdeps/unix/sysv/linux/i386/epoll_pwait.S b/sysdeps/unix/sysv/linux/i386/epoll_pwait.S
deleted file mode 100644
index 65cfb98..0000000
--- a/sysdeps/unix/sysv/linux/i386/epoll_pwait.S
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Copyright (C) 2007-2015 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#define _ERRNO_H
-#include <bits/errno.h>
-#define _SIGNAL_H
-#include <bits/signum.h>
-
-
- .text
-ENTRY (epoll_pwait)
-
-#ifdef __NR_epoll_pwait
-
- /* Save registers. */
- pushl %ebp
- cfi_adjust_cfa_offset (4)
- pushl %ebx
- cfi_adjust_cfa_offset (4)
- pushl %esi
- cfi_adjust_cfa_offset (4)
- pushl %edi
- cfi_adjust_cfa_offset (4)
- cfi_rel_offset (edi, 0)
- cfi_rel_offset (esi, 4)
- cfi_rel_offset (ebx, 8)
- cfi_rel_offset (ebp, 12)
-
- movl 20(%esp), %ebx
- movl 24(%esp), %ecx
- movl 28(%esp), %edx
- movl 32(%esp), %esi
- movl 36(%esp), %edi
- movl $_NSIG/8, %ebp
- movl $__NR_epoll_pwait, %eax
-
- ENTER_KERNEL
-
- /* Restore registers. */
- popl %edi
- cfi_adjust_cfa_offset (-4)
- cfi_restore (edi)
- popl %esi
- cfi_adjust_cfa_offset (-4)
- cfi_restore (esi)
- popl %ebx
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebx)
- popl %ebp
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebp)
-
- /* If 0 > %eax > -4096 there was an error. */
- cmpl $-4096, %eax
- ja SYSCALL_ERROR_LABEL
-
- /* Successful; return the syscall's value. */
-#else
- movl $-ENOSYS, %eax
- jmp SYSCALL_ERROR_LABEL
-#endif
- ret
-PSEUDO_END (epoll_pwait)
diff --git a/sysdeps/unix/sysv/linux/i386/mmap.S b/sysdeps/unix/sysv/linux/i386/mmap.S
deleted file mode 100644
index daf807a..0000000
--- a/sysdeps/unix/sysv/linux/i386/mmap.S
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-#define EINVAL 22
-
- .text
-
-ENTRY (__mmap)
-
- /* Save registers. */
- pushl %ebp
- cfi_adjust_cfa_offset (4)
- pushl %ebx
- cfi_adjust_cfa_offset (4)
- pushl %esi
- cfi_adjust_cfa_offset (4)
- pushl %edi
- cfi_adjust_cfa_offset (4)
-
- movl 20(%esp), %ebx
- cfi_rel_offset (ebx, 8)
- movl 24(%esp), %ecx
- movl 28(%esp), %edx
- movl 32(%esp), %esi
- cfi_rel_offset (esi, 4)
- movl 36(%esp), %edi
- cfi_rel_offset (edi, 0)
- movl 40(%esp), %ebp
- cfi_rel_offset (ebp, 12)
- testl $0xfff, %ebp
- movl $-EINVAL, %eax
- jne L(skip)
- shrl $12, %ebp /* mmap2 takes the offset in pages. */
-
- movl $SYS_ify(mmap2), %eax /* System call number in %eax. */
-
- /* Do the system call trap. */
- ENTER_KERNEL
-L(skip):
- /* Restore registers. */
- popl %edi
- cfi_adjust_cfa_offset (-4)
- cfi_restore (edi)
- popl %esi
- cfi_adjust_cfa_offset (-4)
- cfi_restore (esi)
- popl %ebx
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebx)
- popl %ebp
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebp)
-
- /* If 0 > %eax > -4096 there was an error. */
- cmpl $-4096, %eax
- ja SYSCALL_ERROR_LABEL
-
- /* Successful; return the syscall's value. */
- ret
-
-PSEUDO_END (__mmap)
-
-weak_alias (__mmap, mmap)
diff --git a/sysdeps/unix/sysv/linux/i386/mmap.c b/sysdeps/unix/sysv/linux/i386/mmap.c
new file mode 100644
index 0000000..d6b69c8
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/mmap.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <sysdep.h>
+
+#ifndef MMAP_PAGE_SHIFT
+#define MMAP_PAGE_SHIFT 12
+#endif
+
+__ptr_t
+__mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
+{
+ if (offset & ((1 << MMAP_PAGE_SHIFT) - 1))
+ return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, __ptr_t, -1);
+
+ return INLINE_SYSCALL_RETURN (mmap2, 6, __ptr_t, addr, len, prot,
+ flags, fd, offset >> MMAP_PAGE_SHIFT);
+}
+
+weak_alias (__mmap, mmap)
diff --git a/sysdeps/unix/sysv/linux/i386/mmap64.S b/sysdeps/unix/sysv/linux/i386/mmap64.S
deleted file mode 100644
index 3cf6eb9..0000000
--- a/sysdeps/unix/sysv/linux/i386/mmap64.S
+++ /dev/null
@@ -1,116 +0,0 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-#define EINVAL 22
-#define ENOSYS 38
-
-#define SVRSP 16 /* saved register space */
-#define PARMS 4+SVRSP /* space for 4 saved regs */
-#define ADDR PARMS
-#define LEN ADDR+4
-#define PROT LEN+4
-#define FLAGS PROT+4
-#define FD FLAGS+4
-#define OFFLO FD+4
-#define OFFHI OFFLO+4
-
- .text
-ENTRY (__mmap64)
-
- /* Save registers. */
- pushl %ebp
- cfi_adjust_cfa_offset (4)
- pushl %ebx
- cfi_adjust_cfa_offset (4)
- pushl %esi
- cfi_adjust_cfa_offset (4)
- pushl %edi
- cfi_adjust_cfa_offset (4)
-
- movl OFFLO(%esp), %edx
- movl OFFHI(%esp), %ecx
- testl $0xfff, %edx
- jne L(einval)
- shrdl $12, %ecx, %edx /* mmap2 takes the offset in pages. */
- shrl $12, %ecx
- jne L(einval)
- movl %edx, %ebp
- cfi_rel_offset (ebp, 12)
-
- movl ADDR(%esp), %ebx
- cfi_rel_offset (ebx, 8)
- movl LEN(%esp), %ecx
- movl PROT(%esp), %edx
- movl FLAGS(%esp), %esi
- cfi_rel_offset (esi, 4)
- movl FD(%esp), %edi
- cfi_rel_offset (edi, 0)
-
- movl $SYS_ify(mmap2), %eax /* System call number in %eax. */
-
- /* Do the system call trap. */
-L(do_syscall):
- ENTER_KERNEL
-
- /* Restore registers. */
- popl %edi
- cfi_adjust_cfa_offset (-4)
- cfi_restore (edi)
- popl %esi
- cfi_adjust_cfa_offset (-4)
- cfi_restore (esi)
- popl %ebx
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebx)
- popl %ebp
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebp)
-
- /* If 0 > %eax > -4096 there was an error. */
- cmpl $-4096, %eax
- ja SYSCALL_ERROR_LABEL
-
- /* Successful; return the syscall's value. */
- ret
-
- cfi_adjust_cfa_offset (16)
- cfi_rel_offset (ebp, 12)
- cfi_rel_offset (ebx, 8)
- cfi_rel_offset (esi, 4)
- cfi_rel_offset (edi, 0)
- /* This means the offset value is too large. */
-L(einval):
- popl %edi
- cfi_adjust_cfa_offset (-4)
- cfi_restore (edi)
- popl %esi
- cfi_adjust_cfa_offset (-4)
- cfi_restore (esi)
- popl %ebx
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebx)
- popl %ebp
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebp)
- movl $-EINVAL, %eax
- jmp SYSCALL_ERROR_LABEL
-
-PSEUDO_END (__mmap64)
-
-weak_alias (__mmap64, mmap64)
diff --git a/sysdeps/unix/sysv/linux/i386/semtimedop.S b/sysdeps/unix/sysv/linux/i386/semtimedop.S
deleted file mode 100644
index 80477b7..0000000
--- a/sysdeps/unix/sysv/linux/i386/semtimedop.S
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Copyright (C) 2003-2015 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-#define SYSOP_semtimedop 4
-
-#define SVRSP 12 /* saved register space */
-#define PARMS 4+SVRSP /* space for 3 saved regs */
-#define SEMID PARMS
-#define SOPS SEMID+4
-#define NSOPS SOPS+4
-#define TIMEOUT NSOPS+4
-
- .text
-ENTRY (semtimedop)
-
- pushl %ebp
- cfi_adjust_cfa_offset (4)
- pushl %ebx
- cfi_adjust_cfa_offset (4)
- pushl %edi
- cfi_adjust_cfa_offset (4)
-
- movl $SYSOP_semtimedop, %ebx
- cfi_rel_offset (ebx, 4)
- movl SEMID(%esp), %ecx
- movl NSOPS(%esp), %edx
- movl SOPS(%esp), %edi
- cfi_rel_offset (edi, 0)
- movl TIMEOUT(%esp), %ebp
- cfi_rel_offset (ebp, 8)
- movl $__NR_ipc, %eax
-
- ENTER_KERNEL
-
- /* Restore registers. */
- popl %edi
- cfi_adjust_cfa_offset (-4)
- cfi_restore (edi)
- popl %ebx
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebx)
- popl %ebp
- cfi_adjust_cfa_offset (-4)
- cfi_restore (ebp)
-
- /* If 0 > %eax > -4096 there was an error. */
- cmpl $-4096, %eax
- ja SYSCALL_ERROR_LABEL
-
- /* Successful; return the syscall's value. */
- ret
-
-#ifdef PIC
- .align 4
-#endif
-PSEUDO_END (semtimedop)
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=27179a6db34906becc3723e8bc09bc68698e1d37
commit 27179a6db34906becc3723e8bc09bc68698e1d37
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Aug 12 09:13:29 2015 -0700
Optimize i386 syscall inlining
Define INLINE_SYSCALL_RETURN and INLINE_SYSCALL_ERROR_RETURN so
that i386 can optimize setting errno by branching to the internal
__syscall_error without PLT.
Since GCC 5 and above can properly spill %ebx when needed, we can inline
syscalls with 6 arguments if GCC 5 or above is used to compile glibc.
This patch rewrites INTERNAL_SYSCALL macros and skips __libc_do_syscall
for GCC 5.
For sysdeps/unix/sysv/linux/i386/brk.c, with -O2 -march=i686
-mtune=generic, GCC 5.2 now generates:
<__brk>:
0: push %ebx
1: mov $0x2d,%eax
6: mov 0x8(%esp),%ebx
a: call b <__brk+0xb> b: R_386_PC32 __x86.get_pc_thunk.dx
f: add $0x2,%edx 11: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
15: call *%gs:0x10
1c: mov 0x0(%edx),%edx 1e: R_386_GOT32 __curbrk
22: cmp %eax,%ebx
24: mov %eax,(%edx)
26: ja 30 <__brk+0x30>
28: xor %eax,%eax
2a: pop %ebx
2b: ret
instead of
<__brk>:
0: push %ebx
1: mov 0x8(%esp),%ecx
5: call 6 <__brk+0x6> 6: R_386_PC32 __x86.get_pc_thunk.bx
a: add $0x2,%ebx c: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
10: xchg %ecx,%ebx
12: mov $0x2d,%eax
17: call *%gs:0x10
1e: xchg %ecx,%ebx
20: mov %eax,%edx
22: mov 0x0(%ebx),%eax 24: R_386_GOT32 __curbrk
28: mov %edx,(%eax)
2a: xor %eax,%eax
2c: cmp %edx,%ecx
2e: ja 38 <__brk+0x38>
30: pop %ebx
31: ret
The new one is shorter by 2 instructions.
* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) == csu]
(sysdep-dl-routines): Add sysdep.
[$(subdir) == nptl] (libpthread-routines): Likewise.
[$(subdir) == rt] (librt-routines): Likewise.
* sysdeps/unix/sysv/linux/i386/brk.c (__brk): Add
INTERNAL_SYSCALL_DECL. Use INLINE_SYSCALL_ERROR_RETURN.
* sysdeps/unix/sysv/linux/i386/clone.S (__clone): Don't check
PIC when branching to SYSCALL_ERROR_LABEL.
* sysdeps/unix/sysv/linux/i386/fcntl.c (__fcntl_nocancel): Use
INLINE_SYSCALL_RETURN and INLINE_SYSCALL_ERROR_RETURN.
(__libc_fcntl): Likewise.
* sysdeps/unix/sysv/linux/i386/fxstat.c (__fxstat): Likewise.
* sysdeps/unix/sysv/linux/i386/fxstatat.c (__fxstatat):
Likewise.
* sysdeps/unix/sysv/linux/i386/getmsg.c (getmsg): Likewise.
* sysdeps/unix/sysv/linux/i386/lockf64.c (lockf64): Likewise.
* sysdeps/unix/sysv/linux/i386/lxstat.c (__lxstat): Likewise.
* sysdeps/unix/sysv/linux/i386/msgctl.c (__old_msgctl):
Likewise.
(__new_msgctl): Likewise.
* sysdeps/unix/sysv/linux/i386/putmsg.c (putmsg): Likewise.
* sysdeps/unix/sysv/linux/i386/semctl.c (__old_semctl):
Likewise.
(__new_semctl): Likewise.
* sysdeps/unix/sysv/linux/i386/setegid.c (setegid): Likewise.
* sysdeps/unix/sysv/linux/i386/seteuid.c (seteuid): Likewise.
* sysdeps/unix/sysv/linux/i386/setgid.c (__setgid): Likewise.
* sysdeps/unix/sysv/linux/i386/setgroups.c (setgroups):
Likewise.
* sysdeps/unix/sysv/linux/i386/setregid.c (__setregid):
Likewise.
* sysdeps/unix/sysv/linux/i386/setresgid.c (__setresgid):
Likewise.
* sysdeps/unix/sysv/linux/i386/setresuid.c (__setresuid):
Likewise.
* sysdeps/unix/sysv/linux/i386/setreuid.c (__setreuid):
Likewise.
* sysdeps/unix/sysv/linux/i386/setuid.c (__setuid): Likewise.
* sysdeps/unix/sysv/linux/i386/shmctl.c (__old_shmctl):
Likewise.
(__new_shmctl): Likewise.
* sysdeps/unix/sysv/linux/i386/sigaction.c (__libc_sigaction):
Likewise.
* sysdeps/unix/sysv/linux/i386/xstat.c (__xstat): Likewise.
* sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
(__libc_do_syscall): Defined only if !__GNUC_PREREQ (5,0).
* sysdeps/unix/sysv/linux/i386/sysdep.S: Removed.
* sysdeps/unix/sysv/linux/i386/sysdep.c: New file.
* sysdeps/unix/sysv/linux/i386/sysdep.h: Define assembler macros
only if !__GNUC_PREREQ (5,0).
(SYSCALL_ERROR_LABEL): Changed to __syscall_error.
(SYSCALL_ERROR_HANDLER): Changed to empty.
(SYSCALL_ERROR_ERRNO): Removed.
(SYSCALL_ERROR_HANDLER_TLS_STORE): Likewise.
(__syscall_error): New prototype.
(INLINE_SYSCALL_RETURN): New.
(INLINE_SYSCALL_ERROR_RETURN): Likewise.
(LOADREGS_0): Likewise.
(ASMARGS_0): Likewise.
(LOADREGS_1): Likewise.
(ASMARGS_1): Likewise.
(LOADREGS_2): Likewise.
(ASMARGS_2): Likewise.
(LOADREGS_3): Likewise.
(ASMARGS_3): Likewise.
(LOADREGS_4): Likewise.
(ASMARGS_4): Likewise.
(LOADREGS_5): Likewise.
(ASMARGS_5): Likewise.
(LOADREGS_6): Likewise.
(ASMARGS_6): Likewise.
(INTERNAL_SYSCALL_MAIN_6): Optimize for GCC 5.
(INTERNAL_SYSCALL_MAIN_INLINE): Likewise.
(INTERNAL_SYSCALL_NCS): Likewise.
diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile
index 80da593..e10d133 100644
--- a/sysdeps/unix/sysv/linux/i386/Makefile
+++ b/sysdeps/unix/sysv/linux/i386/Makefile
@@ -27,3 +27,17 @@ endif
ifeq ($(subdir),stdlib)
gen-as-const-headers += ucontext_i.sym
endif
+
+ifeq ($(subdir),csu)
+sysdep-dl-routines += sysdep
+endif
+
+ifeq ($(subdir),nptl)
+# pull in __syscall_error routine
+libpthread-routines += sysdep
+endif
+
+ifeq ($(subdir),rt)
+# pull in __syscall_error routine
+librt-routines += sysdep
+endif
diff --git a/sysdeps/unix/sysv/linux/i386/brk.c b/sysdeps/unix/sysv/linux/i386/brk.c
index 5b9a0ce..210e178 100644
--- a/sysdeps/unix/sysv/linux/i386/brk.c
+++ b/sysdeps/unix/sysv/linux/i386/brk.c
@@ -31,19 +31,11 @@ weak_alias (__curbrk, ___brk_addr)
int
__brk (void *addr)
{
- void *newbrk;
-
INTERNAL_SYSCALL_DECL (err);
- newbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
-
+ void *newbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
__curbrk = newbrk;
-
if (newbrk < addr)
- {
- __set_errno (ENOMEM);
- return -1;
- }
-
+ return INLINE_SYSCALL_ERROR_RETURN (-ENOMEM, int, -1);
return 0;
}
weak_alias (__brk, brk)
diff --git a/sysdeps/unix/sysv/linux/i386/clone.S b/sysdeps/unix/sysv/linux/i386/clone.S
index 243dbfe..2aafb3a 100644
--- a/sysdeps/unix/sysv/linux/i386/clone.S
+++ b/sysdeps/unix/sysv/linux/i386/clone.S
@@ -47,19 +47,11 @@ ENTRY (__clone)
/* Sanity check arguments. */
movl $-EINVAL,%eax
movl FUNC(%esp),%ecx /* no NULL function pointers */
-#ifdef PIC
- jecxz SYSCALL_ERROR_LABEL
-#else
testl %ecx,%ecx
jz SYSCALL_ERROR_LABEL
-#endif
movl STACK(%esp),%ecx /* no NULL stack pointers */
-#ifdef PIC
- jecxz SYSCALL_ERROR_LABEL
-#else
testl %ecx,%ecx
jz SYSCALL_ERROR_LABEL
-#endif
/* Insert the argument onto the new stack. Make sure the new
thread is started with an alignment of (mod 16). */
diff --git a/sysdeps/unix/sysv/linux/i386/fcntl.c b/sysdeps/unix/sysv/linux/i386/fcntl.c
index 56f4bd1..8c46122 100644
--- a/sysdeps/unix/sysv/linux/i386/fcntl.c
+++ b/sysdeps/unix/sysv/linux/i386/fcntl.c
@@ -34,7 +34,7 @@ __fcntl_nocancel (int fd, int cmd, ...)
arg = va_arg (ap, void *);
va_end (ap);
- return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
+ return INLINE_SYSCALL_RETURN (fcntl64, 3, int, fd, cmd, arg);
}
#endif /* NO_CANCELLATION */
@@ -50,7 +50,7 @@ __libc_fcntl (int fd, int cmd, ...)
va_end (ap);
if ((cmd != F_SETLKW) && (cmd != F_SETLKW64))
- return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
+ return INLINE_SYSCALL_RETURN (fcntl64, 3, int, fd, cmd, arg);
return SYSCALL_CANCEL (fcntl64, fd, cmd, arg);
}
diff --git a/sysdeps/unix/sysv/linux/i386/fxstat.c b/sysdeps/unix/sysv/linux/i386/fxstat.c
index 2f7a8fe..9aa7747 100644
--- a/sysdeps/unix/sysv/linux/i386/fxstat.c
+++ b/sysdeps/unix/sysv/linux/i386/fxstat.c
@@ -37,15 +37,18 @@ __fxstat (int vers, int fd, struct stat *buf)
int result;
if (vers == _STAT_VER_KERNEL)
- return INLINE_SYSCALL (fstat, 2, fd, (struct kernel_stat *) buf);
+ return INLINE_SYSCALL_RETURN (fstat, 2, int, fd,
+ (struct kernel_stat *) buf);
{
struct stat64 buf64;
- result = INLINE_SYSCALL (fstat64, 2, fd, &buf64);
- if (result == 0)
- result = __xstat32_conv (vers, &buf64, buf);
- return result;
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL (fstat64, err, 2, fd, &buf64);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, )))
+ return INLINE_SYSCALL_ERROR_RETURN (result, int, -1);
+ else
+ return __xstat32_conv (vers, &buf64, buf);
}
}
diff --git a/sysdeps/unix/sysv/linux/i386/fxstatat.c b/sysdeps/unix/sysv/linux/i386/fxstatat.c
index 6f3c251..896d688 100644
--- a/sysdeps/unix/sysv/linux/i386/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/i386/fxstatat.c
@@ -42,13 +42,10 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
struct stat64 st64;
result = INTERNAL_SYSCALL (fstatat64, err, 4, fd, file, &st64, flag);
- if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
- return __xstat32_conv (vers, &st64, st);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, )))
+ return INLINE_SYSCALL_ERROR_RETURN (result, int, -1);
else
- {
- __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
- return -1;
- }
+ return __xstat32_conv (vers, &st64, st);
}
libc_hidden_def (__fxstatat)
#ifdef XSTAT_IS_XSTAT64
diff --git a/sysdeps/unix/sysv/linux/i386/getmsg.c b/sysdeps/unix/sysv/linux/i386/getmsg.c
index 255b867..63dd1c9 100644
--- a/sysdeps/unix/sysv/linux/i386/getmsg.c
+++ b/sysdeps/unix/sysv/linux/i386/getmsg.c
@@ -30,7 +30,8 @@ getmsg (fildes, ctlptr, dataptr, flagsp)
struct strbuf *dataptr;
int *flagsp;
{
- return INLINE_SYSCALL (getpmsg, 5, fildes, ctlptr, dataptr, NULL, flagsp);
+ return INLINE_SYSCALL_RETURN (getpmsg, 5, int, fildes, ctlptr,
+ dataptr, NULL, flagsp);
}
#else
# include <streams/getmsg.c>
diff --git a/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S b/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
index af5c6f0..cdef3d5 100644
--- a/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
+++ b/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
@@ -18,6 +18,8 @@
#include <sysdep.h>
+#if !__GNUC_PREREQ (5,0)
+
/* %eax, %ecx, %edx and %esi contain the values expected by the kernel.
%edi points to a structure with the values of %ebx, %edi and %ebp. */
@@ -48,3 +50,4 @@ ENTRY (__libc_do_syscall)
cfi_restore (ebx)
ret
END (__libc_do_syscall)
+#endif
diff --git a/sysdeps/unix/sysv/linux/i386/lockf64.c b/sysdeps/unix/sysv/linux/i386/lockf64.c
index 61fcf22..650aee3 100644
--- a/sysdeps/unix/sysv/linux/i386/lockf64.c
+++ b/sysdeps/unix/sysv/linux/i386/lockf64.c
@@ -29,6 +29,7 @@ lockf64 (int fd, int cmd, off64_t len64)
{
struct flock64 fl64;
int cmd64;
+ int result;
memset ((char *) &fl64, '\0', sizeof (fl64));
fl64.l_whence = SEEK_CUR;
@@ -41,12 +42,13 @@ lockf64 (int fd, int cmd, off64_t len64)
/* Test the lock: return 0 if FD is unlocked or locked by this process;
return -1, set errno to EACCES, if another process holds the lock. */
fl64.l_type = F_RDLCK;
- if (INLINE_SYSCALL (fcntl64, 3, fd, F_GETLK64, &fl64) < 0)
- return -1;
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL (fcntl64, err, 3, fd, F_GETLK64, &fl64);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, )))
+ return INLINE_SYSCALL_ERROR_RETURN (result, int, -1);
if (fl64.l_type == F_UNLCK || fl64.l_pid == __getpid ())
return 0;
- __set_errno (EACCES);
- return -1;
+ return INLINE_SYSCALL_ERROR_RETURN (-EACCES, int, -1);
case F_ULOCK:
fl64.l_type = F_UNLCK;
cmd64 = F_SETLK64;
@@ -61,8 +63,7 @@ lockf64 (int fd, int cmd, off64_t len64)
break;
default:
- __set_errno (EINVAL);
- return -1;
+ return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
}
- return INLINE_SYSCALL (fcntl64, 3, fd, cmd64, &fl64);
+ return INLINE_SYSCALL_RETURN (fcntl64, 3, int, fd, cmd64, &fl64);
}
diff --git a/sysdeps/unix/sysv/linux/i386/lxstat.c b/sysdeps/unix/sysv/linux/i386/lxstat.c
index 0891127..ee599ea 100644
--- a/sysdeps/unix/sysv/linux/i386/lxstat.c
+++ b/sysdeps/unix/sysv/linux/i386/lxstat.c
@@ -38,15 +38,18 @@ __lxstat (int vers, const char *name, struct stat *buf)
int result;
if (vers == _STAT_VER_KERNEL)
- return INLINE_SYSCALL (lstat, 2, name, (struct kernel_stat *) buf);
+ return INLINE_SYSCALL_RETURN (lstat, 2, int, name,
+ (struct kernel_stat *) buf);
{
struct stat64 buf64;
- result = INLINE_SYSCALL (lstat64, 2, name, &buf64);
- if (result == 0)
- result = __xstat32_conv (vers, &buf64, buf);
- return result;
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL (lstat64, err, 2, name, &buf64);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, )))
+ return INLINE_SYSCALL_ERROR_RETURN (result, int, -1);
+ else
+ return __xstat32_conv (vers, &buf64, buf);
}
}
diff --git a/sysdeps/unix/sysv/linux/i386/msgctl.c b/sysdeps/unix/sysv/linux/i386/msgctl.c
index e42f71d..c62de7b 100644
--- a/sysdeps/unix/sysv/linux/i386/msgctl.c
+++ b/sysdeps/unix/sysv/linux/i386/msgctl.c
@@ -55,7 +55,8 @@ int
attribute_compat_text_section
__old_msgctl (int msqid, int cmd, struct __old_msqid_ds *buf)
{
- return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, buf);
+ return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_msgctl, msqid, cmd,
+ 0, buf);
}
compat_symbol (libc, __old_msgctl, msgctl, GLIBC_2_0);
#endif
@@ -63,8 +64,8 @@ compat_symbol (libc, __old_msgctl, msgctl, GLIBC_2_0);
int
__new_msgctl (int msqid, int cmd, struct msqid_ds *buf)
{
- return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl,
- msqid, cmd | __IPC_64, 0, buf);
+ return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_msgctl, msqid,
+ cmd | __IPC_64, 0, buf);
}
versioned_symbol (libc, __new_msgctl, msgctl, GLIBC_2_2);
diff --git a/sysdeps/unix/sysv/linux/i386/putmsg.c b/sysdeps/unix/sysv/linux/i386/putmsg.c
index ab0112d..851b61a 100644
--- a/sysdeps/unix/sysv/linux/i386/putmsg.c
+++ b/sysdeps/unix/sysv/linux/i386/putmsg.c
@@ -30,7 +30,8 @@ putmsg (fildes, ctlptr, dataptr, flags)
const struct strbuf *dataptr;
int flags;
{
- return INLINE_SYSCALL (putpmsg, 5, fildes, ctlptr, dataptr, -1, flags);
+ return INLINE_SYSCALL_RETURN (putpmsg, 5, int, fildes, ctlptr,
+ dataptr, -1, flags);
}
#else
# include <streams/putmsg.c>
diff --git a/sysdeps/unix/sysv/linux/i386/semctl.c b/sysdeps/unix/sysv/linux/i386/semctl.c
index 8f13649..fa9c364 100644
--- a/sysdeps/unix/sysv/linux/i386/semctl.c
+++ b/sysdeps/unix/sysv/linux/i386/semctl.c
@@ -71,8 +71,8 @@ __old_semctl (int semid, int semnum, int cmd, ...)
va_end (ap);
- return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
- &arg);
+ return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_semctl, semid,
+ semnum, cmd, &arg);
}
compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0);
#endif
@@ -90,8 +90,8 @@ __new_semctl (int semid, int semnum, int cmd, ...)
va_end (ap);
- return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
- &arg);
+ return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_semctl, semid,
+ semnum, cmd | __IPC_64, &arg);
}
versioned_symbol (libc, __new_semctl, semctl, GLIBC_2_2);
diff --git a/sysdeps/unix/sysv/linux/i386/setegid.c b/sysdeps/unix/sysv/linux/i386/setegid.c
index 8c39784..7c1efdb 100644
--- a/sysdeps/unix/sysv/linux/i386/setegid.c
+++ b/sysdeps/unix/sysv/linux/i386/setegid.c
@@ -17,23 +17,13 @@
#include <errno.h>
#include <unistd.h>
-#include <setxid.h>
int
-setegid (gid)
- gid_t gid;
+setegid (gid_t gid)
{
- int result;
-
if (gid == (gid_t) ~0)
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- result = INLINE_SETXID_SYSCALL (setresgid32, 3, -1, gid, -1);
-
- return result;
+ return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
+ return INLINE_SYSCALL_RETURN (setresgid32, 3, int, -1, gid, -1);
}
libc_hidden_def (setegid)
diff --git a/sysdeps/unix/sysv/linux/i386/seteuid.c b/sysdeps/unix/sysv/linux/i386/seteuid.c
index d6a7a27..9248ae9 100644
--- a/sysdeps/unix/sysv/linux/i386/seteuid.c
+++ b/sysdeps/unix/sysv/linux/i386/seteuid.c
@@ -17,22 +17,13 @@
#include <errno.h>
#include <unistd.h>
-#include <setxid.h>
int
seteuid (uid_t uid)
{
- int result;
-
if (uid == (uid_t) ~0)
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- result = INLINE_SETXID_SYSCALL (setresuid32, 3, -1, uid, -1);
-
- return result;
+ return INLINE_SYSCALL_ERROR_RETURN (-EINVAL, int, -1);
+ return INLINE_SYSCALL_RETURN (setresuid32, 3, int, -1, uid, -1);
}
libc_hidden_def (seteuid)
diff --git a/sysdeps/unix/sysv/linux/i386/setgid.c b/sysdeps/unix/sysv/linux/i386/setgid.c
index d60d2bd..1ac608d 100644
--- a/sysdeps/unix/sysv/linux/i386/setgid.c
+++ b/sysdeps/unix/sysv/linux/i386/setgid.c
@@ -17,17 +17,12 @@
#include <errno.h>
#include <unistd.h>
-#include <setxid.h>
#include <linux/posix_types.h>
int
__setgid (gid_t gid)
{
- int result;
-
- result = INLINE_SETXID_SYSCALL (setgid32, 1, gid);
-
- return result;
+ return INLINE_SYSCALL_RETURN (setgid32, 1, int, gid);
}
#ifndef __setgid
weak_alias (__setgid, setgid)
diff --git a/sysdeps/unix/sysv/linux/i386/setgroups.c b/sysdeps/unix/sysv/linux/i386/setgroups.c
index aabdcf6..e5a99b7 100644
--- a/sysdeps/unix/sysv/linux/i386/setgroups.c
+++ b/sysdeps/unix/sysv/linux/i386/setgroups.c
@@ -23,7 +23,6 @@
#include <sysdep.h>
#include <sys/syscall.h>
-#include <setxid.h>
#include <linux/posix_types.h>
/* Set the group set for the current user to GROUPS (N of them). For
@@ -32,6 +31,6 @@
int
setgroups (size_t n, const gid_t *groups)
{
- return INLINE_SETXID_SYSCALL (setgroups32, 2, n, groups);
+ return INLINE_SYSCALL_RETURN (setgroups32, 2, int, n, groups);
}
libc_hidden_def (setgroups)
diff --git a/sysdeps/unix/sysv/linux/i386/setregid.c b/sysdeps/unix/sysv/linux/i386/setregid.c
index 865c47b..47efe6c 100644
--- a/sysdeps/unix/sysv/linux/i386/setregid.c
+++ b/sysdeps/unix/sysv/linux/i386/setregid.c
@@ -23,11 +23,7 @@
int
__setregid (gid_t rgid, gid_t egid)
{
- int result;
-
- result = INLINE_SETXID_SYSCALL (setregid32, 2, rgid, egid);
-
- return result;
+ return INLINE_SYSCALL_RETURN (setregid32, 2, int, rgid, egid);
}
#ifndef __setregid
weak_alias (__setregid, setregid)
diff --git a/sysdeps/unix/sysv/linux/i386/setresgid.c b/sysdeps/unix/sysv/linux/i386/setresgid.c
index 9639c52..f14625a 100644
--- a/sysdeps/unix/sysv/linux/i386/setresgid.c
+++ b/sysdeps/unix/sysv/linux/i386/setresgid.c
@@ -24,11 +24,7 @@
int
__setresgid (gid_t rgid, gid_t egid, gid_t sgid)
{
- int result;
-
- result = INLINE_SETXID_SYSCALL (setresgid32, 3, rgid, egid, sgid);
-
- return result;
+ return INLINE_SYSCALL_RETURN (setresgid32, 3, int, rgid, egid, sgid);
}
libc_hidden_def (__setresgid)
#ifndef __setresgid
diff --git a/sysdeps/unix/sysv/linux/i386/setresuid.c b/sysdeps/unix/sysv/linux/i386/setresuid.c
index f7e4107..b4151f2 100644
--- a/sysdeps/unix/sysv/linux/i386/setresuid.c
+++ b/sysdeps/unix/sysv/linux/i386/setresuid.c
@@ -24,11 +24,7 @@
int
__setresuid (uid_t ruid, uid_t euid, uid_t suid)
{
- int result;
-
- result = INLINE_SETXID_SYSCALL (setresuid32, 3, ruid, euid, suid);
-
- return result;
+ return INLINE_SYSCALL_RETURN (setresuid32, 3, int, ruid, euid, suid);
}
libc_hidden_def (__setresuid)
#ifndef __setresuid
diff --git a/sysdeps/unix/sysv/linux/i386/setreuid.c b/sysdeps/unix/sysv/linux/i386/setreuid.c
index af3c5b4..73358b3 100644
--- a/sysdeps/unix/sysv/linux/i386/setreuid.c
+++ b/sysdeps/unix/sysv/linux/i386/setreuid.c
@@ -24,11 +24,7 @@
int
__setreuid (uid_t ruid, uid_t euid)
{
- int result;
-
- result = INLINE_SETXID_SYSCALL (setreuid32, 2, ruid, euid);
-
- return result;
+ return INLINE_SYSCALL_RETURN (setreuid32, 2, int, ruid, euid);
}
#ifndef __setreuid
weak_alias (__setreuid, setreuid)
diff --git a/sysdeps/unix/sysv/linux/i386/setuid.c b/sysdeps/unix/sysv/linux/i386/setuid.c
index ce6016e..103047c 100644
--- a/sysdeps/unix/sysv/linux/i386/setuid.c
+++ b/sysdeps/unix/sysv/linux/i386/setuid.c
@@ -24,11 +24,7 @@
int
__setuid (uid_t uid)
{
- int result;
-
- result = INLINE_SETXID_SYSCALL (setuid32, 1, uid);
-
- return result;
+ return INLINE_SYSCALL_RETURN (setuid32, 1, int, uid);
}
#ifndef __setuid
weak_alias (__setuid, setuid)
diff --git a/sysdeps/unix/sysv/linux/i386/shmctl.c b/sysdeps/unix/sysv/linux/i386/shmctl.c
index eeb4453..0fea8ae 100644
--- a/sysdeps/unix/sysv/linux/i386/shmctl.c
+++ b/sysdeps/unix/sysv/linux/i386/shmctl.c
@@ -62,7 +62,8 @@ int
attribute_compat_text_section
__old_shmctl (int shmid, int cmd, struct __old_shmid_ds *buf)
{
- return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, buf);
+ return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_shmctl, shmid,
+ cmd, 0, buf);
}
compat_symbol (libc, __old_shmctl, shmctl, GLIBC_2_0);
#endif
@@ -70,8 +71,8 @@ compat_symbol (libc, __old_shmctl, shmctl, GLIBC_2_0);
int
__new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
{
- return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl,
- shmid, cmd | __IPC_64, 0, buf);
+ return INLINE_SYSCALL_RETURN (ipc, 5, int, IPCOP_shmctl, shmid,
+ cmd | __IPC_64, 0, buf);
}
versioned_symbol (libc, __new_shmctl, shmctl, GLIBC_2_2);
diff --git a/sysdeps/unix/sysv/linux/i386/sigaction.c b/sysdeps/unix/sysv/linux/i386/sigaction.c
index b20a9b9..f48170d 100644
--- a/sysdeps/unix/sysv/linux/i386/sigaction.c
+++ b/sysdeps/unix/sysv/linux/i386/sigaction.c
@@ -69,11 +69,13 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
/* XXX The size argument hopefully will have to be changed to the
real size of the user-level sigset_t. */
- result = INLINE_SYSCALL (rt_sigaction, 4,
- sig, act ? &kact : NULL,
- oact ? &koact : NULL, _NSIG / 8);
-
- if (oact && result >= 0)
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL (rt_sigaction, err, 4,
+ sig, act ? &kact : NULL,
+ oact ? &koact : NULL, _NSIG / 8);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, )))
+ return INLINE_SYSCALL_ERROR_RETURN (result, int, -1);
+ else if (oact && result >= 0)
{
oact->sa_handler = koact.k_sa_handler;
memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.S b/sysdeps/unix/sysv/linux/i386/sysdep.S
deleted file mode 100644
index 4e6c262..0000000
--- a/sysdeps/unix/sysv/linux/i386/sysdep.S
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-/* The following code is only used in the shared library when we
- compile the reentrant version. Otherwise each system call defines
- each own version. */
-
-#ifndef PIC
-
-/* The syscall stubs jump here when they detect an error.
- The code for Linux is almost identical to the canonical Unix/i386
- code, except that the error number in %eax is negated. */
-
-#undef CALL_MCOUNT
-#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %eax. */
-
- .text
-ENTRY (__syscall_error)
- negl %eax
-
-#define __syscall_error __syscall_error_1
-#include <sysdeps/unix/i386/sysdep.S>
-
-#endif /* !PIC */
diff --git a/sysdeps/unix/sysv/linux/i386/setregid.c b/sysdeps/unix/sysv/linux/i386/sysdep.c
similarity index 68%
copy from sysdeps/unix/sysv/linux/i386/setregid.c
copy to sysdeps/unix/sysv/linux/i386/sysdep.c
index 865c47b..2fcc6f8 100644
--- a/sysdeps/unix/sysv/linux/i386/setregid.c
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,19 +16,15 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
-#include <unistd.h>
-#include <setxid.h>
-#include <linux/posix_types.h>
-
+#include <sysdep.h>
+
+/* This routine is jumped to by all the syscall handlers, to stash
+ an error number into errno. ERROR is the negative error number
+ returned from the x86 kernel. */
int
-__setregid (gid_t rgid, gid_t egid)
+__attribute__ ((__regparm__ (1)))
+__syscall_error (int error)
{
- int result;
-
- result = INLINE_SETXID_SYSCALL (setregid32, 2, rgid, egid);
-
- return result;
+ __set_errno (-error);
+ return -1;
}
-#ifndef __setregid
-weak_alias (__setregid, setregid)
-#endif
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index d76aca5..aacf371 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -55,11 +55,7 @@
/* We don't want the label for the error handle to be global when we define
it here. */
-#ifdef PIC
-# define SYSCALL_ERROR_LABEL 0f
-#else
-# define SYSCALL_ERROR_LABEL syscall_error
-#endif
+#define SYSCALL_ERROR_LABEL __syscall_error
#undef PSEUDO
#define PSEUDO(name, syscall_name, args) \
@@ -100,55 +96,7 @@
#define ret_ERRVAL ret
-#ifndef PIC
-# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
-#else
-
-# if RTLD_PRIVATE_ERRNO
-# define SYSCALL_ERROR_HANDLER \
-0:SETUP_PIC_REG(cx); \
- addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
- negl %eax; \
- movl %eax, rtld_errno@GOTOFF(%ecx); \
- orl $-1, %eax; \
- ret;
-
-# elif defined _LIBC_REENTRANT
-
-# if IS_IN (libc)
-# define SYSCALL_ERROR_ERRNO __libc_errno
-# else
-# define SYSCALL_ERROR_ERRNO errno
-# endif
-# define SYSCALL_ERROR_HANDLER \
-0:SETUP_PIC_REG (cx); \
- addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
- movl SYSCALL_ERROR_ERRNO@GOTNTPOFF(%ecx), %ecx; \
- negl %eax; \
- SYSCALL_ERROR_HANDLER_TLS_STORE (%eax, %ecx); \
- orl $-1, %eax; \
- ret;
-# ifndef NO_TLS_DIRECT_SEG_REFS
-# define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
- movl src, %gs:(destoff)
-# else
-# define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
- addl %gs:0, destoff; \
- movl src, (destoff)
-# endif
-# else
-/* Store (- %eax) into errno through the GOT. */
-# define SYSCALL_ERROR_HANDLER \
-0:SETUP_PIC_REG(cx); \
- addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
- negl %eax; \
- movl errno@GOT(%ecx), %ecx; \
- movl %eax, (%ecx); \
- orl $-1, %eax; \
- ret;
-# endif /* _LIBC_REENTRANT */
-#endif /* PIC */
-
+#define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.c is used. */
/* The original calling convention for system calls on Linux/i386 is
to use int $0x80. */
@@ -275,6 +223,10 @@
#else /* !__ASSEMBLER__ */
+extern int __syscall_error (int)
+ attribute_hidden __attribute__ ((__regparm__ (1)));
+
+#if !__GNUC_PREREQ (5,0)
/* We need some help from the assembler to generate optimal code. We
define some macros here which later will be used. */
asm (".L__X'%ebx = 1\n\t"
@@ -314,6 +266,7 @@ struct libc_do_syscall_args
{
int ebx, edi, ebp;
};
+#endif
/* Define a macro which expands inline into the wrapper code for a system
call. */
@@ -328,6 +281,29 @@ struct libc_do_syscall_args
} \
(int) resultvar; })
+/* Similar to INLINE_SYSCALL, but with return type. It should only be
+ used with function return. */
+#undef INLINE_SYSCALL_RETURN
+#define INLINE_SYSCALL_RETURN(name, nr, type, args...) \
+ ({ \
+ unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
+ return INLINE_SYSCALL_ERROR_RETURN (resultvar, type, -1); \
+ (type) resultvar; \
+ }) \
+
+/* Set error number and return value. It should only be used with
+ function return. __syscall_error is for tail call from syscall
+ error. It is OK to tail call __syscall_error instead of returning
+ the user provided return value for syscall error. */
+#undef INLINE_SYSCALL_ERROR_RETURN
+#define INLINE_SYSCALL_ERROR_RETURN(resultvar, type, value) \
+ ({ \
+ _Static_assert ((type) -1 == (type) (value), \
+ "syscall error return is not -1"); \
+ (type) __syscall_error (resultvar); \
+ }) \
+
/* List of system calls which are supported as vsyscalls. */
# define HAVE_CLOCK_GETTIME_VSYSCALL 1
# define HAVE_GETTIMEOFDAY_VSYSCALL 1
@@ -354,8 +330,12 @@ struct libc_do_syscall_args
INTERNAL_SYSCALL_MAIN_INLINE(name, err, 5, args)
/* Each object using 6-argument inline syscalls must include a
definition of __libc_do_syscall. */
-#define INTERNAL_SYSCALL_MAIN_6(name, err, arg1, arg2, arg3, \
- arg4, arg5, arg6) \
+#if __GNUC_PREREQ (5,0)
+# define INTERNAL_SYSCALL_MAIN_6(name, err, args...) \
+ INTERNAL_SYSCALL_MAIN_INLINE(name, err, 6, args)
+#else /* GCC 5 */
+# define INTERNAL_SYSCALL_MAIN_6(name, err, arg1, arg2, arg3, \
+ arg4, arg5, arg6) \
struct libc_do_syscall_args _xv = \
{ \
(int) (arg1), \
@@ -368,14 +348,52 @@ struct libc_do_syscall_args
: "=a" (resultvar) \
: "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \
: "memory", "cc")
+#endif /* GCC 5 */
#define INTERNAL_SYSCALL(name, err, nr, args...) \
({ \
register unsigned int resultvar; \
INTERNAL_SYSCALL_MAIN_##nr (name, err, args); \
(int) resultvar; })
#ifdef I386_USE_SYSENTER
-# ifdef SHARED
-# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+# if __GNUC_PREREQ (5,0)
+# ifdef SHARED
+# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+ LOADREGS_##nr(args) \
+ asm volatile ( \
+ "call *%%gs:%P2" \
+ : "=a" (resultvar) \
+ : "a" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo)) \
+ ASMARGS_##nr(args) : "memory", "cc")
+# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+ ({ \
+ register unsigned int resultvar; \
+ LOADREGS_##nr(args) \
+ asm volatile ( \
+ "call *%%gs:%P2" \
+ : "=a" (resultvar) \
+ : "a" (name), "i" (offsetof (tcbhead_t, sysinfo)) \
+ ASMARGS_##nr(args) : "memory", "cc"); \
+ (int) resultvar; })
+# else
+# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+ LOADREGS_##nr(args) \
+ asm volatile ( \
+ "call *_dl_sysinfo" \
+ : "=a" (resultvar) \
+ : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
+# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+ ({ \
+ register unsigned int resultvar; \
+ LOADREGS_##nr(args) \
+ asm volatile ( \
+ "call *_dl_sysinfo" \
+ : "=a" (resultvar) \
+ : "a" (name) ASMARGS_##nr(args) : "memory", "cc"); \
+ (int) resultvar; })
+# endif
+# else /* GCC 5 */
+# ifdef SHARED
+# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
EXTRAVAR_##nr \
asm volatile ( \
LOADARGS_##nr \
@@ -385,7 +403,7 @@ struct libc_do_syscall_args
: "=a" (resultvar) \
: "i" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo)) \
ASMFMT_##nr(args) : "memory", "cc")
-# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
({ \
register unsigned int resultvar; \
EXTRAVAR_##nr \
@@ -397,8 +415,8 @@ struct libc_do_syscall_args
: "0" (name), "i" (offsetof (tcbhead_t, sysinfo)) \
ASMFMT_##nr(args) : "memory", "cc"); \
(int) resultvar; })
-# else
-# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+# else
+# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
EXTRAVAR_##nr \
asm volatile ( \
LOADARGS_##nr \
@@ -407,7 +425,7 @@ struct libc_do_syscall_args
RESTOREARGS_##nr \
: "=a" (resultvar) \
: "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
-# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
({ \
register unsigned int resultvar; \
EXTRAVAR_##nr \
@@ -418,9 +436,27 @@ struct libc_do_syscall_args
: "=a" (resultvar) \
: "0" (name) ASMFMT_##nr(args) : "memory", "cc"); \
(int) resultvar; })
-# endif
+# endif
+# endif /* GCC 5 */
#else
-# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+# if __GNUC_PREREQ (5,0)
+# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
+ LOADREGS_##nr(args) \
+ asm volatile ( \
+ "int $0x80" \
+ : "=a" (resultvar) \
+ : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
+# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+ ({ \
+ register unsigned int resultvar; \
+ LOADREGS_##nr(args) \
+ asm volatile ( \
+ "int $0x80" \
+ : "=a" (resultvar) \
+ : "a" (name) ASMARGS_##nr(args) : "memory", "cc"); \
+ (int) resultvar; })
+# else /* GCC 5 */
+# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
EXTRAVAR_##nr \
asm volatile ( \
LOADARGS_##nr \
@@ -429,7 +465,7 @@ struct libc_do_syscall_args
RESTOREARGS_##nr \
: "=a" (resultvar) \
: "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
-# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
({ \
register unsigned int resultvar; \
EXTRAVAR_##nr \
@@ -440,6 +476,7 @@ struct libc_do_syscall_args
: "=a" (resultvar) \
: "0" (name) ASMFMT_##nr(args) : "memory", "cc"); \
(int) resultvar; })
+# endif /* GCC 5 */
#endif
#undef INTERNAL_SYSCALL_DECL
@@ -504,6 +541,36 @@ struct libc_do_syscall_args
# define RESTOREARGS_5
#endif
+#if __GNUC_PREREQ (5,0)
+# define LOADREGS_0()
+# define ASMARGS_0()
+# define LOADREGS_1(arg1) \
+ LOADREGS_0 ()
+# define ASMARGS_1(arg1) \
+ ASMARGS_0 (), "b" ((unsigned int) (arg1))
+# define LOADREGS_2(arg1, arg2) \
+ LOADREGS_1 (arg1)
+# define ASMARGS_2(arg1, arg2) \
+ ASMARGS_1 (arg1), "c" ((unsigned int) (arg2))
+# define LOADREGS_3(arg1, arg2, arg3) \
+ LOADREGS_2 (arg1, arg2)
+# define ASMARGS_3(arg1, arg2, arg3) \
+ ASMARGS_2 (arg1, arg2), "d" ((unsigned int) (arg3))
+# define LOADREGS_4(arg1, arg2, arg3, arg4) \
+ LOADREGS_3 (arg1, arg2, arg3)
+# define ASMARGS_4(arg1, arg2, arg3, arg4) \
+ ASMARGS_3 (arg1, arg2, arg3), "S" ((unsigned int) (arg4))
+# define LOADREGS_5(arg1, arg2, arg3, arg4, arg5) \
+ LOADREGS_4 (arg1, arg2, arg3, arg4)
+# define ASMARGS_5(arg1, arg2, arg3, arg4, arg5) \
+ ASMARGS_4 (arg1, arg2, arg3, arg4), "D" ((unsigned int) (arg5))
+# define LOADREGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+ register unsigned int _a6 asm ("ebp") = (unsigned int) (arg6); \
+ LOADREGS_5 (arg1, arg2, arg3, arg4, arg5)
+# define ASMARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
+ ASMARGS_5 (arg1, arg2, arg3, arg4, arg5), "r" (_a6)
+#endif /* GCC 5 */
+
#define ASMFMT_0()
#ifdef __PIC__
# define ASMFMT_1(arg1) \
diff --git a/sysdeps/unix/sysv/linux/i386/xstat.c b/sysdeps/unix/sysv/linux/i386/xstat.c
index 2424434..f6fc6a4 100644
--- a/sysdeps/unix/sysv/linux/i386/xstat.c
+++ b/sysdeps/unix/sysv/linux/i386/xstat.c
@@ -38,15 +38,18 @@ __xstat (int vers, const char *name, struct stat *buf)
int result;
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);
{
struct stat64 buf64;
- result = INLINE_SYSCALL (stat64, 2, name, &buf64);
- if (result == 0)
- result = __xstat32_conv (vers, &buf64, buf);
- return result;
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL (stat64, err, 2, name, &buf64);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (result, )))
+ return INLINE_SYSCALL_ERROR_RETURN (result, int, -1);
+ else
+ return __xstat32_conv (vers, &buf64, buf);
}
}
hidden_def (__xstat)
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources