| * 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 |
| * in1: string length limit N |
| * r8: 0 in case of fault, strlen(buffer)+1 otherwise |
| * Copyright (C) 1999, 2001 David Mosberger-Tang <davidm@hpl.hp.com> |
| #include <asm/asmmacro.h> |
| GLOBAL_ENTRY(__strnlen_user) |
| mov r16=ar.lc // preserve ar.lc |
| // XXX braindead strlen loop---this needs to be optimized |
| EXCLR(.Lexit, ld1 r8=[in0],1) |
| add r9=1,in1 // NUL not found---return N+1 |
| mov ar.lc=r16 // restore ar.lc |