Merge -r 127928:132243 from trunk
[official-gcc.git] / libgfortran / config / fpu-glibc.h
blob27809676fad007b60efed232224a0be593ac878e
1 /* FPU-related code for systems with GNU libc.
2 Copyright 2005, 2007 Free Software Foundation, Inc.
3 Contributed by Francois-Xavier Coudert <coudert@clipper.ens.fr>
5 This file is part of the GNU Fortran 95 runtime library (libgfortran).
7 Libgfortran is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 In addition to the permissions in the GNU General Public License, the
13 Free Software Foundation gives you unlimited permission to link the
14 compiled version of this file into combinations with other programs,
15 and to distribute those combinations without any restriction coming
16 from the use of this file. (The General Public License restrictions
17 do apply in other respects; for example, they cover modification of
18 the file, and distribution when not linked into a combine
19 executable.)
21 Libgfortran is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public
27 License along with libgfortran; see the file COPYING. If not,
28 write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29 Boston, MA 02110-1301, USA. */
32 /* FPU-related code for systems with the GNU libc, providing the
33 feenableexcept function in fenv.h to set individual exceptions
34 (there's nothing to do that in C99). */
36 #ifdef HAVE_FENV_H
37 #include <fenv.h>
38 #endif
40 void set_fpu (void)
42 if (FE_ALL_EXCEPT != 0)
43 fedisableexcept (FE_ALL_EXCEPT);
45 if (options.fpe & GFC_FPE_INVALID)
46 #ifdef FE_INVALID
47 feenableexcept (FE_INVALID);
48 #else
49 st_printf ("Fortran runtime warning: IEEE 'invalid operation' "
50 "exception not supported.\n");
51 #endif
53 /* glibc does never have a FE_DENORMAL. */
54 if (options.fpe & GFC_FPE_DENORMAL)
55 #ifdef FE_DENORMAL
56 feenableexcept (FE_DENORMAL);
57 #else
58 st_printf ("Fortran runtime warning: IEEE 'denormal number' "
59 "exception not supported.\n");
60 #endif
62 if (options.fpe & GFC_FPE_ZERO)
63 #ifdef FE_DIVBYZERO
64 feenableexcept (FE_DIVBYZERO);
65 #else
66 st_printf ("Fortran runtime warning: IEEE 'division by zero' "
67 "exception not supported.\n");
68 #endif
70 if (options.fpe & GFC_FPE_OVERFLOW)
71 #ifdef FE_OVERFLOW
72 feenableexcept (FE_OVERFLOW);
73 #else
74 st_printf ("Fortran runtime warning: IEEE 'overflow' "
75 "exception not supported.\n");
76 #endif
78 if (options.fpe & GFC_FPE_UNDERFLOW)
79 #ifdef FE_UNDERFLOW
80 feenableexcept (FE_UNDERFLOW);
81 #else
82 st_printf ("Fortran runtime warning: IEEE 'underflow' "
83 "exception not supported.\n");
84 #endif
86 if (options.fpe & GFC_FPE_PRECISION)
87 #ifdef FE_INEXACT
88 feenableexcept (FE_INEXACT);
89 #else
90 st_printf ("Fortran runtime warning: IEEE 'loss of precision' "
91 "exception not supported.\n");
92 #endif