strcmp.S 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Optimized version of the standard strcmp() function.
  2. This file is part of the GNU C Library.
  3. Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
  4. Contributed by Dan Pop <Dan.Pop@cern.ch>.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. /* Return: the result of the comparison
  17. Inputs:
  18. in0: s1
  19. in1: s2
  20. Unlike memcmp(), this function is optimized for mismatches within the
  21. first few characters. */
  22. #include <sysdep.h>
  23. #undef ret
  24. #define s1 in0
  25. #define s2 in1
  26. #define val1 r15
  27. #define val2 r16
  28. ENTRY(strcmp)
  29. alloc r2 = ar.pfs, 2, 0, 0, 0
  30. .loop:
  31. ld1 val1 = [s1], 1
  32. ld1 val2 = [s2], 1
  33. cmp.eq p6, p0 = r0, r0 /* set p6 */
  34. ;;
  35. cmp.ne.and p6, p0 = val1, r0
  36. cmp.ne.and p6, p0 = val2, r0
  37. cmp.eq.and p6, p0 = val1, val2
  38. (p6) br.cond.sptk .loop
  39. sub ret0 = val1, val2
  40. br.ret.sptk.many b0
  41. END(strcmp)
  42. libc_hidden_def (strcmp)
  43. #ifndef __UCLIBC_HAS_LOCALE__
  44. strong_alias(strcmp,strcoll)
  45. libc_hidden_def(strcoll)
  46. #endif