Print this page
5261 libm should stop using synonyms.h
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/i386/src/expm1.s
+++ new/usr/src/lib/libm/i386/src/expm1.s
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
23 23 */
24 24 /*
25 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 26 * Use is subject to license terms.
27 27 */
28 28
29 29 .file "expm1.s"
30 30
31 31 #include "libm.h"
32 32 LIBM_ANSI_PRAGMA_WEAK(expm1,function)
33 -#include "libm_synonyms.h"
34 33
35 34 .data
36 35 .align 4
37 36 .mhundred: .float -100.0
38 37
39 38 ENTRY(expm1)
40 39 movl 8(%esp),%ecx / ecx <-- hi_32(x)
41 40 andl $0x7fffffff,%ecx / ecx <-- hi_32(|x|)
42 41 cmpl $0x3fe62e42,%ecx / Is |x| < ln(2)?
43 42 jb .shortcut / If so, take a shortcut.
44 43 je .check_tail / |x| may be only slightly < ln(2)
45 44 cmpl $0x7ff00000,%ecx / hi_32(|x|) >= hi_32(INF)?
46 45 jae .not_finite / if so, x is not finite
47 46 .finite_non_special: / Here, ln(2) < |x| < INF
48 47 fldl 4(%esp) / push x
49 48
50 49 subl $8,%esp / save RP and set round-to-64-bits
51 50 fstcw (%esp)
52 51 movw (%esp),%ax
53 52 movw %ax,4(%esp)
54 53 orw $0x0300,%ax
55 54 movw %ax,(%esp)
56 55 fldcw (%esp)
57 56
58 57 fldl2e / push log2e }not for xtndd_dbl
59 58 fmulp %st,%st(1) / z = x*log2e }not for xtndd_dbl
60 59 fld %st(0) / duplicate stack top
61 60 frndint / [z],z
62 61 / [z] != 0, compute exp(x) and then subtract one to get expm1(x)
63 62 fxch / z,[z]
64 63 fsub %st(1),%st / z-[z],[z]
65 64 f2xm1 / 2**(z-[z])-1,[z]
66 65 / avoid spurious underflow when scaling to compute exp(x)
67 66 PIC_SETUP(1)
68 67 flds PIC_L(.mhundred)
69 68 PIC_WRAPUP
70 69 fucom %st(2) / if -100 !< [z], then use -100
71 70 fstsw %ax
72 71 sahf
73 72 jb .got_int_part
74 73 fxch %st(2)
75 74 .got_int_part:
76 75 fstp %st(0) / 2**(z-[z])-1,max([z],-100)
77 76 fld1 / 1,2**(z-[z])-1,max([z],-100)
78 77 faddp %st,%st(1) / 2**(z-[z]) ,max([z],-100)
79 78 fscale / exp(x) ,max([z],-100)
80 79 fld1 / 1,exp(x) ,max([z],-100)
81 80 fxch / exp(x),1 ,max([z],-100)
82 81 fsubp %st,%st(1) / exp(x)-1 ,max([z],-100)
83 82 fstp %st(1)
84 83
85 84 fstcw (%esp) / restore old RP
86 85 movw (%esp),%dx
87 86 andw $0xfcff,%dx
88 87 movw 4(%esp),%cx
89 88 andw $0x0300,%cx
90 89 orw %dx,%cx
91 90 movw %cx,(%esp)
92 91 fldcw (%esp)
93 92 add $8,%esp
94 93
95 94 ret
96 95
97 96 .check_tail:
98 97 movl 4(%esp),%edx / edx <-- lo_32(x)
99 98 cmpl $0xfefa39ef,%edx / Is |x| slightly < ln(2)?
100 99 ja .finite_non_special / branch if |x| slightly > ln(2)
101 100 .shortcut:
102 101 / Here, |x| < ln(2), so |z| = |x*log2(e)| < 1,
103 102 / whence z is in f2xm1's domain.
104 103 fldl 4(%esp) / push x
105 104 fldl2e / push log2e }not for xtndd_dbl
106 105 fmulp %st,%st(1) / z = x*log2e }not for xtndd_dbl
107 106 f2xm1 / 2**(x*log2(e))-1 = e**x - 1
108 107 ret
109 108
110 109 .not_finite:
111 110 / Here, flags still have settings from execution of
112 111 / cmpl $0x7ff00000,%ecx / hi_32(|x|) > hi_32(INF)?
113 112 ja .NaN_or_pinf / if not, x may be +/- INF
114 113 movl 4(%esp),%edx / edx <-- lo_32(x)
115 114 cmpl $0,%edx / lo_32(x) = 0?
116 115 jne .NaN_or_pinf / if not, x is NaN
117 116 movl 8(%esp),%eax / eax <-- hi_32(x)
118 117 andl $0x80000000,%eax / here, x is infinite, but +/-?
119 118 jz .NaN_or_pinf / branch if x = +INF
120 119 fld1 / Here, x = -inf, so return -1
121 120 fchs
122 121 ret
123 122
124 123 .NaN_or_pinf:
125 124 / Here, x = NaN or +inf, so load x and return immediately.
126 125 fldl 4(%esp)
127 126 fwait
128 127 ret
129 128 .align 4
130 129 SET_SIZE(expm1)
↓ open down ↓ |
87 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX