Skip to content

Commit 6338b6d

Browse files
authored
Merge branch 'google:main' into main
2 parents 80d6c09 + 7ee830d commit 6338b6d

9 files changed

Lines changed: 38 additions & 19 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file. See the AUTHORS file for names of contributors.
44

5-
cmake_minimum_required(VERSION 3.9)
5+
cmake_minimum_required(VERSION 3.22)
66
# Keep the version below in sync with the one in db.h
77
project(leveldb VERSION 1.23.0 LANGUAGES C CXX)
88

@@ -16,8 +16,8 @@ endif(NOT CMAKE_C_STANDARD)
1616

1717
# C++ standard can be overridden when this is used as a sub-project.
1818
if(NOT CMAKE_CXX_STANDARD)
19-
# This project requires C++11.
20-
set(CMAKE_CXX_STANDARD 11)
19+
# This project requires C++17.
20+
set(CMAKE_CXX_STANDARD 17)
2121
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2222
set(CMAKE_CXX_EXTENSIONS OFF)
2323
endif(NOT CMAKE_CXX_STANDARD)

db/db_impl.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,11 @@ void DBImpl::TEST_CompactRange(int level, const Slice* begin,
629629
background_work_finished_signal_.Wait();
630630
}
631631
}
632+
// Finish current background compaction in the case where
633+
// `background_work_finished_signal_` was signalled due to an error.
634+
while (background_compaction_scheduled_) {
635+
background_work_finished_signal_.Wait();
636+
}
632637
if (manual_compaction_ == &manual) {
633638
// Cancel my manual compaction since we aborted early for some reason.
634639
manual_compaction_ = nullptr;
@@ -641,7 +646,8 @@ Status DBImpl::TEST_CompactMemTable() {
641646
if (s.ok()) {
642647
// Wait until the compaction completes
643648
MutexLock l(&mutex_);
644-
while (imm_ != nullptr && bg_error_.ok()) {
649+
while (imm_ != nullptr && bg_error_.ok() &&
650+
!shutting_down_.load(std::memory_order_acquire)) {
645651
background_work_finished_signal_.Wait();
646652
}
647653
if (imm_ != nullptr) {

include/leveldb/slice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class LEVELDB_EXPORT Slice {
5151
// Return true iff the length of the referenced data is zero
5252
bool empty() const { return size_ == 0; }
5353

54+
const char* begin() const { return data(); }
55+
const char* end() const { return data() + size(); }
56+
5457
// Return the ith byte in the referenced data.
5558
// REQUIRES: n < size()
5659
char operator[](size_t n) const {

third_party/benchmark

Submodule benchmark updated 180 files

third_party/googletest

Submodule googletest updated 249 files

util/env_posix.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -874,9 +874,13 @@ class SingletonEnv {
874874
#endif // !defined(NDEBUG)
875875
static_assert(sizeof(env_storage_) >= sizeof(EnvType),
876876
"env_storage_ will not fit the Env");
877-
static_assert(alignof(decltype(env_storage_)) >= alignof(EnvType),
877+
static_assert(std::is_standard_layout_v<SingletonEnv<EnvType>>);
878+
static_assert(
879+
offsetof(SingletonEnv<EnvType>, env_storage_) % alignof(EnvType) == 0,
880+
"env_storage_ does not meet the Env's alignment needs");
881+
static_assert(alignof(SingletonEnv<EnvType>) % alignof(EnvType) == 0,
878882
"env_storage_ does not meet the Env's alignment needs");
879-
new (&env_storage_) EnvType();
883+
new (env_storage_) EnvType();
880884
}
881885
~SingletonEnv() = default;
882886

@@ -892,8 +896,7 @@ class SingletonEnv {
892896
}
893897

894898
private:
895-
typename std::aligned_storage<sizeof(EnvType), alignof(EnvType)>::type
896-
env_storage_;
899+
alignas(EnvType) char env_storage_[sizeof(EnvType)];
897900
#if !defined(NDEBUG)
898901
static std::atomic<bool> env_initialized_;
899902
#endif // !defined(NDEBUG)

util/env_windows.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,9 +769,13 @@ class SingletonEnv {
769769
#endif // !defined(NDEBUG)
770770
static_assert(sizeof(env_storage_) >= sizeof(EnvType),
771771
"env_storage_ will not fit the Env");
772-
static_assert(alignof(decltype(env_storage_)) >= alignof(EnvType),
772+
static_assert(std::is_standard_layout_v<SingletonEnv<EnvType>>);
773+
static_assert(
774+
offsetof(SingletonEnv<EnvType>, env_storage_) % alignof(EnvType) == 0,
775+
"env_storage_ does not meet the Env's alignment needs");
776+
static_assert(alignof(SingletonEnv<EnvType>) % alignof(EnvType) == 0,
773777
"env_storage_ does not meet the Env's alignment needs");
774-
new (&env_storage_) EnvType();
778+
new (env_storage_) EnvType();
775779
}
776780
~SingletonEnv() = default;
777781

@@ -787,8 +791,7 @@ class SingletonEnv {
787791
}
788792

789793
private:
790-
typename std::aligned_storage<sizeof(EnvType), alignof(EnvType)>::type
791-
env_storage_;
794+
alignas(EnvType) char env_storage_[sizeof(EnvType)];
792795
#if !defined(NDEBUG)
793796
static std::atomic<bool> env_initialized_;
794797
#endif // !defined(NDEBUG)

util/hash.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ uint32_t Hash(const char* data, size_t n, uint32_t seed) {
2727
uint32_t h = seed ^ (n * m);
2828

2929
// Pick up four bytes at a time
30-
while (data + 4 <= limit) {
30+
while (limit - data >= 4) {
3131
uint32_t w = DecodeFixed32(data);
3232
data += 4;
3333
h += w;

util/no_destructor.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef STORAGE_LEVELDB_UTIL_NO_DESTRUCTOR_H_
66
#define STORAGE_LEVELDB_UTIL_NO_DESTRUCTOR_H_
77

8+
#include <cstddef>
89
#include <type_traits>
910
#include <utility>
1011

@@ -20,10 +21,14 @@ class NoDestructor {
2021
explicit NoDestructor(ConstructorArgTypes&&... constructor_args) {
2122
static_assert(sizeof(instance_storage_) >= sizeof(InstanceType),
2223
"instance_storage_ is not large enough to hold the instance");
24+
static_assert(std::is_standard_layout_v<NoDestructor<InstanceType>>);
2325
static_assert(
24-
alignof(decltype(instance_storage_)) >= alignof(InstanceType),
26+
offsetof(NoDestructor, instance_storage_) % alignof(InstanceType) == 0,
2527
"instance_storage_ does not meet the instance's alignment requirement");
26-
new (&instance_storage_)
28+
static_assert(
29+
alignof(NoDestructor<InstanceType>) % alignof(InstanceType) == 0,
30+
"instance_storage_ does not meet the instance's alignment requirement");
31+
new (instance_storage_)
2732
InstanceType(std::forward<ConstructorArgTypes>(constructor_args)...);
2833
}
2934

@@ -37,8 +42,7 @@ class NoDestructor {
3742
}
3843

3944
private:
40-
typename std::aligned_storage<sizeof(InstanceType),
41-
alignof(InstanceType)>::type instance_storage_;
45+
alignas(InstanceType) char instance_storage_[sizeof(InstanceType)];
4246
};
4347

4448
} // namespace leveldb

0 commit comments

Comments
 (0)