xref: /titanic_50/usr/src/lib/libc/i386/gen/wslen.s (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
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, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27	.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/asm_linkage.h>
45
46	ANSI_PRAGMA_WEAK(wcslen,function)
47	ANSI_PRAGMA_WEAK(wslen,function)
48
49#include "SYS.h"
50
51	ENTRY(_wcslen)
52	movl	4(%esp),%edx
53	xorl	%eax,%eax
54
55	.align	8
56.loop:
57	cmpl	$0,(%edx)
58	je	.out0
59	cmpl	$0,4(%edx)
60	je	.out1
61	cmpl	$0,8(%edx)
62	je	.out2
63	cmpl	$0,12(%edx)
64	je	.out3
65	addl	$4,%eax
66	addl	$16,%edx
67	jmp	.loop
68
69	.align	4
70.out1:
71	incl	%eax
72.out0:
73	ret
74
75	.align	4
76.out2:
77	add	$2,%eax
78	ret
79
80	.align	4
81.out3:
82	add	$3, %eax
83	ret
84	SET_SIZE(_wcslen)
85
86	ENTRY(_wslen)
87	_prologue_
88	movl	_esp_(8),%eax
89	movl	_esp_(4),%edx
90	pushl	%eax
91	pushl	%edx
92	call	_fref_(_wcslen)
93	addl	$8,%esp
94	_epilogue_
95	ret
96	SET_SIZE(_wslen)
97