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]
22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
35 / This function truncates the top of the
387 stack into
a signed long.
37 ENTRY
(__xtol
) // 387-stack to signed long
42 andw $
0x0c00,%cx
// save RC
46 fistpl two_words
(%esp
)
48 fstcw cw
(%esp
) // fetch CW in case masks changed value
51 orw
%cx
,%ax
// restore RC
54 movl two_words
(%esp
),%eax
59 / This function truncates the top of the
387 stack into
a signed long long.
61 ENTRY
(__xtoll
) // 387-stack to signed long long
66 andw $
0x0c00,%cx
// save RC
70 fistpll two_words
(%esp
)
72 fstcw cw
(%esp
) // fetch CW in case masks changed value
75 orw
%cx
,%ax
// restore RC
78 movl two_words
(%esp
),%eax
79 movl four_words
(%esp
),%edx
84 / This function truncates the top of the
387 stack into
a unsigned long.
87 two_to_31
: .long 0x4f000000
89 ENTRY
(__xtoul
) // 387-stack to unsigned long
94 andw $
0x0c00,%cx
// save RC
99 fcoms _sref_
(two_to_31
) // compare
st to
2**31
101 fstsw
%ax
// store status in
%ax
102 // use fstsw for correct
trap handling
103 sahf
// load AH into flags
104 jb
.donotsub // jump if st < 2**31 or is NaN
106 fsubs _sref_
(two_to_31
) // subtract
2**31
109 fistpl two_words
(%esp
)
110 fwait
// in case fistpl causes exception
111 movl two_words
(%esp
),%eax
112 jb
.donotadd // flags did not change
113 add $
0x80000000,%eax
// add back
2**31
115 fstcw cw
(%esp
) // fetch CW in case masks changed value
118 orw
%cx
,%dx
// restore RC