xref: /llvm-project/libc/test/UnitTest/RoundingModeUtils.h (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1447d59e0SSiva Chandra Reddy //===-- RoundingModeUtils.h -------------------------------------*- C++ -*-===//
2447d59e0SSiva Chandra Reddy //
3447d59e0SSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4447d59e0SSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information.
5447d59e0SSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6447d59e0SSiva Chandra Reddy //
7447d59e0SSiva Chandra Reddy //===----------------------------------------------------------------------===//
8447d59e0SSiva Chandra Reddy 
9330793c9SNick Desaulniers #ifndef LLVM_LIBC_TEST_UNITTEST_ROUNDINGMODEUTILS_H
10330793c9SNick Desaulniers #define LLVM_LIBC_TEST_UNITTEST_ROUNDINGMODEUTILS_H
11447d59e0SSiva Chandra Reddy 
12*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
13447d59e0SSiva Chandra Reddy #include <stdint.h>
14447d59e0SSiva Chandra Reddy 
15*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
16447d59e0SSiva Chandra Reddy namespace fputil {
17447d59e0SSiva Chandra Reddy namespace testing {
18447d59e0SSiva Chandra Reddy 
19447d59e0SSiva Chandra Reddy enum class RoundingMode : uint8_t { Upward, Downward, TowardZero, Nearest };
20447d59e0SSiva Chandra Reddy 
21447d59e0SSiva Chandra Reddy struct ForceRoundingMode {
22447d59e0SSiva Chandra Reddy   ForceRoundingMode(RoundingMode);
23447d59e0SSiva Chandra Reddy   ~ForceRoundingMode();
24447d59e0SSiva Chandra Reddy 
25447d59e0SSiva Chandra Reddy   int old_rounding_mode;
26447d59e0SSiva Chandra Reddy   int rounding_mode;
27055be3c3STue Ly   bool success;
28447d59e0SSiva Chandra Reddy };
29447d59e0SSiva Chandra Reddy 
30447d59e0SSiva Chandra Reddy template <RoundingMode R> struct ForceRoundingModeTest : ForceRoundingMode {
31447d59e0SSiva Chandra Reddy   ForceRoundingModeTest() : ForceRoundingMode(R) {}
32447d59e0SSiva Chandra Reddy };
33447d59e0SSiva Chandra Reddy 
34447d59e0SSiva Chandra Reddy } // namespace testing
35447d59e0SSiva Chandra Reddy } // namespace fputil
36*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
37447d59e0SSiva Chandra Reddy 
38330793c9SNick Desaulniers #endif // LLVM_LIBC_TEST_UNITTEST_ROUNDINGMODEUTILS_H
39