mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Squashed 'src/leveldb/' changes from 04b5790928..4188247086
4188247086 Merge bitcoin-core/leveldb-subtree#47: Fix C++23 compilation errors in leveldb 183e79a495 Fix speculatively some "placement new" issues in leveldb 82c31046ed Fix C++23 compilation errors in leveldb git-subtree-dir: src/leveldb git-subtree-split: 41882470862df219f74cdd38354007b91eb98191
This commit is contained in:
parent
d336b7ab85
commit
a130bbd154
3 changed files with 22 additions and 12 deletions
|
@ -854,9 +854,13 @@ class SingletonEnv {
|
||||||
#endif // !defined(NDEBUG)
|
#endif // !defined(NDEBUG)
|
||||||
static_assert(sizeof(env_storage_) >= sizeof(EnvType),
|
static_assert(sizeof(env_storage_) >= sizeof(EnvType),
|
||||||
"env_storage_ will not fit the Env");
|
"env_storage_ will not fit the Env");
|
||||||
static_assert(alignof(decltype(env_storage_)) >= alignof(EnvType),
|
static_assert(std::is_standard_layout_v<SingletonEnv<EnvType>>);
|
||||||
|
static_assert(
|
||||||
|
offsetof(SingletonEnv<EnvType>, env_storage_) % alignof(EnvType) == 0,
|
||||||
|
"env_storage_ does not meet the Env's alignment needs");
|
||||||
|
static_assert(alignof(SingletonEnv<EnvType>) % alignof(EnvType) == 0,
|
||||||
"env_storage_ does not meet the Env's alignment needs");
|
"env_storage_ does not meet the Env's alignment needs");
|
||||||
new (&env_storage_) EnvType();
|
new (env_storage_) EnvType();
|
||||||
}
|
}
|
||||||
~SingletonEnv() = default;
|
~SingletonEnv() = default;
|
||||||
|
|
||||||
|
@ -872,8 +876,7 @@ class SingletonEnv {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename std::aligned_storage<sizeof(EnvType), alignof(EnvType)>::type
|
alignas(EnvType) char env_storage_[sizeof(EnvType)];
|
||||||
env_storage_;
|
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
static std::atomic<bool> env_initialized_;
|
static std::atomic<bool> env_initialized_;
|
||||||
#endif // !defined(NDEBUG)
|
#endif // !defined(NDEBUG)
|
||||||
|
|
|
@ -802,9 +802,13 @@ class SingletonEnv {
|
||||||
#endif // !defined(NDEBUG)
|
#endif // !defined(NDEBUG)
|
||||||
static_assert(sizeof(env_storage_) >= sizeof(EnvType),
|
static_assert(sizeof(env_storage_) >= sizeof(EnvType),
|
||||||
"env_storage_ will not fit the Env");
|
"env_storage_ will not fit the Env");
|
||||||
static_assert(alignof(decltype(env_storage_)) >= alignof(EnvType),
|
static_assert(std::is_standard_layout_v<SingletonEnv<EnvType>>);
|
||||||
|
static_assert(
|
||||||
|
offsetof(SingletonEnv<EnvType>, env_storage_) % alignof(EnvType) == 0,
|
||||||
|
"env_storage_ does not meet the Env's alignment needs");
|
||||||
|
static_assert(alignof(SingletonEnv<EnvType>) % alignof(EnvType) == 0,
|
||||||
"env_storage_ does not meet the Env's alignment needs");
|
"env_storage_ does not meet the Env's alignment needs");
|
||||||
new (&env_storage_) EnvType();
|
new (env_storage_) EnvType();
|
||||||
}
|
}
|
||||||
~SingletonEnv() = default;
|
~SingletonEnv() = default;
|
||||||
|
|
||||||
|
@ -820,8 +824,7 @@ class SingletonEnv {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename std::aligned_storage<sizeof(EnvType), alignof(EnvType)>::type
|
alignas(EnvType) char env_storage_[sizeof(EnvType)];
|
||||||
env_storage_;
|
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
static std::atomic<bool> env_initialized_;
|
static std::atomic<bool> env_initialized_;
|
||||||
#endif // !defined(NDEBUG)
|
#endif // !defined(NDEBUG)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#ifndef STORAGE_LEVELDB_UTIL_NO_DESTRUCTOR_H_
|
#ifndef STORAGE_LEVELDB_UTIL_NO_DESTRUCTOR_H_
|
||||||
#define STORAGE_LEVELDB_UTIL_NO_DESTRUCTOR_H_
|
#define STORAGE_LEVELDB_UTIL_NO_DESTRUCTOR_H_
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
@ -20,10 +21,14 @@ class NoDestructor {
|
||||||
explicit NoDestructor(ConstructorArgTypes&&... constructor_args) {
|
explicit NoDestructor(ConstructorArgTypes&&... constructor_args) {
|
||||||
static_assert(sizeof(instance_storage_) >= sizeof(InstanceType),
|
static_assert(sizeof(instance_storage_) >= sizeof(InstanceType),
|
||||||
"instance_storage_ is not large enough to hold the instance");
|
"instance_storage_ is not large enough to hold the instance");
|
||||||
|
static_assert(std::is_standard_layout_v<NoDestructor<InstanceType>>);
|
||||||
static_assert(
|
static_assert(
|
||||||
alignof(decltype(instance_storage_)) >= alignof(InstanceType),
|
offsetof(NoDestructor, instance_storage_) % alignof(InstanceType) == 0,
|
||||||
"instance_storage_ does not meet the instance's alignment requirement");
|
"instance_storage_ does not meet the instance's alignment requirement");
|
||||||
new (&instance_storage_)
|
static_assert(
|
||||||
|
alignof(NoDestructor<InstanceType>) % alignof(InstanceType) == 0,
|
||||||
|
"instance_storage_ does not meet the instance's alignment requirement");
|
||||||
|
new (instance_storage_)
|
||||||
InstanceType(std::forward<ConstructorArgTypes>(constructor_args)...);
|
InstanceType(std::forward<ConstructorArgTypes>(constructor_args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +42,7 @@ class NoDestructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename std::aligned_storage<sizeof(InstanceType),
|
alignas(InstanceType) char instance_storage_[sizeof(InstanceType)];
|
||||||
alignof(InstanceType)>::type instance_storage_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace leveldb
|
} // namespace leveldb
|
||||||
|
|
Loading…
Add table
Reference in a new issue