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]
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
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
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
43 #include <sys/ieeefp.h>
46 #include "fex_handler.h"
47 #include "fenv_inlines.h"
50 int feclearexcept(int e
)
55 __fenv_set_ex(fsr
, __fenv_get_ex(fsr
) & ~e
);
63 * note - __fex_hdlr depends on fetestexcept following feraiseexcept
65 int feraiseexcept(int e
)
74 if (e
& FE_DIVBYZERO
) {
78 if (e
& FE_OVERFLOW
) {
79 /* if overflow is not trapped, avoid raising inexact */
81 if (!(__fenv_get_te(fsr
) & (1 << fp_trap_overflow
))) {
82 __fenv_set_ex(fsr
, __fenv_get_ex(fsr
) | FE_OVERFLOW
);
90 if (e
& FE_UNDERFLOW
) {
91 /* if underflow is not trapped, avoid raising inexact */
93 if (!(__fenv_get_te(fsr
) & (1 << fp_trap_underflow
))) {
94 __fenv_set_ex(fsr
, __fenv_get_ex(fsr
) | FE_UNDERFLOW
);
102 if (e
& FE_INEXACT
) {
109 int fetestexcept(int e
)
114 return (int)__fenv_get_ex(fsr
) & e
;
117 int fegetexceptflag(fexcept_t
*p
, int e
)
122 *p
= (int)__fenv_get_ex(fsr
) & e
;
126 int fesetexceptflag(const fexcept_t
*p
, int e
)
131 __fenv_set_ex(fsr
, (((int)__fenv_get_ex(fsr
) & ~e
) | (*p
& e
)) &