Errno v0.1.0

Source
Extracts the positive errno from a raw syscall result.

Package: MacOS

Signature

func Errno(result: int64) -> int64;

Parameters

NameTypeDescription
resultint64Raw syscall return value.

Returns

int64 - the positive errno (1 through 4095) when result is a negative errno in the range -1 through -4095, or 0 for any other value, which the package treats as success.

Errno does not read or modify a global or thread-local errno variable. It negates the result when IsError reports one, and returns 0 otherwise.

Example

import MacOS::{ Close, Errno };

func Main() -> int {
    let code = Errno(Close(3));
    if code != 0i64 {
        // The close failed with errno `code`.
    }
    return 0;
}

See also