mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 04:31:50 +00:00
0f61f6be1f
Now that we have SYM_FUNC_ALIAS() and SYM_FUNC_ALIAS_WEAK(), use those to simplify and more consistently define function aliases across arch/arm64. Aliases are now defined in terms of a canonical function name. For position-independent functions I've made the __pi_<func> name the canonical name, and defined other alises in terms of this. The SYM_FUNC_{START,END}_PI(func) macros obscure the __pi_<func> name, and make this hard to seatch for. The SYM_FUNC_START_WEAK_PI() macro also obscures the fact that the __pi_<func> fymbol is global and the <func> symbol is weak. For clarity, I have removed these macros and used SYM_FUNC_{START,END}() directly with the __pi_<func> name. For example: SYM_FUNC_START_WEAK_PI(func) ... asm insns ... SYM_FUNC_END_PI(func) EXPORT_SYMBOL(func) ... becomes: SYM_FUNC_START(__pi_func) ... asm insns ... SYM_FUNC_END(__pi_func) SYM_FUNC_ALIAS_WEAK(func, __pi_func) EXPORT_SYMBOL(func) For clarity, where there are multiple annotations such as EXPORT_SYMBOL(), I've tried to keep annotations grouped by symbol. For example, where a function has a name and an alias which are both exported, this is organised as: SYM_FUNC_START(func) ... asm insns ... SYM_FUNC_END(func) EXPORT_SYMBOL(func) SYM_FUNC_ALIAS(alias, func) EXPORT_SYMBOL(alias) For consistency with the other string functions, I've defined strrchr as a position-independent function, as it can safely be used as such even though we have no users today. As we no longer use SYM_FUNC_{START,END}_ALIAS(), our local copies are removed. The common versions will be removed by a subsequent patch. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Acked-by: Mark Brown <broonie@kernel.org> Cc: Joey Gouly <joey.gouly@arm.com> Cc: Will Deacon <will@kernel.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20220216162229.1076788-3-mark.rutland@arm.com Signed-off-by: Will Deacon <will@kernel.org>
77 lines
1.4 KiB
ArmAsm
77 lines
1.4 KiB
ArmAsm
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2021 Arm Ltd.
|
|
*/
|
|
|
|
#include <linux/linkage.h>
|
|
#include <asm/assembler.h>
|
|
|
|
/*
|
|
* Find a character in an area of memory.
|
|
*
|
|
* Parameters:
|
|
* x0 - buf
|
|
* x1 - c
|
|
* x2 - n
|
|
* Returns:
|
|
* x0 - address of first occurrence of 'c' or 0
|
|
*/
|
|
|
|
#define L(label) .L ## label
|
|
|
|
#define REP8_01 0x0101010101010101
|
|
#define REP8_7f 0x7f7f7f7f7f7f7f7f
|
|
|
|
#define srcin x0
|
|
#define chrin w1
|
|
#define cntin x2
|
|
|
|
#define result x0
|
|
|
|
#define wordcnt x3
|
|
#define rep01 x4
|
|
#define repchr x5
|
|
#define cur_word x6
|
|
#define cur_byte w6
|
|
#define tmp x7
|
|
#define tmp2 x8
|
|
|
|
.p2align 4
|
|
nop
|
|
SYM_FUNC_START(__pi_memchr)
|
|
and chrin, chrin, #0xff
|
|
lsr wordcnt, cntin, #3
|
|
cbz wordcnt, L(byte_loop)
|
|
mov rep01, #REP8_01
|
|
mul repchr, x1, rep01
|
|
and cntin, cntin, #7
|
|
L(word_loop):
|
|
ldr cur_word, [srcin], #8
|
|
sub wordcnt, wordcnt, #1
|
|
eor cur_word, cur_word, repchr
|
|
sub tmp, cur_word, rep01
|
|
orr tmp2, cur_word, #REP8_7f
|
|
bics tmp, tmp, tmp2
|
|
b.ne L(found_word)
|
|
cbnz wordcnt, L(word_loop)
|
|
L(byte_loop):
|
|
cbz cntin, L(not_found)
|
|
ldrb cur_byte, [srcin], #1
|
|
sub cntin, cntin, #1
|
|
cmp cur_byte, chrin
|
|
b.ne L(byte_loop)
|
|
sub srcin, srcin, #1
|
|
ret
|
|
L(found_word):
|
|
CPU_LE( rev tmp, tmp)
|
|
clz tmp, tmp
|
|
sub tmp, tmp, #64
|
|
add result, srcin, tmp, asr #3
|
|
ret
|
|
L(not_found):
|
|
mov result, #0
|
|
ret
|
|
SYM_FUNC_END(__pi_memchr)
|
|
SYM_FUNC_ALIAS_WEAK(memchr, __pi_memchr)
|
|
EXPORT_SYMBOL_NOKASAN(memchr)
|