strchr.S 596 B

1234567891011121314151617181920212223242526272829303132
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Based on arch/arm/lib/strchr.S
  4. *
  5. * Copyright (C) 1995-2000 Russell King
  6. * Copyright (C) 2013 ARM Ltd.
  7. */
  8. #include <linux/linkage.h>
  9. #include <asm/assembler.h>
  10. /*
  11. * Find the first occurrence of a character in a string.
  12. *
  13. * Parameters:
  14. * x0 - str
  15. * x1 - c
  16. * Returns:
  17. * x0 - address of first occurrence of 'c' or 0
  18. */
  19. SYM_FUNC_START_WEAK(strchr)
  20. and w1, w1, #0xff
  21. 1: ldrb w2, [x0], #1
  22. cmp w2, w1
  23. ccmp w2, wzr, #4, ne
  24. b.ne 1b
  25. sub x0, x0, #1
  26. cmp w2, w1
  27. csel x0, x0, xzr, eq
  28. ret
  29. SYM_FUNC_END(strchr)
  30. EXPORT_SYMBOL_NOKASAN(strchr)