1#ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_
2#define FORTRAN_TEST_EVALUATE_FP_TESTING_H_
3
4#include "flang/Evaluate/target.h"
5#include <fenv.h>
6
7using Fortran::common::RoundingMode;
8using Fortran::evaluate::RealFlags;
9using Fortran::evaluate::Rounding;
10
11class ScopedHostFloatingPointEnvironment {
12public:
13 ScopedHostFloatingPointEnvironment(bool treatSubnormalOperandsAsZero = false,
14 bool flushSubnormalResultsToZero = false);
15 ~ScopedHostFloatingPointEnvironment();
16 void ClearFlags() const;
17 static RealFlags CurrentFlags();
18 static void SetRounding(Rounding rounding);
19
20private:
21 fenv_t originalFenv_;
22#if __x86_64__
23 unsigned int originalMxcsr;
24#endif
25};
26
27#endif // FORTRAN_TEST_EVALUATE_FP_TESTING_H_
28

source code of flang/unittests/Evaluate/fp-testing.h