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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 / Wide character wcsncpy
() implementation
32 / Algorithm based on Solaris
2.6 gen
/strncpy.s implementation
35 #include <sys/asm_linkage.h>
37 ANSI_PRAGMA_WEAK
(wcsncmp
,function
)
38 ANSI_PRAGMA_WEAK
(wsncmp
,function
)
40 ENTRY
(wcsncmp
) /* (wchar *ws1, wchar_t *ws2, size_t n) */
41 cmpq
%rdi
,%rsi
/ same string?
43 incq
%rdx
/ will later predecrement this uint
46 je
.equal / Used all n chars?
47 movl
(%rdi
),%eax
/ slodb ; scab
49 jne
.notequal_0 / Are the bytes equal?
51 je
.equal / End of string?
54 je
.equal / Used all n chars?
55 movl
4(%rdi
),%eax
/ slodb ; scab
57 jne
.notequal_1 / Are the bytes equal?
59 je
.equal / End of string?
62 je
.equal / Used all n chars?
63 movl
8(%rdi
),%eax
/ slodb ; scab
65 jne
.notequal_2 / Are the bytes equal?
67 je
.equal / End of string?
70 je
.equal / Used all n chars?
71 movl
12(%rdi
),%eax
/ slodb ; scab
73 jne
.notequal_3 / Are the bytes equal?
77 jne
.loop / End of string?
80 xorl
%eax
,%eax
/ return
0
91 subl
(%rsi
),%eax
/ return value is
(*s1
- *--s2
)
96 jmp wcsncmp
/ tail call into wcsncmp