| 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 <fenv.h> |
| 8 | #include <internal.h> |
| 9 | |
| 10 | /* 7.6.2.2 |
| 11 | The fegetexceptflag function stores an implementation-defined |
| 12 | representation of the exception flags indicated by the argument |
| 13 | excepts in the object pointed to by the argument flagp. */ |
| 14 | |
| 15 | int fegetexceptflag(fexcept_t *status, int excepts) |
| 16 | { |
| 17 | #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) |
| 18 | unsigned int x87, sse = 0; |
| 19 | __mingw_setfp(NULL, 0, &x87, 0); |
| 20 | if (__mingw_has_sse()) |
| 21 | __mingw_setfp_sse(NULL, 0, &sse, 0); |
| 22 | *status = fenv_encode(x87 & excepts, sse & excepts); |
| 23 | #else |
| 24 | *status = fenv_encode(0, __mingw_statusfp() & excepts); |
| 25 | #endif |
| 26 | return 0; |
| 27 | } |