5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 */
25 /*
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 #pragma weak __fex_merge_flags = fex_merge_flags
31
32 #pragma weak __feholdexcept = feholdexcept
33 #pragma weak __feupdateenv = feupdateenv
34 #pragma weak __fegetenv = fegetenv
35 #pragma weak __fesetenv = fesetenv
36
37 #pragma weak feupdateenv96 = feupdateenv
38 #pragma weak fegetenv96 = fegetenv
39 #pragma weak fesetenv96 = fesetenv
40
41 #include <fenv.h>
42 #include <ucontext.h>
43 #include <thread.h>
44 #include "fex_handler.h"
45 #include "fenv_inlines.h"
46
47 const fenv_t __fenv_dfl_env = {
48 {
49 { FEX_NONSTOP, (void(*)())0 },
50 { FEX_NONSTOP, (void(*)())0 },
51 { FEX_NONSTOP, (void(*)())0 },
52 { FEX_NONSTOP, (void(*)())0 },
53 { FEX_NONSTOP, (void(*)())0 },
54 { FEX_NONSTOP, (void(*)())0 },
55 { FEX_NONSTOP, (void(*)())0 },
56 { FEX_NONSTOP, (void(*)())0 },
57 { FEX_NONSTOP, (void(*)())0 },
58 { FEX_NONSTOP, (void(*)())0 },
59 { FEX_NONSTOP, (void(*)())0 },
60 { FEX_NONSTOP, (void(*)())0 },
61 },
62 #ifdef __x86
63 0x13000000
64 #else
65 0
66 #endif
67 };
68
69 int feholdexcept(fenv_t *p)
70 {
71 (void) fegetenv(p);
72 (void) feclearexcept(FE_ALL_EXCEPT);
73 return !fex_set_handling(FEX_ALL, FEX_NONSTOP, NULL);
74 }
75
76 int feholdexcept96(fenv_t *p)
77 {
78 (void) fegetenv(p);
79 (void) feclearexcept(FE_ALL_EXCEPT);
80 return fex_set_handling(FEX_ALL, FEX_NONSTOP, NULL);
81 }
82
83 int feupdateenv(const fenv_t *p)
84 {
85 unsigned long fsr;
86
87 __fenv_getfsr(&fsr);
88 (void) fesetenv(p);
89 (void) feraiseexcept((int)__fenv_get_ex(fsr));
90 return 0;
91 }
92
93 int fegetenv(fenv_t *p)
94 {
95 fex_getexcepthandler(&p->__handlers, FEX_ALL);
96 __fenv_getfsr(&p->__fsr);
97 return 0;
98 }
99
100 int fesetenv(const fenv_t *p)
101 {
102 __fenv_setfsr(&p->__fsr);
103 fex_setexcepthandler(&p->__handlers, FEX_ALL);
104 return 0;
105 }
106
107 void fex_merge_flags(const fenv_t *p)
108 {
109 unsigned long fsr;
110
111 __fenv_getfsr(&fsr);
112 __fenv_set_ex(fsr, __fenv_get_ex(fsr) | __fenv_get_ex(p->__fsr));
113 __fenv_setfsr(&fsr);
114 if (fex_get_log())
115 __fex_update_te();
116 }
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 */
25
26 /*
27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
29 */
30
31 #pragma weak __fex_merge_flags = fex_merge_flags
32
33 #pragma weak __feholdexcept = feholdexcept
34 #pragma weak __feupdateenv = feupdateenv
35 #pragma weak __fegetenv = fegetenv
36 #pragma weak __fesetenv = fesetenv
37
38 #pragma weak feupdateenv96 = feupdateenv
39 #pragma weak fegetenv96 = fegetenv
40 #pragma weak fesetenv96 = fesetenv
41
42 #include <fenv.h>
43 #include <ucontext.h>
44 #include <thread.h>
45 #include "fex_handler.h"
46 #include "fenv_inlines.h"
47
48 const fenv_t __fenv_dfl_env = {
49 {
50 { FEX_NONSTOP, (void (*)()) 0 },
51 { FEX_NONSTOP, (void (*)()) 0 },
52 { FEX_NONSTOP, (void (*)()) 0 },
53 { FEX_NONSTOP, (void (*)()) 0 },
54 { FEX_NONSTOP, (void (*)()) 0 },
55 { FEX_NONSTOP, (void (*)()) 0 },
56 { FEX_NONSTOP, (void (*)()) 0 },
57 { FEX_NONSTOP, (void (*)()) 0 },
58 { FEX_NONSTOP, (void (*)()) 0 },
59 { FEX_NONSTOP, (void (*)()) 0 },
60 { FEX_NONSTOP, (void (*)()) 0 },
61 { FEX_NONSTOP, (void (*)()) 0 },
62 },
63 #ifdef __x86
64 0x13000000
65 #else
66 0
67 #endif
68 };
69
70 int
71 feholdexcept(fenv_t *p)
72 {
73 (void) fegetenv(p);
74 (void) feclearexcept(FE_ALL_EXCEPT);
75 return (!fex_set_handling(FEX_ALL, FEX_NONSTOP, NULL));
76 }
77
78 int
79 feholdexcept96(fenv_t *p)
80 {
81 (void) fegetenv(p);
82 (void) feclearexcept(FE_ALL_EXCEPT);
83 return (fex_set_handling(FEX_ALL, FEX_NONSTOP, NULL));
84 }
85
86 int
87 feupdateenv(const fenv_t *p)
88 {
89 unsigned long fsr;
90
91 __fenv_getfsr(&fsr);
92 (void) fesetenv(p);
93 (void) feraiseexcept((int)__fenv_get_ex(fsr));
94 return (0);
95 }
96
97 int
98 fegetenv(fenv_t *p)
99 {
100 fex_getexcepthandler(&p->__handlers, FEX_ALL);
101 __fenv_getfsr(&p->__fsr);
102 return (0);
103 }
104
105 int
106 fesetenv(const fenv_t *p)
107 {
108 __fenv_setfsr(&p->__fsr);
109 fex_setexcepthandler(&p->__handlers, FEX_ALL);
110 return (0);
111 }
112
113 void
114 fex_merge_flags(const fenv_t *p)
115 {
116 unsigned long fsr;
117
118 __fenv_getfsr(&fsr);
119 __fenv_set_ex(fsr, __fenv_get_ex(fsr) | __fenv_get_ex(p->__fsr));
120 __fenv_setfsr(&fsr);
121
122 if (fex_get_log())
123 __fex_update_te();
124 }
|