summaryrefslogtreecommitdiff
path: root/libm/kvx/fetestexcept.c
diff options
context:
space:
mode:
Diffstat (limited to 'libm/kvx/fetestexcept.c')
-rw-r--r--libm/kvx/fetestexcept.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libm/kvx/fetestexcept.c b/libm/kvx/fetestexcept.c
new file mode 100644
index 000000000..b8ed8f0e6
--- /dev/null
+++ b/libm/kvx/fetestexcept.c
@@ -0,0 +1,21 @@
+/*
+ (C) Copyright 2019 Kalray S.A.
+ This file provides fesetexcept for the Coolidge processor.
+*/
+
+#include <fenv.h>
+
+int fetestexcept(int excepts)
+{
+ /* Mask excepts to be sure only supported flag bits are set */
+ excepts &= FE_ALL_EXCEPT;
+
+ /* Get the current exception flags of the $cs register. */
+ fexcept_t flags;
+ flags = __builtin_kvx_get(KVX_SFR_CS);
+
+ /* Return the floating-point exception macros that are both included
+ in excepts and correspond to the floating-point exceptions
+ currently set. */
+ return (flags & excepts);
+}