This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
These changes are substantially cosmetic and pave the way for BP support to come with a later checkin. The problem this solves is to accommodate argument-offset shifts that come with 3-word bounded pointer arguments to string, memory, setjmp/longjmp and MPN functions. For most functions, there is no difference in the binary before & after, as verified by disassembling and diff'ing the results. In a few instances, I reordered instructions by hoisting a line out of an `#if/#else' that was identical in both arms. Here's a summary of the differences: ------------------------------------------------------------------------------ target=i386: no differences ------------------------------------------------------------------------------ target=i486: string/strcat.o: file format elf32-i386 < 1: 8b 4c 24 0c mov 0xc(%esp,1),%ecx < 5: 8b 54 24 08 mov 0x8(%esp,1),%edx --- > 1: 8b 54 24 08 mov 0x8(%esp,1),%edx > 5: 8b 4c 24 0c mov 0xc(%esp,1),%ecx ------------------------------------------------------------------------------ target=i586: > string/strcat.o: file format elf32-i386 < 1: 8b 4c 24 0c mov 0xc(%esp,1),%ecx < 5: 8b 54 24 08 mov 0x8(%esp,1),%edx --- > 1: 8b 54 24 08 mov 0x8(%esp,1),%edx > 5: 8b 4c 24 0c mov 0xc(%esp,1),%ecx string/strcpy.o: file format elf32-i386 [ This one changed because I wanted to use the DEST offset which is relative to the stack with saved registers present. I shifted the DEST(%esp) access to before the register restores. ] < 83: 5b pop %ebx < 84: 5e pop %esi < 85: 5f pop %edi < 86: 8b 44 24 04 mov 0x4(%esp,1),%eax --- > 83: 8b 44 24 10 mov 0x10(%esp,1),%eax > 87: 5b pop %ebx > 88: 5e pop %esi > 89: 5f pop %edi string/memset.o: file format elf32-i386 < 5: 8a 44 24 0c mov 0xc(%esp,1),%al < 9: 8b 54 24 10 mov 0x10(%esp,1),%edx --- > 5: 8b 54 24 10 mov 0x10(%esp,1),%edx > 9: 8a 44 24 0c mov 0xc(%esp,1),%al string/bzero.o: file format elf32-i386 < 5: 31 c0 xor %eax,%eax < 7: 8b 54 24 0c mov 0xc(%esp,1),%edx --- > 5: 8b 54 24 0c mov 0xc(%esp,1),%edx > 9: 31 c0 xor %eax,%eax ------------------------------------------------------------------------------ target=i686: string/strcat.o: file format elf32-i386 < 1: 8b 4c 24 0c mov 0xc(%esp,1),%ecx < 5: 8b 54 24 08 mov 0x8(%esp,1),%edx --- > 1: 8b 54 24 08 mov 0x8(%esp,1),%edx > 5: 8b 4c 24 0c mov 0xc(%esp,1),%ecx string/memset.o: file format elf32-i386 < 6: 0f b6 44 24 0c movzbl 0xc(%esp,1),%eax < b: 8b 4c 24 10 mov 0x10(%esp,1),%ecx --- > 6: 8b 4c 24 10 mov 0x10(%esp,1),%ecx > a: 0f b6 44 24 0c movzbl 0xc(%esp,1),%eax ------------------------------------------------------------------------------ 2000-06-08 Greg McGary <greg@mcgary.org> * sysdeps/i386/bp-asm.h: New file. * sysdeps/i386/__longjmp.S: Define & use symbolic argument stack offsets. Add ENTER/LEAVE macros for optionally maintaining frame-pointer chain when debugging. * sysdeps/i386/add_n.S: Likewise. * sysdeps/i386/addmul_1.S: Likewise. * sysdeps/i386/lshift.S: Likewise. * sysdeps/i386/memchr.S: Likewise. * sysdeps/i386/memcmp.S: Likewise. * sysdeps/i386/mul_1.S: Likewise. * sysdeps/i386/rawmemchr.S: Likewise. * sysdeps/i386/rshift.S: Likewise. * sysdeps/i386/stpcpy.S: Likewise. * sysdeps/i386/stpncpy.S: Likewise. * sysdeps/i386/strchr.S: Likewise. * sysdeps/i386/strchrnul.S: Likewise. * sysdeps/i386/strcspn.S: Likewise. * sysdeps/i386/strpbrk.S: Likewise. * sysdeps/i386/strrchr.S: Likewise. * sysdeps/i386/strspn.S: Likewise. * sysdeps/i386/strtok.S: Likewise. * sysdeps/i386/sub_n.S: Likewise. * sysdeps/i386/submul_1.S: Likewise. * sysdeps/i386/elf/setjmp.S: Likewise. * sysdeps/i386/i486/strcat.S: Likewise. * sysdeps/i386/i486/strlen.S: Likewise. * sysdeps/i386/i586/add_n.S: Likewise. * sysdeps/i386/i586/lshift.S: Likewise. * sysdeps/i386/i586/memcpy.S: Likewise. * sysdeps/i386/i586/memset.S: Likewise. * sysdeps/i386/i586/rshift.S: Likewise. * sysdeps/i386/i586/strchr.S: Likewise. * sysdeps/i386/i586/strcpy.S: Likewise. * sysdeps/i386/i586/strlen.S: Likewise. * sysdeps/i386/i586/sub_n.S: Likewise. * sysdeps/i386/i686/add_n.S: Likewise. * sysdeps/i386/i686/memcpy.S: Likewise. * sysdeps/i386/i686/mempcpy.S: Likewise. * sysdeps/i386/i686/memset.S: Likewise. * sysdeps/i386/i686/strcmp.S: Likewise. Index: sysdeps/i386/__longjmp.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/__longjmp.S,v retrieving revision 1.8 diff -u -p -r1.8 __longjmp.S --- __longjmp.S 1998/02/24 15:21:16 1.8 +++ __longjmp.S 2000/06/09 02:00:51 @@ -1,5 +1,5 @@ /* longjmp for i386. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 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 @@ -21,10 +21,19 @@ #define _ASM #define _SETJMP_H #include <bits/setjmp.h> +#include <bp-asm.h> +#define PARMS LINKAGE /* no space for saved regs */ +#define JBUF PARMS +#define VAL JBUF+PTR_SIZE + ENTRY (__longjmp) - movl 4(%esp), %ecx /* User's jmp_buf in %ecx. */ - movl 8(%esp), %eax /* Second argument is return value. */ + ENTER + + movl JBUF(%esp), %ecx /* User's jmp_buf in %ecx. */ + LEAVE + + movl VAL(%esp), %eax /* Second argument is return value. */ /* Save the return address now. */ movl (JB_PC*4)(%ecx), %edx /* Restore registers. */ Index: sysdeps/i386/add_n.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/add_n.S,v retrieving revision 1.9 diff -u -p -r1.9 add_n.S --- add_n.S 1998/03/02 17:58:36 1.9 +++ add_n.S 2000/06/09 02:00:51 @@ -1,6 +1,6 @@ /* Add two limb vectors of the same length > 0 and store sum in a third limb vector. - Copyright (C) 1992, 94, 95, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 97, 98, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,26 +18,27 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define S2 S1+PTR_SIZE +#define SIZE S2+PTR_SIZE .text ENTRY(__mpn_add_n) + ENTER + pushl %edi pushl %esi - movl 12(%esp),%edi /* res_ptr */ - movl 16(%esp),%esi /* s1_ptr */ - movl 20(%esp),%edx /* s2_ptr */ - movl 24(%esp),%ecx /* size */ + movl RES(%esp),%edi + movl S1(%esp),%esi + movl S2(%esp),%edx + movl SIZE(%esp),%ecx movl %ecx,%eax shrl $3,%ecx /* compute count for unrolled loop */ @@ -99,5 +100,7 @@ L(oop): movl (%esi),%eax popl %esi popl %edi + + LEAVE ret END(__mpn_add_n) Index: sysdeps/i386/addmul_1.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/addmul_1.S,v retrieving revision 1.6 diff -u -p -r1.6 addmul_1.S --- addmul_1.S 1998/03/02 17:58:37 1.6 +++ addmul_1.S 2000/06/09 02:00:51 @@ -1,6 +1,6 @@ /* i80386 __mpn_addmul_1 -- Multiply a limb vector with a limb and add the result to a second limb vector. - Copyright (C) 1992, 1994, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,16 +18,15 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - sizeP (sp + 12) - s2_limb (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define SIZE S1+PTR_SIZE +#define S2LIMB SIZE+4 #define res_ptr edi #define s1_ptr esi @@ -42,10 +41,10 @@ ENTRY(__mpn_addmul_1) INSN1(push,l ,R(ebx)) INSN1(push,l ,R(ebp)) - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(sizeP),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) + INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,RES)) + INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,S1)) + INSN2(mov,l ,R(sizeP),MEM_DISP(esp,SIZE)) + INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,S2LIMB)) INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,sizeP,4)) INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,sizeP,4)) Index: sysdeps/i386/bp-asm.h =================================================================== RCS file: bp-asm.h diff -N bp-asm.h --- /dev/null Tue May 5 13:32:27 1998 +++ bp-asm.h Thu Jun 8 19:00:51 2000 @@ -0,0 +1,142 @@ +/* Bounded-pointer definitions for x86 assembler. + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by Greg McGary <greg@mcgary.org> + + This file is part of the GNU C Library. Its master source is NOT part of + the C library, however. The master source lives in the GNU MP Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _bp_asm_h_ +# define _bp_asm_h_ 1 + +# if __ASSEMBLER__ + +# if __BOUNDED_POINTERS__ + +/* Bounded pointers occupy three words. */ +# define PTR_SIZE 12 +/* Bounded pointer return values are passed back through a hidden + argument that points to caller-allocate space. The hidden arg + occupies one word on the stack. */ +# define RTN_SIZE 4 +/* Although the caller pushes the hidden arg, the callee is + responsible for popping it. */ +# define RET_PTR ret $RTN_SIZE +/* Maintain frame pointer chain in leaf assembler functions for the benefit + of debugging stack traces when bounds violations occur. */ +# define ENTER pushl %ebp; movl %esp, %ebp +# define LEAVE movl %ebp, %esp; popl %ebp +/* Stack space overhead of procedure-call linkage: return address and + frame pointer. */ +# define LINKAGE 8 + +/* Int 5 is the "bound range" exception also raised by the "bound" + instruction. */ +# define BOUNDS_VIOLATED int $5 + +# define CHECK_BOUNDS_LOW(VAL_REG, BP_MEM) \ + cmpl 4+BP_MEM, VAL_REG; \ + jae 0f; /* continue if value >= low */ \ + BOUNDS_VIOLATED; \ + 0: + +# define CHECK_BOUNDS_HIGH(VAL_REG, BP_MEM, Jcc) \ + cmpl 8+BP_MEM, VAL_REG; \ + Jcc 0f; /* continue if value < high */ \ + BOUNDS_VIOLATED; \ + 0: + +# define CHECK_BOUNDS_BOTH(VAL_REG, BP_MEM) \ + cmpl 4+BP_MEM, VAL_REG; \ + jb 1f; /* die if value < low */ \ + cmpl 8+BP_MEM, VAL_REG; \ + jb 0f; /* continue if value < high */ \ + 1: BOUNDS_VIOLATED; \ + 0: + +# define CHECK_BOUNDS_BOTH_WIDE(VAL_REG, BP_MEM, LENGTH) \ + CHECK_BOUNDS_LOW(VAL_REG, BP_MEM); \ + addl LENGTH, VAL_REG; \ + cmpl 8+BP_MEM, VAL_REG; \ + jbe 0f; /* continue if value <= high */ \ + BOUNDS_VIOLATED; \ + 0: subl LENGTH, VAL_REG /* restore value */ + +/* Take bounds from BP_MEM and affix them to the pointer + value in %eax, stuffing all into memory at RTN(%esp). + Use %ecx as a scratch register. */ + +# define RETURN_BOUNDED_POINTER(BP_MEM) \ + movl RTN(%esp), %ecx; \ + movl %eax, 0(%ecx); \ + movl 4+BP_MEM, %eax; \ + movl %eax, 4(%ecx); \ + movl 8+BP_MEM, %eax; \ + movl %eax, 8(%ecx) + +# define RETURN_NULL_BOUNDED_POINTER \ + movl RTN(%esp), %ecx; \ + movl %eax, 0(%ecx); \ + movl %eax, 4(%ecx); \ + movl %eax, 8(%ecx) + +/* The caller of __errno_location is responsible for allocating space + for the three-word BP return-value and passing pushing its address + as an implicit first argument. */ +# define PUSH_ERRNO_LOCATION_RETURN \ + subl $8, %esp; \ + subl $4, %esp; \ + pushl %esp + +/* __errno_location is responsible for popping the implicit first + argument, but we must pop the space for the BP itself. We also + dereference the return value in order to dig out the pointer value. */ +# define POP_ERRNO_LOCATION_RETURN \ + movl (%esp), %eax; \ + addl $4, %esp; \ + addl $8, %esp + +# else /* !__BOUNDED_POINTERS__ */ + +/* Unbounded pointers occupy one word. */ +# define PTR_SIZE 4 +/* Unbounded pointer return values are passed back in the register %eax. */ +# define RTN_SIZE 0 +/* Use simple return instruction for unbounded pointer values. */ +# define RET_PTR ret +/* Don't maintain frame pointer chain for leaf assembler functions. */ +# define ENTER +# define LEAVE +/* Stack space overhead of procedure-call linkage: return address only. */ +# define LINKAGE 4 + +# define CHECK_BOUNDS_LOW(VAL_REG, BP_MEM) +# define CHECK_BOUNDS_HIGH(VAL_REG, BP_MEM, Jcc) +# define CHECK_BOUNDS_BOTH(VAL_REG, BP_MEM) +# define CHECK_BOUNDS_BOTH_WIDE(VAL_REG, BP_MEM, LENGTH) +# define RETURN_BOUNDED_POINTER(BP_MEM) + +# define RETURN_NULL_BOUNDED_POINTER + +# define PUSH_ERRNO_LOCATION_RETURN +# define POP_ERRNO_LOCATION_RETURN + +# endif /* !__BOUNDED_POINTERS__ */ + +# endif /* __ASSEMBLER__ */ + +#endif /* _bp_asm_h_ */ Index: sysdeps/i386/lshift.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/lshift.S,v retrieving revision 1.7 diff -u -p -r1.7 lshift.S --- lshift.S 1999/10/01 15:56:46 1.7 +++ lshift.S 2000/06/09 02:00:51 @@ -1,5 +1,5 @@ /* i80386 __mpn_lshift -- - Copyright (C) 1992, 1994, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -17,27 +17,28 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+12 /* space for 3 saved regs */ +#define RES PARMS +#define S RES+PTR_SIZE +#define SIZE S+PTR_SIZE +#define CNT SIZE+4 .text ENTRY(__mpn_lshift) + ENTER + pushl %edi pushl %esi pushl %ebx - movl 16(%esp),%edi /* res_ptr */ - movl 20(%esp),%esi /* s_ptr */ - movl 24(%esp),%edx /* size */ - movl 28(%esp),%ecx /* cnt */ + movl RES(%esp),%edi + movl S(%esp),%esi + movl SIZE(%esp),%edx + movl CNT(%esp),%ecx subl $4,%esi /* adjust s_ptr */ @@ -70,6 +71,8 @@ L(1): movl (%esi,%edx,4),%eax popl %ebx popl %esi popl %edi + + LEAVE ret L(end): shll %cl,%ebx /* compute least significant limb */ @@ -78,5 +81,7 @@ L(end): shll %cl,%ebx /* compute least popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_lshift) Index: sysdeps/i386/memchr.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/memchr.S,v retrieving revision 1.6 diff -u -p -r1.6 memchr.S --- memchr.S 1998/07/16 11:29:40 1.6 +++ memchr.S 2000/06/09 02:00:51 @@ -1,7 +1,7 @@ -/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less - than N. +/* memchr (str, chr, len) -- Return pointer to first occurrence of CHR in STR less + than LEN. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> Optimised a little by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> @@ -32,32 +32,34 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - c (sp + 8) - len (sp + 12) -*/ +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE +#define LEN CHR+4 .text ENTRY (memchr) + ENTER + /* Save callee-safe registers used in this function. */ pushl %esi pushl %edi /* Load parameters into registers. */ - movl 12(%esp), %eax /* str: pointer to memory block. */ - movl 16(%esp), %edx /* c: byte we are looking for. */ - movl 20(%esp), %esi /* len: length of memory block. */ + movl STR(%esp), %eax /* str: pointer to memory block. */ + movl CHR(%esp), %edx /* c: byte we are looking for. */ + movl LEN(%esp), %esi /* len: length of memory block. */ /* If my must not test more than three characters test them one by one. This is especially true for 0. */ cmpl $4, %esi jb L(3) - /* At the moment %edx contains C. What we need for the - algorithm is C in all bytes of the dword. Avoid + /* At the moment %edx contains CHR. What we need for the + algorithm is CHR in all bytes of the dword. Avoid operations on 16 bit words because these require an prefix byte (and one more cycle). */ movb %dl, %dh /* Now it is 0|0|c|c */ @@ -117,9 +119,9 @@ ENTRY (memchr) into bit 32 (=carry flag), so all of the hole bits will be changed. - 3) But wait! Aren't we looking for C, not zero? + 3) But wait! Aren't we looking for CHR, not zero? Good point. So what we do is XOR LONGWORD with a longword, - each of whose bytes is C. This turns each byte that is C + each of whose bytes is CHR. This turns each byte that is CHR into a zero. */ @@ -152,7 +154,7 @@ L(1): movl (%eax), %ecx /* get word (= 4 incl %edi /* add 1: if one carry bit was *not* set the addition will not result in 0. */ - /* If at least one byte of the word is C we don't get 0 in %edi. */ + /* If at least one byte of the word is CHR we don't get 0 in %edi. */ jnz L(8) /* found it => return pointer */ /* This process is unfolded four times for better performance. @@ -169,7 +171,7 @@ L(1): movl (%eax), %ecx /* get word (= 4 addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(7) /* highest byte is C => return pointer */ + jnc L(7) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -183,7 +185,7 @@ L(1): movl (%eax), %ecx /* get word (= 4 addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(6) /* highest byte is C => return pointer */ + jnc L(6) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -197,7 +199,7 @@ L(1): movl (%eax), %ecx /* get word (= 4 addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(5) /* highest byte is C => return pointer */ + jnc L(5) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -220,7 +222,7 @@ L(2): subl $16, %esi addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(8) /* highest byte is C => return pointer */ + jnc L(8) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -238,7 +240,7 @@ L(2): subl $16, %esi addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(8) /* highest byte is C => return pointer */ + jnc L(8) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -256,7 +258,7 @@ L(2): subl $16, %esi addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(8) /* highest byte is C => return pointer */ + jnc L(8) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -268,19 +270,19 @@ L(2): subl $16, %esi L(3): andl $3, %esi /* mask out uninteresting bytes */ jz L(4) /* no remaining bytes => return NULL */ - cmpb %dl, (%eax) /* compare byte with C */ + cmpb %dl, (%eax) /* compare byte with CHR */ je L(9) /* equal, than return pointer */ incl %eax /* increment source pointer */ decl %esi /* decrement length */ jz L(4) /* no remaining bytes => return NULL */ - cmpb %dl, (%eax) /* compare byte with C */ + cmpb %dl, (%eax) /* compare byte with CHR */ je L(9) /* equal, than return pointer */ incl %eax /* increment source pointer */ decl %esi /* decrement length */ jz L(4) /* no remaining bytes => return NULL */ - cmpb %dl, (%eax) /* compare byte with C */ + cmpb %dl, (%eax) /* compare byte with CHR */ je L(9) /* equal, than return pointer */ L(4): /* no byte found => return NULL */ @@ -312,5 +314,6 @@ L(8): testb %cl, %cl /* test first byte L(9): popl %edi /* pop saved registers */ popl %esi - ret + LEAVE + RET_PTR END (memchr) Index: sysdeps/i386/memcmp.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/memcmp.S,v retrieving revision 1.6 diff -u -p -r1.6 memcmp.S --- memcmp.S 2000/02/22 08:50:03 1.6 +++ memcmp.S 2000/06/09 02:00:51 @@ -1,5 +1,5 @@ /* Compare two memory blocks for differences in the first COUNT bytes. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 2000 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 @@ -19,23 +19,24 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - block1 (sp + 4) - block2 (sp + 8) - len (sp + 12) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define BLK1 PARMS +#define BLK2 BLK1+PTR_SIZE +#define LEN BLK2+PTR_SIZE .text ENTRY (memcmp) + ENTER + pushl %esi /* Save callee-safe registers. */ movl %edi, %edx /* Note that %edx is not used and can so be used to save %edi. It's faster. */ - movl 8(%esp), %esi /* Load address of block #1. */ - movl 12(%esp), %edi /* Load address of block #2. */ - movl 16(%esp), %ecx /* Load maximal length of compare area. */ + movl BLK1(%esp), %esi + movl BLK2(%esp), %edi + movl LEN(%esp), %ecx cld /* Set direction of comparison. */ @@ -61,6 +62,7 @@ ENTRY (memcmp) L(1): popl %esi /* Restore registers. */ movl %edx, %edi + LEAVE ret END (memcmp) Index: sysdeps/i386/mul_1.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/mul_1.S,v retrieving revision 1.4 diff -u -p -r1.4 mul_1.S --- mul_1.S 1998/03/02 17:58:39 1.4 +++ mul_1.S 2000/06/09 02:00:51 @@ -1,6 +1,6 @@ /* i80386 __mpn_mul_1 -- Multiply a limb vector with a limb and store the result in a second limb vector. - Copyright (C) 1992, 1994, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -28,7 +28,14 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define SIZE S1+PTR_SIZE +#define S2LIMB SIZE+4 + #define res_ptr edi #define s1_ptr esi #define size ecx @@ -36,16 +43,17 @@ .text ENTRY(__mpn_mul_1) + ENTER INSN1(push,l ,R(edi)) INSN1(push,l ,R(esi)) INSN1(push,l ,R(ebx)) INSN1(push,l ,R(ebp)) - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(size),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) + INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,RES)) + INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,S1)) + INSN2(mov,l ,R(size),MEM_DISP(esp,SIZE)) + INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,S2LIMB)) INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) @@ -68,6 +76,8 @@ L(oop): INSN1(pop,l ,R(ebx)) INSN1(pop,l ,R(esi)) INSN1(pop,l ,R(edi)) + + LEAVE ret #undef size END(__mpn_mul_1) Index: sysdeps/i386/rawmemchr.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/rawmemchr.S,v retrieving revision 1.1 diff -u -p -r1.1 rawmemchr.S --- rawmemchr.S 1999/01/16 17:05:22 1.1 +++ rawmemchr.S 2000/06/09 02:00:51 @@ -1,6 +1,6 @@ /* rawmemchr (str, ch) -- Return pointer to first occurrence of CH in STR. For Intel 80x86, x>=3. - Copyright (C) 1994, 95, 96, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> Optimised a little by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> @@ -31,21 +31,23 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - c (sp + 8) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE .text ENTRY (__rawmemchr) + ENTER + /* Save callee-safe register used in this function. */ pushl %edi /* Load parameters into registers. */ - movl 8(%esp), %eax /* str: pointer to memory block. */ - movl 12(%esp), %edx /* c: byte we are looking for. */ + movl STR(%esp), %eax + movl CHR(%esp), %edx /* At the moment %edx contains C. What we need for the algorithm is C in all bytes of the dword. Avoid @@ -213,6 +215,7 @@ L(8): testb %cl, %cl /* test first byte L(9): popl %edi /* pop saved register */ + LEAVE ret END (__rawmemchr) weak_alias (__rawmemchr, rawmemchr) Index: sysdeps/i386/rshift.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/rshift.S,v retrieving revision 1.7 diff -u -p -r1.7 rshift.S --- rshift.S 1999/10/01 15:57:29 1.7 +++ rshift.S 2000/06/09 02:00:51 @@ -1,5 +1,5 @@ /* i80386 __mpn_rshift -- - Copyright (C) 1992, 1994, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -17,27 +17,28 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+12 /* space for 3 saved regs */ +#define RES PARMS +#define S RES+PTR_SIZE +#define SIZE S+PTR_SIZE +#define CNT SIZE+4 .text ENTRY(__mpn_rshift) + ENTER + pushl %edi pushl %esi pushl %ebx - movl 16(%esp),%edi /* res_ptr */ - movl 20(%esp),%esi /* s_ptr */ - movl 24(%esp),%edx /* size */ - movl 28(%esp),%ecx /* cnt */ + movl RES(%esp),%edi + movl S(%esp),%esi + movl SIZE(%esp),%edx + movl CNT(%esp),%ecx leal -4(%edi,%edx,4),%edi leal (%esi,%edx,4),%esi @@ -72,6 +73,8 @@ L(1): movl (%esi,%edx,4),%eax popl %ebx popl %esi popl %edi + + LEAVE ret L(end): shrl %cl,%ebx /* compute most significant limb */ @@ -80,5 +83,7 @@ L(end): shrl %cl,%ebx /* compute most s popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_rshift) Index: sysdeps/i386/stpcpy.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/stpcpy.S,v retrieving revision 1.5 diff -u -p -r1.5 stpcpy.S --- stpcpy.S 1997/03/31 22:43:05 1.5 +++ stpcpy.S 2000/06/09 02:00:51 @@ -1,6 +1,6 @@ /* Copy SRC to DEST returning the address of the terminating '\0' in DEST. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper (drepper@gnu.ai.mit.edu). @@ -24,18 +24,19 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - dest (sp + 4) - src (sp + 8) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE .text ENTRY (__stpcpy) - movl 4(%esp), %eax /* load destination pointer */ - movl 8(%esp), %ecx /* load source pointer */ + ENTER + movl DEST(%esp), %eax + movl SRC(%esp), %ecx subl %eax, %ecx /* magic: reduce number of loop variants to one using addressing mode */ @@ -81,7 +82,9 @@ L(1): addl $4, %eax /* increment loop c L(4): incl %eax L(3): incl %eax L(2): - ret + + LEAVE + RET_PTR END (__stpcpy) weak_alias (__stpcpy, stpcpy) Index: sysdeps/i386/stpncpy.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/stpncpy.S,v retrieving revision 1.5 diff -u -p -r1.5 stpncpy.S --- stpncpy.S 1997/03/31 22:43:06 1.5 +++ stpncpy.S 2000/06/09 02:00:51 @@ -1,7 +1,7 @@ /* copy no more then N bytes from SRC to DEST, returning the address of the terminating '\0' in DEST. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> Some bug fixes by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> @@ -26,22 +26,23 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - dest (sp + 4) - src (sp + 8) - maxlen (sp + 12) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE +#define LEN SRC+PTR_SIZE .text ENTRY (__stpncpy) + ENTER pushl %esi - movl 8(%esp), %eax /* load destination pointer */ - movl 12(%esp), %esi /* load source pointer */ - movl 16(%esp), %ecx /* load maximal length */ + movl DEST(%esp), %eax + movl SRC(%esp), %esi + movl LEN(%esp), %ecx subl %eax, %esi /* magic: reduce number of loop variants to one using addressing mode */ @@ -138,7 +139,8 @@ L(3): decl %ecx /* all bytes written? * L(9): popl %esi /* restore saved register content */ - ret + LEAVE + RET_PTR END (__stpncpy) weak_alias (__stpncpy, stpncpy) Index: sysdeps/i386/strchr.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/strchr.S,v retrieving revision 1.8 diff -u -p -r1.8 strchr.S --- strchr.S 1999/10/01 15:58:28 1.8 +++ strchr.S 2000/06/09 02:00:51 @@ -1,6 +1,6 @@ /* strchr (str, ch) -- Return pointer to first occurrence of CH in STR. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> Some optimisations by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> @@ -22,19 +22,20 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - ch (sp + 8) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE .text ENTRY (strchr) - pushl %edi /* Save callee-safe registers used here. */ + ENTER - movl 8(%esp), %eax /* get string pointer */ - movl 12(%esp), %edx /* get character we are looking for */ + pushl %edi /* Save callee-safe registers used here. */ + movl STR(%esp), %eax + movl CHR(%esp), %edx /* At the moment %edx contains C. What we need for the algorithm is C in all bytes of the dword. Avoid @@ -240,7 +241,9 @@ L(11): movl (%eax), %ecx /* get word (= L(2): /* Return NULL. */ xorl %eax, %eax /* load NULL in return value register */ popl %edi /* restore saved register content */ - ret + + LEAVE + RET_PTR L(73): addl $4, %eax /* adjust pointer */ L(72): addl $4, %eax @@ -273,7 +276,8 @@ L(7): testb %cl, %cl /* is first byte C L(6): popl %edi /* restore saved register content */ - ret + LEAVE + RET_PTR END (strchr) weak_alias (strchr, index) Index: sysdeps/i386/strchrnul.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/strchrnul.S,v retrieving revision 1.3 diff -u -p -r1.3 strchrnul.S --- strchrnul.S 1999/10/01 15:59:03 1.3 +++ strchrnul.S 2000/06/09 02:00:51 @@ -1,7 +1,7 @@ -/* strchrnul (str, ch) -- Return pointer to first occurrence of CH in STR +/* strchrnul (str, chr) -- Return pointer to first occurrence of CHR in STR or the final NUL byte. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.org> Some optimisations by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> @@ -23,22 +23,24 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - ch (sp + 8) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE .text ENTRY (__strchrnul) + ENTER + pushl %edi /* Save callee-safe registers used here. */ - movl 8(%esp), %eax /* get string pointer */ - movl 12(%esp), %edx /* get character we are looking for */ + movl STR(%esp), %eax + movl CHR(%esp), %edx - /* At the moment %edx contains C. What we need for the - algorithm is C in all bytes of the dword. Avoid + /* At the moment %edx contains CHR. What we need for the + algorithm is CHR in all bytes of the dword. Avoid operations on 16 bit words because these require an prefix byte (and one more cycle). */ movb %dl, %dh /* now it is 0|0|c|c */ @@ -108,9 +110,9 @@ ENTRY (__strchrnul) into bit 32 (=carry flag), so all of the hole bits will be changed. - 3) But wait! Aren't we looking for C, not zero? + 3) But wait! Aren't we looking for CHR, not zero? Good point. So what we do is XOR LONGWORD with a longword, - each of whose bytes is C. This turns each byte that is C + each of whose bytes is CHR. This turns each byte that is CHR into a zero. */ /* Each round the main loop processes 16 bytes. */ @@ -125,7 +127,7 @@ L(11): movl (%eax), %ecx /* get word (= movl $0xfefefeff, %edi /* magic value */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which - is *not* C */ + is *not* CHR */ /* According to the algorithm we had to reverse the effect of the XOR first and then test the overflow bits. But because the @@ -144,7 +146,7 @@ L(11): movl (%eax), %ecx /* get word (= incl %edi /* add 1: if one carry bit was *not* set the addition will not result in 0. */ - /* If at least one byte of the word is C we don't get 0 in %edi. */ + /* If at least one byte of the word is CHR we don't get 0 in %edi. */ jnz L(7) /* found it => return pointer */ /* Now we made sure the dword does not contain the character we are @@ -169,8 +171,8 @@ L(11): movl (%eax), %ecx /* get word (= movl $0xfefefeff, %edi /* magic value */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which - is *not* C */ - jnc L(71) /* highest byte is C => return pointer */ + is *not* CHR */ + jnc L(71) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -194,8 +196,8 @@ L(11): movl (%eax), %ecx /* get word (= movl $0xfefefeff, %edi /* magic value */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which - is *not* C */ - jnc L(72) /* highest byte is C => return pointer */ + is *not* CHR */ + jnc L(72) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -219,8 +221,8 @@ L(11): movl (%eax), %ecx /* get word (= movl $0xfefefeff, %edi /* magic value */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which - is *not* C */ - jnc L(73) /* highest byte is C => return pointer */ + is *not* CHR */ + jnc L(73) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -246,20 +248,20 @@ L(71): addl $4, %eax But we have to take care of the case that a NUL char is found before this in the dword. */ -L(7): testb %cl, %cl /* is first byte C? */ +L(7): testb %cl, %cl /* is first byte CHR? */ jz L(6) /* yes => return pointer */ cmpb %dl, %cl /* is first byte NUL? */ je L(6) /* yes => return NULL */ incl %eax /* it's not in the first byte */ - testb %ch, %ch /* is second byte C? */ + testb %ch, %ch /* is second byte CHR? */ jz L(6) /* yes => return pointer */ cmpb %dl, %ch /* is second byte NUL? */ je L(6) /* yes => return NULL? */ incl %eax /* it's not in the second byte */ shrl $16, %ecx /* make upper byte accessible */ - testb %cl, %cl /* is third byte C? */ + testb %cl, %cl /* is third byte CHR? */ jz L(6) /* yes => return pointer */ cmpb %dl, %cl /* is third byte NUL? */ je L(6) /* yes => return NULL */ @@ -269,7 +271,8 @@ L(7): testb %cl, %cl /* is first byte C L(6): popl %edi /* restore saved register content */ - ret + LEAVE + RET_PTR END (__strchrnul) weak_alias (__strchrnul, strchrnul) Index: sysdeps/i386/strcspn.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/strcspn.S,v retrieving revision 1.5 diff -u -p -r1.5 strcspn.S --- strcspn.S 1997/03/31 22:43:11 1.5 +++ strcspn.S 2000/06/09 02:00:51 @@ -1,7 +1,7 @@ /* strcspn (str, ss) -- Return the length of the initial segment of STR which contains no characters from SS. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> Bug fixes by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> @@ -23,18 +23,19 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - stopset (sp + 8) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define STR PARMS +#define STOP STR+PTR_SIZE .text ENTRY (strcspn) - movl 4(%esp), %edx /* get string pointer */ - movl 8(%esp), %eax /* get stopset pointer */ + ENTER + movl STR(%esp), %edx + movl STOP(%esp), %eax + /* First we create a table with flags for all possible characters. For the ASCII (7bit/8bit) or ISO-8859-X character sets which are supported by the C string functions we have 256 characters. @@ -173,5 +174,6 @@ L(4): subl %edx, %eax /* we have to ret non-valid character */ addl $256, %esp /* remove stopset */ + LEAVE ret END (strcspn) Index: sysdeps/i386/strpbrk.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/strpbrk.S,v retrieving revision 1.4 diff -u -p -r1.4 strpbrk.S --- strpbrk.S 1997/03/31 22:43:15 1.4 +++ strpbrk.S 2000/06/09 02:00:51 @@ -1,7 +1,7 @@ /* strcspn (str, ss) -- Return the length of the initial segement of STR which contains no characters from SS. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> Bug fixes by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> This file is part of the GNU C Library. @@ -23,18 +23,20 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - stopset (sp + 8) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define STOP STR+PTR_SIZE .text ENTRY (strpbrk) - movl 4(%esp), %edx /* get string pointer */ - movl 8(%esp), %eax /* get stopset pointer */ + ENTER + movl STR(%esp), %edx + movl STOP(%esp), %eax + /* First we create a table with flags for all possible characters. For the ASCII (7bit/8bit) or ISO-8859-X character sets which are supported by the C string functions we have 256 characters. @@ -174,5 +176,6 @@ L(4): addl $256, %esp /* remove stopset jnz L(7) /* no => return pointer */ xorl %eax, %eax /* return NULL */ -L(7): ret +L(7): LEAVE + RET_PTR END (strpbrk) Index: sysdeps/i386/strrchr.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/strrchr.S,v retrieving revision 1.7 diff -u -p -r1.7 strrchr.S --- strrchr.S 1997/03/31 22:43:17 1.7 +++ strrchr.S 2000/06/09 02:00:51 @@ -1,6 +1,6 @@ /* strrchr (str, ch) -- Return pointer to last occurrence of CH in STR. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> Some optimisations by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> @@ -22,21 +22,23 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - ch (sp + 8) -*/ +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE .text ENTRY (strrchr) + ENTER + pushl %edi /* Save callee-safe registers used here. */ pushl %esi xorl %eax, %eax - movl 12(%esp), %esi /* get string pointer */ - movl 16(%esp), %ecx /* get character we are looking for */ + movl STR(%esp), %esi + movl CHR(%esp), %ecx /* At the moment %ecx contains C. What we need for the algorithm is C in all bytes of the dword. Avoid @@ -320,7 +322,8 @@ L(26): testb %dl, %dl /* is third byte L(2): popl %esi /* restore saved register content */ popl %edi - ret + LEAVE + RET_PTR END (strrchr) weak_alias (strrchr, rindex) Index: sysdeps/i386/strspn.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/strspn.S,v retrieving revision 1.5 diff -u -p -r1.5 strspn.S --- strspn.S 1997/03/31 22:43:20 1.5 +++ strspn.S 2000/06/09 02:00:51 @@ -1,7 +1,7 @@ /* strcspn (str, ss) -- Return the length of the initial segment of STR which contains only characters from SS. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> Bug fixes by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> @@ -23,18 +23,19 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - skipset (sp + 8) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define STR PARMS +#define SKIP STR+PTR_SIZE .text ENTRY (strspn) - movl 4(%esp), %edx /* get string pointer */ - movl 8(%esp), %eax /* get skipset pointer */ + ENTER + movl STR(%esp), %edx + movl SKIP(%esp), %eax + /* First we create a table with flags for all possible characters. For the ASCII (7bit/8bit) or ISO-8859-X character sets which are supported by the C string functions we have 256 characters. @@ -173,5 +174,6 @@ L(4): subl %edx, %eax /* we have to ret non-valid character */ addl $256, %esp /* remove stopset */ + LEAVE ret END (strspn) Index: sysdeps/i386/strtok.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/strtok.S,v retrieving revision 1.7 diff -u -p -r1.7 strtok.S --- strtok.S 1998/04/03 11:29:51 1.7 +++ strtok.S 2000/06/09 02:00:52 @@ -1,6 +1,6 @@ /* strtok (str, delim) -- Return next DELIM separated token from STR. For Intel 80x86, x>=3. - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -21,6 +21,7 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" /* This file can be used for three variants of the strtok function: @@ -48,12 +49,19 @@ save_ptr: #define FUNCTION strtok #endif +#define PARMS LINKAGE /* no space for saved regs */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define DELIM STR+PTR_SIZE +#define SAVE DELIM+PTR_SIZE + .text ENTRY (FUNCTION) + ENTER - movl 4(%esp), %edx /* Get start of string. */ - movl 8(%esp), %eax /* Get start of delimiter set. */ + movl STR(%esp), %edx + movl DELIM(%esp), %eax #if !defined (USE_AS_STRTOK_R) && defined (PIC) pushl %ebx /* Save PIC register. */ @@ -70,7 +78,7 @@ L(here): #ifdef USE_AS_STRTOK_R /* The value is stored in the third argument. */ - movl 12(%esp), %edx + movl SAVE(%esp), %edx movl (%edx), %edx #else /* The value is in the local variable defined above. But @@ -257,7 +265,7 @@ L(11): L(return): /* Store the pointer to the next character. */ #ifdef USE_AS_STRTOK_R - movl 12(%esp), %ecx + movl SAVE(%esp), %ecx movl %edx, (%ecx) #else # ifndef PIC @@ -267,7 +275,8 @@ L(return): popl %ebx # endif #endif - ret + LEAVE + RET_PTR L(returnNULL): xorl %eax, %eax Index: sysdeps/i386/sub_n.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/sub_n.S,v retrieving revision 1.9 diff -u -p -r1.9 sub_n.S --- sub_n.S 1998/03/02 17:58:41 1.9 +++ sub_n.S 2000/06/09 02:00:52 @@ -1,6 +1,6 @@ /* i80386 __mpn_sub_n -- Add two limb vectors of the same length > 0 and store sum in a third limb vector. - Copyright (C) 1992, 1994, 1995, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1995, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,26 +18,27 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define S2 S1+PTR_SIZE +#define SIZE S2+PTR_SIZE .text ENTRY(__mpn_sub_n) + ENTER + pushl %edi pushl %esi - movl 12(%esp),%edi /* res_ptr */ - movl 16(%esp),%esi /* s1_ptr */ - movl 20(%esp),%edx /* s2_ptr */ - movl 24(%esp),%ecx /* size */ + movl RES(%esp),%edi + movl S1(%esp),%esi + movl S2(%esp),%edx + movl SIZE(%esp),%ecx movl %ecx,%eax shrl $3,%ecx /* compute count for unrolled loop */ @@ -99,5 +100,7 @@ L(oop): movl (%esi),%eax popl %esi popl %edi + + LEAVE ret END(__mpn_sub_n) Index: sysdeps/i386/submul_1.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/submul_1.S,v retrieving revision 1.6 diff -u -p -r1.6 submul_1.S --- submul_1.S 1998/03/02 17:58:42 1.6 +++ submul_1.S 2000/06/09 02:00:52 @@ -1,6 +1,6 @@ /* i80386 __mpn_submul_1 -- Multiply a limb vector with a limb and subtract the result from a second limb vector. - Copyright (C) 1992, 1994, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,16 +18,15 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - sizeP (sp + 12) - s2_limb (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define SIZE S1+PTR_SIZE +#define S2LIMB SIZE+4 #define res_ptr edi #define s1_ptr esi @@ -36,16 +35,17 @@ .text ENTRY(__mpn_submul_1) + ENTER INSN1(push,l ,R(edi)) INSN1(push,l ,R(esi)) INSN1(push,l ,R(ebx)) INSN1(push,l ,R(ebp)) - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(sizeP),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) + INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,RES)) + INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,S1)) + INSN2(mov,l ,R(sizeP),MEM_DISP(esp,SIZE)) + INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,S2LIMB)) INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,sizeP,4)) INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,sizeP,4)) @@ -69,5 +69,7 @@ L(oop): INSN1(pop,l ,R(ebx)) INSN1(pop,l ,R(esi)) INSN1(pop,l ,R(edi)) + + LEAVE ret END(__mpn_submul_1) Index: sysdeps/i386/elf/setjmp.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/elf/setjmp.S,v retrieving revision 1.3 diff -u -p -r1.3 setjmp.S --- setjmp.S 2000/06/01 07:13:22 1.3 +++ setjmp.S 2000/06/09 02:00:52 @@ -21,7 +21,12 @@ #define _ASM #define _SETJMP_H #include <bits/setjmp.h> +#include "bp-asm.h" +#define PARMS LINKAGE /* no space for saved regs */ +#define JBUF PARMS +#define SGMSK JBUF+PRT_SIZE + /* We include the BSD entry points here as well but we make them weak. */ ENTRY (setjmp) @@ -55,7 +60,7 @@ ENTRY (__sigsetjmp) movl %esi, (JB_SI*4)(%eax) movl %edi, (JB_DI*4)(%eax) movl %ebp, (JB_BP*4)(%eax) - leal 4(%esp), %ecx /* Save SP as it will be after we return. */ + leal JBUF(%esp), %ecx /* Save SP as it will be after we return. */ movl %ecx, (JB_SP*4)(%eax) movl 0(%esp), %ecx /* Save PC we are returning to now. */ movl %ecx, (JB_PC*4)(%eax) Index: sysdeps/i386/i486/strcat.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i486/strcat.S,v retrieving revision 1.6 diff -u -p -r1.6 strcat.S --- strcat.S 1997/03/31 22:43:53 1.6 +++ strcat.S 2000/06/09 02:00:52 @@ -1,6 +1,6 @@ /* strcat(dest, src) -- Append SRC on the end of DEST. For Intel 80x86, x>=4. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@ipd.info.uni-karlsruhe.de>. Optimised a little by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au> @@ -22,19 +22,21 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - dest (sp + 4) - src (sp + 8) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE .text ENTRY (strcat) + ENTER + pushl %edi /* Save callee-safe register. */ - movl 12(%esp), %ecx /* load source pointer */ - movl 8(%esp), %edx /* load destination pointer */ + movl DEST(%esp), %edx + movl SRC(%esp), %ecx testb $0xff, (%ecx) /* Is source string empty? */ jz L(8) /* yes => return */ @@ -254,8 +256,9 @@ L(9): movb %al, (%ecx,%edx) /* store fir movb %ah, 3(%ecx,%edx) /* store fourth byte of last word */ -L(8): movl 8(%esp), %eax /* start address of destination is result */ +L(8): movl DEST(%esp), %eax /* start address of destination is result */ popl %edi /* restore saved register */ - ret + LEAVE + RET_PTR END (strcat) Index: sysdeps/i386/i486/strlen.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i486/strlen.S,v retrieving revision 1.4 diff -u -p -r1.4 strlen.S --- strlen.S 1997/03/31 22:43:55 1.4 +++ strlen.S 2000/06/09 02:00:52 @@ -1,6 +1,6 @@ /* strlen(str) -- determine the length of the string STR. Optimized for Intel 80x86, x>=4. - Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. + Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 2000 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>. This file is part of the GNU C Library. @@ -21,15 +21,16 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define STR PARMS .text ENTRY (strlen) - movl 4(%esp), %ecx /* get string pointer */ + ENTER + + movl STR(%esp), %ecx movl %ecx, %eax /* duplicate it */ andl $3, %ecx /* mask alignment bits */ @@ -127,7 +128,8 @@ L(3): testb %cl, %cl /* is first byte N jz L(2) /* yes => return pointer */ incl %eax /* increment pointer */ -L(2): subl 4(%esp), %eax /* compute difference to string start */ +L(2): subl STR(%esp), %eax /* compute difference to string start */ + LEAVE ret END (strlen) Index: sysdeps/i386/i586/add_n.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i586/add_n.S,v retrieving revision 1.6 diff -u -p -r1.6 add_n.S --- add_n.S 1998/03/02 17:59:46 1.6 +++ add_n.S 2000/06/09 02:00:52 @@ -1,6 +1,6 @@ /* Pentium __mpn_add_n -- Add two limb vectors of the same length > 0 and store sum in a third limb vector. - Copyright (C) 1992, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 96, 97, 98, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,28 +18,29 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define S2 S1+PTR_SIZE +#define SIZE S2+PTR_SIZE .text ENTRY(__mpn_add_n) + ENTER + pushl %edi pushl %esi pushl %ebx pushl %ebp - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s1_ptr */ - movl 28(%esp),%ebp /* s2_ptr */ - movl 32(%esp),%ecx /* size */ + movl RES(%esp),%edi + movl S1(%esp),%esi + movl S2(%esp),%ebp + movl SIZE(%esp),%ecx movl (%ebp),%ebx @@ -123,5 +124,7 @@ L(end2): popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_add_n) Index: sysdeps/i386/i586/lshift.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i586/lshift.S,v retrieving revision 1.6 diff -u -p -r1.6 lshift.S --- lshift.S 1998/03/02 17:59:48 1.6 +++ lshift.S 2000/06/09 02:00:52 @@ -1,5 +1,5 @@ /* Pentium optimized __mpn_lshift -- - Copyright (C) 1992, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 96, 97, 98, 2000 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 @@ -17,28 +17,29 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S RES+PTR_SIZE +#define SIZE S+PTR_SIZE +#define CNT SIZE+4 -.text + .text ENTRY(__mpn_lshift) + ENTER + pushl %edi pushl %esi pushl %ebx pushl %ebp - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s_ptr */ - movl 28(%esp),%ebp /* size */ - movl 32(%esp),%ecx /* cnt */ + movl RES(%esp),%edi + movl S(%esp),%esi + movl SIZE(%esp),%ebp + movl CNT(%esp),%ecx /* We can use faster code for shift-by-1 under certain conditions. */ cmp $1,%ecx @@ -127,6 +128,8 @@ L(end2): popl %ebx popl %esi popl %edi + + LEAVE ret /* We loop from least significant end of the arrays, which is only @@ -216,5 +219,7 @@ L(L1): movl %edx,(%edi) /* store last l popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_lshift) Index: sysdeps/i386/i586/memcpy.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i586/memcpy.S,v retrieving revision 1.1 diff -u -p -r1.1 memcpy.S --- memcpy.S 1997/11/11 23:38:36 1.1 +++ memcpy.S 2000/06/09 02:00:52 @@ -1,5 +1,5 @@ /* Highly optimized version for i586. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -20,23 +20,31 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - dst (sp + 4) - src (sp + 8) - len (sp + 12) -*/ +/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */ +#define BCOPY_P (defined memcpy) +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#if BCOPY_P +# define DEST PARMS +#else +# define RTN PARMS +# define DEST RTN+RTN_SIZE +#endif +#define SRC DEST+PTR_SIZE +#define LEN SRC+PTR_SIZE .text ENTRY (memcpy) + ENTER + pushl %edi pushl %esi - movl 12(%esp), %edi /* dst */ - movl 16(%esp), %esi /* src */ - movl 20(%esp), %ecx /* len */ + movl DEST(%esp), %edi + movl SRC(%esp), %esi + movl LEN(%esp), %ecx movl %edi, %eax /* We need this in any case. */ @@ -91,18 +99,23 @@ L(3): movl 28(%edi), %edx /* Correct extra loop counter modification. */ L(2): addl $32, %ecx -#ifndef memcpy - movl 12(%esp), %eax /* dst */ +#if !BCOPY_P + movl DEST(%esp), %eax #endif L(1): rep; movsb -#ifdef memcpy +#if BCOPY_P movl %edi, %eax #endif popl %esi popl %edi + LEAVE +#if BCOPY_P ret +#else + RET_PTR +#endif END (memcpy) Index: sysdeps/i386/i586/memset.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i586/memset.S,v retrieving revision 1.5 diff -u -p -r1.5 memset.S --- memset.S 1997/11/11 23:39:37 1.5 +++ memset.S 2000/06/09 02:00:52 @@ -1,6 +1,6 @@ /* memset/bzero -- set memory area to CH/0 Highly optimized version for ix86, x>=5. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund, <tege@matematik.su.se> @@ -21,27 +21,33 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - (memset) (bzero) - dst (sp + 4) dst (sp + 4) - ch (sp + 8) len (sp + 8) - len (sp + 12) -*/ +/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */ +#define BZERO_P (defined memset) +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#if BZERO_P +# define LEN DEST+PTR_SIZE +#else +# define CHR DEST+PTR_SIZE +# define LEN CHR+4 +#endif .text ENTRY (memset) + ENTER + pushl %edi - movl 8(%esp), %edi /* destination pointer */ -#ifdef memset + movl DEST(%esp), %edi + movl LEN(%esp), %edx +#if BZERO_P xorl %eax, %eax /* we fill with 0 */ - movl 12(%esp), %edx /* size (in 8-bit words) */ #else - movb 12(%esp), %al /* use CH to fill */ - movl 16(%esp), %edx /* size (in 8-bit words) */ + movb CHR(%esp), %al movb %al, %ah movl %eax, %ecx @@ -93,11 +99,16 @@ L(2): shrl $2, %ecx /* convert byte coun rep stosb +#if !BZERO_P /* Load result (only if used as memset). */ -#ifndef memset - movl 8(%esp), %eax + movl DEST(%esp), %eax #endif popl %edi + LEAVE +#if BZERO_P ret +#else + RET_PTR +#endif END (memset) Index: sysdeps/i386/i586/rshift.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i586/rshift.S,v retrieving revision 1.6 diff -u -p -r1.6 rshift.S --- rshift.S 1998/03/02 17:59:51 1.6 +++ rshift.S 2000/06/09 02:00:52 @@ -1,5 +1,5 @@ /* Pentium optimized __mpn_rshift -- - Copyright (C) 1992, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 96, 97, 98, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -17,28 +17,29 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S RES+PTR_SIZE +#define SIZE S+PTR_SIZE +#define CNT SIZE+4 -.text + .text ENTRY(__mpn_rshift) + ENTER + pushl %edi pushl %esi pushl %ebx pushl %ebp - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s_ptr */ - movl 28(%esp),%ebp /* size */ - movl 32(%esp),%ecx /* cnt */ + movl RES(%esp),%edi + movl S(%esp),%esi + movl SIZE(%esp),%ebp + movl CNT(%esp),%ecx /* We can use faster code for shift-by-1 under certain conditions. */ cmp $1,%ecx @@ -124,6 +125,8 @@ L(end2): popl %ebx popl %esi popl %edi + + LEAVE ret /* We loop from least significant end of the arrays, which is only @@ -216,5 +219,7 @@ L(L1): movl %edx,(%edi) /* store last l popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_rshift) Index: sysdeps/i386/i586/strchr.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i586/strchr.S,v retrieving revision 1.8 diff -u -p -r1.8 strchr.S --- strchr.S 1997/03/31 22:45:12 1.8 +++ strchr.S 2000/06/09 02:00:52 @@ -1,6 +1,6 @@ /* Find character CH in a NUL terminated string. Highly optimized version for ix85, x>=5. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>. @@ -21,6 +21,7 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" /* This version is especially optimized for the i586 (and following?) processors. This is mainly done by using the two pipelines. The @@ -35,22 +36,23 @@ /* The magic value which is used throughout in the whole code. */ #define magic 0xfefefeff -/* - INPUT PARAMETERS: - str (sp + 4) - ch (sp + 8) -*/ +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE .text ENTRY (strchr) + ENTER + pushl %edi /* Save callee-safe registers. */ pushl %esi pushl %ebx pushl %ebp - movl 20(%esp), %eax /* get string pointer */ - movl 24(%esp), %edx /* get character we are looking for */ + movl STR(%esp), %eax + movl CHR(%esp), %edx movl %eax, %edi /* duplicate string pointer for later */ xorl %ecx, %ecx /* clear %ecx */ @@ -283,7 +285,8 @@ L(2): popl %ebp /* restore saved regist popl %esi popl %edi - ret + LEAVE + RET_PTR /* We know there is a NUL byte in the word. But we have to test whether there is an C byte before it in the word. */ @@ -326,7 +329,8 @@ L(3): xorl %eax, %eax /* set return val popl %esi popl %edi - ret + LEAVE + RET_PTR END (strchr) #undef index Index: sysdeps/i386/i586/strcpy.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i586/strcpy.S,v retrieving revision 1.1 diff -u -p -r1.1 strcpy.S --- strcpy.S 1997/08/10 17:28:18 1.1 +++ strcpy.S 2000/06/09 02:00:52 @@ -1,5 +1,5 @@ /* strcpy/stpcpy implementation for i586. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -20,7 +20,13 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" +#define PARMS LINKAGE+12 /* space for 3 saved regs */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE + #ifndef USE_AS_STPCPY # define STRCPY strcpy #endif @@ -29,12 +35,14 @@ .text ENTRY(STRCPY) + ENTER + pushl %edi pushl %esi pushl %ebx - movl 16(%esp), %edi - movl 20(%esp), %esi + movl DEST(%esp), %edi + movl SRC(%esp), %esi xorl %eax, %eax leal -1(%esi), %ecx @@ -136,12 +144,13 @@ L(end): movb %ah, (%edi) L(end2): #ifdef USE_AS_STPCPY movl %edi, %eax +#else + movl DEST(%esp), %eax #endif popl %ebx popl %esi popl %edi -#ifndef USE_AS_STPCPY - movl 4(%esp), %eax -#endif - ret + + LEAVE + RET_PTR END(STRCPY) Index: sysdeps/i386/i586/strlen.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i586/strlen.S,v retrieving revision 1.8 diff -u -p -r1.8 strlen.S --- strlen.S 1997/03/31 22:45:14 1.8 +++ strlen.S 2000/06/09 02:00:52 @@ -1,6 +1,6 @@ /* strlen -- Compute length og NUL terminated string. Highly optimized version for ix86, x>=5. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>. @@ -21,6 +21,7 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" /* This version is especially optimized for the i586 (and following?) processors. This is mainly done by using the two pipelines. The @@ -35,14 +36,14 @@ /* The magic value which is used throughout in the whole code. */ #define magic 0xfefefeff -/* - INPUT PARAMETERS: - str (sp + 4) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define STR PARMS .text ENTRY(strlen) - movl 4(%esp), %eax /* get string pointer */ + ENTER + + movl STR(%esp), %eax movl $3, %edx /* load mask (= 3) */ andl %eax, %edx /* separate last two bits of address */ @@ -176,9 +177,9 @@ L(3): subl $4, %eax /* correct too earl incl %eax /* increment pointer */ -L(2): subl 4(%esp), %eax /* now compute the length as difference +L(2): subl STR(%esp), %eax /* now compute the length as difference between start and terminating NUL character */ - + LEAVE ret END (strlen) Index: sysdeps/i386/i586/sub_n.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i586/sub_n.S,v retrieving revision 1.6 diff -u -p -r1.6 sub_n.S --- sub_n.S 1998/03/02 17:59:52 1.6 +++ sub_n.S 2000/06/09 02:00:52 @@ -1,6 +1,6 @@ /* Pentium __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and store difference in a third limb vector. - Copyright (C) 1992, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 96, 97, 98, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,28 +18,29 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define S2 S1+PTR_SIZE +#define SIZE S2+PTR_SIZE .text ENTRY(__mpn_sub_n) + ENTER + pushl %edi pushl %esi pushl %ebx pushl %ebp - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s1_ptr */ - movl 28(%esp),%ebp /* s2_ptr */ - movl 32(%esp),%ecx /* size */ + movl RES(%esp),%edi + movl S1(%esp),%esi + movl S2(%esp),%ebp + movl SIZE(%esp),%ecx movl (%ebp),%ebx @@ -123,5 +124,7 @@ L(end2): popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_sub_n) Index: sysdeps/i386/i686/add_n.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i686/add_n.S,v retrieving revision 1.1 diff -u -p -r1.1 add_n.S --- add_n.S 2000/01/05 00:23:06 1.1 +++ add_n.S 2000/06/09 02:00:52 @@ -18,16 +18,15 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define S2 S1+PTR_SIZE +#define SIZE S2+PTR_SIZE .text #ifdef PIC @@ -35,13 +34,15 @@ L(1): addl (%esp), %eax ret #endif ENTRY(__mpn_add_n) + ENTER + pushl %edi pushl %esi - movl 12(%esp),%edi /* res_ptr */ - movl 16(%esp),%esi /* s1_ptr */ - movl 20(%esp),%edx /* s2_ptr */ - movl 24(%esp),%ecx /* size */ + movl RES(%esp),%edi + movl S1(%esp),%esi + movl S2(%esp),%edx + movl SIZE(%esp),%ecx movl %ecx,%eax shrl $3,%ecx /* compute count for unrolled loop */ @@ -100,5 +101,7 @@ L(oop): movl (%esi),%eax popl %esi popl %edi + + LEAVE ret END(__mpn_add_n) Index: sysdeps/i386/i686/memcpy.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i686/memcpy.S,v retrieving revision 1.1 diff -u -p -r1.1 memcpy.S --- memcpy.S 1999/01/07 22:33:32 1.1 +++ memcpy.S 2000/06/09 02:00:52 @@ -1,7 +1,7 @@ /* Copy memory block and return pointer to beginning of destination block For Intel 80x86, x>=6. This file is part of the GNU C Library. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999. The GNU C Library is free software; you can redistribute it and/or @@ -21,20 +21,23 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* memcpy: - INPUT PARAMETER: - dest (sp + 4) - src (sp + 8) - len (sp + 12) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE +#define LEN SRC+PTR_SIZE + .text ENTRY(memcpy) - movl 12(%esp), %ecx + ENTER + + movl LEN(%esp), %ecx movl %edi, %eax - movl 4(%esp), %edi + movl DEST(%esp), %edi movl %esi, %edx - movl 8(%esp), %esi + movl SRC(%esp), %esi cld shrl $1, %ecx jnc 1f @@ -46,6 +49,8 @@ ENTRY(memcpy) movsl movl %eax, %edi movl %edx, %esi - movl 4(%esp), %eax - ret + movl DEST(%esp), %eax + + LEAVE + RET_PTR END(memcpy) Index: sysdeps/i386/i686/mempcpy.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i686/mempcpy.S,v retrieving revision 1.2 diff -u -p -r1.2 mempcpy.S --- mempcpy.S 1999/01/07 22:32:24 1.2 +++ mempcpy.S 2000/06/09 02:00:52 @@ -1,7 +1,7 @@ /* Copy memory block and return pointer to following byte. For Intel 80x86, x>=6. This file is part of the GNU C Library. - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. The GNU C Library is free software; you can redistribute it and/or @@ -21,20 +21,23 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* mempcpy: - INPUT PARAMETER: - dest (sp + 4) - src (sp + 8) - len (sp + 12) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE +#define LEN SRC+PTR_SIZE + .text ENTRY(__mempcpy) - movl 12(%esp), %ecx + ENTER + + movl LEN(%esp), %ecx movl %edi, %eax - movl 4(%esp), %edi + movl DEST(%esp), %edi movl %esi, %edx - movl 8(%esp), %esi + movl SRC(%esp), %esi cld shrl $1, %ecx jnc 1f @@ -46,6 +49,8 @@ ENTRY(__mempcpy) movsl xchgl %edi, %eax movl %edx, %esi - ret + + LEAVE + RET_PTR END(__mempcpy) weak_alias (__mempcpy, mempcpy) Index: sysdeps/i386/i686/memset.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i686/memset.S,v retrieving revision 1.2 diff -u -p -r1.2 memset.S --- memset.S 1999/01/07 20:50:53 1.2 +++ memset.S 2000/06/09 02:00:53 @@ -1,6 +1,6 @@ /* memset/bzero -- set memory area to CH/0 Highly optimized version for ix86, x>=6. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999. @@ -21,27 +21,34 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - (memset) (bzero) - dst (sp + 4) dst (sp + 4) - ch (sp + 8) len (sp + 8) - len (sp + 12) -*/ +/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */ +#define BZERO_P (defined memset) +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#if BZERO_P +# define DEST PARMS +# define LEN DEST+PTR_SIZE +#else +# define RTN PARMS +# define DEST RTN+RTN_SIZE +# define CHR DEST+PTR_SIZE +# define LEN CHR+4 +#endif .text ENTRY (memset) + ENTER + cld pushl %edi - movl 8(%esp), %edx -#ifdef memset - movl 12(%esp), %ecx - xorl %eax, %eax + movl DEST(%esp), %edx + movl LEN(%esp), %ecx +#if BZERO_P + xorl %eax, %eax /* fill with 0 */ #else - movzbl 12(%esp), %eax - movl 16(%esp), %ecx + movzbl CHR(%esp), %eax #endif jecxz 1f movl %edx, %edi @@ -61,7 +68,7 @@ ENTRY (memset) 2: movl %ecx, %edx shrl $2, %ecx andl $3, %edx -#ifndef memset +#if !BZERO_P imul $0x01010101, %eax #endif rep @@ -71,9 +78,15 @@ ENTRY (memset) stosb 1: -#ifndef memset - movl 8(%esp), %eax +#if !BZERO_P + movl DEST(%esp), %eax #endif popl %edi + + LEAVE +#if BZERO_P ret +#else + RET_PTR +#endif END (memset) Index: sysdeps/i386/i686/strcmp.S =================================================================== RCS file: /cvs/glibc/libc/sysdeps/i386/i686/strcmp.S,v retrieving revision 1.1 diff -u -p -r1.1 strcmp.S --- strcmp.S 1999/01/07 20:48:40 1.1 +++ strcmp.S 2000/06/09 02:00:53 @@ -1,5 +1,5 @@ /* Highly optimized version for ix86, x>=6. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999. @@ -20,29 +20,34 @@ #include <sysdep.h> #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - s1 (sp + 4) - s2 (sp + 8) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define STR1 PARMS +#define STR2 STR1+PTR_SIZE - .text ENTRY (strcmp) - movl 4(%esp), %ecx - movl 8(%esp), %edx -1: movb (%ecx), %al + ENTER + + movl STR1(%esp), %ecx + movl STR2(%esp), %edx + +L(oop): movb (%ecx), %al incl %ecx cmpb (%edx), %al - jne 2f + jne L(neq) incl %edx testb %al, %al - jnz 1b + jnz L(oop) + xorl %eax, %eax - jmp 3f -2: movl $1, %eax - ja 3f + jmp L(out) + +L(neq): movl $1, %eax + ja L(out) negl %eax -3: ret + +L(out): LEAVE + ret END (strcmp)
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |