mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 06:35:12 +00:00
fix: use manual padding of instance_map_shard (#5200)
* Use manual padding of instance_map_shard. The alignas(64) specifier requires aligned allocation, which is not available on macOS when targeting versions before 10.14. * Add 'see #5200' * Update include/pybind11/detail/internals.h * Update include/pybind11/detail/internals.h --------- Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
This commit is contained in:
parent
895e657220
commit
2e35470cff
@ -148,18 +148,14 @@ struct override_hash {
|
||||
|
||||
using instance_map = std::unordered_multimap<const void *, instance *>;
|
||||
|
||||
// ignore: structure was padded due to alignment specifier
|
||||
PYBIND11_WARNING_PUSH
|
||||
PYBIND11_WARNING_DISABLE_MSVC(4324)
|
||||
|
||||
// Instance map shards are used to reduce mutex contention in free-threaded Python.
|
||||
struct alignas(64) instance_map_shard {
|
||||
struct instance_map_shard {
|
||||
std::mutex mutex;
|
||||
instance_map registered_instances;
|
||||
// alignas(64) would be better, but causes compile errors in macOS before 10.14 (see #5200)
|
||||
char padding[64 - (sizeof(std::mutex) + sizeof(instance_map)) % 64];
|
||||
};
|
||||
|
||||
PYBIND11_WARNING_POP
|
||||
|
||||
/// Internal data structure used to track registered instances and types.
|
||||
/// Whenever binary incompatible changes are made to this structure,
|
||||
/// `PYBIND11_INTERNALS_VERSION` must be incremented.
|
||||
|
Loading…
Reference in New Issue
Block a user