summaryrefslogtreecommitdiff
path: root/libc/src/math/generic/sinhf.cpp
diff options
context:
space:
mode:
authorTue Ly <lntue@google.com>2023-06-06 11:50:26 -0400
committerTue Ly <lntue@google.com>2023-06-12 09:36:41 -0400
commita98243129530c852cbd42bffafc74ab635934d8a (patch)
tree1ffbfcc04f7addce908bdd20746182b0a302362b /libc/src/math/generic/sinhf.cpp
parent282324aa4a6c29d5ce31c66f8def15d9bd8e84e4 (diff)
[libc] Add platform independent floating point rounding mode checks.
Many math functions need to check for floating point rounding modes to return correct values. Currently most of them use the internal implementation of `fegetround`, which is platform-dependent and blocking math functions to be enabled on platforms with unimplemented `fegetround`. In this change, we add platform independent rounding mode checks and switching math functions to use them instead. https://github.com/llvm/llvm-project/issues/63016 Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D152280
Diffstat (limited to 'libc/src/math/generic/sinhf.cpp')
-rw-r--r--libc/src/math/generic/sinhf.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/libc/src/math/generic/sinhf.cpp b/libc/src/math/generic/sinhf.cpp
index 92edd4ea6a98..7f4d0d6e3af2 100644
--- a/libc/src/math/generic/sinhf.cpp
+++ b/libc/src/math/generic/sinhf.cpp
@@ -8,6 +8,7 @@
#include "src/math/sinhf.h"
#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include "src/math/generic/explogxf.h"
@@ -33,7 +34,7 @@ LLVM_LIBC_FUNCTION(float, sinhf, (float x)) {
if (xbits.is_inf())
return x;
- int rounding = fputil::get_round();
+ int rounding = fputil::quick_get_round();
if (sign) {
if (LIBC_UNLIKELY(rounding == FE_UPWARD || rounding == FE_TOWARDZERO))
return FPBits(FPBits::MAX_NORMAL | FPBits::FloatProp::SIGN_MASK)
@@ -53,7 +54,7 @@ LLVM_LIBC_FUNCTION(float, sinhf, (float x)) {
if (LIBC_UNLIKELY(x_abs <= 0x3da0'0000U)) {
// |x| = 0.0005589424981735646724700927734375
if (LIBC_UNLIKELY(x_abs == 0x3a12'85ffU)) {
- if (fputil::get_round() == FE_TONEAREST)
+ if (fputil::fenv_is_round_to_nearest())
return x;
}