[libc-commits] [libc] 40a55ff - [libc][NFC] Make explicit uint16_t casts in fenv
Alex Brachet via libc-commits
libc-commits at lists.llvm.org
Thu Jun 16 09:19:02 PDT 2022
Author: Alex Brachet
Date: 2022-06-16T16:18:44Z
New Revision: 40a55fff0517b5e3093d00a4ec634bb4c29e4abb
URL: https://github.com/llvm/llvm-project/commit/40a55fff0517b5e3093d00a4ec634bb4c29e4abb
DIFF: https://github.com/llvm/llvm-project/commit/40a55fff0517b5e3093d00a4ec634bb4c29e4abb.diff
LOG: [libc][NFC] Make explicit uint16_t casts in fenv
Added:
Modified:
libc/src/__support/FPUtil/x86_64/FEnvImpl.h
libc/src/fenv/fesetexceptflag.cpp
Removed:
################################################################################
diff --git a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
index 6bac3e9e6a0f1..c8e8fcb5448ee 100644
--- a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
@@ -203,7 +203,8 @@ static inline int get_except() {
static inline int clear_except(int excepts) {
internal::X87StateDescriptor state;
internal::get_x87_state_descriptor(state);
- state.status_word &= ~internal::get_status_value_for_except(excepts);
+ state.status_word &=
+ static_cast<uint16_t>(~internal::get_status_value_for_except(excepts));
internal::write_x87_state_descriptor(state);
uint32_t mxcsr = internal::get_mxcsr();
@@ -215,8 +216,8 @@ static inline int clear_except(int excepts) {
static inline int test_except(int excepts) {
uint16_t status_value = internal::get_status_value_for_except(excepts);
// Check both x87 status word and MXCSR.
- return internal::exception_status_to_macro(status_value &
- internal::get_mxcsr());
+ return internal::exception_status_to_macro(
+ static_cast<uint16_t>(status_value & internal::get_mxcsr()));
}
// Sets the exception flags but does not trigger the exception handler.
diff --git a/libc/src/fenv/fesetexceptflag.cpp b/libc/src/fenv/fesetexceptflag.cpp
index 7ee9b1c63a309..3e134aba7fcf7 100644
--- a/libc/src/fenv/fesetexceptflag.cpp
+++ b/libc/src/fenv/fesetexceptflag.cpp
@@ -20,7 +20,7 @@ LLVM_LIBC_FUNCTION(int, fesetexceptflag,
// can fit in int type.
static_assert(sizeof(int) >= sizeof(fexcept_t),
"fexcept_t value cannot fit in an int value.");
- int excepts_to_set = static_cast<const int>(*flagp) & excepts;
+ int excepts_to_set = static_cast<int>(*flagp) & excepts;
fputil::clear_except(FE_ALL_EXCEPT);
return fputil::set_except(excepts_to_set);
}
More information about the libc-commits
mailing list