aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/microbdb/align.h
diff options
context:
space:
mode:
authorqrort <qrort@yandex-team.com>2022-11-30 23:47:12 +0300
committerqrort <qrort@yandex-team.com>2022-11-30 23:47:12 +0300
commit22f8ae0e3f5d68b92aecccdf96c1d841a0334311 (patch)
treebffa27765faf54126ad44bcafa89fadecb7a73d7 /library/cpp/microbdb/align.h
parent332b99e2173f0425444abb759eebcb2fafaa9209 (diff)
downloadydb-22f8ae0e3f5d68b92aecccdf96c1d841a0334311.tar.gz
validate canons without yatest_common
Diffstat (limited to 'library/cpp/microbdb/align.h')
-rw-r--r--library/cpp/microbdb/align.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/library/cpp/microbdb/align.h b/library/cpp/microbdb/align.h
new file mode 100644
index 0000000000..2f8567f134
--- /dev/null
+++ b/library/cpp/microbdb/align.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include <util/system/defaults.h>
+
+using TDatAlign = int;
+
+static inline size_t DatFloor(size_t size) {
+ return (size - 1) & ~(sizeof(TDatAlign) - 1);
+}
+
+static inline size_t DatCeil(size_t size) {
+ return DatFloor(size) + sizeof(TDatAlign);
+}
+
+static inline void DatSet(void* ptr, size_t size) {
+ *(TDatAlign*)((char*)ptr + DatFloor(size)) = 0;
+}