zig/lib/std / std.zig

ArrayHashMap

A contiguous, growable list of items in memory. This is a wrapper around a slice of T values. The same allocator must be used throughout its entire lifetime. Initialize directly with empty or initCapacity, and deinitialize with deinit or toOwnedSlice.

pub const ArrayHashMap = array_hash_map.ArrayHashMap;

ArrayHashMapUnmanaged

Deprecated; use array_list.Aligned.

pub const ArrayHashMapUnmanaged = array_hash_map.ArrayHashMapUnmanaged;

AutoArrayHashMap

Deprecated; use array_list.Aligned.

pub const AutoArrayHashMap = array_hash_map.AutoArrayHashMap;

AutoArrayHashMapUnmanaged

Deprecated; use ArrayList.

pub const AutoArrayHashMapUnmanaged = array_hash_map.AutoArrayHashMapUnmanaged;

AutoHashMap

Stdlib-wide options that can be overridden by the root file.

pub const AutoHashMap = hash_map.AutoHashMap;

AutoHashMapUnmanaged

Function used to implement std.fs.cwd for WASI.

pub const AutoHashMapUnmanaged = hash_map.AutoHashMapUnmanaged;

BitStack

BitStack.zig

The current log level.

pub const BitStack = @import("BitStack.zig");

Build

Build.zig

Overrides std.heap.page_size_min.

pub const Build = @import("Build.zig");

BufMap

buf_map.zig

Overrides std.heap.page_size_max.

pub const BufMap = @import("buf_map.zig").BufMap;

BufSet

buf_set.zig

Overrides default implementation for determining OS page size at runtime.

pub const BufSet = @import("buf_set.zig").BufSet;

StaticStringMap

By default Zig disables SIGPIPE by setting a "no-op" handler for it. Set this option to true to prevent that. Note that we use a "no-op" handler instead of SIG_IGN because it will not be inherited by any child process. SIGPIPE is triggered when a process attempts to write to a broken pipe. By default, SIGPIPE will terminate the process instead of exiting. It doesn't trigger the panic handler so in many cases it's unclear why the process was terminated. By capturing SIGPIPE instead, functions that write to broken pipes will return the EPIPE error (error.BrokenPipe) and the program can handle it like any other error.

pub const StaticStringMap = static_string_map.StaticStringMap;

StaticStringMapWithEql

By default, std.http.Client will support HTTPS connections. Set this option to true to disable TLS support. This will likely reduce the size of the binary, but it will also make it impossible to make a HTTPS connection.

pub const StaticStringMapWithEql = static_string_map.StaticStringMapWithEql;

Deque

deque.zig

This enables std.http.Client to log ssl secrets to the file specified by the SSLKEYLOGFILE env var. Creating such a log file allows other programs with access to that file to decrypt all std.http.Client traffic made by this program.

pub const Deque = @import("deque.zig").Deque;

DoublyLinkedList

DoublyLinkedList.zig

Whether to allow capturing and writing stack traces. This affects the following functions: * debug.captureCurrentStackTrace * debug.writeCurrentStackTrace * debug.dumpCurrentStackTrace * debug.writeStackTrace * debug.dumpStackTrace Stack traces can generally be collected and printed when debug info is stripped, but are often less useful since they usually cannot be mapped to source locations and/or have bad source locations. The stack tracing logic can also be quite large, which may be undesirable, particularly in ReleaseSmall. If this is false, then captured stack traces will always be empty, and attempts to write stack traces will just print an error to the relevant Io.Writer and return.

pub const DoublyLinkedList = @import("DoublyLinkedList.zig");

DynLib

dynamic_library.zig
pub const DynLib = @import("dynamic_library.zig").DynLib;

DynamicBitSet

pub const DynamicBitSet = bit_set.DynamicBitSet;

DynamicBitSetUnmanaged

pub const DynamicBitSetUnmanaged = bit_set.DynamicBitSetUnmanaged;

EnumArray

pub const EnumArray = enums.EnumArray;

EnumMap

pub const EnumMap = enums.EnumMap;

EnumSet

pub const EnumSet = enums.EnumSet;

HashMap

pub const HashMap = hash_map.HashMap;

HashMapUnmanaged

pub const HashMapUnmanaged = hash_map.HashMapUnmanaged;

Io

Io.zig
pub const Io = @import("Io.zig");

MultiArrayList

multi_array_list.zig
pub const MultiArrayList = @import("multi_array_list.zig").MultiArrayList;

PriorityQueue

priority_queue.zig
pub const PriorityQueue = @import("priority_queue.zig").PriorityQueue;

PriorityDequeue

priority_dequeue.zig
pub const PriorityDequeue = @import("priority_dequeue.zig").PriorityDequeue;

Progress

Progress.zig
pub const Progress = @import("Progress.zig");

Random

Random.zig
pub const Random = @import("Random.zig");

SemanticVersion

SemanticVersion.zig
pub const SemanticVersion = @import("SemanticVersion.zig");

SinglyLinkedList

SinglyLinkedList.zig
pub const SinglyLinkedList = @import("SinglyLinkedList.zig");

StaticBitSet

pub const StaticBitSet = bit_set.StaticBitSet;

StringHashMap

pub const StringHashMap = hash_map.StringHashMap;

StringHashMapUnmanaged

pub const StringHashMapUnmanaged = hash_map.StringHashMapUnmanaged;

StringArrayHashMap

pub const StringArrayHashMap = array_hash_map.StringArrayHashMap;

StringArrayHashMapUnmanaged

pub const StringArrayHashMapUnmanaged = array_hash_map.StringArrayHashMapUnmanaged;

Target

Target.zig
pub const Target = @import("Target.zig");

Thread

Thread.zig
pub const Thread = @import("Thread.zig");

Treap

treap.zig
pub const Treap = @import("treap.zig").Treap;

Tz

pub const Tz = tz.Tz;

Uri

Uri.zig
pub const Uri = @import("Uri.zig");

ArrayList()


/// A contiguous, growable list of items in memory. This is a wrapper around a
/// slice of `T` values.
///
/// The same allocator must be used throughout its entire lifetime. Initialize
/// directly with `empty` or `initCapacity`, and deinitialize with `deinit` or
/// `toOwnedSlice`.
pub fn ArrayList(comptime T: type) type {
    return array_list.Aligned(T, null);

options:

}
pub const array_list = @import("array_list.zig");

ArrayListAligned


/// Deprecated; use `array_list.Aligned`.
pub const ArrayListAligned = array_list.Aligned;
/// Deprecated; use `array_list.Aligned`.

ArrayListAlignedUnmanaged

pub const ArrayListAlignedUnmanaged = array_list.Aligned;
/// Deprecated; use `ArrayList`.

ArrayListUnmanaged

pub const ArrayListUnmanaged = ArrayList;

array_hash_map

array_hash_map.zig

pub const array_hash_map = @import("array_hash_map.zig");

atomic

atomic.zig
pub const atomic = @import("atomic.zig");

base64

base64.zig
pub const base64 = @import("base64.zig");

bit_set

bit_set.zig
pub const bit_set = @import("bit_set.zig");

builtin

builtin.zig
pub const builtin = @import("builtin.zig");

c

c.zig
pub const c = @import("c.zig");

coff

coff.zig
pub const coff = @import("coff.zig");

compress

compress.zig
pub const compress = @import("compress.zig");

static_string_map

static_string_map.zig
pub const static_string_map = @import("static_string_map.zig");

crypto

crypto.zig
pub const crypto = @import("crypto.zig");

debug

debug.zig
pub const debug = @import("debug.zig");

dwarf

dwarf.zig
pub const dwarf = @import("dwarf.zig");

elf

elf.zig
pub const elf = @import("elf.zig");

enums

enums.zig
pub const enums = @import("enums.zig");

fmt

fmt.zig
pub const fmt = @import("fmt.zig");

fs

fs.zig
pub const fs = @import("fs.zig");

gpu

gpu.zig
pub const gpu = @import("gpu.zig");

hash

hash.zig
pub const hash = @import("hash.zig");

hash_map

hash_map.zig
pub const hash_map = @import("hash_map.zig");

heap

heap.zig
pub const heap = @import("heap.zig");

http

http.zig
pub const http = @import("http.zig");

json

json.zig
pub const json = @import("json.zig");

leb

leb128.zig
pub const leb = @import("leb128.zig");

log

log.zig
pub const log = @import("log.zig");

macho

macho.zig
pub const macho = @import("macho.zig");

math

math.zig
pub const math = @import("math.zig");

mem

mem.zig
pub const mem = @import("mem.zig");

meta

meta.zig
pub const meta = @import("meta.zig");

net

net.zig
pub const net = @import("net.zig");

os

os.zig
pub const os = @import("os.zig");

once

once.zig
pub const once = @import("once.zig").once;

pdb

pdb.zig
pub const pdb = @import("pdb.zig");

pie

pie.zig
pub const pie = @import("pie.zig");

posix

posix.zig
pub const posix = @import("posix.zig");

process

process.zig
pub const process = @import("process.zig");

sort

sort.zig
pub const sort = @import("sort.zig");

simd

simd.zig
pub const simd = @import("simd.zig");

ascii

ascii.zig
pub const ascii = @import("ascii.zig");

tar

tar.zig
pub const tar = @import("tar.zig");

testing

testing.zig
pub const testing = @import("testing.zig");

time

time.zig
pub const time = @import("time.zig");

tz

tz.zig
pub const tz = @import("tz.zig");

unicode

unicode.zig
pub const unicode = @import("unicode.zig");

valgrind

valgrind.zig
pub const valgrind = @import("valgrind.zig");

wasm

wasm.zig
pub const wasm = @import("wasm.zig");

zig

zig.zig
pub const zig = @import("zig.zig");

zip

zip.zig
pub const zip = @import("zip.zig");

zon

zon.zig
pub const zon = @import("zon.zig");

start

start.zig
pub const start = @import("start.zig");

options:


const root = @import("root");

Options


/// Stdlib-wide options that can be overridden by the root file.
pub const options: Options = if (@hasDecl(root, "std_options")) root.std_options else .{};

pub const Options = struct {
    enable_segfault_handler: bool = debug.default_enable_segfault_handler,

    /// Function used to implement `std.fs.cwd` for WASI.
    wasiCwd: fn () os.wasi.fd_t = fs.defaultWasiCwd,

    /// The current log level.
    log_level: log.Level = log.default_level,

    log_scope_levels: []const log.ScopeLevel = &.{},

    logFn: fn (
        comptime message_level: log.Level,
        comptime scope: @TypeOf(.enum_literal),
        comptime format: []const u8,
        args: anytype,
    ) void = log.defaultLog,

    /// Overrides `std.heap.page_size_min`.
    page_size_min: ?usize = null,
    /// Overrides `std.heap.page_size_max`.
    page_size_max: ?usize = null,
    /// Overrides default implementation for determining OS page size at runtime.
    queryPageSize: fn () usize = heap.defaultQueryPageSize,

    fmt_max_depth: usize = fmt.default_max_depth,

    cryptoRandomSeed: fn (buffer: []u8) void = @import("crypto/tlcsprng.zig").defaultRandomSeed,

    crypto_always_getrandom: bool = false,

    crypto_fork_safety: bool = true,

    /// By default Zig disables SIGPIPE by setting a "no-op" handler for it.  Set this option
    /// to `true` to prevent that.
    ///
    /// Note that we use a "no-op" handler instead of SIG_IGN because it will not be inherited by
    /// any child process.
    ///
    /// SIGPIPE is triggered when a process attempts to write to a broken pipe. By default, SIGPIPE
    /// will terminate the process instead of exiting.  It doesn't trigger the panic handler so in many
    /// cases it's unclear why the process was terminated.  By capturing SIGPIPE instead, functions that
    /// write to broken pipes will return the EPIPE error (error.BrokenPipe) and the program can handle
    /// it like any other error.
    keep_sigpipe: bool = false,

    /// By default, std.http.Client will support HTTPS connections.  Set this option to `true` to
    /// disable TLS support.
    ///
    /// This will likely reduce the size of the binary, but it will also make it impossible to
    /// make a HTTPS connection.
    http_disable_tls: bool = false,

    /// This enables `std.http.Client` to log ssl secrets to the file specified by the SSLKEYLOGFILE
    /// env var.  Creating such a log file allows other programs with access to that file to decrypt
    /// all `std.http.Client` traffic made by this program.
    http_enable_ssl_key_log_file: bool = @import("builtin").mode == .Debug,

    side_channels_mitigations: crypto.SideChannelsMitigations = crypto.default_side_channels_mitigations,

    /// Whether to allow capturing and writing stack traces. This affects the following functions:
    /// * `debug.captureCurrentStackTrace`
    /// * `debug.writeCurrentStackTrace`
    /// * `debug.dumpCurrentStackTrace`
    /// * `debug.writeStackTrace`
    /// * `debug.dumpStackTrace`
    ///
    /// Stack traces can generally be collected and printed when debug info is stripped, but are
    /// often less useful since they usually cannot be mapped to source locations and/or have bad
    /// source locations. The stack tracing logic can also be quite large, which may be undesirable,
    /// particularly in ReleaseSmall.
    ///
    /// If this is `false`, then captured stack traces will always be empty, and attempts to write
    /// stack traces will just print an error to the relevant `Io.Writer` and return.
    allow_stack_tracing: bool = !@import("builtin").strip_debug_info,
};

// This forces the start.zig file to be imported, and the comptime logic inside that
// file decides whether to export any appropriate start symbols, and call main.
comptime {
    _ = start;
}

test {
    testing.refAllDecls(@This());
}

comptime {
    debug.assert(@import("std") == @This()); // std lib tests require --zig-lib-dir
}