2 * arch/alpha/lib/strlen_user.S
4 * Return the length of the string including the NUL terminator
5 * (strlen+1) or zero if an error occurred.
7 * In places where it is critical to limit the processing time,
8 * and the data is not trusted, strnlen_user() should be used.
9 * It will return a value greater than its second argument if
10 * that limit would be exceeded. This implementation is allowed
11 * to access memory beyond the limit, but will not cross a page
12 * boundary when doing so.
15 #include <asm/regdef.h>
18 /* Allow an exception for an insn; exit if we get one. */
21 .section __ex_table,"a"; \
23 lda v0, $exception-99b(zero); \
37 ldah a1, 32767(zero) # do not use plain strlen_user() for strings
38 # that might be almost 2 GB long; you should
39 # be using strnlen_user() instead
47 EX( ldq_u t0, 0(a0) ) # load first quadword (a0 may be misaligned)
52 subq a0, 1, a0 # get our +1 for the return
53 cmpbge zero, t0, t1 # t1 <- bitmask: bit i == 1 <==> i-th byte == 0
65 addq v0, 8, v0 # addr += 8
69 $found: negq t1, t2 # clear all but least set bit
72 and t1, 0xf0, t2 # binary search for that set bit
81 nop # dual issue next two on ev4 and ev5
86 .align 3 # currently redundant