| 1 | /** |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. |
| 3 | * This file is part of the mingw-w64 runtime package. |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ |
| 6 | |
| 7 | #include <internal.h> |
| 8 | |
| 9 | /* 7.6.4.1 |
| 10 | The fegetenv function stores the current floating-point environment |
| 11 | in the object pointed to by envp. */ |
| 12 | |
| 13 | int fegetenv(fenv_t *env) |
| 14 | { |
| 15 | #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) |
| 16 | unsigned int x87, sse = 0; |
| 17 | __mingw_control87_2(0, 0, &x87, &sse); |
| 18 | env->_Fe_ctl = fenv_encode(x87, sse); |
| 19 | __mingw_setfp(NULL, 0, &x87, 0); |
| 20 | if (__mingw_has_sse()) |
| 21 | __mingw_setfp_sse(NULL, 0, &sse, 0); |
| 22 | env->_Fe_stat = fenv_encode(x87, sse); |
| 23 | #else |
| 24 | env->_Fe_ctl = fenv_encode(0, __mingw_controlfp(0, 0)); |
| 25 | env->_Fe_stat = fenv_encode(0, __mingw_statusfp()); |
| 26 | #endif |
| 27 | return 0; |
| 28 | } |
| 29 | |