Skip to content

Commit d47d8f9

Browse files
Zainullin DamirZainullin Damir
authored andcommitted
++
1 parent 8bb2de7 commit d47d8f9

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

include/ipfixprobe/outputPlugin/outputStorage/cacheAlligned.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#pragma once
22

3+
#include <cstddef>
4+
#include <new>
5+
36
namespace ipxp::output {
47

58
template<typename Type>
@@ -22,10 +25,16 @@ class CacheAlligned {
2225
constexpr auto operator->(this auto& self) noexcept { return &self.data; }
2326

2427
private:
25-
static constexpr std::size_t EXPECTED_CACHE_LINE_SIZE = 64;
28+
#pragma GCC diagnostic push
29+
#pragma GCC diagnostic ignored "-Winterference-size"
30+
static constexpr std::size_t EXPECTED_CACHE_LINE_SIZE
31+
= std::hardware_destructive_interference_size;
32+
#pragma GCC diagnostic pop
33+
static constexpr std::size_t PADDING_SIZE
34+
= (sizeof(Type) < EXPECTED_CACHE_LINE_SIZE) ? (EXPECTED_CACHE_LINE_SIZE - sizeof(Type)) : 0;
2635

2736
alignas(EXPECTED_CACHE_LINE_SIZE) Type data;
28-
// const std::array<std::byte, EXPECTED_CACHE_LINE_SIZE - sizeof(Type)> m_padding {};
37+
const std::array<std::byte, PADDING_SIZE> m_padding {};
2938
};
3039

3140
} // namespace ipxp::output

0 commit comments

Comments
 (0)