mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +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
0c69e1eb21
commit
3b47b4648b
@ -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