From 6c50082654cc486258536c0ddd37c7157c626027 Mon Sep 17 00:00:00 2001 From: tagliavini Date: Thu, 26 May 2022 16:55:08 -0700 Subject: [PATCH] Remove code that only compiles for Visual Studio versions older than 2015 (#10065) Summary: There are currently some preprocessor checks that assume support for Visual Studio versions older than 2015 (i.e., 0 < _MSC_VER < 1900), although we don't support them any more. We removed all code that only compiles on those older versions, except third-party/ files. The ROCKSDB_NOEXCEPT symbol is now obsolete, since it now always gets replaced by noexcept. We removed it. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10065 Reviewed By: pdillinger Differential Revision: D36721901 Pulled By: guidotag fbshipit-source-id: a2892d365ef53cce44a0a7d90dd6b72ee9b5e5f2 --- db/c_test.c | 5 ---- include/rocksdb/io_status.h | 24 ++++--------------- include/rocksdb/status.h | 24 ++++--------------- port/port_posix.h | 2 -- port/win/port_win.h | 18 ++------------ port/win/win_jemalloc.cc | 4 ++-- table/format.h | 4 +--- table/scoped_arena_iterator.h | 7 +++--- util/aligned_buffer.h | 6 ++--- util/compression.h | 12 ++++------ utilities/backup/backup_engine.cc | 16 ++++++------- .../persistent_cache/volatile_tier_impl.h | 5 ++-- 12 files changed, 33 insertions(+), 94 deletions(-) diff --git a/db/c_test.c b/db/c_test.c index 0d7cf23b2b..5b0594fed0 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -33,11 +33,6 @@ int geteuid() { return result; } -// VS < 2015 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif - #endif const char* phase = ""; diff --git a/include/rocksdb/io_status.h b/include/rocksdb/io_status.h index 5e8cf6c7aa..9f9c69dba2 100644 --- a/include/rocksdb/io_status.h +++ b/include/rocksdb/io_status.h @@ -42,16 +42,8 @@ class IOStatus : public Status { // Copy the specified status. IOStatus(const IOStatus& s); IOStatus& operator=(const IOStatus& s); - IOStatus(IOStatus&& s) -#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) - noexcept -#endif - ; - IOStatus& operator=(IOStatus&& s) -#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) - noexcept -#endif - ; + IOStatus(IOStatus&& s) noexcept; + IOStatus& operator=(IOStatus&& s) noexcept; bool operator==(const IOStatus& rhs) const; bool operator!=(const IOStatus& rhs) const; @@ -194,19 +186,11 @@ inline IOStatus& IOStatus::operator=(const IOStatus& s) { return *this; } -inline IOStatus::IOStatus(IOStatus&& s) -#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) - noexcept -#endif - : IOStatus() { +inline IOStatus::IOStatus(IOStatus&& s) noexcept : IOStatus() { *this = std::move(s); } -inline IOStatus& IOStatus::operator=(IOStatus&& s) -#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) - noexcept -#endif -{ +inline IOStatus& IOStatus::operator=(IOStatus&& s) noexcept { if (this != &s) { #ifdef ROCKSDB_ASSERT_STATUS_CHECKED s.checked_ = true; diff --git a/include/rocksdb/status.h b/include/rocksdb/status.h index b512b2da90..265e29cd45 100644 --- a/include/rocksdb/status.h +++ b/include/rocksdb/status.h @@ -56,16 +56,8 @@ class Status { // Copy the specified status. Status(const Status& s); Status& operator=(const Status& s); - Status(Status&& s) -#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) - noexcept -#endif - ; - Status& operator=(Status&& s) -#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) - noexcept -#endif - ; + Status(Status&& s) noexcept; + Status& operator=(Status&& s) noexcept; bool operator==(const Status& rhs) const; bool operator!=(const Status& rhs) const; @@ -537,20 +529,12 @@ inline Status& Status::operator=(const Status& s) { return *this; } -inline Status::Status(Status&& s) -#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) - noexcept -#endif - : Status() { +inline Status::Status(Status&& s) noexcept : Status() { s.MarkChecked(); *this = std::move(s); } -inline Status& Status::operator=(Status&& s) -#if !(defined _MSC_VER) || ((defined _MSC_VER) && (_MSC_VER >= 1900)) - noexcept -#endif -{ +inline Status& Status::operator=(Status&& s) noexcept { if (this != &s) { s.MarkChecked(); MustCheck(); diff --git a/port/port_posix.h b/port/port_posix.h index 925ec07d46..b175c13ac8 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -23,8 +23,6 @@ #define __declspec(S) -#define ROCKSDB_NOEXCEPT noexcept - #undef PLATFORM_IS_LITTLE_ENDIAN #if defined(OS_MACOSX) #include diff --git a/port/win/port_win.h b/port/win/port_win.h index 1ee30cba40..55ecc71f99 100644 --- a/port/win/port_win.h +++ b/port/win/port_win.h @@ -70,20 +70,6 @@ extern const bool kDefaultToAdaptiveMutex; namespace port { -// VS < 2015 -#if defined(_MSC_VER) && (_MSC_VER < 1900) - -// VS 15 has snprintf -#define snprintf _snprintf - -#define ROCKSDB_NOEXCEPT - -#else // VS >= 2015 or MinGW - -#define ROCKSDB_NOEXCEPT noexcept - -#endif //_MSC_VER - // "Windows is designed to run on little-endian computer architectures." // https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types constexpr bool kLittleEndian = true; @@ -230,8 +216,8 @@ extern void InitOnce(OnceType* once, void (*initializer)()); #ifdef ROCKSDB_JEMALLOC // Separate inlines so they can be replaced if needed -void* jemalloc_aligned_alloc(size_t size, size_t alignment) ROCKSDB_NOEXCEPT; -void jemalloc_aligned_free(void* p) ROCKSDB_NOEXCEPT; +void* jemalloc_aligned_alloc(size_t size, size_t alignment) noexcept; +void jemalloc_aligned_free(void* p) noexcept; #endif inline void *cacheline_aligned_alloc(size_t size) { diff --git a/port/win/win_jemalloc.cc b/port/win/win_jemalloc.cc index f054469ccc..691ebc27e4 100644 --- a/port/win/win_jemalloc.cc +++ b/port/win/win_jemalloc.cc @@ -41,10 +41,10 @@ ZSTD_customMem GetJeZstdAllocationOverrides() { namespace ROCKSDB_NAMESPACE { namespace port { -void* jemalloc_aligned_alloc(size_t size, size_t alignment) ROCKSDB_NOEXCEPT { +void* jemalloc_aligned_alloc(size_t size, size_t alignment) noexcept { return je_aligned_alloc(alignment, size); } -void jemalloc_aligned_free(void* p) ROCKSDB_NOEXCEPT { je_free(p); } +void jemalloc_aligned_free(void* p) noexcept { je_free(p); } } // namespace port } // namespace ROCKSDB_NAMESPACE diff --git a/table/format.h b/table/format.h index 011dab241f..de11648e4a 100644 --- a/table/format.h +++ b/table/format.h @@ -307,9 +307,7 @@ struct BlockContents { return usable_size() + sizeof(*this); } - BlockContents(BlockContents&& other) ROCKSDB_NOEXCEPT { - *this = std::move(other); - } + BlockContents(BlockContents&& other) noexcept { *this = std::move(other); } BlockContents& operator=(BlockContents&& other) { data = std::move(other.data); diff --git a/table/scoped_arena_iterator.h b/table/scoped_arena_iterator.h index 8d73d12ee1..619b93c180 100644 --- a/table/scoped_arena_iterator.h +++ b/table/scoped_arena_iterator.h @@ -12,8 +12,7 @@ namespace ROCKSDB_NAMESPACE { class ScopedArenaIterator { - - void reset(InternalIterator* iter) ROCKSDB_NOEXCEPT { + void reset(InternalIterator* iter) noexcept { if (iter_ != nullptr) { iter_->~InternalIterator(); } @@ -28,12 +27,12 @@ class ScopedArenaIterator { ScopedArenaIterator(const ScopedArenaIterator&) = delete; ScopedArenaIterator& operator=(const ScopedArenaIterator&) = delete; - ScopedArenaIterator(ScopedArenaIterator&& o) ROCKSDB_NOEXCEPT { + ScopedArenaIterator(ScopedArenaIterator&& o) noexcept { iter_ = o.iter_; o.iter_ = nullptr; } - ScopedArenaIterator& operator=(ScopedArenaIterator&& o) ROCKSDB_NOEXCEPT { + ScopedArenaIterator& operator=(ScopedArenaIterator&& o) noexcept { reset(o.iter_); o.iter_ = nullptr; return *this; diff --git a/util/aligned_buffer.h b/util/aligned_buffer.h index 7098322f82..eb32c21b4e 100644 --- a/util/aligned_buffer.h +++ b/util/aligned_buffer.h @@ -69,11 +69,9 @@ public: bufstart_(nullptr) { } - AlignedBuffer(AlignedBuffer&& o) ROCKSDB_NOEXCEPT { - *this = std::move(o); - } + AlignedBuffer(AlignedBuffer&& o) noexcept { *this = std::move(o); } - AlignedBuffer& operator=(AlignedBuffer&& o) ROCKSDB_NOEXCEPT { + AlignedBuffer& operator=(AlignedBuffer&& o) noexcept { alignment_ = std::move(o.alignment_); buf_ = std::move(o.buf_); capacity_ = std::move(o.capacity_); diff --git a/util/compression.h b/util/compression.h index 909116780a..d310ca09de 100644 --- a/util/compression.h +++ b/util/compression.h @@ -86,12 +86,11 @@ class ZSTDUncompressCachedData { // Init from cache ZSTDUncompressCachedData(const ZSTDUncompressCachedData& o) = delete; ZSTDUncompressCachedData& operator=(const ZSTDUncompressCachedData&) = delete; - ZSTDUncompressCachedData(ZSTDUncompressCachedData&& o) ROCKSDB_NOEXCEPT + ZSTDUncompressCachedData(ZSTDUncompressCachedData&& o) noexcept : ZSTDUncompressCachedData() { *this = std::move(o); } - ZSTDUncompressCachedData& operator=(ZSTDUncompressCachedData&& o) - ROCKSDB_NOEXCEPT { + ZSTDUncompressCachedData& operator=(ZSTDUncompressCachedData&& o) noexcept { assert(zstd_ctx_ == nullptr); std::swap(zstd_ctx_, o.zstd_ctx_); std::swap(cache_idx_, o.cache_idx_); @@ -137,10 +136,9 @@ class ZSTDUncompressCachedData { ZSTDUncompressCachedData() {} ZSTDUncompressCachedData(const ZSTDUncompressCachedData&) {} ZSTDUncompressCachedData& operator=(const ZSTDUncompressCachedData&) = delete; - ZSTDUncompressCachedData(ZSTDUncompressCachedData&&) - ROCKSDB_NOEXCEPT = default; - ZSTDUncompressCachedData& operator=(ZSTDUncompressCachedData&&) - ROCKSDB_NOEXCEPT = default; + ZSTDUncompressCachedData(ZSTDUncompressCachedData&&) noexcept = default; + ZSTDUncompressCachedData& operator=(ZSTDUncompressCachedData&&) noexcept = + default; ZSTDNativeContext Get() const { return nullptr; } int64_t GetCacheIndex() const { return -1; } void CreateIfNeeded() {} diff --git a/utilities/backup/backup_engine.cc b/utilities/backup/backup_engine.cc index 2681a65ca5..a14dbc8800 100644 --- a/utilities/backup/backup_engine.cc +++ b/utilities/backup/backup_engine.cc @@ -699,11 +699,11 @@ class BackupEngineImpl { CopyOrCreateWorkItem(const CopyOrCreateWorkItem&) = delete; CopyOrCreateWorkItem& operator=(const CopyOrCreateWorkItem&) = delete; - CopyOrCreateWorkItem(CopyOrCreateWorkItem&& o) ROCKSDB_NOEXCEPT { + CopyOrCreateWorkItem(CopyOrCreateWorkItem&& o) noexcept { *this = std::move(o); } - CopyOrCreateWorkItem& operator=(CopyOrCreateWorkItem&& o) ROCKSDB_NOEXCEPT { + CopyOrCreateWorkItem& operator=(CopyOrCreateWorkItem&& o) noexcept { src_path = std::move(o.src_path); dst_path = std::move(o.dst_path); src_temperature = std::move(o.src_temperature); @@ -772,13 +772,13 @@ class BackupEngineImpl { dst_path(""), dst_relative("") {} - BackupAfterCopyOrCreateWorkItem(BackupAfterCopyOrCreateWorkItem&& o) - ROCKSDB_NOEXCEPT { + BackupAfterCopyOrCreateWorkItem( + BackupAfterCopyOrCreateWorkItem&& o) noexcept { *this = std::move(o); } BackupAfterCopyOrCreateWorkItem& operator=( - BackupAfterCopyOrCreateWorkItem&& o) ROCKSDB_NOEXCEPT { + BackupAfterCopyOrCreateWorkItem&& o) noexcept { result = std::move(o.result); shared = o.shared; needed_to_copy = o.needed_to_copy; @@ -817,13 +817,13 @@ class BackupEngineImpl { from_file(_from_file), to_file(_to_file), checksum_hex(_checksum_hex) {} - RestoreAfterCopyOrCreateWorkItem(RestoreAfterCopyOrCreateWorkItem&& o) - ROCKSDB_NOEXCEPT { + RestoreAfterCopyOrCreateWorkItem( + RestoreAfterCopyOrCreateWorkItem&& o) noexcept { *this = std::move(o); } RestoreAfterCopyOrCreateWorkItem& operator=( - RestoreAfterCopyOrCreateWorkItem&& o) ROCKSDB_NOEXCEPT { + RestoreAfterCopyOrCreateWorkItem&& o) noexcept { result = std::move(o.result); checksum_hex = std::move(o.checksum_hex); return *this; diff --git a/utilities/persistent_cache/volatile_tier_impl.h b/utilities/persistent_cache/volatile_tier_impl.h index d6dbcdef4e..09265e457f 100644 --- a/utilities/persistent_cache/volatile_tier_impl.h +++ b/utilities/persistent_cache/volatile_tier_impl.h @@ -74,9 +74,8 @@ class VolatileCacheTier : public PersistentCacheTier { // Cache data abstraction // struct CacheData : LRUElement { - explicit CacheData(CacheData&& rhs) ROCKSDB_NOEXCEPT - : key(std::move(rhs.key)), - value(std::move(rhs.value)) {} + explicit CacheData(CacheData&& rhs) noexcept + : key(std::move(rhs.key)), value(std::move(rhs.value)) {} explicit CacheData(const std::string& _key, const std::string& _value = "") : key(_key), value(_value) {}