[libc-commits] [PATCH] D105085: [libc] Clear all exceptions before setting in fesetexceptflag.
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Jun 30 10:30:03 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG804dc3dcf27d: [libc] Clear all exceptions before setting in fesetexceptflag. (authored by sivachandra).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105085/new/
https://reviews.llvm.org/D105085
Files:
libc/src/fenv/fesetexceptflag.cpp
libc/test/src/fenv/exception_flags_test.cpp
Index: libc/test/src/fenv/exception_flags_test.cpp
===================================================================
--- libc/test/src/fenv/exception_flags_test.cpp
+++ libc/test/src/fenv/exception_flags_test.cpp
@@ -42,4 +42,15 @@
// Cleanup
__llvm_libc::fputil::clearExcept(e);
}
+
+ // Next, we will raise one exception and save the flags.
+ __llvm_libc::fputil::raiseExcept(FE_INVALID);
+ fexcept_t eflags;
+ __llvm_libc::fegetexceptflag(&eflags, FE_ALL_EXCEPT);
+ // Clear all exceptions and raise two other exceptions.
+ __llvm_libc::fputil::clearExcept(FE_ALL_EXCEPT);
+ __llvm_libc::fputil::raiseExcept(FE_OVERFLOW | FE_INEXACT);
+ // When we set the flags and test, we should only see FE_INVALID.
+ __llvm_libc::fesetexceptflag(&eflags, FE_ALL_EXCEPT);
+ EXPECT_EQ(__llvm_libc::fputil::testExcept(FE_ALL_EXCEPT), FE_INVALID);
}
Index: libc/src/fenv/fesetexceptflag.cpp
===================================================================
--- libc/src/fenv/fesetexceptflag.cpp
+++ libc/src/fenv/fesetexceptflag.cpp
@@ -21,6 +21,7 @@
static_assert(sizeof(int) >= sizeof(fexcept_t),
"fexcept_t value cannot fit in an int value.");
int excepts_to_set = static_cast<const int>(*flagp) & excepts;
+ fputil::clearExcept(FE_ALL_EXCEPT);
return fputil::setExcept(excepts_to_set);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105085.355616.patch
Type: text/x-patch
Size: 1337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210630/b1dd80e7/attachment-0001.bin>
More information about the libc-commits
mailing list