import less(1)
[unleashed/tickless.git] / usr / src / lib / libc / i386 / gen / wslen.s
blob8e7d1dd36d5b2a9b5552070533e05a157a15e726
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 .file "wslen.s"
30 * Wide character wcslen() implementation
32 * size_t
33 * wcslen(const wchar_t *s)
35 * const wchar_t *s0 = s + 1;
36 * while (*s++)
37 * ;
38 * return (s - s0);
40 */
42 #include "SYS.h"
44 ANSI_PRAGMA_WEAK(wcslen,function)
45 ANSI_PRAGMA_WEAK(wslen,function)
47 ENTRY(wcslen)
48 movl 4(%esp),%edx
49 xorl %eax,%eax
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
65 .align 4
66 .out1:
67 incl %eax
68 .out0:
69 ret
71 .align 4
72 .out2:
73 add $2,%eax
74 ret
76 .align 4
77 .out3:
78 add $3, %eax
79 ret
80 SET_SIZE(wcslen)
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)