xref: /aosp_15_r20/external/llvm-libc/test/UnitTest/RoundingModeUtils.h (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-- RoundingModeUtils.h -------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_TEST_UNITTEST_ROUNDINGMODEUTILS_H
10 #define LLVM_LIBC_TEST_UNITTEST_ROUNDINGMODEUTILS_H
11 
12 #include "src/__support/macros/config.h"
13 #include <stdint.h>
14 
15 namespace LIBC_NAMESPACE_DECL {
16 namespace fputil {
17 namespace testing {
18 
19 enum class RoundingMode : uint8_t { Upward, Downward, TowardZero, Nearest };
20 
21 struct ForceRoundingMode {
22   ForceRoundingMode(RoundingMode);
23   ~ForceRoundingMode();
24 
25   int old_rounding_mode;
26   int rounding_mode;
27   bool success;
28 };
29 
30 template <RoundingMode R> struct ForceRoundingModeTest : ForceRoundingMode {
ForceRoundingModeTestForceRoundingModeTest31   ForceRoundingModeTest() : ForceRoundingMode(R) {}
32 };
33 
34 } // namespace testing
35 } // namespace fputil
36 } // namespace LIBC_NAMESPACE_DECL
37 
38 #endif // LLVM_LIBC_TEST_UNITTEST_ROUNDINGMODEUTILS_H
39