diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h index 50a101f833c55..ba145a3da45cc 100644 --- a/libc/src/__support/FPUtil/FEnvImpl.h +++ b/libc/src/__support/FPUtil/FEnvImpl.h @@ -15,6 +15,7 @@ #include "src/__support/libc_errno.h" #include "src/__support/macros/attributes.h" // LIBC_INLINE #include "src/__support/macros/config.h" +#include "src/__support/macros/optimization.h" #include "src/__support/macros/properties/architectures.h" #if defined(LIBC_TARGET_ARCH_IS_AARCH64) && defined(__ARM_FP) @@ -71,27 +72,35 @@ LIBC_INLINE int set_env(const fenv_t *) { return 0; } namespace LIBC_NAMESPACE_DECL { namespace fputil { -LIBC_INLINE int clear_except_if_required(int excepts) { +LIBC_INLINE static int clear_except_if_required([[maybe_unused]] int excepts) { +#ifndef LIBC_MATH_HAS_NO_EXCEPT if (math_errhandling & MATH_ERREXCEPT) return clear_except(excepts); +#endif // LIBC_MATH_HAS_NO_EXCEPT return 0; } -LIBC_INLINE int set_except_if_required(int excepts) { +LIBC_INLINE static int set_except_if_required([[maybe_unused]] int excepts) { +#ifndef LIBC_MATH_HAS_NO_EXCEPT if (math_errhandling & MATH_ERREXCEPT) return set_except(excepts); +#endif // LIBC_MATH_HAS_NO_EXCEPT return 0; } -LIBC_INLINE int raise_except_if_required(int excepts) { +LIBC_INLINE static int raise_except_if_required([[maybe_unused]] int excepts) { +#ifndef LIBC_MATH_HAS_NO_EXCEPT if (math_errhandling & MATH_ERREXCEPT) return raise_except(excepts); +#endif // LIBC_MATH_HAS_NO_EXCEPT return 0; } -LIBC_INLINE void set_errno_if_required(int err) { +LIBC_INLINE static void set_errno_if_required([[maybe_unused]] int err) { +#ifndef LIBC_MATH_HAS_NO_ERRNO if (math_errhandling & MATH_ERRNO) libc_errno = err; +#endif // LIBC_MATH_HAS_NO_ERRNO } } // namespace fputil diff --git a/libc/src/__support/macros/optimization.h b/libc/src/__support/macros/optimization.h index 253843e5e37aa..db008d323b3a3 100644 --- a/libc/src/__support/macros/optimization.h +++ b/libc/src/__support/macros/optimization.h @@ -63,4 +63,12 @@ LIBC_INLINE constexpr bool expects_bool_condition(T value, T expected) { #define LIBC_MATH_HAS_INTERMEDIATE_COMP_IN_FLOAT #endif +#if (LIBC_MATH & LIBC_MATH_NO_ERRNO) +#define LIBC_MATH_HAS_NO_ERRNO +#endif + +#if (LIBC_MATH & LIBC_MATH_NO_EXCEPT) +#define LIBC_MATH_HAS_NO_EXCEPT +#endif + #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_OPTIMIZATION_H
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: