From e0b84538af3804a960755997aa7ffd964dd02322 Mon Sep 17 00:00:00 2001 From: Zhongyi Xie Date: Wed, 7 Aug 2019 20:15:21 -0700 Subject: [PATCH] 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 --- third-party/folly/folly/detail/Futex.cpp | 6 +++--- .../folly/folly/synchronization/DistributedMutex-inl.h | 3 ++- .../folly/synchronization/test/DistributedMutexTest.cpp | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/third-party/folly/folly/detail/Futex.cpp b/third-party/folly/folly/detail/Futex.cpp index 208578a901..62d6ea2b20 100644 --- a/third-party/folly/folly/detail/Futex.cpp +++ b/third-party/folly/folly/detail/Futex.cpp @@ -49,7 +49,7 @@ namespace { #endif int nativeFutexWake(const void* addr, int count, uint32_t wakeMask) { - int rv = syscall( + long rv = syscall( __NR_futex, addr, /* addr1 */ FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG, /* op */ @@ -65,7 +65,7 @@ int nativeFutexWake(const void* addr, int count, uint32_t wakeMask) { if (rv < 0) { return 0; } - return rv; + return static_cast(rv); } template @@ -111,7 +111,7 @@ FutexResult nativeFutexWaitImpl( // Unlike FUTEX_WAIT, FUTEX_WAIT_BITSET requires an absolute timeout // value - http://locklessinc.com/articles/futex_cheat_sheet/ - int rv = syscall( + long rv = syscall( __NR_futex, addr, /* addr1 */ op, /* op */ diff --git a/third-party/folly/folly/synchronization/DistributedMutex-inl.h b/third-party/folly/folly/synchronization/DistributedMutex-inl.h index b3f7d20140..8eedb9cd34 100644 --- a/third-party/folly/folly/synchronization/DistributedMutex-inl.h +++ b/third-party/folly/folly/synchronization/DistributedMutex-inl.h @@ -1311,6 +1311,7 @@ inline std::uintptr_t tryCombine( std::uint64_t iteration, std::chrono::nanoseconds now, CombineFunction task) { +#ifndef ROCKSDB_LITE // if the waiter has asked for a combine operation, we should combine its // critical section and move on to the next waiter // @@ -1339,7 +1340,7 @@ inline std::uintptr_t tryCombine( } return next; } - +#endif // ROCKSDB_LITE return 0; } diff --git a/third-party/folly/folly/synchronization/test/DistributedMutexTest.cpp b/third-party/folly/folly/synchronization/test/DistributedMutexTest.cpp index 3de232b6a8..b83fdda712 100644 --- a/third-party/folly/folly/synchronization/test/DistributedMutexTest.cpp +++ b/third-party/folly/folly/synchronization/test/DistributedMutexTest.cpp @@ -13,6 +13,8 @@ #include #endif +#ifndef ROCKSDB_LITE + #include #include #include @@ -960,7 +962,6 @@ class ExceptionWithConstructionTrack : public std::exception { TEST(DistributedMutex, TestExceptionPropagationUncontended) { TestConstruction::reset(); auto&& mutex = folly::DistributedMutex{}; - auto&& thread = std::thread{[&]() { try { mutex.lock_combine([&]() { throw ExceptionWithConstructionTrack{46}; }); @@ -969,11 +970,9 @@ TEST(DistributedMutex, TestExceptionPropagationUncontended) { EXPECT_EQ(integer, 46); EXPECT_GT(TestConstruction::defaultConstructs(), 0); } - EXPECT_EQ( TestConstruction::defaultConstructs(), TestConstruction::destructs()); }}; - thread.join(); } @@ -1123,6 +1122,7 @@ TEST(DistributedMutex, StressBigValueReturnSixtyFourThreads) { } } // namespace folly +#endif // ROCKSDB_LITE int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv);