xref: /titanic_41/usr/src/lib/libc/i386/gen/wslen.s (revision 9c8b6a95c9422a18be4946d4fca84a58fa1385ff)
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#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29	.file	"%M%"
30
31/*
32 * Wide character wcslen() implementation
33 *
34 * size_t
35 * wcslen(const wchar_t *s)
36 *{
37 *	const wchar_t *s0 = s + 1;
38 *	while (*s++)
39 *		;
40 *	return (s - s0);
41 *}
42 */
43
44#include "SYS.h"
45
46	ANSI_PRAGMA_WEAK(wcslen,function)
47	ANSI_PRAGMA_WEAK(wslen,function)
48
49	ENTRY(wcslen)
50	movl	4(%esp),%edx
51	xorl	%eax,%eax
52
53	.align	8
54.loop:
55	cmpl	$0,(%edx)
56	je	.out0
57	cmpl	$0,4(%edx)
58	je	.out1
59	cmpl	$0,8(%edx)
60	je	.out2
61	cmpl	$0,12(%edx)
62	je	.out3
63	addl	$4,%eax
64	addl	$16,%edx
65	jmp	.loop
66
67	.align	4
68.out1:
69	incl	%eax
70.out0:
71	ret
72
73	.align	4
74.out2:
75	add	$2,%eax
76	ret
77
78	.align	4
79.out3:
80	add	$3, %eax
81	ret
82	SET_SIZE(wcslen)
83
84	ENTRY(wslen)
85	_prologue_
86	movl	_esp_(8),%eax
87	movl	_esp_(4),%edx
88	pushl	%eax
89	pushl	%edx
90	call	_fref_(wcslen)
91	addl	$8,%esp
92	_epilogue_
93	ret
94	SET_SIZE(wslen)
95