OSDN Git Service

Make floating point environment more robust.
[mingw/mingw-org-wsl.git] / mingwrt / CRT_fenv.c
1 /*
2  * CRT_fenv.c
3  *
4  * Specifies the default FPU configuration, in terms of one of the
5  * predefined floating point environments defined in <fenv.h>, via
6  * a global variable assignment, whence the specified selection will
7  * be copied to FE_DFL_ENV at application start-up.
8  *
9  * $Id$
10  *
11  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
12  * Copyright (C) 2017, MinGW.org Project.
13  *
14  *
15  * Permission is hereby granted, free of charge, to any person obtaining a
16  * copy of this software and associated documentation files (the "Software"),
17  * to deal in the Software without restriction, including without limitation
18  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19  * and/or sell copies of the Software, and to permit persons to whom the
20  * Software is furnished to do so, subject to the following conditions:
21  *
22  * The above copyright notice, this permission notice, and the following
23  * disclaimer shall be included in all copies or substantial portions of
24  * the Software.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
29  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
32  * DEALINGS IN THE SOFTWARE.
33  *
34  *
35  * This file replaces the two original files CRT_fp8.c, and CRT_fp10.c;
36  * compile it using each of the two commands:
37  *
38  *   gcc -c -D_CRT_FE_DFL_ENV=8  CRT_fenv.c -o CRT_fp8.o
39  *   gcc -c -D_CRT_FE_DFL_ENV=10 CRT_fenv.c -o CRT_fp10.o
40  *
41  * to create the complementary pair of object files, reproducing the
42  * intended effect of the original similarly named object file pair.
43  *
44  */
45 #include <fenv.h>
46
47 #ifndef _CRT_FE_DFL_ENV
48 /* If the user neglects to specify this, assume that the intention is
49  * to reproduce, in FE_DFL_ENV, the effect of the original CRT_fp10.o
50  * object file.
51  */
52 # define _CRT_FE_DFL_ENV  10
53 #endif
54
55 /* Initialize the "_CRT_fenv" global variable, based on compile time
56  * selection, to map FE_DFL_ENV to FE_PC53_env, (precision configured
57  * to 53-bits), or to FE_PC64_ENV, (precision configured to 64-bits),
58  * via initial FPU configuration to FE_PD53_ENV, (precision default
59  * 53-bits), or FE_PD64_ENV, (precision default 64-bits).
60  */
61 const fenv_t *_CRT_fenv = (_CRT_FE_DFL_ENV == 8) ? FE_PD53_ENV : FE_PD64_ENV;
62
63 /* $RCSfile$: end of file */