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 2011 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
34 movl
4(%esp
),%ecx
/ ecx
<-- x
35 andl $
0x7fffffff,%ecx
/ ecx
<-- |x|
36 cmpl $
0x3e9a209a,%ecx
/ Is |x|
< log10
(2)?
37 jbe
.shortcut / If so, take a shortcut.
38 cmpl $
0x7f800000,%ecx
/ |x|
>= INF?
39 jae
.not_finite / if so, x is not finite
40 flds
4(%esp
) / push x
(=arg
)
42 subl $
8,%esp
/ save RP
and set round-to-
64-bits
50 fldl2t
/ push log2
(10) }NOT for xtndd_dbl
51 fmulp
%st,%st(1) / z
= x
*log2
(10) }NOT for xtndd_dbl
52 fld
%st(0) / duplicate stack top
57 je
.z_integral / branch if z integral
59 fsub %st(1),%st / z-
[z
], [z
]
60 f2xm1
/ 2**(z-
[z
])-1, [z
]
61 fld1
/ 1,2**(z-
[z
])-1, [z
]
62 faddp
%st,%st(1) / 2**(z-
[z
]), [z
]
63 fscale
/ 2**z
= 10**(arg
), [z
]
66 fstcw
(%esp
) / restore old RP
78 .z_integral: / here, z is integral
81 fscale
/ 2**(0 + z
) = 2**z
= 10**(arg
), z
82 fstp
%st(1) / 10**(arg
)
84 fstcw
(%esp
) / restore old RP
97 / Here
, |x|
< log10
(2), so |z|
= |x
*log2
(10)|
< 1
98 / whence z is in f2xm1
's domain.
99 flds 4(%esp) / push x (=arg)
100 fldl2t / push log2(10) }NOT for xtndd_dbl
101 fmulp %st,%st(1) / z = x*log2(10) }NOT for xtndd_dbl
104 faddp %st,%st(1) / 2**z = 10**x
108 ja .NaN_or_pinf / branch if x is NaN
109 movl 4(%esp),%eax / eax <-- x
110 andl $0x80000000,%eax / here, x is infinite, but +/-?
111 jz .NaN_or_pinf / branch if x = +INF
112 fldz / Here, x = -inf, so return 0
116 / Here, x = NaN or +inf, so load x and return immediately.