summaryrefslogtreecommitdiff
path: root/libguile/whippet/src/gc-align.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2025-04-11 14:10:41 +0200
committerAndy Wingo <wingo@pobox.com>2025-04-11 14:10:41 +0200
commitdb181e67ff482ab08cbdb0c1a88997b3a886f900 (patch)
tree6d16fbca515ae3cf506a9d16dbc89c472446e5d9 /libguile/whippet/src/gc-align.h
parentaf96820e072d18c49ac03e80c6f3466d568dc77d (diff)
parentf909438596f63ecd44c5b9a28385260714857361 (diff)
downloadguile-db181e67ff482ab08cbdb0c1a88997b3a886f900.tar.gz
Merged Whippet into libguile/whippet
Diffstat (limited to 'libguile/whippet/src/gc-align.h')
-rw-r--r--libguile/whippet/src/gc-align.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/libguile/whippet/src/gc-align.h b/libguile/whippet/src/gc-align.h
new file mode 100644
index 000000000..c0758b1e0
--- /dev/null
+++ b/libguile/whippet/src/gc-align.h
@@ -0,0 +1,22 @@
+#ifndef GC_ALIGN_H
+#define GC_ALIGN_H
+
+#ifndef GC_IMPL
+#error internal header file, not part of API
+#endif
+
+#include <stdint.h>
+
+static inline uintptr_t align_down(uintptr_t addr, size_t align) {
+ return addr & ~(align - 1);
+}
+static inline uintptr_t align_up(uintptr_t addr, size_t align) {
+ return align_down(addr + align - 1, align);
+}
+
+// Poor man's equivalent of std::hardware_destructive_interference_size.
+#define AVOID_FALSE_SHARING 128
+#define ALIGNED_TO_AVOID_FALSE_SHARING \
+ __attribute__((aligned(AVOID_FALSE_SHARING)))
+
+#endif // GC_ALIGN_H