xref: /kernel/linux/linux-5.10/arch/arm64/lib/memchr.S
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-5.10/arch/arm64/lib/
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Based on arch/arm/lib/memchr.S
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 1995-2000 Russell King
68c2ecf20Sopenharmony_ci * Copyright (C) 2013 ARM Ltd.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/linkage.h>
108c2ecf20Sopenharmony_ci#include <asm/assembler.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci/*
138c2ecf20Sopenharmony_ci * Find a character in an area of memory.
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * Parameters:
168c2ecf20Sopenharmony_ci *	x0 - buf
178c2ecf20Sopenharmony_ci *	x1 - c
188c2ecf20Sopenharmony_ci *	x2 - n
198c2ecf20Sopenharmony_ci * Returns:
208c2ecf20Sopenharmony_ci *	x0 - address of first occurrence of 'c' or 0
218c2ecf20Sopenharmony_ci */
228c2ecf20Sopenharmony_ciSYM_FUNC_START_WEAK_PI(memchr)
238c2ecf20Sopenharmony_ci	and	w1, w1, #0xff
248c2ecf20Sopenharmony_ci1:	subs	x2, x2, #1
258c2ecf20Sopenharmony_ci	b.mi	2f
268c2ecf20Sopenharmony_ci	ldrb	w3, [x0], #1
278c2ecf20Sopenharmony_ci	cmp	w3, w1
288c2ecf20Sopenharmony_ci	b.ne	1b
298c2ecf20Sopenharmony_ci	sub	x0, x0, #1
308c2ecf20Sopenharmony_ci	ret
318c2ecf20Sopenharmony_ci2:	mov	x0, #0
328c2ecf20Sopenharmony_ci	ret
338c2ecf20Sopenharmony_ciSYM_FUNC_END_PI(memchr)
348c2ecf20Sopenharmony_ciEXPORT_SYMBOL_NOKASAN(memchr)
35

Indexes created Thu Nov 07 10:32:03 CST 2024