| 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.2.4 |
| 10 | The fesetexceptflag function sets the complete status for those |
| 11 | exception flags indicated by the argument excepts, according to the |
| 12 | representation in the object pointed to by flagp. The value of |
| 13 | *flagp shall have been set by a previous call to fegetexceptflag |
| 14 | whose second argument represented at least those exceptions |
| 15 | represented by the argument excepts. This function does not raise |
| 16 | exceptions, but only sets the state of the flags. */ |
| 17 | |
| 18 | int fesetexceptflag(const fexcept_t *status, int excepts) |
| 19 | { |
| 20 | fenv_t env; |
| 21 | |
| 22 | excepts &= FE_ALL_EXCEPT; |
| 23 | if(!excepts) |
| 24 | return 0; |
| 25 | |
| 26 | fegetenv(&env); |
| 27 | env._Fe_stat &= ~fenv_encode(excepts, excepts); |
| 28 | env._Fe_stat |= *status & fenv_encode(excepts, excepts); |
| 29 | return fesetenv(&env); |
| 30 | } |