blob: 80a5dfd1d402b9d28581315f5a59424fc149d7ce [file] [log] [blame]
* Returns 0 if exception before NUL or reaching the supplied limit (N),
* a value greater than N if the string is longer than the limit, else
* strlen.
* Inputs:
* in0: address of buffer
* in1: string length limit N
* Outputs:
* r8: 0 in case of fault, strlen(buffer)+1 otherwise
* Copyright (C) 1999, 2001 David Mosberger-Tang <>
#include <asm/asmmacro.h>
#include <asm/export.h>
alloc r2=ar.pfs,2,0,0,0
.save, r16
mov // preserve
add r3=-1,in1
mov r9=0
// XXX braindead strlen loop---this needs to be optimized
EXCLR(.Lexit, ld1 r8=[in0],1)
add r9=1,r9
cmp.eq p6,p0=r8,r0
(p6) br.cond.dpnt .Lexit
br.cloop.dptk.few .Loop1
add r9=1,in1 // NUL not found---return N+1
mov r8=r9
mov // restore
br.ret.sptk.many rp