aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/microbdb/align.h
blob: 2f8567f13444395d5d56a2a26facf64cafff8657 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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;
}