Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

alignBackward

Public Function
std.mem.alignBackward
pub fn alignBackward(comptime T: type, addr: T, alignment: T) T

Round an address down to the previous (or current) aligned address. The alignment must be a power of 2 and greater than 0.

Params

  • T: type
  • addr: T
  • alignment: T

File

mem.zig:4933
4933
4934
4935
4936
4937
4938
4939
pub fn alignBackward(comptime T: type, addr: T, alignment: T) T {
    assert(isValidAlignGeneric(T, alignment));
    // 000010000 // example alignment
    // 000001111 // subtract 1
    // 111110000 // binary not
    return addr & ~(alignment - 1);
}