1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <linux/linkage.h>
5 #include <asm/alternative-macros.h>
8 /* int strcmp(const char *cs, const char *ct) */
11 ALTERNATIVE("nop", "j strcmp_zbb", 0, RISCV_ISA_EXT_ZBB, CONFIG_RISCV_ISA_ZBB)
15 * a0 - comparison result, value like strcmp
35 * strcmp only needs to return (< 0, 0, > 0) values
36 * not necessarily -1, 0, +1
42 * Variant of strcmp using the ZBB extension if available.
43 * The code was published as part of the bitmanip manual
46 #ifdef CONFIG_RISCV_ISA_ZBB
54 * a0 - comparison result, value like strcmp
69 /* Main loop for aligned string. */
81 * Words don't match, and no null byte in the first
82 * word. Get bytes in big-endian order and compare.
84 #ifndef CONFIG_CPU_BIG_ENDIAN
89 /* Synthesize (t0 >= t1) ? 1 : -1 in a branchless sequence. */
98 * If words don't match, fall back to simple loop.
102 /* Otherwise, strings are equal. */
106 /* Simple loop for misaligned strings. */
123 SYM_FUNC_ALIAS(__pi_strcmp, strcmp)
124 EXPORT_SYMBOL(strcmp)