Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/riscv/lib/strrchr.S
170891 views
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
3
/*
4
* Copyright (C) 2025 Feng Jiang <[email protected]>
5
*/
6
7
#include <linux/linkage.h>
8
#include <asm/asm.h>
9
10
/* char *strrchr(const char *s, int c) */
11
SYM_FUNC_START(strrchr)
12
/*
13
* Parameters
14
* a0 - The string to be searched
15
* a1 - The character to seaerch for
16
*
17
* Returns
18
* a0 - Address of last occurrence of 'c' or 0
19
*
20
* Clobbers
21
* t0, t1
22
*/
23
andi a1, a1, 0xff
24
mv t1, a0
25
li a0, 0
26
1:
27
lbu t0, 0(t1)
28
bne t0, a1, 2f
29
mv a0, t1
30
2:
31
addi t1, t1, 1
32
bnez t0, 1b
33
ret
34
SYM_FUNC_END(strrchr)
35
36
SYM_FUNC_ALIAS_WEAK(__pi_strrchr, strrchr)
37
EXPORT_SYMBOL(strrchr)
38
39