xref: /onnv-gate/usr/src/lib/libc/i386/gen/wslen.s (revision 7298:b69e27387f74)
10Sstevel@tonic-gate/*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
56812Sraf * Common Development and Distribution License (the "License").
66812Sraf * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
216812Sraf
220Sstevel@tonic-gate/*
236812Sraf * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
27*7298SMark.J.Nelson@Sun.COM	.file	"wslen.s"
280Sstevel@tonic-gate
290Sstevel@tonic-gate/*
300Sstevel@tonic-gate * Wide character wcslen() implementation
310Sstevel@tonic-gate *
320Sstevel@tonic-gate * size_t
336812Sraf * wcslen(const wchar_t *s)
340Sstevel@tonic-gate *{
350Sstevel@tonic-gate *	const wchar_t *s0 = s + 1;
360Sstevel@tonic-gate *	while (*s++)
370Sstevel@tonic-gate *		;
380Sstevel@tonic-gate *	return (s - s0);
390Sstevel@tonic-gate *}
400Sstevel@tonic-gate */
410Sstevel@tonic-gate
426812Sraf#include "SYS.h"
430Sstevel@tonic-gate
440Sstevel@tonic-gate	ANSI_PRAGMA_WEAK(wcslen,function)
450Sstevel@tonic-gate	ANSI_PRAGMA_WEAK(wslen,function)
460Sstevel@tonic-gate
476812Sraf	ENTRY(wcslen)
480Sstevel@tonic-gate	movl	4(%esp),%edx
490Sstevel@tonic-gate	xorl	%eax,%eax
500Sstevel@tonic-gate
510Sstevel@tonic-gate	.align	8
520Sstevel@tonic-gate.loop:
530Sstevel@tonic-gate	cmpl	$0,(%edx)
540Sstevel@tonic-gate	je	.out0
550Sstevel@tonic-gate	cmpl	$0,4(%edx)
560Sstevel@tonic-gate	je	.out1
570Sstevel@tonic-gate	cmpl	$0,8(%edx)
580Sstevel@tonic-gate	je	.out2
590Sstevel@tonic-gate	cmpl	$0,12(%edx)
600Sstevel@tonic-gate	je	.out3
610Sstevel@tonic-gate	addl	$4,%eax
620Sstevel@tonic-gate	addl	$16,%edx
630Sstevel@tonic-gate	jmp	.loop
640Sstevel@tonic-gate
650Sstevel@tonic-gate	.align	4
660Sstevel@tonic-gate.out1:
670Sstevel@tonic-gate	incl	%eax
680Sstevel@tonic-gate.out0:
690Sstevel@tonic-gate	ret
700Sstevel@tonic-gate
710Sstevel@tonic-gate	.align	4
720Sstevel@tonic-gate.out2:
730Sstevel@tonic-gate	add	$2,%eax
740Sstevel@tonic-gate	ret
750Sstevel@tonic-gate
760Sstevel@tonic-gate	.align	4
770Sstevel@tonic-gate.out3:
780Sstevel@tonic-gate	add	$3, %eax
790Sstevel@tonic-gate	ret
806812Sraf	SET_SIZE(wcslen)
810Sstevel@tonic-gate
826812Sraf	ENTRY(wslen)
830Sstevel@tonic-gate	_prologue_
840Sstevel@tonic-gate	movl	_esp_(8),%eax
850Sstevel@tonic-gate	movl	_esp_(4),%edx
860Sstevel@tonic-gate	pushl	%eax
870Sstevel@tonic-gate	pushl	%edx
886812Sraf	call	_fref_(wcslen)
890Sstevel@tonic-gate	addl	$8,%esp
900Sstevel@tonic-gate	_epilogue_
910Sstevel@tonic-gate	ret
926812Sraf	SET_SIZE(wslen)
93