2 * User string length functions for kernel
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #define max r1 /* Do not change! */
27 #define obo r6 /* off-by-one */
34 * The vector mask version of this turned out *really* badly.
35 * The hardware loop version also turned out *really* badly.
36 * Seems straight pointer arithmetic basically wins here.
39 #define fname __strnlen_user
43 .type fname, @function
55 if (P0.new) jump:t dw_loop; /* fire up the oven */
60 tmp1 = memb(start++#1);
64 if (P0.new) jump:nt exit_found;
65 P1 = cmp.gtu(end,start);
69 if (!P1) jump exit_error; /* hit the end */
73 if (!P0) jump alignment_loop;
84 P0 = vcmpb.eq(dbuf,dcmp);
88 P0 = cmp.gtu(end,start);
93 if (!P0) jump end_check;
96 P0 = cmp.eq(tmp1,#32);
97 if (!P0.new) jump:nt exit_found;
98 if (!P0.new) start = add(obo,tmp1);
101 start = add(start,#8);
103 } /* might be nice to combine these jumps... */
108 P0 = cmp.gt(tmp1,mod8);
109 if (P0.new) jump:nt exit_error; /* neverfound! */
110 start = add(obo,tmp1);
115 R0 = sub(start,isrc);
125 /* Uh, what does the "fixup" return here? */
136 .section __ex_table,"a"