Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Based on arch/arm/lib/strchr.S
0004  *
0005  * Copyright (C) 1995-2000 Russell King
0006  * Copyright (C) 2013 ARM Ltd.
0007  */
0008 
0009 #include <linux/linkage.h>
0010 #include <asm/assembler.h>
0011 
0012 /*
0013  * Find the first occurrence of a character in a string.
0014  *
0015  * Parameters:
0016  *  x0 - str
0017  *  x1 - c
0018  * Returns:
0019  *  x0 - address of first occurrence of 'c' or 0
0020  */
0021 SYM_FUNC_START(__pi_strchr)
0022     and w1, w1, #0xff
0023 1:  ldrb    w2, [x0], #1
0024     cmp w2, w1
0025     ccmp    w2, wzr, #4, ne
0026     b.ne    1b
0027     sub x0, x0, #1
0028     cmp w2, w1
0029     csel    x0, x0, xzr, eq
0030     ret
0031 SYM_FUNC_END(__pi_strchr)
0032 
0033 SYM_FUNC_ALIAS_WEAK(strchr, __pi_strchr)
0034 EXPORT_SYMBOL_NOKASAN(strchr)