2 * Returns 0 if exception before NUL or reaching the supplied limit (N),
3 * a value greater than N if the string is longer than the limit, else
7 * in0: address of buffer
8 * in1: string length limit N
10 * r8: 0 in case of fault, strlen(buffer)+1 otherwise
12 * Copyright (C) 1999 David Mosberger-Tang <davidm@hpl.hp.com>
15 #include <asm/asmmacro.h>
17 /* If a fault occurs, r8 gets set to -EFAULT and r9 gets cleared. */
19 .section __ex_table,"a"; \
21 data4 (.Lexit-99f)|1; \
30 GLOBAL_ENTRY(__strnlen_user)
32 alloc r2=ar.pfs,2,0,0,0
34 mov r16=ar.lc // preserve ar.lc
43 // XXX braindead strlen loop---this needs to be optimized
49 (p6) br.dpnt.few .Lexit
50 br.cloop.dptk.few .Loop1
52 add r9=1,in1 // NUL not found---return N+1
56 mov ar.lc=r16 // restore ar.lc