Zig 0.17.0-dev (Split by item)
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 library itself.
Zig › std/ › elf.zig › gnu_hash
gnu_hash
elf.gnu_hash
pub const gnu_hash = struct
File
Code
pub const gnu_hash = struct {
pub const Header = extern struct {
nbuckets : u32 ,
symoffset : u32 ,
bloom_size : u32 ,
bloom_shift : u32 ,
};
pub const ChainEntry = packed struct (u32 ) {
end_of_chain : bool ,
hash : u31 ,
};
pub fn calculate (name : []const u8 ) u32 {
var hash : u32 = 5381 ;
for (name ) |char | {
hash = (hash << 5 ) +% hash +% char ;
}
return hash ;
}
test calculate {
try std .testing .expectEqual (0x00001505 , calculate ("" ));
try std .testing .expectEqual (0x156b2bb8 , calculate ("printf" ));
try std .testing .expectEqual (0x7c967e3f , calculate ("exit" ));
try std .testing .expectEqual (0xbac212a0 , calculate ("syscall" ));
try std .testing .expectEqual (0x8ae9f18e , calculate ("flapenguin.me" ));
}
}