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_get_handling = fex_get_handling
31 #pragma weak __fex_set_handling = fex_set_handling
32 #pragma weak __fex_getexcepthandler = fex_getexcepthandler
33 #pragma weak __fex_setexcepthandler = fex_setexcepthandler
34
35 #include <fenv.h>
36 #include <ucontext.h>
37 #include <thread.h>
38 #include "fex_handler.h"
39
40 int fex_get_handling(int e)
41 {
42 struct fex_handler_data *thr_handlers;
43 int i;
44
45 thr_handlers = __fex_get_thr_handlers();
46 for (i = 0; i < FEX_NUM_EXC; i++)
47 if (e & (1 << i))
48 return thr_handlers[i].__mode;
49 return FEX_NOHANDLER;
50 }
51
52 int fex_set_handling(int e, int mode, void (*handler)())
53 {
54 struct fex_handler_data *thr_handlers;
55 int i;
56
57 if (e & ~((1 << FEX_NUM_EXC) - 1))
58 return 0;
59 thr_handlers = __fex_get_thr_handlers();
60 for (i = 0; i < FEX_NUM_EXC; i++) {
61 if (e & (1 << i)) {
62 thr_handlers[i].__mode = mode;
63 thr_handlers[i].__handler = handler;
64 }
65 }
66 __fex_update_te();
67 return 1;
68 }
69
70 void fex_getexcepthandler(fex_handler_t *buf, int e)
71 {
72 struct fex_handler_data *thr_handlers;
73 int i;
74
75 thr_handlers = __fex_get_thr_handlers();
76 for (i = 0; i < FEX_NUM_EXC; i++)
77 if (e & (1 << i))
78 (*buf)[i] = thr_handlers[i];
79 }
80
81 void fex_setexcepthandler(const fex_handler_t *buf, int e)
82 {
83 struct fex_handler_data *thr_handlers;
84 int i;
85
86 thr_handlers = __fex_get_thr_handlers();
87 for (i = 0; i < FEX_NUM_EXC; i++)
88 if (e & (1 << i))
89 thr_handlers[i] = (*buf)[i];
90 __fex_update_te();
91 }
|
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_get_handling = fex_get_handling
32 #pragma weak __fex_set_handling = fex_set_handling
33 #pragma weak __fex_getexcepthandler = fex_getexcepthandler
34 #pragma weak __fex_setexcepthandler = fex_setexcepthandler
35
36 #include <fenv.h>
37 #include <ucontext.h>
38 #include <thread.h>
39 #include "fex_handler.h"
40
41 int
42 fex_get_handling(int e)
43 {
44 struct fex_handler_data *thr_handlers;
45 int i;
46
47 thr_handlers = __fex_get_thr_handlers();
48
49 for (i = 0; i < FEX_NUM_EXC; i++)
50 if (e & (1 << i))
51 return (thr_handlers[i].__mode);
52
53 return (FEX_NOHANDLER);
54 }
55
56 int
57 fex_set_handling(int e, int mode, void (*handler)())
58 {
59 struct fex_handler_data *thr_handlers;
60 int i;
61
62 if (e & ~((1 << FEX_NUM_EXC) - 1))
63 return (0);
64
65 thr_handlers = __fex_get_thr_handlers();
66
67 for (i = 0; i < FEX_NUM_EXC; i++) {
68 if (e & (1 << i)) {
69 thr_handlers[i].__mode = mode;
70 thr_handlers[i].__handler = handler;
71 }
72 }
73
74 __fex_update_te();
75 return (1);
76 }
77
78 void
79 fex_getexcepthandler(fex_handler_t *buf, int e)
80 {
81 struct fex_handler_data *thr_handlers;
82 int i;
83
84 thr_handlers = __fex_get_thr_handlers();
85
86 for (i = 0; i < FEX_NUM_EXC; i++)
87 if (e & (1 << i))
88 (*buf)[i] = thr_handlers[i];
89 }
90
91 void
92 fex_setexcepthandler(const fex_handler_t *buf, int e)
93 {
94 struct fex_handler_data *thr_handlers;
95 int i;
96
97 thr_handlers = __fex_get_thr_handlers();
98
99 for (i = 0; i < FEX_NUM_EXC; i++)
100 if (e & (1 << i))
101 thr_handlers[i] = (*buf)[i];
102
103 __fex_update_te();
104 }
|