diff --git a/util/comparator.cc b/util/comparator.cc index 5e3332737..821a2540b 100644 --- a/util/comparator.cc +++ b/util/comparator.cc @@ -85,23 +85,14 @@ class ReverseBytewiseComparatorImpl : public BytewiseComparatorImpl { }// namespace -static port::OnceType once = LEVELDB_ONCE_INIT; -static std::unique_ptr bytewise; -static std::unique_ptr rbytewise; - -static void InitModule() { - bytewise.reset(new BytewiseComparatorImpl); - rbytewise.reset(new ReverseBytewiseComparatorImpl); -} - const Comparator* BytewiseComparator() { - port::InitOnce(&once, InitModule); - return bytewise.get(); + static BytewiseComparatorImpl bytewise; + return &bytewise; } const Comparator* ReverseBytewiseComparator() { - port::InitOnce(&once, InitModule); - return rbytewise.get(); + static ReverseBytewiseComparatorImpl rbytewise; + return &rbytewise; } } // namespace rocksdb diff --git a/util/thread_local.cc b/util/thread_local.cc index 969690739..ffe636d9e 100644 --- a/util/thread_local.cc +++ b/util/thread_local.cc @@ -149,14 +149,13 @@ ThreadLocalPtr::StaticMeta::StaticMeta() : next_instance_id_(0) { // of memory backing destructed statically-scoped objects. Perhaps // registering with atexit(3) would be more robust. // - // This is not required on Windows. -#if !defined(OS_WIN) + // This is not required on Windows. Also, it's not required on Mac + // as ThreadLocal is not supported in Mac. +#if !defined(OS_MACOSX) && !defined(IOS_CROSS_COMPILE) && !defined(OS_WIN) static struct A { ~A() { -#if defined(OS_MACOSX) ThreadData* tls_ = static_cast(pthread_getspecific(Instance()->pthread_key_)); -#endif if (tls_) { OnThreadExit(tls_); }