[libc-commits] [libc] 4f281fa - [libc] Reset rounding mode after fsetround tests

Alex Brachet via libc-commits libc-commits at lists.llvm.org
Wed Jul 13 08:43:24 PDT 2022


Author: Alex Brachet
Date: 2022-07-13T15:42:47Z
New Revision: 4f281fa2a86b1806ec3143373795d8eac559e37f

URL: https://github.com/llvm/llvm-project/commit/4f281fa2a86b1806ec3143373795d8eac559e37f
DIFF: https://github.com/llvm/llvm-project/commit/4f281fa2a86b1806ec3143373795d8eac559e37f.diff

LOG: [libc] Reset rounding mode after fsetround tests

Differential Revision: https://reviews.llvm.org/D129619

Added: 
    

Modified: 
    libc/test/src/fenv/rounding_mode_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/fenv/rounding_mode_test.cpp b/libc/test/src/fenv/rounding_mode_test.cpp
index 66f564d174e34..add006a2c1cdb 100644
--- a/libc/test/src/fenv/rounding_mode_test.cpp
+++ b/libc/test/src/fenv/rounding_mode_test.cpp
@@ -14,6 +14,13 @@
 #include <fenv.h>
 
 TEST(LlvmLibcRoundingModeTest, SetAndGet) {
+  struct ResetDefaultRoundingMode {
+    int original;
+    ~ResetDefaultRoundingMode() {
+      __llvm_libc::fesetround(original);
+    }
+  } reset{__llvm_libc::fegetround()};
+
   int s = __llvm_libc::fesetround(FE_TONEAREST);
   EXPECT_EQ(s, 0);
   int rm = __llvm_libc::fegetround();


        


More information about the libc-commits mailing list