From bfbcec2339461827bf1d20055d8b29da6adda73d Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 13 Dec 2016 18:22:00 -0800 Subject: [PATCH] Gcc 7 error expansion to defined Summary: sorry if these gcc-7/clang-4 cleanups are getting tedious. Closes https://github.com/facebook/rocksdb/pull/1658 Differential Revision: D4318792 Pulled By: yiwu-arbug fbshipit-source-id: 8e85891 --- db/db_impl.cc | 2 +- db/db_test.cc | 4 ++-- db/listener_test.cc | 12 ++++++------ include/rocksdb/thread_status.h | 5 ++--- util/concurrent_arena.cc | 4 ++-- util/concurrent_arena.h | 2 +- util/random.cc | 2 +- util/thread_list_test.cc | 2 +- util/thread_local.cc | 6 +++--- util/thread_local.h | 7 +++---- util/thread_operation.h | 2 +- util/thread_status_impl.cc | 2 +- util/thread_status_updater.cc | 2 +- util/thread_status_updater.h | 6 +++--- util/thread_status_updater_debug.cc | 2 +- util/thread_status_util.cc | 2 +- util/thread_status_util.h | 4 ++-- util/threadpool_imp.cc | 4 ++-- 18 files changed, 34 insertions(+), 36 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index 3a758252f..b70ee3281 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -6302,7 +6302,7 @@ Status DBImpl::RenameTempFileToOptionsFile(const std::string& file_name) { #endif // !ROCKSDB_LITE } -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS void DBImpl::NewThreadStatusCfInfo( ColumnFamilyData* cfd) const { diff --git a/db/db_test.cc b/db/db_test.cc index d7e597971..7c6907182 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -3663,7 +3663,7 @@ TEST_F(DBTest, DynamicMemtableOptions) { } #endif // ROCKSDB_LITE -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS namespace { void VerifyOperationCount(Env* env, ThreadStatus::OperationType op_type, int expected_count) { @@ -4970,7 +4970,7 @@ TEST_F(DBTest, MergeTestTime) { ASSERT_EQ(1, count); ASSERT_EQ(2000000, TestGetTickerCount(options, MERGE_OPERATION_TOTAL_TIME)); -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS ASSERT_GT(TestGetTickerCount(options, FLUSH_WRITE_BYTES), 0); #endif // ROCKSDB_USING_THREAD_STATUS this->env_->time_elapse_only_sleep_ = false; diff --git a/db/listener_test.cc b/db/listener_test.cc index 00cabb6a1..ebfd4beb7 100644 --- a/db/listener_test.cc +++ b/db/listener_test.cc @@ -119,7 +119,7 @@ TEST_F(EventListenerTest, OnSingleDBCompactionTest) { options.max_bytes_for_level_base = options.target_file_size_base * 2; options.max_bytes_for_level_multiplier = 2; options.compression = kNoCompression; -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS options.enable_thread_tracking = true; #endif // ROCKSDB_USING_THREAD_STATUS options.level0_file_num_compaction_trigger = kNumL0Files; @@ -176,7 +176,7 @@ class TestFlushListener : public EventListener { ASSERT_GT(info.table_properties.num_data_blocks, 0U); ASSERT_GT(info.table_properties.num_entries, 0U); -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS // Verify the id of the current thread that created this table // file matches the id of any active flush or compaction thread. uint64_t thread_id = env_->GetThreadID(); @@ -232,7 +232,7 @@ class TestFlushListener : public EventListener { TEST_F(EventListenerTest, OnSingleDBFlushTest) { Options options; options.write_buffer_size = k110KB; -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS options.enable_thread_tracking = true; #endif // ROCKSDB_USING_THREAD_STATUS TestFlushListener* listener = new TestFlushListener(options.env); @@ -268,7 +268,7 @@ TEST_F(EventListenerTest, OnSingleDBFlushTest) { TEST_F(EventListenerTest, MultiCF) { Options options; options.write_buffer_size = k110KB; -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS options.enable_thread_tracking = true; #endif // ROCKSDB_USING_THREAD_STATUS TestFlushListener* listener = new TestFlushListener(options.env); @@ -302,7 +302,7 @@ TEST_F(EventListenerTest, MultiCF) { TEST_F(EventListenerTest, MultiDBMultiListeners) { Options options; -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS options.enable_thread_tracking = true; #endif // ROCKSDB_USING_THREAD_STATUS options.table_properties_collector_factories.push_back( @@ -384,7 +384,7 @@ TEST_F(EventListenerTest, MultiDBMultiListeners) { TEST_F(EventListenerTest, DisableBGCompaction) { Options options; -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS options.enable_thread_tracking = true; #endif // ROCKSDB_USING_THREAD_STATUS TestFlushListener* listener = new TestFlushListener(options.env); diff --git a/include/rocksdb/thread_status.h b/include/rocksdb/thread_status.h index 0cdea2b51..3950b81e5 100644 --- a/include/rocksdb/thread_status.h +++ b/include/rocksdb/thread_status.h @@ -20,12 +20,11 @@ #include #include -#ifndef ROCKSDB_USING_THREAD_STATUS -#define ROCKSDB_USING_THREAD_STATUS \ - !defined(ROCKSDB_LITE) && \ +#if !defined(ROCKSDB_LITE) && \ !defined(NROCKSDB_THREAD_STATUS) && \ !defined(OS_MACOSX) && \ !defined(IOS_CROSS_COMPILE) +#define ROCKSDB_USING_THREAD_STATUS #endif namespace rocksdb { diff --git a/util/concurrent_arena.cc b/util/concurrent_arena.cc index 6aa82751f..df870114a 100644 --- a/util/concurrent_arena.cc +++ b/util/concurrent_arena.cc @@ -15,7 +15,7 @@ namespace rocksdb { -#if ROCKSDB_SUPPORT_THREAD_LOCAL +#ifdef ROCKSDB_SUPPORT_THREAD_LOCAL __thread uint32_t ConcurrentArena::tls_cpuid = 0; #endif @@ -39,7 +39,7 @@ ConcurrentArena::Shard* ConcurrentArena::Repick() { cpuid = Random::GetTLSInstance()->Uniform(static_cast(index_mask_) + 1); } -#if ROCKSDB_SUPPORT_THREAD_LOCAL +#ifdef ROCKSDB_SUPPORT_THREAD_LOCAL // even if we are cpu 0, use a non-zero tls_cpuid so we can tell we // have repicked tls_cpuid = cpuid | (static_cast(index_mask_) + 1); diff --git a/util/concurrent_arena.h b/util/concurrent_arena.h index ba4b024b9..3a20bb6db 100644 --- a/util/concurrent_arena.h +++ b/util/concurrent_arena.h @@ -94,7 +94,7 @@ class ConcurrentArena : public Allocator { Shard() : allocated_and_unused_(0) {} }; -#if ROCKSDB_SUPPORT_THREAD_LOCAL +#ifdef ROCKSDB_SUPPORT_THREAD_LOCAL static __thread uint32_t tls_cpuid; #else enum ZeroFirstEnum : uint32_t { tls_cpuid = 0 }; diff --git a/util/random.cc b/util/random.cc index 9f0f9bb4c..289eda20d 100644 --- a/util/random.cc +++ b/util/random.cc @@ -14,7 +14,7 @@ #include "port/likely.h" #include "util/thread_local.h" -#if ROCKSDB_SUPPORT_THREAD_LOCAL +#ifdef ROCKSDB_SUPPORT_THREAD_LOCAL #define STORAGE_DECL static __thread #else #define STORAGE_DECL static diff --git a/util/thread_list_test.cc b/util/thread_list_test.cc index c706a2e3e..f09197cb6 100644 --- a/util/thread_list_test.cc +++ b/util/thread_list_test.cc @@ -10,7 +10,7 @@ #include "util/testharness.h" #include "rocksdb/db.h" -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS namespace rocksdb { diff --git a/util/thread_local.cc b/util/thread_local.cc index 8ee0a02a3..9002571fd 100644 --- a/util/thread_local.cc +++ b/util/thread_local.cc @@ -14,7 +14,7 @@ namespace rocksdb { -#if ROCKSDB_SUPPORT_THREAD_LOCAL +#ifdef ROCKSDB_SUPPORT_THREAD_LOCAL __thread ThreadLocalPtr::ThreadData* ThreadLocalPtr::StaticMeta::tls_ = nullptr; #endif @@ -184,7 +184,7 @@ ThreadLocalPtr::StaticMeta::StaticMeta() : next_instance_id_(0), head_(this) { #if !defined(OS_WIN) static struct A { ~A() { -#if !(ROCKSDB_SUPPORT_THREAD_LOCAL) +#ifndef ROCKSDB_SUPPORT_THREAD_LOCAL ThreadData* tls_ = static_cast(pthread_getspecific(Instance()->pthread_key_)); #endif @@ -222,7 +222,7 @@ void ThreadLocalPtr::StaticMeta::RemoveThreadData( } ThreadLocalPtr::ThreadData* ThreadLocalPtr::StaticMeta::GetThreadLocal() { -#if !(ROCKSDB_SUPPORT_THREAD_LOCAL) +#ifndef ROCKSDB_SUPPORT_THREAD_LOCAL // Make this local variable name look like a member variable so that we // can share all the code below ThreadData* tls_ = diff --git a/util/thread_local.h b/util/thread_local.h index 5806b544e..7d762a888 100644 --- a/util/thread_local.h +++ b/util/thread_local.h @@ -17,9 +17,8 @@ #include "util/autovector.h" #include "port/port.h" -#ifndef ROCKSDB_SUPPORT_THREAD_LOCAL -#define ROCKSDB_SUPPORT_THREAD_LOCAL \ - !defined(OS_WIN) && !defined(OS_MACOSX) && !defined(IOS_CROSS_COMPILE) +#if !defined(OS_WIN) && !defined(OS_MACOSX) && !defined(IOS_CROSS_COMPILE) +#define ROCKSDB_SUPPORT_THREAD_LOCAL #endif namespace rocksdb { @@ -202,7 +201,7 @@ class ThreadLocalPtr { // The private mutex. Developers should always use Mutex() instead of // using this variable directly. port::Mutex mutex_; -#if ROCKSDB_SUPPORT_THREAD_LOCAL +#ifdef ROCKSDB_SUPPORT_THREAD_LOCAL // Thread local storage static __thread ThreadData* tls_; #endif diff --git a/util/thread_operation.h b/util/thread_operation.h index ace619817..ee2261e39 100644 --- a/util/thread_operation.h +++ b/util/thread_operation.h @@ -19,7 +19,7 @@ namespace rocksdb { -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS // The structure that describes a major thread operation. struct OperationInfo { diff --git a/util/thread_status_impl.cc b/util/thread_status_impl.cc index e9a702bba..88ab0119b 100644 --- a/util/thread_status_impl.cc +++ b/util/thread_status_impl.cc @@ -13,7 +13,7 @@ namespace rocksdb { -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS const std::string& ThreadStatus::GetThreadTypeName( ThreadStatus::ThreadType thread_type) { static std::string thread_type_names[NUM_THREAD_TYPES + 1] = { diff --git a/util/thread_status_updater.cc b/util/thread_status_updater.cc index a3f9a9afc..40ba5b337 100644 --- a/util/thread_status_updater.cc +++ b/util/thread_status_updater.cc @@ -11,7 +11,7 @@ namespace rocksdb { -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS __thread ThreadStatusData* ThreadStatusUpdater::thread_status_data_ = nullptr; diff --git a/util/thread_status_updater.h b/util/thread_status_updater.h index 23d6d6f58..39920edec 100644 --- a/util/thread_status_updater.h +++ b/util/thread_status_updater.h @@ -47,7 +47,7 @@ class ColumnFamilyHandle; // The structure that keeps constant information about a column family. struct ConstantColumnFamilyInfo { -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS public: ConstantColumnFamilyInfo( const void* _db_key, @@ -63,7 +63,7 @@ struct ConstantColumnFamilyInfo { // the internal data-structure that is used to reflect the current // status of a thread using a set of atomic pointers. struct ThreadStatusData { -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS explicit ThreadStatusData() : enable_tracking(false) { thread_id.store(0); thread_type.store(ThreadStatus::USER); @@ -194,7 +194,7 @@ class ThreadStatusUpdater { bool check_exist); protected: -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS // The thread-local variable for storing thread status. static __thread ThreadStatusData* thread_status_data_; diff --git a/util/thread_status_updater_debug.cc b/util/thread_status_updater_debug.cc index 501181faf..647ef0de5 100644 --- a/util/thread_status_updater_debug.cc +++ b/util/thread_status_updater_debug.cc @@ -11,7 +11,7 @@ namespace rocksdb { #ifndef NDEBUG -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS void ThreadStatusUpdater::TEST_VerifyColumnFamilyInfoMap( const std::vector& handles, bool check_exist) { diff --git a/util/thread_status_util.cc b/util/thread_status_util.cc index d573e0566..dc2e7dcfe 100644 --- a/util/thread_status_util.cc +++ b/util/thread_status_util.cc @@ -11,7 +11,7 @@ namespace rocksdb { -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS __thread ThreadStatusUpdater* ThreadStatusUtil::thread_updater_local_cache_ = nullptr; __thread bool ThreadStatusUtil::thread_updater_initialized_ = false; diff --git a/util/thread_status_util.h b/util/thread_status_util.h index 3445182ec..455c9f14f 100644 --- a/util/thread_status_util.h +++ b/util/thread_status_util.h @@ -84,7 +84,7 @@ class ThreadStatusUtil { // a non-null pointer. static bool MaybeInitThreadLocalUpdater(const Env* env); -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS // A boolean flag indicating whether thread_updater_local_cache_ // is initialized. It is set to true when an Env uses any // ThreadStatusUtil functions using the current thread other @@ -125,7 +125,7 @@ class AutoThreadOperationStageUpdater { ThreadStatus::OperationStage stage); ~AutoThreadOperationStageUpdater(); -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS private: ThreadStatus::OperationStage prev_stage_; #endif diff --git a/util/threadpool_imp.cc b/util/threadpool_imp.cc index 128124cb2..0c4ab4fc7 100644 --- a/util/threadpool_imp.cc +++ b/util/threadpool_imp.cc @@ -242,7 +242,7 @@ static void* BGThreadWrapper(void* arg) { BGThreadMetadata* meta = reinterpret_cast(arg); size_t thread_id = meta->thread_id_; ThreadPoolImpl* tp = meta->thread_pool_; -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS // for thread-status ThreadStatusUtil::RegisterThread( tp->GetHostEnv(), (tp->GetThreadPriority() == Env::Priority::HIGH @@ -251,7 +251,7 @@ static void* BGThreadWrapper(void* arg) { #endif delete meta; tp->BGThread(thread_id); -#if ROCKSDB_USING_THREAD_STATUS +#ifdef ROCKSDB_USING_THREAD_STATUS ThreadStatusUtil::UnregisterThread(); #endif return nullptr;