* [PATCH] i386: Assembly Implementation cleanup
@ 2015-07-03 15:41 Adhemerval Zanella
2015-07-09 18:58 ` Adhemerval Zanella
2015-08-12 0:22 ` H.J. Lu
0 siblings, 2 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2015-07-03 15:41 UTC (permalink / raw)
To: GNU C Library
This patch removes i386 assembly implementation for epoll_wait, mmap,
mmap64, semtimeop now that i386 have 6 argument syscall support from
C code.
The mmap implementation used is the wordsize-32 generic linux one.
Tested in i386.
---
* 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/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..2cb4907
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/mmap.c
@@ -0,0 +1,18 @@
+/* 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 <sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c>
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)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-07-03 15:41 [PATCH] i386: Assembly Implementation cleanup Adhemerval Zanella
@ 2015-07-09 18:58 ` Adhemerval Zanella
2015-08-11 18:49 ` Adhemerval Zanella
2015-08-12 0:22 ` H.J. Lu
1 sibling, 1 reply; 19+ messages in thread
From: Adhemerval Zanella @ 2015-07-09 18:58 UTC (permalink / raw)
To: GNU C Library
Ping.
On 03-07-2015 12:41, Adhemerval Zanella wrote:
> This patch removes i386 assembly implementation for epoll_wait, mmap,
> mmap64, semtimeop now that i386 have 6 argument syscall support from
> C code.
>
> The mmap implementation used is the wordsize-32 generic linux one.
>
> Tested in i386.
>
> ---
>
> * 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/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..2cb4907
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/i386/mmap.c
> @@ -0,0 +1,18 @@
> +/* 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 <sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c>
> 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)
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-07-09 18:58 ` Adhemerval Zanella
@ 2015-08-11 18:49 ` Adhemerval Zanella
0 siblings, 0 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2015-08-11 18:49 UTC (permalink / raw)
To: GNU C Library; +Cc: H.J. Lu
Ping.
On 09-07-2015 15:58, Adhemerval Zanella wrote:
> Ping.
>
> On 03-07-2015 12:41, Adhemerval Zanella wrote:
>> This patch removes i386 assembly implementation for epoll_wait, mmap,
>> mmap64, semtimeop now that i386 have 6 argument syscall support from
>> C code.
>>
>> The mmap implementation used is the wordsize-32 generic linux one.
>>
>> Tested in i386.
>>
>> ---
>>
>> * 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/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..2cb4907
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/i386/mmap.c
>> @@ -0,0 +1,18 @@
>> +/* 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 <sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c>
>> 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)
>>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-07-03 15:41 [PATCH] i386: Assembly Implementation cleanup Adhemerval Zanella
2015-07-09 18:58 ` Adhemerval Zanella
@ 2015-08-12 0:22 ` H.J. Lu
2015-08-12 12:38 ` Adhemerval Zanella
2015-08-12 13:07 ` Torvald Riegel
1 sibling, 2 replies; 19+ messages in thread
From: H.J. Lu @ 2015-08-12 0:22 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: GNU C Library
On Fri, Jul 3, 2015 at 8:41 AM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
> This patch removes i386 assembly implementation for epoll_wait, mmap,
> mmap64, semtimeop now that i386 have 6 argument syscall support from
> C code.
>
> The mmap implementation used is the wordsize-32 generic linux one.
>
> Tested in i386.
>
> ---
>
> * 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.
>
What is the motivation? 6 argument syscalls aren't really inlined.
They put arguments on stack and call __libc_do_syscall. It is
slower than assembly code.
--
H.J.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 0:22 ` H.J. Lu
@ 2015-08-12 12:38 ` Adhemerval Zanella
2015-08-12 12:44 ` H.J. Lu
2015-08-12 13:07 ` Torvald Riegel
1 sibling, 1 reply; 19+ messages in thread
From: Adhemerval Zanella @ 2015-08-12 12:38 UTC (permalink / raw)
To: H.J. Lu; +Cc: GNU C Library
On 11-08-2015 21:22, H.J. Lu wrote:
> On Fri, Jul 3, 2015 at 8:41 AM, Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>> This patch removes i386 assembly implementation for epoll_wait, mmap,
>> mmap64, semtimeop now that i386 have 6 argument syscall support from
>> C code.
>>
>> The mmap implementation used is the wordsize-32 generic linux one.
>>
>> Tested in i386.
>>
>> ---
>>
>> * 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.
>>
>
> What is the motivation? 6 argument syscalls aren't really inlined.
> They put arguments on stack and call __libc_do_syscall. It is
> slower than assembly code.
>
Same for ARM: code maintainability on functions that are not really
performance-critical. This avoids issues like the x86 pthread_cond_*
assembly implementation (which are now aimed to be removed), that
required specific fixes just for x86.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 12:38 ` Adhemerval Zanella
@ 2015-08-12 12:44 ` H.J. Lu
2015-08-12 13:58 ` Adhemerval Zanella
2015-08-12 15:01 ` Florian Weimer
0 siblings, 2 replies; 19+ messages in thread
From: H.J. Lu @ 2015-08-12 12:44 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: GNU C Library
On Wed, Aug 12, 2015 at 5:38 AM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
> On 11-08-2015 21:22, H.J. Lu wrote:
>> On Fri, Jul 3, 2015 at 8:41 AM, Adhemerval Zanella
>> <adhemerval.zanella@linaro.org> wrote:
>>> This patch removes i386 assembly implementation for epoll_wait, mmap,
>>> mmap64, semtimeop now that i386 have 6 argument syscall support from
>>> C code.
>>>
>>> The mmap implementation used is the wordsize-32 generic linux one.
>>>
>>> Tested in i386.
>>>
>>> ---
>>>
>>> * 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.
>>>
>>
>> What is the motivation? 6 argument syscalls aren't really inlined.
>> They put arguments on stack and call __libc_do_syscall. It is
>> slower than assembly code.
>>
>
> Same for ARM: code maintainability on functions that are not really
> performance-critical. This avoids issues like the x86 pthread_cond_*
> assembly implementation (which are now aimed to be removed), that
> required specific fixes just for x86.
Is there a way to truly inline syscall with 6 arguments, not by calling
__libc_do_syscall?
--
H.J.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 0:22 ` H.J. Lu
2015-08-12 12:38 ` Adhemerval Zanella
@ 2015-08-12 13:07 ` Torvald Riegel
1 sibling, 0 replies; 19+ messages in thread
From: Torvald Riegel @ 2015-08-12 13:07 UTC (permalink / raw)
To: H.J. Lu; +Cc: Adhemerval Zanella, GNU C Library
On Tue, 2015-08-11 at 17:22 -0700, H.J. Lu wrote:
> On Fri, Jul 3, 2015 at 8:41 AM, Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
> > This patch removes i386 assembly implementation for epoll_wait, mmap,
> > mmap64, semtimeop now that i386 have 6 argument syscall support from
> > C code.
> >
> > The mmap implementation used is the wordsize-32 generic linux one.
> >
> > Tested in i386.
> >
> > ---
> >
> > * 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.
> >
>
> What is the motivation? 6 argument syscalls aren't really inlined.
> They put arguments on stack and call __libc_do_syscall. It is
> slower than assembly code.
Does this matter for any of those functions? Are they typically called
on fast paths that would notice that? If not, I think ease of
maintenance is more worthwile.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 12:44 ` H.J. Lu
@ 2015-08-12 13:58 ` Adhemerval Zanella
2015-08-12 14:20 ` Ondřej Bílka
2015-08-12 14:47 ` H.J. Lu
2015-08-12 15:01 ` Florian Weimer
1 sibling, 2 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2015-08-12 13:58 UTC (permalink / raw)
To: H.J. Lu; +Cc: GNU C Library
On 12-08-2015 09:44, H.J. Lu wrote:
> On Wed, Aug 12, 2015 at 5:38 AM, Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>>
>> On 11-08-2015 21:22, H.J. Lu wrote:
>>> On Fri, Jul 3, 2015 at 8:41 AM, Adhemerval Zanella
>>> <adhemerval.zanella@linaro.org> wrote:
>>>> This patch removes i386 assembly implementation for epoll_wait, mmap,
>>>> mmap64, semtimeop now that i386 have 6 argument syscall support from
>>>> C code.
>>>>
>>>> The mmap implementation used is the wordsize-32 generic linux one.
>>>>
>>>> Tested in i386.
>>>>
>>>> ---
>>>>
>>>> * 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.
>>>>
>>>
>>> What is the motivation? 6 argument syscalls aren't really inlined.
>>> They put arguments on stack and call __libc_do_syscall. It is
>>> slower than assembly code.
>>>
>>
>> Same for ARM: code maintainability on functions that are not really
>> performance-critical. This avoids issues like the x86 pthread_cond_*
>> assembly implementation (which are now aimed to be removed), that
>> required specific fixes just for x86.
>
> Is there a way to truly inline syscall with 6 arguments, not by calling
> __libc_do_syscall?
>
I checked around some other projects that implements i386 syscall and
neither seems to have a workaround for this. I also recall that Joseph
has said GCC does not really support to not cobbler the required register,
so that's why he has implemented through a helper function. Anyway, as
Tovarld has asked, I think these are not really heavy hitter (and kernel
implementation is much more complex than the time to save/restore the
register in stack).
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 13:58 ` Adhemerval Zanella
@ 2015-08-12 14:20 ` Ondřej Bílka
2015-08-12 14:47 ` H.J. Lu
1 sibling, 0 replies; 19+ messages in thread
From: Ondřej Bílka @ 2015-08-12 14:20 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: H.J. Lu, GNU C Library
On Wed, Aug 12, 2015 at 10:58:16AM -0300, Adhemerval Zanella wrote:
>
>
> On 12-08-2015 09:44, H.J. Lu wrote:
> > On Wed, Aug 12, 2015 at 5:38 AM, Adhemerval Zanella
> > <adhemerval.zanella@linaro.org> wrote:
> >>
> >>
> >> On 11-08-2015 21:22, H.J. Lu wrote:
> >>> On Fri, Jul 3, 2015 at 8:41 AM, Adhemerval Zanella
> >>> <adhemerval.zanella@linaro.org> wrote:
> >>>> This patch removes i386 assembly implementation for epoll_wait, mmap,
> >>>> mmap64, semtimeop now that i386 have 6 argument syscall support from
> >>>> C code.
> >>>>
> >>>> The mmap implementation used is the wordsize-32 generic linux one.
> >>>>
> >>>> Tested in i386.
> >>>>
> >>>> ---
> >>>>
> >>>> * 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.
> >>>>
> >>>
> >>> What is the motivation? 6 argument syscalls aren't really inlined.
> >>> They put arguments on stack and call __libc_do_syscall. It is
> >>> slower than assembly code.
> >>>
> >>
> >> Same for ARM: code maintainability on functions that are not really
> >> performance-critical. This avoids issues like the x86 pthread_cond_*
> >> assembly implementation (which are now aimed to be removed), that
> >> required specific fixes just for x86.
> >
> > Is there a way to truly inline syscall with 6 arguments, not by calling
> > __libc_do_syscall?
> >
>
> I checked around some other projects that implements i386 syscall and
> neither seems to have a workaround for this. I also recall that Joseph
> has said GCC does not really support to not cobbler the required register,
> so that's why he has implemented through a helper function. Anyway, as
> Tovarld has asked, I think these are not really heavy hitter (and kernel
> implementation is much more complex than the time to save/restore the
> register in stack).
Correct, only questionable is semtimedop that could be made fast by
using vdso to avoid syscall.
For mmap* its 2000+ cycles if we map single page and usually
more so it doesnt't matter. Epoll_pwait will likely block so difference
of assembly is again very small.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 13:58 ` Adhemerval Zanella
2015-08-12 14:20 ` Ondřej Bílka
@ 2015-08-12 14:47 ` H.J. Lu
1 sibling, 0 replies; 19+ messages in thread
From: H.J. Lu @ 2015-08-12 14:47 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: GNU C Library
On Wed, Aug 12, 2015 at 6:58 AM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
> On 12-08-2015 09:44, H.J. Lu wrote:
>> On Wed, Aug 12, 2015 at 5:38 AM, Adhemerval Zanella
>> <adhemerval.zanella@linaro.org> wrote:
>>>
>>>
>>> On 11-08-2015 21:22, H.J. Lu wrote:
>>>> On Fri, Jul 3, 2015 at 8:41 AM, Adhemerval Zanella
>>>> <adhemerval.zanella@linaro.org> wrote:
>>>>> This patch removes i386 assembly implementation for epoll_wait, mmap,
>>>>> mmap64, semtimeop now that i386 have 6 argument syscall support from
>>>>> C code.
>>>>>
>>>>> The mmap implementation used is the wordsize-32 generic linux one.
>>>>>
>>>>> Tested in i386.
>>>>>
>>>>> ---
>>>>>
>>>>> * 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.
>>>>>
>>>>
>>>> What is the motivation? 6 argument syscalls aren't really inlined.
>>>> They put arguments on stack and call __libc_do_syscall. It is
>>>> slower than assembly code.
>>>>
>>>
>>> Same for ARM: code maintainability on functions that are not really
>>> performance-critical. This avoids issues like the x86 pthread_cond_*
>>> assembly implementation (which are now aimed to be removed), that
>>> required specific fixes just for x86.
>>
>> Is there a way to truly inline syscall with 6 arguments, not by calling
>> __libc_do_syscall?
>>
>
> I checked around some other projects that implements i386 syscall and
> neither seems to have a workaround for this. I also recall that Joseph
> has said GCC does not really support to not cobbler the required register,
> so that's why he has implemented through a helper function. Anyway, as
> Tovarld has asked, I think these are not really heavy hitter (and kernel
> implementation is much more complex than the time to save/restore the
> register in stack).
Let me take a look on this.
--
H.J.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 12:44 ` H.J. Lu
2015-08-12 13:58 ` Adhemerval Zanella
@ 2015-08-12 15:01 ` Florian Weimer
2015-08-12 15:06 ` H.J. Lu
2015-08-12 17:04 ` Joseph Myers
1 sibling, 2 replies; 19+ messages in thread
From: Florian Weimer @ 2015-08-12 15:01 UTC (permalink / raw)
To: H.J. Lu, Adhemerval Zanella; +Cc: GNU C Library
On 08/12/2015 02:44 PM, H.J. Lu wrote:
> Is there a way to truly inline syscall with 6 arguments, not by calling
> __libc_do_syscall?
Yes, newer GCC versions are able to spill %ebx just by writing
appropriate constraints.
Test case:
int
doit(int v)
{
int r;
__asm__ ("MAGIC"
: "=r" (r)
: "b" (v));
return r;
}
Compile with â-m32 -fpic -O2â.
Older GCC (4.8.3 in this example):
reg.c: In function âdoitâ:
reg.c:5:3: error: inconsistent operand constraints in an âasmâ
__asm__ ("MAGIC"
^
Newer GCC:
doit:
.LFB0:
.cfi_startproc
pushl %ebx
.cfi_def_cfa_offset 8
.cfi_offset 3, -8
movl 8(%esp), %ebx
#APP
# 5 "/tmp/t.c" 1
MAGIC
# 0 "" 2
#NO_APP
popl %ebx
.cfi_restore 3
.cfi_def_cfa_offset 4
ret
.cfi_endproc
--
Florian Weimer / Red Hat Product Security
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 15:01 ` Florian Weimer
@ 2015-08-12 15:06 ` H.J. Lu
2015-08-12 19:22 ` H.J. Lu
2015-08-12 17:04 ` Joseph Myers
1 sibling, 1 reply; 19+ messages in thread
From: H.J. Lu @ 2015-08-12 15:06 UTC (permalink / raw)
To: Florian Weimer; +Cc: Adhemerval Zanella, GNU C Library
On Wed, Aug 12, 2015 at 8:01 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 08/12/2015 02:44 PM, H.J. Lu wrote:
>
>> Is there a way to truly inline syscall with 6 arguments, not by calling
>> __libc_do_syscall?
>
> Yes, newer GCC versions are able to spill %ebx just by writing
> appropriate constraints.
>
> Test case:
>
> int
> doit(int v)
> {
> int r;
> __asm__ ("MAGIC"
> : "=r" (r)
> : "b" (v));
> return r;
> }
>
> Compile with “-m32 -fpic -O2”.
>
I am working on it now.
--
H.J.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 15:01 ` Florian Weimer
2015-08-12 15:06 ` H.J. Lu
@ 2015-08-12 17:04 ` Joseph Myers
1 sibling, 0 replies; 19+ messages in thread
From: Joseph Myers @ 2015-08-12 17:04 UTC (permalink / raw)
To: Florian Weimer; +Cc: H.J. Lu, Adhemerval Zanella, GNU C Library
On Wed, 12 Aug 2015, Florian Weimer wrote:
> On 08/12/2015 02:44 PM, H.J. Lu wrote:
>
> > Is there a way to truly inline syscall with 6 arguments, not by calling
> > __libc_do_syscall?
>
> Yes, newer GCC versions are able to spill %ebx just by writing
> appropriate constraints.
I don't think that test is really relevant. What's relevant is an asm
that *uses every register other than %esp as an input*, as part of a
larger function that does more than just have the asm. (Or uses every
register either as an input or as a clobber with some arguments coming
from the stack, but that could be less efficient and this discussion seems
to be about optimal code sequences.)
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 15:06 ` H.J. Lu
@ 2015-08-12 19:22 ` H.J. Lu
2015-08-12 20:27 ` Adhemerval Zanella
2015-08-12 20:38 ` Florian Weimer
0 siblings, 2 replies; 19+ messages in thread
From: H.J. Lu @ 2015-08-12 19:22 UTC (permalink / raw)
To: Florian Weimer; +Cc: Adhemerval Zanella, GNU C Library
[-- Attachment #1: Type: text/plain, Size: 480 bytes --]
On Wed, Aug 12, 2015 at 8:06 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Aug 12, 2015 at 8:01 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 08/12/2015 02:44 PM, H.J. Lu wrote:
>>
>>> Is there a way to truly inline syscall with 6 arguments, not by calling
>>> __libc_do_syscall?
>>
With my GCC 5 patch:
https://sourceware.org/ml/libc-alpha/2015-08/msg00477.html
This updated patch will generate optimized code when GCC 5
or above is used. Any comments?
--
H.J.
[-- Attachment #2: 0002-i386-Assembly-Implementation-cleanup.patch --]
[-- Type: text/x-patch, Size: 13177 bytes --]
From 5a53b05a6366ea691eede3eab4d5f6c0cc9d4431 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 12 Aug 2015 12:10:06 -0700
Subject: [PATCH 2/2] i386: Assembly Implementation cleanup
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.
* 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.
---
sysdeps/unix/sysv/linux/i386/Makefile | 9 +++
sysdeps/unix/sysv/linux/i386/epoll_pwait.S | 78 -------------------
sysdeps/unix/sysv/linux/i386/mmap.S | 79 --------------------
sysdeps/unix/sysv/linux/i386/mmap.c | 18 +++++
sysdeps/unix/sysv/linux/i386/mmap64.S | 116 -----------------------------
sysdeps/unix/sysv/linux/i386/semtimedop.S | 73 ------------------
6 files changed, 27 insertions(+), 346 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/i386/epoll_pwait.S
delete mode 100644 sysdeps/unix/sysv/linux/i386/mmap.S
create mode 100644 sysdeps/unix/sysv/linux/i386/mmap.c
delete mode 100644 sysdeps/unix/sysv/linux/i386/mmap64.S
delete mode 100644 sysdeps/unix/sysv/linux/i386/semtimedop.S
diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile
index 80da593..1dc1b1c 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..2cb4907
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/mmap.c
@@ -0,0 +1,18 @@
+/* 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 <sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c>
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)
--
2.4.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 19:22 ` H.J. Lu
@ 2015-08-12 20:27 ` Adhemerval Zanella
2015-08-12 20:38 ` Florian Weimer
1 sibling, 0 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2015-08-12 20:27 UTC (permalink / raw)
To: H.J. Lu, Florian Weimer; +Cc: GNU C Library
LGTM.
On 12-08-2015 16:22, H.J. Lu wrote:
> On Wed, Aug 12, 2015 at 8:06 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Wed, Aug 12, 2015 at 8:01 AM, Florian Weimer <fweimer@redhat.com> wrote:
>>> On 08/12/2015 02:44 PM, H.J. Lu wrote:
>>>
>>>> Is there a way to truly inline syscall with 6 arguments, not by calling
>>>> __libc_do_syscall?
>>>
>
> With my GCC 5 patch:
>
> https://sourceware.org/ml/libc-alpha/2015-08/msg00477.html
>
> This updated patch will generate optimized code when GCC 5
> or above is used. Any comments?
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 19:22 ` H.J. Lu
2015-08-12 20:27 ` Adhemerval Zanella
@ 2015-08-12 20:38 ` Florian Weimer
2015-08-12 20:48 ` Joseph Myers
2015-08-12 22:16 ` H.J. Lu
1 sibling, 2 replies; 19+ messages in thread
From: Florian Weimer @ 2015-08-12 20:38 UTC (permalink / raw)
To: H.J. Lu; +Cc: Adhemerval Zanella, GNU C Library
On 08/12/2015 09:22 PM, H.J. Lu wrote:
> On Wed, Aug 12, 2015 at 8:06 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Wed, Aug 12, 2015 at 8:01 AM, Florian Weimer <fweimer@redhat.com> wrote:
>>> On 08/12/2015 02:44 PM, H.J. Lu wrote:
>>>
>>>> Is there a way to truly inline syscall with 6 arguments, not by calling
>>>> __libc_do_syscall?
>>>
>
> With my GCC 5 patch:
>
> https://sourceware.org/ml/libc-alpha/2015-08/msg00477.html
>
> This updated patch will generate optimized code when GCC 5
> or above is used. Any comments?
I like it. Perhaps you could quote a bit of disassembly in the commit
message?
I would suggest to define a new macro (say,
__usues_many_argument_syscall or something shorter) which expands to
"__attribute__ ((optimize ("omit-frame-pointer), noinline))” on i386 and
apply it to the function in the C source file, instead of adding it to
the makefiles (assuming that this works, I have not tried it). This
way, it would be more explicit what happens. In the documentation of
the new macro, quote a typical GCC error message if a many-argument
system call is used without it.
(There are quite a few -fomit-frame-pointer settings in the makefiles,
some of which are curious.)
--
Florian Weimer / Red Hat Product Security
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 20:38 ` Florian Weimer
@ 2015-08-12 20:48 ` Joseph Myers
2015-08-12 22:16 ` H.J. Lu
1 sibling, 0 replies; 19+ messages in thread
From: Joseph Myers @ 2015-08-12 20:48 UTC (permalink / raw)
To: Florian Weimer; +Cc: H.J. Lu, Adhemerval Zanella, GNU C Library
[-- Attachment #1: Type: text/plain, Size: 784 bytes --]
On Wed, 12 Aug 2015, Florian Weimer wrote:
> I would suggest to define a new macro (say,
> __usues_many_argument_syscall or something shorter) which expands to
> "__attribute__ ((optimize ("omit-frame-pointer), noinline))” on i386 and
> apply it to the function in the C source file, instead of adding it to
> the makefiles (assuming that this works, I have not tried it). This
> way, it would be more explicit what happens. In the documentation of
> the new macro, quote a typical GCC error message if a many-argument
> system call is used without it.
I see several uses of the affected lowlevellock-futex.h macros that aren't
in the files listed in that Makefile change - are they all in files with
separate x86-specific versions?
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 20:38 ` Florian Weimer
2015-08-12 20:48 ` Joseph Myers
@ 2015-08-12 22:16 ` H.J. Lu
2015-08-14 13:17 ` Florian Weimer
1 sibling, 1 reply; 19+ messages in thread
From: H.J. Lu @ 2015-08-12 22:16 UTC (permalink / raw)
To: Florian Weimer; +Cc: Adhemerval Zanella, GNU C Library
On Wed, Aug 12, 2015 at 1:38 PM, Florian Weimer <fweimer@redhat.com> wrote:
> On 08/12/2015 09:22 PM, H.J. Lu wrote:
>> On Wed, Aug 12, 2015 at 8:06 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Wed, Aug 12, 2015 at 8:01 AM, Florian Weimer <fweimer@redhat.com> wrote:
>>>> On 08/12/2015 02:44 PM, H.J. Lu wrote:
>>>>
>>>>> Is there a way to truly inline syscall with 6 arguments, not by calling
>>>>> __libc_do_syscall?
>>>>
>>
>> With my GCC 5 patch:
>>
>> https://sourceware.org/ml/libc-alpha/2015-08/msg00477.html
>>
>> This updated patch will generate optimized code when GCC 5
>> or above is used. Any comments?
>
> I like it. Perhaps you could quote a bit of disassembly in the commit
> message?
See:
https://sourceware.org/ml/libc-alpha/2015-08/msg00492.html
> I would suggest to define a new macro (say,
> __usues_many_argument_syscall or something shorter) which expands to
> "__attribute__ ((optimize ("omit-frame-pointer), noinline))” on i386 and
> apply it to the function in the C source file, instead of adding it to
> the makefiles (assuming that this works, I have not tried it). This
> way, it would be more explicit what happens. In the documentation of
> the new macro, quote a typical GCC error message if a many-argument
> system call is used without it.
>
This only applies to syscalls with 6 arguments. It is easier
to add -fomit-frame-pointer to Makefile than a new macro since
it has to be added by hand for each system call with 6 arguments.
--
H.J.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH] i386: Assembly Implementation cleanup
2015-08-12 22:16 ` H.J. Lu
@ 2015-08-14 13:17 ` Florian Weimer
0 siblings, 0 replies; 19+ messages in thread
From: Florian Weimer @ 2015-08-14 13:17 UTC (permalink / raw)
To: H.J. Lu; +Cc: Adhemerval Zanella, GNU C Library
On 08/13/2015 12:16 AM, H.J. Lu wrote:
> On Wed, Aug 12, 2015 at 1:38 PM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 08/12/2015 09:22 PM, H.J. Lu wrote:
>>> On Wed, Aug 12, 2015 at 8:06 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> On Wed, Aug 12, 2015 at 8:01 AM, Florian Weimer <fweimer@redhat.com> wrote:
>>>>> On 08/12/2015 02:44 PM, H.J. Lu wrote:
>>>>>
>>>>>> Is there a way to truly inline syscall with 6 arguments, not by calling
>>>>>> __libc_do_syscall?
>>>>>
>>>
>>> With my GCC 5 patch:
>>>
>>> https://sourceware.org/ml/libc-alpha/2015-08/msg00477.html
>>>
>>> This updated patch will generate optimized code when GCC 5
>>> or above is used. Any comments?
>>
>> I like it. Perhaps you could quote a bit of disassembly in the commit
>> message?
>
> See:
>
> https://sourceware.org/ml/libc-alpha/2015-08/msg00492.html
Thanks, if this ends up in the commit messages, that's good.
>> I would suggest to define a new macro (say,
>> __usues_many_argument_syscall or something shorter) which expands to
>> "__attribute__ ((optimize ("omit-frame-pointer), noinline))â on i386 and
>> apply it to the function in the C source file, instead of adding it to
>> the makefiles (assuming that this works, I have not tried it). This
>> way, it would be more explicit what happens. In the documentation of
>> the new macro, quote a typical GCC error message if a many-argument
>> system call is used without it.
>>
>
> This only applies to syscalls with 6 arguments. It is easier
> to add -fomit-frame-pointer to Makefile than a new macro since
> it has to be added by hand for each system call with 6 arguments.
I still think my proposal has merit. I can submit a patch as a cleanup
after your changes went in.
--
Florian Weimer / Red Hat Product Security
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2015-08-14 13:17 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-03 15:41 [PATCH] i386: Assembly Implementation cleanup Adhemerval Zanella
2015-07-09 18:58 ` Adhemerval Zanella
2015-08-11 18:49 ` Adhemerval Zanella
2015-08-12 0:22 ` H.J. Lu
2015-08-12 12:38 ` Adhemerval Zanella
2015-08-12 12:44 ` H.J. Lu
2015-08-12 13:58 ` Adhemerval Zanella
2015-08-12 14:20 ` Ondřej Bílka
2015-08-12 14:47 ` H.J. Lu
2015-08-12 15:01 ` Florian Weimer
2015-08-12 15:06 ` H.J. Lu
2015-08-12 19:22 ` H.J. Lu
2015-08-12 20:27 ` Adhemerval Zanella
2015-08-12 20:38 ` Florian Weimer
2015-08-12 20:48 ` Joseph Myers
2015-08-12 22:16 ` H.J. Lu
2015-08-14 13:17 ` Florian Weimer
2015-08-12 17:04 ` Joseph Myers
2015-08-12 13:07 ` Torvald Riegel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).