3 * Copyright (C) 2001 Jason Beegan
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include <gsl/gsl_ieee_utils.h>
22 #include <gsl/gsl_errno.h>
24 /* This is a copy of fp-netbsd.c, modified for openbsd by Toby White
28 gsl_ieee_set_mode (int precision, int rounding, int exception_mask)
35 case GSL_IEEE_SINGLE_PRECISION:
36 GSL_ERROR ("OpenBSD only supports default precision rounding",
39 case GSL_IEEE_DOUBLE_PRECISION:
40 GSL_ERROR ("OpenBSD only supports default precision rounding",
43 case GSL_IEEE_EXTENDED_PRECISION:
44 GSL_ERROR ("OpenBSD only supports default precision rounding",
51 case GSL_IEEE_ROUND_TO_NEAREST:
55 case GSL_IEEE_ROUND_DOWN:
59 case GSL_IEEE_ROUND_UP:
63 case GSL_IEEE_ROUND_TO_ZERO:
72 /* Turn on all available exceptions apart from 'inexact'.
73 Denormalized operand exception not available on all platforms. */
75 mode = FP_X_INV | FP_X_DZ | FP_X_OFL | FP_X_UFL;
77 mode = mode | FP_X_DNML;
80 if (exception_mask & GSL_IEEE_MASK_INVALID)
83 if (exception_mask & GSL_IEEE_MASK_DENORMALIZED)
92 GSL_ERROR ("OpenBSD does not support the denormalized operand exception on this platform. "
93 "Use 'mask-denormalized' to work around this.",
98 if (exception_mask & GSL_IEEE_MASK_DIVISION_BY_ZERO)
101 if (exception_mask & GSL_IEEE_MASK_OVERFLOW)
104 if (exception_mask & GSL_IEEE_MASK_UNDERFLOW)
107 if (exception_mask & GSL_IEEE_TRAP_INEXACT)