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
main
Daniel Black 8 years ago committed by Facebook Github Bot
parent 6653e32ac2
commit bfbcec2339
  1. 2
      db/db_impl.cc
  2. 4
      db/db_test.cc
  3. 12
      db/listener_test.cc
  4. 5
      include/rocksdb/thread_status.h
  5. 4
      util/concurrent_arena.cc
  6. 2
      util/concurrent_arena.h
  7. 2
      util/random.cc
  8. 2
      util/thread_list_test.cc
  9. 6
      util/thread_local.cc
  10. 7
      util/thread_local.h
  11. 2
      util/thread_operation.h
  12. 2
      util/thread_status_impl.cc
  13. 2
      util/thread_status_updater.cc
  14. 6
      util/thread_status_updater.h
  15. 2
      util/thread_status_updater_debug.cc
  16. 2
      util/thread_status_util.cc
  17. 4
      util/thread_status_util.h
  18. 4
      util/threadpool_imp.cc

@ -6302,7 +6302,7 @@ Status DBImpl::RenameTempFileToOptionsFile(const std::string& file_name) {
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE
} }
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
void DBImpl::NewThreadStatusCfInfo( void DBImpl::NewThreadStatusCfInfo(
ColumnFamilyData* cfd) const { ColumnFamilyData* cfd) const {

@ -3663,7 +3663,7 @@ TEST_F(DBTest, DynamicMemtableOptions) {
} }
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
namespace { namespace {
void VerifyOperationCount(Env* env, ThreadStatus::OperationType op_type, void VerifyOperationCount(Env* env, ThreadStatus::OperationType op_type,
int expected_count) { int expected_count) {
@ -4970,7 +4970,7 @@ TEST_F(DBTest, MergeTestTime) {
ASSERT_EQ(1, count); ASSERT_EQ(1, count);
ASSERT_EQ(2000000, TestGetTickerCount(options, MERGE_OPERATION_TOTAL_TIME)); 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); ASSERT_GT(TestGetTickerCount(options, FLUSH_WRITE_BYTES), 0);
#endif // ROCKSDB_USING_THREAD_STATUS #endif // ROCKSDB_USING_THREAD_STATUS
this->env_->time_elapse_only_sleep_ = false; this->env_->time_elapse_only_sleep_ = false;

@ -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_base = options.target_file_size_base * 2;
options.max_bytes_for_level_multiplier = 2; options.max_bytes_for_level_multiplier = 2;
options.compression = kNoCompression; options.compression = kNoCompression;
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
options.enable_thread_tracking = true; options.enable_thread_tracking = true;
#endif // ROCKSDB_USING_THREAD_STATUS #endif // ROCKSDB_USING_THREAD_STATUS
options.level0_file_num_compaction_trigger = kNumL0Files; 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_data_blocks, 0U);
ASSERT_GT(info.table_properties.num_entries, 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 // Verify the id of the current thread that created this table
// file matches the id of any active flush or compaction thread. // file matches the id of any active flush or compaction thread.
uint64_t thread_id = env_->GetThreadID(); uint64_t thread_id = env_->GetThreadID();
@ -232,7 +232,7 @@ class TestFlushListener : public EventListener {
TEST_F(EventListenerTest, OnSingleDBFlushTest) { TEST_F(EventListenerTest, OnSingleDBFlushTest) {
Options options; Options options;
options.write_buffer_size = k110KB; options.write_buffer_size = k110KB;
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
options.enable_thread_tracking = true; options.enable_thread_tracking = true;
#endif // ROCKSDB_USING_THREAD_STATUS #endif // ROCKSDB_USING_THREAD_STATUS
TestFlushListener* listener = new TestFlushListener(options.env); TestFlushListener* listener = new TestFlushListener(options.env);
@ -268,7 +268,7 @@ TEST_F(EventListenerTest, OnSingleDBFlushTest) {
TEST_F(EventListenerTest, MultiCF) { TEST_F(EventListenerTest, MultiCF) {
Options options; Options options;
options.write_buffer_size = k110KB; options.write_buffer_size = k110KB;
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
options.enable_thread_tracking = true; options.enable_thread_tracking = true;
#endif // ROCKSDB_USING_THREAD_STATUS #endif // ROCKSDB_USING_THREAD_STATUS
TestFlushListener* listener = new TestFlushListener(options.env); TestFlushListener* listener = new TestFlushListener(options.env);
@ -302,7 +302,7 @@ TEST_F(EventListenerTest, MultiCF) {
TEST_F(EventListenerTest, MultiDBMultiListeners) { TEST_F(EventListenerTest, MultiDBMultiListeners) {
Options options; Options options;
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
options.enable_thread_tracking = true; options.enable_thread_tracking = true;
#endif // ROCKSDB_USING_THREAD_STATUS #endif // ROCKSDB_USING_THREAD_STATUS
options.table_properties_collector_factories.push_back( options.table_properties_collector_factories.push_back(
@ -384,7 +384,7 @@ TEST_F(EventListenerTest, MultiDBMultiListeners) {
TEST_F(EventListenerTest, DisableBGCompaction) { TEST_F(EventListenerTest, DisableBGCompaction) {
Options options; Options options;
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
options.enable_thread_tracking = true; options.enable_thread_tracking = true;
#endif // ROCKSDB_USING_THREAD_STATUS #endif // ROCKSDB_USING_THREAD_STATUS
TestFlushListener* listener = new TestFlushListener(options.env); TestFlushListener* listener = new TestFlushListener(options.env);

@ -20,12 +20,11 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#ifndef ROCKSDB_USING_THREAD_STATUS #if !defined(ROCKSDB_LITE) && \
#define ROCKSDB_USING_THREAD_STATUS \
!defined(ROCKSDB_LITE) && \
!defined(NROCKSDB_THREAD_STATUS) && \ !defined(NROCKSDB_THREAD_STATUS) && \
!defined(OS_MACOSX) && \ !defined(OS_MACOSX) && \
!defined(IOS_CROSS_COMPILE) !defined(IOS_CROSS_COMPILE)
#define ROCKSDB_USING_THREAD_STATUS
#endif #endif
namespace rocksdb { namespace rocksdb {

@ -15,7 +15,7 @@
namespace rocksdb { namespace rocksdb {
#if ROCKSDB_SUPPORT_THREAD_LOCAL #ifdef ROCKSDB_SUPPORT_THREAD_LOCAL
__thread uint32_t ConcurrentArena::tls_cpuid = 0; __thread uint32_t ConcurrentArena::tls_cpuid = 0;
#endif #endif
@ -39,7 +39,7 @@ ConcurrentArena::Shard* ConcurrentArena::Repick() {
cpuid = cpuid =
Random::GetTLSInstance()->Uniform(static_cast<int>(index_mask_) + 1); Random::GetTLSInstance()->Uniform(static_cast<int>(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 // even if we are cpu 0, use a non-zero tls_cpuid so we can tell we
// have repicked // have repicked
tls_cpuid = cpuid | (static_cast<int>(index_mask_) + 1); tls_cpuid = cpuid | (static_cast<int>(index_mask_) + 1);

@ -94,7 +94,7 @@ class ConcurrentArena : public Allocator {
Shard() : allocated_and_unused_(0) {} Shard() : allocated_and_unused_(0) {}
}; };
#if ROCKSDB_SUPPORT_THREAD_LOCAL #ifdef ROCKSDB_SUPPORT_THREAD_LOCAL
static __thread uint32_t tls_cpuid; static __thread uint32_t tls_cpuid;
#else #else
enum ZeroFirstEnum : uint32_t { tls_cpuid = 0 }; enum ZeroFirstEnum : uint32_t { tls_cpuid = 0 };

@ -14,7 +14,7 @@
#include "port/likely.h" #include "port/likely.h"
#include "util/thread_local.h" #include "util/thread_local.h"
#if ROCKSDB_SUPPORT_THREAD_LOCAL #ifdef ROCKSDB_SUPPORT_THREAD_LOCAL
#define STORAGE_DECL static __thread #define STORAGE_DECL static __thread
#else #else
#define STORAGE_DECL static #define STORAGE_DECL static

@ -10,7 +10,7 @@
#include "util/testharness.h" #include "util/testharness.h"
#include "rocksdb/db.h" #include "rocksdb/db.h"
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
namespace rocksdb { namespace rocksdb {

@ -14,7 +14,7 @@
namespace rocksdb { namespace rocksdb {
#if ROCKSDB_SUPPORT_THREAD_LOCAL #ifdef ROCKSDB_SUPPORT_THREAD_LOCAL
__thread ThreadLocalPtr::ThreadData* ThreadLocalPtr::StaticMeta::tls_ = nullptr; __thread ThreadLocalPtr::ThreadData* ThreadLocalPtr::StaticMeta::tls_ = nullptr;
#endif #endif
@ -184,7 +184,7 @@ ThreadLocalPtr::StaticMeta::StaticMeta() : next_instance_id_(0), head_(this) {
#if !defined(OS_WIN) #if !defined(OS_WIN)
static struct A { static struct A {
~A() { ~A() {
#if !(ROCKSDB_SUPPORT_THREAD_LOCAL) #ifndef ROCKSDB_SUPPORT_THREAD_LOCAL
ThreadData* tls_ = ThreadData* tls_ =
static_cast<ThreadData*>(pthread_getspecific(Instance()->pthread_key_)); static_cast<ThreadData*>(pthread_getspecific(Instance()->pthread_key_));
#endif #endif
@ -222,7 +222,7 @@ void ThreadLocalPtr::StaticMeta::RemoveThreadData(
} }
ThreadLocalPtr::ThreadData* ThreadLocalPtr::StaticMeta::GetThreadLocal() { 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 // Make this local variable name look like a member variable so that we
// can share all the code below // can share all the code below
ThreadData* tls_ = ThreadData* tls_ =

@ -17,9 +17,8 @@
#include "util/autovector.h" #include "util/autovector.h"
#include "port/port.h" #include "port/port.h"
#ifndef ROCKSDB_SUPPORT_THREAD_LOCAL #if !defined(OS_WIN) && !defined(OS_MACOSX) && !defined(IOS_CROSS_COMPILE)
#define ROCKSDB_SUPPORT_THREAD_LOCAL \ #define ROCKSDB_SUPPORT_THREAD_LOCAL
!defined(OS_WIN) && !defined(OS_MACOSX) && !defined(IOS_CROSS_COMPILE)
#endif #endif
namespace rocksdb { namespace rocksdb {
@ -202,7 +201,7 @@ class ThreadLocalPtr {
// The private mutex. Developers should always use Mutex() instead of // The private mutex. Developers should always use Mutex() instead of
// using this variable directly. // using this variable directly.
port::Mutex mutex_; port::Mutex mutex_;
#if ROCKSDB_SUPPORT_THREAD_LOCAL #ifdef ROCKSDB_SUPPORT_THREAD_LOCAL
// Thread local storage // Thread local storage
static __thread ThreadData* tls_; static __thread ThreadData* tls_;
#endif #endif

@ -19,7 +19,7 @@
namespace rocksdb { namespace rocksdb {
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
// The structure that describes a major thread operation. // The structure that describes a major thread operation.
struct OperationInfo { struct OperationInfo {

@ -13,7 +13,7 @@
namespace rocksdb { namespace rocksdb {
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
const std::string& ThreadStatus::GetThreadTypeName( const std::string& ThreadStatus::GetThreadTypeName(
ThreadStatus::ThreadType thread_type) { ThreadStatus::ThreadType thread_type) {
static std::string thread_type_names[NUM_THREAD_TYPES + 1] = { static std::string thread_type_names[NUM_THREAD_TYPES + 1] = {

@ -11,7 +11,7 @@
namespace rocksdb { namespace rocksdb {
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
__thread ThreadStatusData* ThreadStatusUpdater::thread_status_data_ = nullptr; __thread ThreadStatusData* ThreadStatusUpdater::thread_status_data_ = nullptr;

@ -47,7 +47,7 @@ class ColumnFamilyHandle;
// The structure that keeps constant information about a column family. // The structure that keeps constant information about a column family.
struct ConstantColumnFamilyInfo { struct ConstantColumnFamilyInfo {
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
public: public:
ConstantColumnFamilyInfo( ConstantColumnFamilyInfo(
const void* _db_key, const void* _db_key,
@ -63,7 +63,7 @@ struct ConstantColumnFamilyInfo {
// the internal data-structure that is used to reflect the current // the internal data-structure that is used to reflect the current
// status of a thread using a set of atomic pointers. // status of a thread using a set of atomic pointers.
struct ThreadStatusData { struct ThreadStatusData {
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
explicit ThreadStatusData() : enable_tracking(false) { explicit ThreadStatusData() : enable_tracking(false) {
thread_id.store(0); thread_id.store(0);
thread_type.store(ThreadStatus::USER); thread_type.store(ThreadStatus::USER);
@ -194,7 +194,7 @@ class ThreadStatusUpdater {
bool check_exist); bool check_exist);
protected: protected:
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
// The thread-local variable for storing thread status. // The thread-local variable for storing thread status.
static __thread ThreadStatusData* thread_status_data_; static __thread ThreadStatusData* thread_status_data_;

@ -11,7 +11,7 @@
namespace rocksdb { namespace rocksdb {
#ifndef NDEBUG #ifndef NDEBUG
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
void ThreadStatusUpdater::TEST_VerifyColumnFamilyInfoMap( void ThreadStatusUpdater::TEST_VerifyColumnFamilyInfoMap(
const std::vector<ColumnFamilyHandle*>& handles, const std::vector<ColumnFamilyHandle*>& handles,
bool check_exist) { bool check_exist) {

@ -11,7 +11,7 @@
namespace rocksdb { namespace rocksdb {
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
__thread ThreadStatusUpdater* __thread ThreadStatusUpdater*
ThreadStatusUtil::thread_updater_local_cache_ = nullptr; ThreadStatusUtil::thread_updater_local_cache_ = nullptr;
__thread bool ThreadStatusUtil::thread_updater_initialized_ = false; __thread bool ThreadStatusUtil::thread_updater_initialized_ = false;

@ -84,7 +84,7 @@ class ThreadStatusUtil {
// a non-null pointer. // a non-null pointer.
static bool MaybeInitThreadLocalUpdater(const Env* env); 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_ // A boolean flag indicating whether thread_updater_local_cache_
// is initialized. It is set to true when an Env uses any // is initialized. It is set to true when an Env uses any
// ThreadStatusUtil functions using the current thread other // ThreadStatusUtil functions using the current thread other
@ -125,7 +125,7 @@ class AutoThreadOperationStageUpdater {
ThreadStatus::OperationStage stage); ThreadStatus::OperationStage stage);
~AutoThreadOperationStageUpdater(); ~AutoThreadOperationStageUpdater();
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
private: private:
ThreadStatus::OperationStage prev_stage_; ThreadStatus::OperationStage prev_stage_;
#endif #endif

@ -242,7 +242,7 @@ static void* BGThreadWrapper(void* arg) {
BGThreadMetadata* meta = reinterpret_cast<BGThreadMetadata*>(arg); BGThreadMetadata* meta = reinterpret_cast<BGThreadMetadata*>(arg);
size_t thread_id = meta->thread_id_; size_t thread_id = meta->thread_id_;
ThreadPoolImpl* tp = meta->thread_pool_; ThreadPoolImpl* tp = meta->thread_pool_;
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
// for thread-status // for thread-status
ThreadStatusUtil::RegisterThread( ThreadStatusUtil::RegisterThread(
tp->GetHostEnv(), (tp->GetThreadPriority() == Env::Priority::HIGH tp->GetHostEnv(), (tp->GetThreadPriority() == Env::Priority::HIGH
@ -251,7 +251,7 @@ static void* BGThreadWrapper(void* arg) {
#endif #endif
delete meta; delete meta;
tp->BGThread(thread_id); tp->BGThread(thread_id);
#if ROCKSDB_USING_THREAD_STATUS #ifdef ROCKSDB_USING_THREAD_STATUS
ThreadStatusUtil::UnregisterThread(); ThreadStatusUtil::UnregisterThread();
#endif #endif
return nullptr; return nullptr;

Loading…
Cancel
Save