Commit d43c44b8 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

tweak atomic-fetch-bit-op mask casts

Summary: Cast the result of shifts to the integer type parameter, rather than the shift width.

Reviewed By: aary, luciang

Differential Revision: D32160950

fbshipit-source-id: 0100a1a92c48bfa1cd957cf42ed84d01302ea4f7
parent 1cc6c6d9
...@@ -115,7 +115,7 @@ template <typename Atomic> ...@@ -115,7 +115,7 @@ template <typename Atomic>
bool atomic_fetch_set_fallback( bool atomic_fetch_set_fallback(
Atomic& atomic, std::size_t bit, std::memory_order order) { Atomic& atomic, std::size_t bit, std::memory_order order) {
using Integer = decltype(atomic.load()); using Integer = decltype(atomic.load());
auto mask = Integer{0b1} << static_cast<Integer>(bit); auto mask = Integer(Integer{0b1} << bit);
return (atomic.fetch_or(mask, order) & mask); return (atomic.fetch_or(mask, order) & mask);
} }
...@@ -123,8 +123,8 @@ template <typename Atomic> ...@@ -123,8 +123,8 @@ template <typename Atomic>
bool atomic_fetch_reset_fallback( bool atomic_fetch_reset_fallback(
Atomic& atomic, std::size_t bit, std::memory_order order) { Atomic& atomic, std::size_t bit, std::memory_order order) {
using Integer = decltype(atomic.load()); using Integer = decltype(atomic.load());
auto mask = Integer{0b1} << static_cast<Integer>(bit); auto mask = Integer(Integer{0b1} << bit);
return (atomic.fetch_and(static_cast<Integer>(~mask), order) & mask); return (atomic.fetch_and(Integer(~mask), order) & mask);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment