1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3/* 4 * Copyright (C) 2025 Feng Jiang <jiangfeng@kylinos.cn> 5 */ 6 7#include <linux/linkage.h> 8#include <asm/asm.h> 9 10/* char *strrchr(const char *s, int c) */ 11SYM_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 261: 27 lbu t0, 0(t1) 28 bne t0, a1, 2f 29 mv a0, t1 302: 31 addi t1, t1, 1 32 bnez t0, 1b 33 ret 34SYM_FUNC_END(strrchr) 35 36SYM_FUNC_ALIAS_WEAK(__pi_strrchr, strrchr) 37EXPORT_SYMBOL(strrchr) 38