summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/include/hardware.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/include/hardware.h')
-rw-r--r--src/third_party/wiredtiger/src/include/hardware.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/third_party/wiredtiger/src/include/hardware.h b/src/third_party/wiredtiger/src/include/hardware.h
index 0e52818ae05..2530659db21 100644
--- a/src/third_party/wiredtiger/src/include/hardware.h
+++ b/src/third_party/wiredtiger/src/include/hardware.h
@@ -55,7 +55,19 @@
#else
#define WT_CACHE_LINE_ALIGNMENT 64
#endif
-#define WT_CACHE_LINE_ALIGNMENT_VERIFY(session, a) \
- WT_ASSERT(session, \
- WT_PTRDIFF(&(a)[1], &(a)[0]) >= WT_CACHE_LINE_ALIGNMENT && \
- WT_PTRDIFF(&(a)[1], &(a)[0]) % WT_CACHE_LINE_ALIGNMENT == 0)
+
+/*
+ * Pad a structure so an array of structures get separate cache lines.
+ *
+ * Note that we avoid compiler structure alignment because that requires
+ * allocating aligned blocks of memory, and alignment pollutes any other type
+ * that contains an aligned field. It is possible that a hot field positioned
+ * before this one will be on the same cache line, but not if it is also
+ * padded.
+ *
+ * This alignment has a small impact on portability as well, as we are using an
+ * anonymous union here which is supported under C11, earlier versions of
+ * the GNU standard, and MSVC versions as early as 2003.
+ */
+#define WT_CACHE_LINE_PAD_BEGIN union { struct {
+#define WT_CACHE_LINE_PAD_END }; char __padding[WT_CACHE_LINE_ALIGNMENT]; };