xref: /openbsd-src/lib/libc/arch/sparc64/string/strlen.S (revision 9b9d2a55a62c8e82206c25f94fcc7f4e2765250e)
1*9b9d2a55Sguenther/*	$OpenBSD: strlen.S,v 1.3 2015/08/31 02:53:57 guenther Exp $	*/
211096442Sart/*	$NetBSD: strlen.S,v 1.1 1998/09/11 04:56:33 eeh Exp $	*/
311096442Sart
411096442Sart/*
511096442Sart * Copyright (c) 1992, 1993
611096442Sart *	The Regents of the University of California.  All rights reserved.
711096442Sart *
811096442Sart * This software was developed by the Computer Systems Engineering group
911096442Sart * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
1011096442Sart * contributed to Berkeley.
1111096442Sart *
1211096442Sart * Redistribution and use in source and binary forms, with or without
1311096442Sart * modification, are permitted provided that the following conditions
1411096442Sart * are met:
1511096442Sart * 1. Redistributions of source code must retain the above copyright
1611096442Sart *    notice, this list of conditions and the following disclaimer.
1711096442Sart * 2. Redistributions in binary form must reproduce the above copyright
1811096442Sart *    notice, this list of conditions and the following disclaimer in the
1911096442Sart *    documentation and/or other materials provided with the distribution.
206580fee3Smillert * 3. Neither the name of the University nor the names of its contributors
2111096442Sart *    may be used to endorse or promote products derived from this software
2211096442Sart *    without specific prior written permission.
2311096442Sart *
2411096442Sart * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2511096442Sart * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2611096442Sart * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2711096442Sart * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2811096442Sart * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2911096442Sart * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3011096442Sart * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3111096442Sart * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3211096442Sart * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3311096442Sart * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3411096442Sart * SUCH DAMAGE.
3511096442Sart */
3611096442Sart
37*9b9d2a55Sguenther#include "SYS.h"
3811096442Sart
3911096442SartENTRY(strlen)
4011096442Sart	add	%o0, 1, %o1	! save starting point + 1
4111096442Sart1:
4211096442Sart	ldsb	[%o0], %o2	! fetch byte
4311096442Sart	brnz,pt	%o2, 1b		! no, keep going
4411096442Sart	 inc	%o0		! always increment pointer
4511096442Sart	retl
4611096442Sart	 sub	%o0, %o1, %o0	! return length (ptr - (origptr+1))
47*9b9d2a55SguentherEND_STRONG(strlen)
48