1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * User string length functions for kernel
5 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
9 #define max r1 /* Do not change! */
14 #define obo r6 /* off-by-one */
21 * The vector mask version of this turned out *really* badly.
22 * The hardware loop version also turned out *really* badly.
23 * Seems straight pointer arithmetic basically wins here.
26 #define fname __strnlen_user
30 .type fname, @function
42 if (P0.new) jump:t dw_loop; /* fire up the oven */
47 tmp1 = memb(start++#1);
51 if (P0.new) jump:nt exit_found;
52 P1 = cmp.gtu(end,start);
56 if (!P1) jump exit_error; /* hit the end */
60 if (!P0) jump alignment_loop;
71 P0 = vcmpb.eq(dbuf,dcmp);
75 P0 = cmp.gtu(end,start);
80 if (!P0) jump end_check;
83 P0 = cmp.eq(tmp1,#32);
84 if (!P0.new) jump:nt exit_found;
85 if (!P0.new) start = add(obo,tmp1);
88 start = add(start,#8);
90 } /* might be nice to combine these jumps... */
95 P0 = cmp.gt(tmp1,mod8);
96 if (P0.new) jump:nt exit_error; /* neverfound! */
97 start = add(obo,tmp1);
102 R0 = sub(start,isrc);
112 /* Uh, what does the "fixup" return here? */
123 .section __ex_table,"a"