Commit 2f595596 authored by Max Warsewa's avatar Max Warsewa Committed by Facebook Github Bot 3

Fix clang build for MicroLock

Summary: clang would complain about losing integer precision. Use unsigned for offset calculation.

Reviewed By: luciang

Differential Revision: D3011253

fb-gh-sync-id: 10cb603708a22bf0e57f41b2486ffca4f5bf7a14
shipit-source-id: 10cb603708a22bf0e57f41b2486ffca4f5bf7a14
parent cb8456bd
...@@ -110,11 +110,11 @@ inline detail::Futex<>* MicroLockCore::word() const { ...@@ -110,11 +110,11 @@ inline detail::Futex<>* MicroLockCore::word() const {
inline unsigned MicroLockCore::baseShift(unsigned slot) const { inline unsigned MicroLockCore::baseShift(unsigned slot) const {
assert(slot < CHAR_BIT / 2); assert(slot < CHAR_BIT / 2);
uintptr_t offset_bytes = (uintptr_t)&lock_ - (uintptr_t)word();
assert(offset_bytes < sizeof(uint32_t)); unsigned offset_bytes = (unsigned)((uintptr_t)&lock_ - (uintptr_t)word());
return kIsLittleEndian return kIsLittleEndian
? (unsigned)offset_bytes * CHAR_BIT + slot * 2 ? offset_bytes * CHAR_BIT + slot * 2
: CHAR_BIT * (sizeof(uint32_t) - offset_bytes - 1) + slot * 2; : CHAR_BIT * (sizeof(uint32_t) - offset_bytes - 1) + slot * 2;
} }
......
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