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
37 ANSI_PRAGMA_WEAK
(wcsncmp
,function
)
38 ANSI_PRAGMA_WEAK
(wsncmp
,function
)
41 pushl
%esi
/ save register variables
42 movl
8(%esp
),%esi
/ %esi
= first string
44 movl
12(%esp
),%edi
/ %edi
= second string
45 cmpl %esi
,%edi
/ same string?
47 movl
16(%esp
),%ecx
/ %ecx
= length
48 incl
%ecx
/ will later predecrement this uint
51 je
.equal / Used all n chars?
52 movl
(%esi
),%eax
/ slodb ; scab
54 jne
.notequal_0 / Are the bytes equal?
56 je
.equal / End of string?
59 je
.equal / Used all n chars?
60 movl
4(%esi
),%eax
/ slodb ; scab
62 jne
.notequal_1 / Are the bytes equal?
64 je
.equal / End of string?
67 je
.equal / Used all n chars?
68 movl
8(%esi
),%eax
/ slodb ; scab
70 jne
.notequal_2 / Are the bytes equal?
72 je
.equal / End of string?
75 je
.equal / Used all n chars?
76 movl
12(%esi
),%eax
/ slodb ; scab
78 jne
.notequal_3 / Are the bytes equal?
82 jne
.loop / End of string?
85 popl
%esi
/ restore registers
86 xorl
%eax
,%eax
/ return
0
98 popl
%esi
/ restore registers
99 subl
(%edi
),%eax
/ return value is
(*s1
- *--s2
)