^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Based on arch/arm/lib/memchr.S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 1995-2000 Russell King
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2013 ARM Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <asm/assembler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Find a character in an area of memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Parameters:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * x0 - buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * x1 - c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * x2 - n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * x0 - address of first occurrence of 'c' or 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) SYM_FUNC_START_WEAK_PI(memchr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) and w1, w1, #0xff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 1: subs x2, x2, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) b.mi 2f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) ldrb w3, [x0], #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) cmp w3, w1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) b.ne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) sub x0, x0, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ret
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 2: mov x0, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) ret
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) SYM_FUNC_END_PI(memchr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) EXPORT_SYMBOL_NOKASAN(memchr)