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.
34 /* This function truncates the top of the 387 stack into a signed long. */
36 ENTRY
(__xtol
) /* 387-stack to signed long */
41 andw $
0x0c00,%cx
/* save RC */
45 fistpl two_words
(%rsp
)
46 /* fwait implied here */
47 fstcw cw
(%rsp
) /* fetch CW in case masks changed */
50 orw
%cx
,%ax
/* restore RC */
53 movl two_words
(%rsp
),%eax
58 /* This function truncates the top of the 387 stack into a signed long long. */
60 ENTRY
(__xtoll
) /* 387-stack to signed long long */
65 andw $
0x0c00,%cx
/* save RC */
70 /* fwait implied here */
71 fstcw cw
(%rsp
) /* fetch CW in case masks changed */
74 orw
%cx
,%ax
/* restore RC */
82 /* This function truncates the top of the 387 stack into a unsigned long. */
85 two_to_31
: .4byte
0x4f000000
87 ENTRY
(__xtoul
) /* 387-stack to unsigned */
92 andw $
0x0c00,%cx
/* save RC */
97 fcomip
%st(1),%st /* compare 2**31 to x */
98 jp
.donotsub /* jump if x is NaN */
99 ja
.donotsub /* jump if 2**31 > x */
100 fsubs two_to_31
(%rip
) /* subtract 2**31 */
102 fistpl two_words
(%rsp
)
103 fwait
/* in case fistpl causes exception */
104 movl two_words
(%rsp
),%eax
105 jp
.donotadd /* flags did not change */
106 ja
.donotadd /* flags did not change */
107 addl $
-2147483648,%eax
/* add back 2**31 */
109 fstcw cw
(%rsp
) /* fetch CW in case masks changed */
112 orw
%cx
,%dx
/* restore RC */