Fix clang_check and lite failures (#5680)

Summary:
This PR fixes two test failures:
1. clang check:
```
third-party/folly/folly/detail/Futex.cpp:52:12: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32]
  int rv = syscall(
      ~~   ^~~~~~~~
third-party/folly/folly/detail/Futex.cpp:114:12: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32]
  int rv = syscall(
      ~~   ^~~~~~~~
```
2. lite
```
./third-party/folly/folly/synchronization/DistributedMutex-inl.h:1337:7: error: exception handling disabled, use -fexceptions to enable
     } catch (...) {
       ^
```
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5680

Differential Revision: D16704042

Pulled By: miasantreble

fbshipit-source-id: a53cb06128365d9e864f07476b0af8fc27140f07
This commit is contained in:
Zhongyi Xie 2019-08-07 20:15:21 -07:00 committed by Facebook Github Bot
parent 38b03c840e
commit e0b84538af
3 changed files with 8 additions and 7 deletions

View File

@ -49,7 +49,7 @@ namespace {
#endif #endif
int nativeFutexWake(const void* addr, int count, uint32_t wakeMask) { int nativeFutexWake(const void* addr, int count, uint32_t wakeMask) {
int rv = syscall( long rv = syscall(
__NR_futex, __NR_futex,
addr, /* addr1 */ addr, /* addr1 */
FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG, /* op */ FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG, /* op */
@ -65,7 +65,7 @@ int nativeFutexWake(const void* addr, int count, uint32_t wakeMask) {
if (rv < 0) { if (rv < 0) {
return 0; return 0;
} }
return rv; return static_cast<int>(rv);
} }
template <class Clock> template <class Clock>
@ -111,7 +111,7 @@ FutexResult nativeFutexWaitImpl(
// Unlike FUTEX_WAIT, FUTEX_WAIT_BITSET requires an absolute timeout // Unlike FUTEX_WAIT, FUTEX_WAIT_BITSET requires an absolute timeout
// value - http://locklessinc.com/articles/futex_cheat_sheet/ // value - http://locklessinc.com/articles/futex_cheat_sheet/
int rv = syscall( long rv = syscall(
__NR_futex, __NR_futex,
addr, /* addr1 */ addr, /* addr1 */
op, /* op */ op, /* op */

View File

@ -1311,6 +1311,7 @@ inline std::uintptr_t tryCombine(
std::uint64_t iteration, std::uint64_t iteration,
std::chrono::nanoseconds now, std::chrono::nanoseconds now,
CombineFunction task) { CombineFunction task) {
#ifndef ROCKSDB_LITE
// if the waiter has asked for a combine operation, we should combine its // if the waiter has asked for a combine operation, we should combine its
// critical section and move on to the next waiter // critical section and move on to the next waiter
// //
@ -1339,7 +1340,7 @@ inline std::uintptr_t tryCombine(
} }
return next; return next;
} }
#endif // ROCKSDB_LITE
return 0; return 0;
} }

View File

@ -13,6 +13,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#endif #endif
#ifndef ROCKSDB_LITE
#include <chrono> #include <chrono>
#include <cmath> #include <cmath>
#include <thread> #include <thread>
@ -960,7 +962,6 @@ class ExceptionWithConstructionTrack : public std::exception {
TEST(DistributedMutex, TestExceptionPropagationUncontended) { TEST(DistributedMutex, TestExceptionPropagationUncontended) {
TestConstruction::reset(); TestConstruction::reset();
auto&& mutex = folly::DistributedMutex{}; auto&& mutex = folly::DistributedMutex{};
auto&& thread = std::thread{[&]() { auto&& thread = std::thread{[&]() {
try { try {
mutex.lock_combine([&]() { throw ExceptionWithConstructionTrack{46}; }); mutex.lock_combine([&]() { throw ExceptionWithConstructionTrack{46}; });
@ -969,11 +970,9 @@ TEST(DistributedMutex, TestExceptionPropagationUncontended) {
EXPECT_EQ(integer, 46); EXPECT_EQ(integer, 46);
EXPECT_GT(TestConstruction::defaultConstructs(), 0); EXPECT_GT(TestConstruction::defaultConstructs(), 0);
} }
EXPECT_EQ( EXPECT_EQ(
TestConstruction::defaultConstructs(), TestConstruction::destructs()); TestConstruction::defaultConstructs(), TestConstruction::destructs());
}}; }};
thread.join(); thread.join();
} }
@ -1123,6 +1122,7 @@ TEST(DistributedMutex, StressBigValueReturnSixtyFourThreads) {
} }
} // namespace folly } // namespace folly
#endif // ROCKSDB_LITE
int main(int argc, char** argv) { int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);