xref: /titanic_52/usr/src/lib/libc/i386/gen/wschr.s (revision c1ecd8b9404ee0d96d93f02e82c441b9bb149a3d)
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 wcschr() implementation
33/
34/ Algorithm based on Solaris 2.6 gen/strchr.s implementation
35/
36
37#include "SYS.h"
38
39	ANSI_PRAGMA_WEAK(wcschr,function)
40	ANSI_PRAGMA_WEAK(wschr,function)
41
42	.align	8		/ accounts for .loop alignment and prolog
43
44	ENTRY(wcschr)
45	movl	4(%esp),%eax	/ %eax = string address
46	movl	8(%esp),%ecx	/ %ecx = wchar sought
47.loop:
48	movl	(%eax),%edx	/ %edx = wchar of string
49	cmpl	%ecx,%edx	/ find it?
50	je	.found		/ yes
51	testl	%edx,%edx	/ is it null?
52	je	.notfound
53
54	movl	4(%eax),%edx	/ %edx = wchar of string
55	cmpl	%ecx,%edx	/ find it?
56	je	.found1		/ yes
57	testl	%edx,%edx	/ is it null?
58	je	.notfound
59
60	movl	8(%eax),%edx	/ %edx = wchar of string
61	cmpl	%ecx,%edx	/ find it?
62	je	.found2		/ yes
63	testl	%edx,%edx	/ is it null?
64	je	.notfound
65
66	movl	12(%eax),%edx	/ %edx = wchar of string
67	cmpl	%ecx,%edx	/ find it?
68	je	.found3		/ yes
69	addl	$16,%eax
70	testl	%edx,%edx	/ is it null?
71	jne	.loop
72
73.notfound:
74	xorl	%eax,%eax	/ %eax = NULL
75	ret
76
77.found3:
78	addl	$12,%eax
79	ret
80.found2:
81	addl	$8,%eax
82	ret
83.found1:
84	addl	$4,%eax
85.found:
86	ret
87	SET_SIZE(wcschr)
88
89	ENTRY(wschr)
90	_prologue_
91	movl	_esp_(8),%eax
92	movl	_esp_(4),%edx
93	pushl	%eax
94	pushl	%edx
95	call	_fref_(wcschr)
96	addl	$8,%esp
97	_epilogue_
98	ret
99	SET_SIZE(wschr)
100