lib/tldr/src/formats/elf/layout/reserve.zig
daab053ee43316e1809a84551d573ddd1e5bf3d2
1 pub fn size(section_size: u64, alignment: u64, options: anytype) u64 {
2 if (options.incremental_mode == .off or section_size == 0) return alignForwardU64(section_size, alignment);
3 const proportional = (section_size * options.incremental_reserve_percent + 99) / 100;
4 const slack = @max(alignment, proportional);
5 return alignForwardU64(section_size + slack, alignment);
6 }
7
8 pub fn contribution(section_size: u64, alignment: u64, options: anytype) u64 {
9 if (options.incremental_mode == .off) return section_size;
10 return size(section_size, alignment, options);
11 }
12
13 fn alignForwardU64(value: u64, alignment: u64) u64 {
14 if (alignment == 0) return value;
15 const mask = alignment - 1;
16 return (value + mask) & ~mask;
17 }