diff options
Diffstat (limited to 'src/fenv/_fenv.h')
-rw-r--r-- | src/fenv/_fenv.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/fenv/_fenv.h b/src/fenv/_fenv.h index debfc2ad..b35ec050 100644 --- a/src/fenv/_fenv.h +++ b/src/fenv/_fenv.h @@ -5,9 +5,14 @@ struct __fenv_t { int flags; }; +struct __fexcept_t { + int mask; + int set; +}; + extern struct __fenv_h { - fexcept_t *valid_fexcept; - size_t nvalid_fexcept; + struct __fexcept_t *fexcept; + size_t nfexcept; struct __fenv_t *fenv; size_t nfenv; } __fenv_h; @@ -23,10 +28,17 @@ extern struct __fenv_h { } \ } while (0) -/* TODO!!! */ -#define ASSERT_PREV_FEXCEPT(_f, _e) (void)(_f) +#define ASSERT_PREV_FEXCEPT(__f, __e) do { \ + if (!(__f->__impl >= __fenv_h.fexcept && __f->__impl <= __fenv_h.fexcept + __fenv_h.nfexcept)) { \ + UNDEFINED("In call to %s(): %s must be previously set by calling fegetexceptflag()", __func__, #__f); \ + } \ + if ((__f->__impl->mask & (__e)) != (__e)) { \ + UNDEFINED("In call to %s(): Attempting to set flags not specified by previous call to fegetexceptflag()", __func__); \ + } \ +} while (0) + #define ASSERT_PREV_FENV(__f) do { \ - if (!(envp == FE_DFL_ENV) || (envp->__impl >= __fenv_h.fenv && envp->__impl <= __fenv_h.fenv + __fenv_h.nfenv)) { \ + if (!(__f == FE_DFL_ENV) || (__f->__impl >= __fenv_h.fenv && __f->__impl <= __fenv_h.fenv + __fenv_h.nfenv)) { \ UNDEFINED("In call to %s(): %s must be previously set by calling fegetenv() or feholdexcept()", __func__, #__f); \ } \ } while (0) |