OSDN Git Service

* runtime/fpu.c: Add _GNU_SOURCE definition.
[pf3gnuchains/gcc-fork.git] / libgfortran / config / fpu-glibc.h
1 /* FPU-related code for systems with GNU libc.
2    Copyright 2005 Free Software Foundation, Inc.
3    Contributed by Francois-Xavier Coudert <coudert@clipper.ens.fr>
4
5 This file is part of the GNU Fortran 95 runtime library (libgfortran).
6
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.
11
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.)
20
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.
25
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.  */
30
31
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).  */
35
36 #ifdef HAVE_FENV_H
37 #include <fenv.h>
38 #endif
39
40 void set_fpu (void)
41 {
42   fedisableexcept (FE_ALL_EXCEPT);
43
44   if (options.fpe & GFC_FPE_INVALID)
45 #ifdef FE_INVALID
46     feenableexcept (FE_INVALID);
47 #else
48     st_printf ("Fortran runtime warning: IEEE 'invalid operation' "
49                "exception not supported.\n");
50 #endif
51
52 /* glibc does never have a FE_DENORMAL.  */
53   if (options.fpe & GFC_FPE_DENORMAL)
54 #ifdef FE_DENORMAL
55     feenableexcept (FE_DENORMAL);
56 #else
57     st_printf ("Fortran runtime warning: IEEE 'denormal number' "
58                "exception not supported.\n");
59 #endif
60
61   if (options.fpe & GFC_FPE_ZERO)
62 #ifdef FE_DIVBYZERO
63     feenableexcept (FE_DIVBYZERO);
64 #else
65     st_printf ("Fortran runtime warning: IEEE 'division by zero' "
66                "exception not supported.\n");
67 #endif
68
69   if (options.fpe & GFC_FPE_OVERFLOW)
70 #ifdef FE_OVERFLOW
71     feenableexcept (FE_OVERFLOW);
72 #else
73     st_printf ("Fortran runtime warning: IEEE 'overflow' "
74                "exception not supported.\n");
75 #endif
76
77   if (options.fpe & GFC_FPE_UNDERFLOW)
78 #ifdef FE_UNDERFLOW
79     feenableexcept (FE_UNDERFLOW);
80 #else
81     st_printf ("Fortran runtime warning: IEEE 'underflow' "
82                "exception not supported.\n");
83 #endif
84
85   if (options.fpe & GFC_FPE_PRECISION)
86 #ifdef FE_INEXACT
87     feenableexcept (FE_INEXACT);
88 #else
89     st_printf ("Fortran runtime warning: IEEE 'loss of precision' "
90                "exception not supported.\n");
91 #endif
92 }