summaryrefslogtreecommitdiff
path: root/src/fenv/_fenv.h
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-06-07 13:43:01 -0400
committerJakob Kaivo <jkk@ung.org>2024-06-07 13:43:01 -0400
commit85ee577101d7ee7fdafcc73bd73e2a3c3944022d (patch)
treea545e2fdac8b85ad3d09d17d4f3ef2092a5492e0 /src/fenv/_fenv.h
parent5fdba7baaab65651eb5bd431e969d59242e484db (diff)
track usable fenv_t values
Diffstat (limited to 'src/fenv/_fenv.h')
-rw-r--r--src/fenv/_fenv.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/fenv/_fenv.h b/src/fenv/_fenv.h
index 0455fef3..debfc2ad 100644
--- a/src/fenv/_fenv.h
+++ b/src/fenv/_fenv.h
@@ -1,25 +1,33 @@
#include <fenv.h>
#include "_safety.h"
+struct __fenv_t {
+ int flags;
+};
+
extern struct __fenv_h {
fexcept_t *valid_fexcept;
size_t nvalid_fexcept;
- fenv_t *valid_fenv;
- size_t nvalid_fenv;
+ struct __fenv_t *fenv;
+ size_t nfenv;
} __fenv_h;
#ifdef NDEBUG
#define ASSERT_VALID_EXCEPTION_MASK(_n) (void)(_n)
-#define ASSERT_PREVIOUS_FEXCEPT(_f, _e) (void)(_f)
-#define ASSERT_PREVIOUS_FENV(_f) (void)(_f)
+#define ASSERT_PREV_FEXCEPT(_f, _e) (void)(_f)
+#define ASSERT_PREV_FENV(_f) (void)(_f)
#else
#define ASSERT_VALID_EXCEPTION_MASK(_n) do { \
if (((_n) & ~(FE_ALL_EXCEPT)) != 0) { \
- UNDEFINED("In call to %s(), exception mask 0x(%jx) is not valid", __func__, (uintmax_t)(_n)); \
+ UNDEFINED("In call to %s(): exception mask 0x(%jx) is not valid", __func__, (uintmax_t)(_n)); \
} \
} while (0)
/* TODO!!! */
-#define ASSERT_PREVIOUS_FEXCEPT(_f, _e) (void)(_f)
-#define ASSERT_PREVIOUS_FENV(_f) (void)(_f)
+#define ASSERT_PREV_FEXCEPT(_f, _e) (void)(_f)
+#define ASSERT_PREV_FENV(__f) do { \
+ if (!(envp == FE_DFL_ENV) || (envp->__impl >= __fenv_h.fenv && envp->__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)
#endif