Print this page
5261 libm should stop using synonyms.h
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/m9x/feexcept.c
+++ new/usr/src/lib/libm/common/m9x/feexcept.c
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
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25 /*
26 26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 27 * Use is subject to license terms.
28 28 */
29 29
30 -#pragma weak feclearexcept = __feclearexcept
31 -#pragma weak feraiseexcept = __feraiseexcept
32 -#pragma weak fetestexcept = __fetestexcept
33 -#pragma weak fegetexceptflag = __fegetexceptflag
34 -#pragma weak fesetexceptflag = __fesetexceptflag
35 -
36 -#pragma weak feclearexcept96 = __feclearexcept
37 -#pragma weak feraiseexcept96 = __feraiseexcept
38 -#pragma weak fetestexcept96 = __fetestexcept
39 -#pragma weak fegetexceptflag96 = __fegetexceptflag
40 -#pragma weak fesetexceptflag96 = __fesetexceptflag
30 +#pragma weak __feclearexcept = feclearexcept
31 +#pragma weak __feraiseexcept = feraiseexcept
32 +#pragma weak __fetestexcept = fetestexcept
33 +#pragma weak __fegetexceptflag = fegetexceptflag
34 +#pragma weak __fesetexceptflag = fesetexceptflag
35 +
36 +#pragma weak feclearexcept96 = feclearexcept
37 +#pragma weak feraiseexcept96 = feraiseexcept
38 +#pragma weak fetestexcept96 = fetestexcept
39 +#pragma weak fegetexceptflag96 = fegetexceptflag
40 +#pragma weak fesetexceptflag96 = fesetexceptflag
41 41
42 -#include "fenv_synonyms.h"
43 42 #include <fenv.h>
44 43 #include <sys/ieeefp.h>
45 44 #include <ucontext.h>
46 45 #include <thread.h>
47 46 #include "fex_handler.h"
48 47 #include "fenv_inlines.h"
49 48
50 49
51 50 int feclearexcept(int e)
52 51 {
53 52 unsigned long fsr;
54 53
55 54 __fenv_getfsr(&fsr);
56 55 __fenv_set_ex(fsr, __fenv_get_ex(fsr) & ~e);
57 56 __fenv_setfsr(&fsr);
58 57 if (fex_get_log())
59 58 __fex_update_te();
60 59 return 0;
61 60 }
62 61
63 62 /*
64 63 * note - __fex_hdlr depends on fetestexcept following feraiseexcept
65 64 */
66 65 int feraiseexcept(int e)
67 66 {
68 67 volatile double t;
69 68 unsigned long fsr;
70 69
71 70 if (e & FE_INVALID) {
72 71 t = 0.0;
73 72 t /= 0.0;
74 73 }
75 74 if (e & FE_DIVBYZERO) {
76 75 t = 1.0e300;
77 76 t /= 0.0;
78 77 }
79 78 if (e & FE_OVERFLOW) {
80 79 /* if overflow is not trapped, avoid raising inexact */
81 80 __fenv_getfsr(&fsr);
82 81 if (!(__fenv_get_te(fsr) & (1 << fp_trap_overflow))) {
83 82 __fenv_set_ex(fsr, __fenv_get_ex(fsr) | FE_OVERFLOW);
84 83 __fenv_setfsr(&fsr);
85 84 }
86 85 else {
87 86 t = 1.0e300;
88 87 t *= 1.0e300;
89 88 }
90 89 }
91 90 if (e & FE_UNDERFLOW) {
92 91 /* if underflow is not trapped, avoid raising inexact */
93 92 __fenv_getfsr(&fsr);
94 93 if (!(__fenv_get_te(fsr) & (1 << fp_trap_underflow))) {
95 94 __fenv_set_ex(fsr, __fenv_get_ex(fsr) | FE_UNDERFLOW);
96 95 __fenv_setfsr(&fsr);
97 96 }
98 97 else {
99 98 t = 1.0e-307;
100 99 t -= 1.001e-307;
101 100 }
102 101 }
103 102 if (e & FE_INEXACT) {
104 103 t = 1.0e300;
105 104 t += 1.0e-307;
106 105 }
107 106 return 0;
108 107 }
109 108
110 109 int fetestexcept(int e)
111 110 {
112 111 unsigned long fsr;
113 112
114 113 __fenv_getfsr(&fsr);
115 114 return (int)__fenv_get_ex(fsr) & e;
116 115 }
117 116
118 117 int fegetexceptflag(fexcept_t *p, int e)
119 118 {
120 119 unsigned long fsr;
121 120
122 121 __fenv_getfsr(&fsr);
123 122 *p = (int)__fenv_get_ex(fsr) & e;
124 123 return 0;
125 124 }
126 125
127 126 int fesetexceptflag(const fexcept_t *p, int e)
128 127 {
129 128 unsigned long fsr;
130 129
131 130 __fenv_getfsr(&fsr);
132 131 __fenv_set_ex(fsr, (((int)__fenv_get_ex(fsr) & ~e) | (*p & e)) &
133 132 FE_ALL_EXCEPT);
134 133 __fenv_setfsr(&fsr);
135 134 if (fex_get_log())
136 135 __fex_update_te();
137 136 return 0;
138 137 }
↓ open down ↓ |
86 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX