xref: /titanic_41/usr/src/lib/libc/i386/gen/wslen.s (revision d29f5a711240f866521445b1656d114da090335e)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27	.file	"wslen.s"
28
29/*
30 * Wide character wcslen() implementation
31 *
32 * size_t
33 * wcslen(const wchar_t *s)
34 *{
35 *	const wchar_t *s0 = s + 1;
36 *	while (*s++)
37 *		;
38 *	return (s - s0);
39 *}
40 */
41
42#include "SYS.h"
43
44	ANSI_PRAGMA_WEAK(wcslen,function)
45	ANSI_PRAGMA_WEAK(wslen,function)
46
47	ENTRY(wcslen)
48	movl	4(%esp),%edx
49	xorl	%eax,%eax
50
51	.align	8
52.loop:
53	cmpl	$0,(%edx)
54	je	.out0
55	cmpl	$0,4(%edx)
56	je	.out1
57	cmpl	$0,8(%edx)
58	je	.out2
59	cmpl	$0,12(%edx)
60	je	.out3
61	addl	$4,%eax
62	addl	$16,%edx
63	jmp	.loop
64
65	.align	4
66.out1:
67	incl	%eax
68.out0:
69	ret
70
71	.align	4
72.out2:
73	add	$2,%eax
74	ret
75
76	.align	4
77.out3:
78	add	$3, %eax
79	ret
80	SET_SIZE(wcslen)
81
82	ENTRY(wslen)
83	_prologue_
84	movl	_esp_(8),%eax
85	movl	_esp_(4),%edx
86	pushl	%eax
87	pushl	%edx
88	call	_fref_(wcslen)
89	addl	$8,%esp
90	_epilogue_
91	ret
92	SET_SIZE(wslen)
93