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 Namespace

hash

Public Namespace
std.elf.hash
pub const hash = struct

Structs

Functions

pub fn calculate(name: []const u8) u32

File

elf.zig:3315
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
pub const hash = struct {
    pub fn calculate(name: []const u8) u32 {
        var h: u32 = 0;
        for (name) |c| {
            h = (h << 4) +% c;
            const g = h & 0xF000_0000;
            h = (h ^ (g >> 24)) & ~g;
        }
        return h;
    }

    /// The header of a `SHT.HASH` section on most architectures. Immediately followed by:
    /// * `buckets: [nbucket]u32`
    /// * `chains: [nchain]u32`
    ///
    /// The bucket for a symbol named `name` is `std.elf.hash.calculate(name) % nbuckets`.
    ///
    /// `buckets[b]` is the index of the first symbol in bucket `b`. If bucket `b` is empty then the
    /// value is 0 (`STN_UNDEF`).
    ///
    /// `chain[sym_index]` is the index of the next symbol in the same bucket as `sym_index`. If
    /// `sym_index` is the last symbol in its bucket then the value is 0 (`STN_UNDEF`).
    ///
    /// See also `Header64`.
    pub const Header32 = extern struct {
        nbucket: u32,
        nchain: u32,
    };

    /// The header of a `SHT.HASH` section on alpha and s390x. Immediately followed by:
    /// * `buckets: [nbucket]u64`
    /// * `chains: [nchain]u64`
    ///
    /// See also `Header32`.
    pub const Header64 = extern struct {
        nbucket: u64,
        nchain: u64,
    };
}