Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Based on arch/arm/lib/strrchr.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 last occurrence of a character in a string.
0014  *
0015  * Parameters:
0016  *  x0 - str
0017  *  x1 - c
0018  * Returns:
0019  *  x0 - address of last occurrence of 'c' or 0
0020  */
0021 SYM_FUNC_START(__pi_strrchr)
0022     mov x3, #0
0023     and w1, w1, #0xff
0024 1:  ldrb    w2, [x0], #1
0025     cbz w2, 2f
0026     cmp w2, w1
0027     b.ne    1b
0028     sub x3, x0, #1
0029     b   1b
0030 2:  mov x0, x3
0031     ret
0032 SYM_FUNC_END(__pi_strrchr)
0033 SYM_FUNC_ALIAS_WEAK(strrchr, __pi_strrchr)
0034 EXPORT_SYMBOL_NOKASAN(strrchr)