strcmp.S 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Highly optimized version for x86-64.
  2. Copyright (C) 1999, 2000, 2002, 2003, 2005 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Based on i686 version contributed by Ulrich Drepper
  5. <drepper@cygnus.com>, 1999.
  6. The GNU C Library is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Lesser General Public
  8. License as published by the Free Software Foundation; either
  9. version 2.1 of the License, or (at your option) any later version.
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with the GNU C Library; if not, write to the Free
  16. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  17. 02111-1307 USA. */
  18. #include "_glibc_inc.h"
  19. .text
  20. .global strcmp
  21. .set strcmp,__strcmp
  22. .hidden __strcmp
  23. ENTRY (BP_SYM (__strcmp))
  24. L(oop): movb (%rdi), %al
  25. cmpb (%rsi), %al
  26. jne L(neq)
  27. incq %rdi
  28. incq %rsi
  29. testb %al, %al
  30. jnz L(oop)
  31. xorl %eax, %eax
  32. ret
  33. L(neq): movl $1, %eax
  34. movl $-1, %ecx
  35. cmovbl %ecx, %eax
  36. ret
  37. END (BP_SYM (__strcmp))