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 Struct

LoadCommand

Public Struct
std.macho.LoadCommandIterator.LoadCommand
pub const LoadCommand = struct

Fields

hdr: load_command
data: []const u8

Functions

pub fn cast(lc: LoadCommand, comptime Cmd: type) ?Cmd
pub fn getSections(lc: LoadCommand) []align(1) const section_64

Asserts LoadCommand is of type segment_command_64. If the native endian is not .little, the section_64 values must be byte-swapped by the caller.

pub fn getDylibPathName(lc: LoadCommand) []const u8

Asserts LoadCommand is of type dylib_command.

pub fn getRpathPathName(lc: LoadCommand) []const u8

Asserts LoadCommand is of type rpath_command.

pub fn getBuildVersionTools(lc: LoadCommand) []align(1) const build_tool_version

Asserts LoadCommand is of type build_version_command. If the native endian is not .little, the build_tool_version values must be byte-swapped by the caller.

File

macho.zig:1940
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
    pub const LoadCommand = struct {
        hdr: load_command,
        data: []const u8,

        pub fn cast(lc: LoadCommand, comptime Cmd: type) ?Cmd {
            if (lc.data.len < @sizeOf(Cmd)) return null;
            const ptr: *align(1) const Cmd = @ptrCast(lc.data.ptr);
            var cmd = ptr.*;
            if (builtin.cpu.arch.endian() != .little) std.mem.byteSwapAllFields(Cmd, &cmd);
            return cmd;
        }

        /// Asserts LoadCommand is of type segment_command_64.
        /// If the native endian is not `.little`, the `section_64` values must be byte-swapped by the caller.
        pub fn getSections(lc: LoadCommand) []align(1) const section_64 {
            const segment_lc = lc.cast(segment_command_64).?;
            const sects_ptr: [*]align(1) const section_64 = @ptrCast(lc.data[@sizeOf(segment_command_64)..]);
            return sects_ptr[0..segment_lc.nsects];
        }

        /// Asserts LoadCommand is of type dylib_command.
        pub fn getDylibPathName(lc: LoadCommand) []const u8 {
            const dylib_lc = lc.cast(dylib_command).?;
            return mem.sliceTo(lc.data[dylib_lc.dylib.name..], 0);
        }

        /// Asserts LoadCommand is of type rpath_command.
        pub fn getRpathPathName(lc: LoadCommand) []const u8 {
            const rpath_lc = lc.cast(rpath_command).?;
            return mem.sliceTo(lc.data[rpath_lc.path..], 0);
        }

        /// Asserts LoadCommand is of type build_version_command.
        /// If the native endian is not `.little`, the `build_tool_version` values must be byte-swapped by the caller.
        pub fn getBuildVersionTools(lc: LoadCommand) []align(1) const build_tool_version {
            const build_lc = lc.cast(build_version_command).?;
            const tools_ptr: [*]align(1) const build_tool_version = @ptrCast(lc.data[@sizeOf(build_version_command)..]);
            return tools_ptr[0..build_lc.ntools];
        }
    }