Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/riscv/lib/strchr.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 *strchr(const char *s, int c) */
11
SYM_FUNC_START(strchr)
12
/*
13
* Parameters
14
* a0 - The string to be searched
15
* a1 - The character to search for
16
*
17
* Returns
18
* a0 - Address of first occurrence of 'c' or 0
19
*
20
* Clobbers
21
* t0
22
*/
23
andi a1, a1, 0xff
24
1:
25
lbu t0, 0(a0)
26
beq t0, a1, 2f
27
addi a0, a0, 1
28
bnez t0, 1b
29
li a0, 0
30
2:
31
ret
32
SYM_FUNC_END(strchr)
33
34
SYM_FUNC_ALIAS_WEAK(__pi_strchr, strchr)
35
EXPORT_SYMBOL(strchr)
36
37