Blame docs/src/misc.rst

Packit b5b901
Packit b5b901
.. _misc:
Packit b5b901
Packit b5b901
Miscellaneous utilities
Packit b5b901
=======================
Packit b5b901
Packit b5b901
This section contains miscellaneous functions that don't really belong in any
Packit b5b901
other section.
Packit b5b901
Packit b5b901
Packit b5b901
Data types
Packit b5b901
----------
Packit b5b901
Packit b5b901
.. c:type:: uv_buf_t
Packit b5b901
Packit b5b901
    Buffer data type.
Packit b5b901
Packit b5b901
    .. c:member:: char* uv_buf_t.base
Packit b5b901
Packit b5b901
        Pointer to the base of the buffer.
Packit b5b901
Packit b5b901
    .. c:member:: size_t uv_buf_t.len
Packit b5b901
Packit b5b901
        Total bytes in the buffer.
Packit b5b901
Packit b5b901
        .. note::
Packit b5b901
            On Windows this field is ULONG.
Packit b5b901
Packit b5b901
.. c:type:: void* (*uv_malloc_func)(size_t size)
Packit b5b901
Packit b5b901
        Replacement function for :man:`malloc(3)`.
Packit b5b901
        See :c:func:`uv_replace_allocator`.
Packit b5b901
Packit b5b901
.. c:type::  void* (*uv_realloc_func)(void* ptr, size_t size)
Packit b5b901
Packit b5b901
        Replacement function for :man:`realloc(3)`.
Packit b5b901
        See :c:func:`uv_replace_allocator`.
Packit b5b901
Packit b5b901
.. c:type::  void* (*uv_calloc_func)(size_t count, size_t size)
Packit b5b901
Packit b5b901
        Replacement function for :man:`calloc(3)`.
Packit b5b901
        See :c:func:`uv_replace_allocator`.
Packit b5b901
Packit b5b901
.. c:type:: void (*uv_free_func)(void* ptr)
Packit b5b901
Packit b5b901
        Replacement function for :man:`free(3)`.
Packit b5b901
        See :c:func:`uv_replace_allocator`.
Packit b5b901
Packit Service e08953
.. c:type::  void (*uv_random_cb)(uv_random_t* req, int status, void* buf, size_t buflen)
Packit Service e08953
Packit Service e08953
    Callback passed to :c:func:`uv_random`. `status` is non-zero in case of
Packit Service e08953
    error. The `buf` pointer is the same pointer that was passed to
Packit Service e08953
    :c:func:`uv_random`.
Packit Service e08953
Packit b5b901
.. c:type:: uv_file
Packit b5b901
Packit b5b901
    Cross platform representation of a file handle.
Packit b5b901
Packit b5b901
.. c:type:: uv_os_sock_t
Packit b5b901
Packit b5b901
    Cross platform representation of a socket handle.
Packit b5b901
Packit b5b901
.. c:type:: uv_os_fd_t
Packit b5b901
Packit b5b901
    Abstract representation of a file descriptor. On Unix systems this is a
Packit b5b901
    `typedef` of `int` and on Windows a `HANDLE`.
Packit b5b901
Packit b5b901
.. c:type:: uv_pid_t
Packit b5b901
Packit b5b901
    Cross platform representation of a `pid_t`.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.16.0
Packit b5b901
Packit Service e08953
.. c:type:: uv_timeval_t
Packit Service e08953
Packit Service e08953
    Data type for storing times.
Packit Service e08953
Packit Service e08953
    ::
Packit Service e08953
Packit Service e08953
        typedef struct {
Packit Service e08953
            long tv_sec;
Packit Service e08953
            long tv_usec;
Packit Service e08953
        } uv_timeval_t;
Packit Service e08953
Packit Service e08953
.. c:type:: uv_timeval64_t
Packit Service e08953
Packit Service e08953
    Alternative data type for storing times.
Packit Service e08953
Packit Service e08953
    ::
Packit Service e08953
Packit Service e08953
        typedef struct {
Packit Service e08953
            int64_t tv_sec;
Packit Service e08953
            int32_t tv_usec;
Packit Service e08953
        } uv_timeval64_t;
Packit Service e08953
Packit b5b901
.. c:type:: uv_rusage_t
Packit b5b901
Packit b5b901
    Data type for resource usage results.
Packit b5b901
Packit b5b901
    ::
Packit b5b901
Packit b5b901
        typedef struct {
Packit b5b901
            uv_timeval_t ru_utime; /* user CPU time used */
Packit b5b901
            uv_timeval_t ru_stime; /* system CPU time used */
Packit b5b901
            uint64_t ru_maxrss; /* maximum resident set size */
Packit b5b901
            uint64_t ru_ixrss; /* integral shared memory size (X) */
Packit b5b901
            uint64_t ru_idrss; /* integral unshared data size (X) */
Packit b5b901
            uint64_t ru_isrss; /* integral unshared stack size (X) */
Packit b5b901
            uint64_t ru_minflt; /* page reclaims (soft page faults) (X) */
Packit b5b901
            uint64_t ru_majflt; /* page faults (hard page faults) */
Packit b5b901
            uint64_t ru_nswap; /* swaps (X) */
Packit b5b901
            uint64_t ru_inblock; /* block input operations */
Packit b5b901
            uint64_t ru_oublock; /* block output operations */
Packit b5b901
            uint64_t ru_msgsnd; /* IPC messages sent (X) */
Packit b5b901
            uint64_t ru_msgrcv; /* IPC messages received (X) */
Packit b5b901
            uint64_t ru_nsignals; /* signals received (X) */
Packit b5b901
            uint64_t ru_nvcsw; /* voluntary context switches (X) */
Packit b5b901
            uint64_t ru_nivcsw; /* involuntary context switches (X) */
Packit b5b901
        } uv_rusage_t;
Packit b5b901
Packit b5b901
    Members marked with `(X)` are unsupported on Windows.
Packit b5b901
    See :man:`getrusage(2)` for supported fields on Unix
Packit b5b901
Packit b5b901
.. c:type:: uv_cpu_info_t
Packit b5b901
Packit b5b901
    Data type for CPU information.
Packit b5b901
Packit b5b901
    ::
Packit b5b901
Packit b5b901
        typedef struct uv_cpu_info_s {
Packit b5b901
            char* model;
Packit b5b901
            int speed;
Packit b5b901
            struct uv_cpu_times_s {
Packit Service e08953
                uint64_t user; /* milliseconds */
Packit Service e08953
                uint64_t nice; /* milliseconds */
Packit Service e08953
                uint64_t sys; /* milliseconds */
Packit Service e08953
                uint64_t idle; /* milliseconds */
Packit Service e08953
                uint64_t irq; /* milliseconds */
Packit b5b901
            } cpu_times;
Packit b5b901
        } uv_cpu_info_t;
Packit b5b901
Packit b5b901
.. c:type:: uv_interface_address_t
Packit b5b901
Packit b5b901
    Data type for interface addresses.
Packit b5b901
Packit b5b901
    ::
Packit b5b901
Packit b5b901
        typedef struct uv_interface_address_s {
Packit b5b901
            char* name;
Packit b5b901
            char phys_addr[6];
Packit b5b901
            int is_internal;
Packit b5b901
            union {
Packit b5b901
                struct sockaddr_in address4;
Packit b5b901
                struct sockaddr_in6 address6;
Packit b5b901
            } address;
Packit b5b901
            union {
Packit b5b901
                struct sockaddr_in netmask4;
Packit b5b901
                struct sockaddr_in6 netmask6;
Packit b5b901
            } netmask;
Packit b5b901
        } uv_interface_address_t;
Packit b5b901
Packit b5b901
.. c:type:: uv_passwd_t
Packit b5b901
Packit b5b901
    Data type for password file information.
Packit b5b901
Packit b5b901
    ::
Packit b5b901
Packit b5b901
        typedef struct uv_passwd_s {
Packit b5b901
            char* username;
Packit b5b901
            long uid;
Packit b5b901
            long gid;
Packit b5b901
            char* shell;
Packit b5b901
            char* homedir;
Packit b5b901
        } uv_passwd_t;
Packit b5b901
Packit Service e08953
.. c:type:: uv_utsname_t
Packit Service e08953
Packit Service e08953
    Data type for operating system name and version information.
Packit Service e08953
Packit Service e08953
    ::
Packit Service e08953
Packit Service e08953
        typedef struct uv_utsname_s {
Packit Service e08953
            char sysname[256];
Packit Service e08953
            char release[256];
Packit Service e08953
            char version[256];
Packit Service e08953
            char machine[256];
Packit Service e08953
        } uv_utsname_t;
Packit Service e08953
Packit Service e08953
.. c:type:: uv_env_item_t
Packit Service e08953
Packit Service e08953
    Data type for environment variable storage.
Packit Service e08953
Packit Service e08953
    ::
Packit Service e08953
Packit Service e08953
        typedef struct uv_env_item_s {
Packit Service e08953
            char* name;
Packit Service e08953
            char* value;
Packit Service e08953
        } uv_env_item_t;
Packit Service e08953
Packit Service e08953
.. c:type:: uv_random_t
Packit Service e08953
Packit Service e08953
    Random data request type.
Packit b5b901
Packit b5b901
API
Packit b5b901
---
Packit b5b901
Packit b5b901
.. c:function:: uv_handle_type uv_guess_handle(uv_file file)
Packit b5b901
Packit b5b901
    Used to detect what type of stream should be used with a given file
Packit b5b901
    descriptor. Usually this will be used during initialization to guess the
Packit b5b901
    type of the stdio streams.
Packit b5b901
Packit b5b901
    For :man:`isatty(3)` equivalent functionality use this function and test
Packit b5b901
    for ``UV_TTY``.
Packit b5b901
Packit b5b901
.. c:function:: int uv_replace_allocator(uv_malloc_func malloc_func, uv_realloc_func realloc_func, uv_calloc_func calloc_func, uv_free_func free_func)
Packit b5b901
Packit b5b901
    .. versionadded:: 1.6.0
Packit b5b901
Packit b5b901
    Override the use of the standard library's :man:`malloc(3)`,
Packit b5b901
    :man:`calloc(3)`, :man:`realloc(3)`, :man:`free(3)`, memory allocation
Packit b5b901
    functions.
Packit b5b901
Packit b5b901
    This function must be called before any other libuv function is called or
Packit b5b901
    after all resources have been freed and thus libuv doesn't reference
Packit b5b901
    any allocated memory chunk.
Packit b5b901
Packit b5b901
    On success, it returns 0, if any of the function pointers is NULL it
Packit b5b901
    returns UV_EINVAL.
Packit b5b901
Packit b5b901
    .. warning:: There is no protection against changing the allocator multiple
Packit b5b901
                 times. If the user changes it they are responsible for making
Packit b5b901
                 sure the allocator is changed while no memory was allocated with
Packit b5b901
                 the previous allocator, or that they are compatible.
Packit b5b901
Packit Service e08953
    .. warning:: Allocator must be thread-safe.
Packit Service e08953
Packit Service e08953
.. c:function:: void uv_library_shutdown(void);
Packit Service e08953
Packit Service e08953
    .. versionadded:: 1.38.0
Packit Service e08953
Packit Service e08953
    Release any global state that libuv is holding onto. Libuv will normally
Packit Service e08953
    do so automatically when it is unloaded but it can be instructed to perform
Packit Service e08953
    cleanup manually.
Packit Service e08953
Packit Service e08953
    .. warning:: Only call :c:func:`uv_library_shutdown()` once.
Packit Service e08953
Packit Service e08953
    .. warning:: Don't call :c:func:`uv_library_shutdown()` when there are
Packit Service e08953
                 still event loops or I/O requests active.
Packit Service e08953
Packit Service e08953
    .. warning:: Don't call libuv functions after calling
Packit Service e08953
                 :c:func:`uv_library_shutdown()`.
Packit Service e08953
Packit b5b901
.. c:function:: uv_buf_t uv_buf_init(char* base, unsigned int len)
Packit b5b901
Packit b5b901
    Constructor for :c:type:`uv_buf_t`.
Packit b5b901
Packit b5b901
    Due to platform differences the user cannot rely on the ordering of the
Packit b5b901
    `base` and `len` members of the uv_buf_t struct. The user is responsible for
Packit b5b901
    freeing `base` after the uv_buf_t is done. Return struct passed by value.
Packit b5b901
Packit b5b901
.. c:function:: char** uv_setup_args(int argc, char** argv)
Packit b5b901
Packit b5b901
    Store the program arguments. Required for getting / setting the process title.
Packit Service e08953
    Libuv may take ownership of the memory that `argv` points to. This function
Packit Service e08953
    should be called exactly once, at program start-up.
Packit Service e08953
Packit Service e08953
    Example:
Packit Service e08953
Packit Service e08953
    ::
Packit Service e08953
Packit Service e08953
        argv = uv_setup_args(argc, argv);  /* May return a copy of argv. */
Packit Service e08953
Packit b5b901
Packit b5b901
.. c:function:: int uv_get_process_title(char* buffer, size_t size)
Packit b5b901
Packit b5b901
    Gets the title of the current process. You *must* call `uv_setup_args`
Packit b5b901
    before calling this function. If `buffer` is `NULL` or `size` is zero,
Packit b5b901
    `UV_EINVAL` is returned. If `size` cannot accommodate the process title and
Packit b5b901
    terminating `NULL` character, the function returns `UV_ENOBUFS`.
Packit b5b901
Packit b5b901
    .. versionchanged:: 1.18.1 now thread-safe on all supported platforms.
Packit b5b901
Packit b5b901
.. c:function:: int uv_set_process_title(const char* title)
Packit b5b901
Packit b5b901
    Sets the current process title. You *must* call `uv_setup_args` before
Packit b5b901
    calling this function. On platforms with a fixed size buffer for the process
Packit b5b901
    title the contents of `title` will be copied to the buffer and truncated if
Packit b5b901
    larger than the available space. Other platforms will return `UV_ENOMEM` if
Packit b5b901
    they cannot allocate enough space to duplicate the contents of `title`.
Packit b5b901
Packit b5b901
    .. versionchanged:: 1.18.1 now thread-safe on all supported platforms.
Packit b5b901
Packit b5b901
.. c:function:: int uv_resident_set_memory(size_t* rss)
Packit b5b901
Packit b5b901
    Gets the resident set size (RSS) for the current process.
Packit b5b901
Packit b5b901
.. c:function:: int uv_uptime(double* uptime)
Packit b5b901
Packit b5b901
    Gets the current system uptime.
Packit b5b901
Packit b5b901
.. c:function:: int uv_getrusage(uv_rusage_t* rusage)
Packit b5b901
Packit b5b901
    Gets the resource usage measures for the current process.
Packit b5b901
Packit b5b901
    .. note::
Packit b5b901
        On Windows not all fields are set, the unsupported fields are filled with zeroes.
Packit b5b901
        See :c:type:`uv_rusage_t` for more details.
Packit b5b901
Packit b5b901
.. c:function:: uv_pid_t uv_os_getpid(void)
Packit b5b901
Packit b5b901
    Returns the current process ID.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.18.0
Packit b5b901
Packit b5b901
.. c:function:: uv_pid_t uv_os_getppid(void)
Packit b5b901
Packit b5b901
    Returns the parent process ID.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.16.0
Packit b5b901
Packit b5b901
.. c:function:: int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count)
Packit b5b901
Packit b5b901
    Gets information about the CPUs on the system. The `cpu_infos` array will
Packit b5b901
    have `count` elements and needs to be freed with :c:func:`uv_free_cpu_info`.
Packit b5b901
Packit b5b901
.. c:function:: void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count)
Packit b5b901
Packit b5b901
    Frees the `cpu_infos` array previously allocated with :c:func:`uv_cpu_info`.
Packit b5b901
Packit b5b901
.. c:function:: int uv_interface_addresses(uv_interface_address_t** addresses, int* count)
Packit b5b901
Packit b5b901
    Gets address information about the network interfaces on the system. An
Packit b5b901
    array of `count` elements is allocated and returned in `addresses`. It must
Packit b5b901
    be freed by the user, calling :c:func:`uv_free_interface_addresses`.
Packit b5b901
Packit b5b901
.. c:function:: void uv_free_interface_addresses(uv_interface_address_t* addresses, int count)
Packit b5b901
Packit b5b901
    Free an array of :c:type:`uv_interface_address_t` which was returned by
Packit b5b901
    :c:func:`uv_interface_addresses`.
Packit b5b901
Packit b5b901
.. c:function:: void uv_loadavg(double avg[3])
Packit b5b901
Packit Service e08953
    Gets the load average. See: `<https://en.wikipedia.org/wiki/Load_(computing)>`_
Packit b5b901
Packit b5b901
    .. note::
Packit b5b901
        Returns [0,0,0] on Windows (i.e., it's not implemented).
Packit b5b901
Packit b5b901
.. c:function:: int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr)
Packit b5b901
Packit b5b901
    Convert a string containing an IPv4 addresses to a binary structure.
Packit b5b901
Packit b5b901
.. c:function:: int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr)
Packit b5b901
Packit b5b901
    Convert a string containing an IPv6 addresses to a binary structure.
Packit b5b901
Packit b5b901
.. c:function:: int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size)
Packit b5b901
Packit b5b901
    Convert a binary structure containing an IPv4 address to a string.
Packit b5b901
Packit b5b901
.. c:function:: int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size)
Packit b5b901
Packit b5b901
    Convert a binary structure containing an IPv6 address to a string.
Packit b5b901
Packit b5b901
.. c:function:: int uv_inet_ntop(int af, const void* src, char* dst, size_t size)
Packit b5b901
.. c:function:: int uv_inet_pton(int af, const char* src, void* dst)
Packit b5b901
Packit b5b901
    Cross-platform IPv6-capable implementation of :man:`inet_ntop(3)`
Packit b5b901
    and :man:`inet_pton(3)`. On success they return 0. In case of error
Packit b5b901
    the target `dst` pointer is unmodified.
Packit b5b901
Packit b5b901
.. c:macro:: UV_IF_NAMESIZE
Packit b5b901
Packit b5b901
    Maximum IPv6 interface identifier name length.  Defined as
Packit b5b901
    `IFNAMSIZ` on Unix and `IF_NAMESIZE` on Linux and Windows.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.16.0
Packit b5b901
Packit b5b901
.. c:function:: int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size)
Packit b5b901
Packit b5b901
    IPv6-capable implementation of :man:`if_indextoname(3)`. When called,
Packit b5b901
    `*size` indicates the length of the `buffer`, which is used to store the
Packit b5b901
    result.
Packit b5b901
    On success, zero is returned, `buffer` contains the interface name, and
Packit b5b901
    `*size` represents the string length of the `buffer`, excluding the NUL
Packit b5b901
    terminator byte from `*size`. On error, a negative result is
Packit b5b901
    returned. If `buffer` is not large enough to hold the result,
Packit b5b901
    `UV_ENOBUFS` is returned, and `*size` represents the necessary size in
Packit b5b901
    bytes, including the NUL terminator byte into the `*size`.
Packit b5b901
Packit b5b901
    On Unix, the returned interface name can be used directly as an
Packit b5b901
    interface identifier in scoped IPv6 addresses, e.g.
Packit b5b901
    `fe80::abc:def1:2345%en0`.
Packit b5b901
Packit b5b901
    On Windows, the returned interface cannot be used as an interface
Packit b5b901
    identifier, as Windows uses numerical interface identifiers, e.g.
Packit b5b901
    `fe80::abc:def1:2345%5`.
Packit b5b901
Packit b5b901
    To get an interface identifier in a cross-platform compatible way,
Packit b5b901
    use `uv_if_indextoiid()`.
Packit b5b901
Packit b5b901
    Example:
Packit b5b901
Packit b5b901
    ::
Packit b5b901
Packit b5b901
        char ifname[UV_IF_NAMESIZE];
Packit b5b901
        size_t size = sizeof(ifname);
Packit b5b901
        uv_if_indextoname(sin6->sin6_scope_id, ifname, &size);
Packit b5b901
Packit b5b901
    .. versionadded:: 1.16.0
Packit b5b901
Packit b5b901
.. c:function:: int uv_if_indextoiid(unsigned int ifindex, char* buffer, size_t* size)
Packit b5b901
Packit b5b901
    Retrieves a network interface identifier suitable for use in an IPv6 scoped
Packit b5b901
    address. On Windows, returns the numeric `ifindex` as a string. On all other
Packit b5b901
    platforms, `uv_if_indextoname()` is called. The result is written to
Packit b5b901
    `buffer`, with `*size` indicating the length of `buffer`. If `buffer` is not
Packit b5b901
    large enough to hold the result, then `UV_ENOBUFS` is returned, and `*size`
Packit b5b901
    represents the size, including the NUL byte, required to hold the
Packit b5b901
    result.
Packit b5b901
Packit b5b901
    See `uv_if_indextoname` for further details.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.16.0
Packit b5b901
Packit b5b901
.. c:function:: int uv_exepath(char* buffer, size_t* size)
Packit b5b901
Packit b5b901
    Gets the executable path.
Packit b5b901
Packit b5b901
.. c:function:: int uv_cwd(char* buffer, size_t* size)
Packit b5b901
Packit b5b901
    Gets the current working directory, and stores it in `buffer`. If the
Packit b5b901
    current working directory is too large to fit in `buffer`, this function
Packit b5b901
    returns `UV_ENOBUFS`, and sets `size` to the required length, including the
Packit b5b901
    null terminator.
Packit b5b901
Packit b5b901
    .. versionchanged:: 1.1.0
Packit b5b901
Packit b5b901
        On Unix the path no longer ends in a slash.
Packit b5b901
Packit b5b901
    .. versionchanged:: 1.9.0 the returned length includes the terminating null
Packit b5b901
                        byte on `UV_ENOBUFS`, and the buffer is null terminated
Packit b5b901
                        on success.
Packit b5b901
Packit b5b901
Packit b5b901
.. c:function:: int uv_chdir(const char* dir)
Packit b5b901
Packit b5b901
    Changes the current working directory.
Packit b5b901
Packit b5b901
.. c:function:: int uv_os_homedir(char* buffer, size_t* size)
Packit b5b901
Packit b5b901
    Gets the current user's home directory. On Windows, `uv_os_homedir()` first
Packit b5b901
    checks the `USERPROFILE` environment variable using
Packit b5b901
    `GetEnvironmentVariableW()`. If `USERPROFILE` is not set,
Packit b5b901
    `GetUserProfileDirectoryW()` is called. On all other operating systems,
Packit b5b901
    `uv_os_homedir()` first checks the `HOME` environment variable using
Packit b5b901
    :man:`getenv(3)`. If `HOME` is not set, :man:`getpwuid_r(3)` is called. The
Packit b5b901
    user's home directory is stored in `buffer`. When `uv_os_homedir()` is
Packit b5b901
    called, `size` indicates the maximum size of `buffer`. On success `size` is set
Packit b5b901
    to the string length of `buffer`. On `UV_ENOBUFS` failure `size` is set to the
Packit b5b901
    required length for `buffer`, including the null byte.
Packit b5b901
Packit b5b901
    .. warning::
Packit b5b901
        `uv_os_homedir()` is not thread safe.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.6.0
Packit b5b901
Packit b5b901
.. c:function:: int uv_os_tmpdir(char* buffer, size_t* size)
Packit b5b901
Packit b5b901
    Gets the temp directory. On Windows, `uv_os_tmpdir()` uses `GetTempPathW()`.
Packit b5b901
    On all other operating systems, `uv_os_tmpdir()` uses the first environment
Packit b5b901
    variable found in the ordered list `TMPDIR`, `TMP`, `TEMP`, and `TEMPDIR`.
Packit b5b901
    If none of these are found, the path `"/tmp"` is used, or, on Android,
Packit b5b901
    `"/data/local/tmp"` is used. The temp directory is stored in `buffer`. When
Packit b5b901
    `uv_os_tmpdir()` is called, `size` indicates the maximum size of `buffer`.
Packit b5b901
    On success `size` is set to the string length of `buffer` (which does not
Packit b5b901
    include the terminating null). On `UV_ENOBUFS` failure `size` is set to the
Packit b5b901
    required length for `buffer`, including the null byte.
Packit b5b901
Packit b5b901
    .. warning::
Packit b5b901
        `uv_os_tmpdir()` is not thread safe.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.9.0
Packit b5b901
Packit b5b901
.. c:function:: int uv_os_get_passwd(uv_passwd_t* pwd)
Packit b5b901
Packit b5b901
    Gets a subset of the password file entry for the current effective uid (not
Packit b5b901
    the real uid). The populated data includes the username, euid, gid, shell,
Packit b5b901
    and home directory. On non-Windows systems, all data comes from
Packit b5b901
    :man:`getpwuid_r(3)`. On Windows, uid and gid are set to -1 and have no
Packit b5b901
    meaning, and shell is `NULL`. After successfully calling this function, the
Packit b5b901
    memory allocated to `pwd` needs to be freed with
Packit b5b901
    :c:func:`uv_os_free_passwd`.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.9.0
Packit b5b901
Packit b5b901
.. c:function:: void uv_os_free_passwd(uv_passwd_t* pwd)
Packit b5b901
Packit b5b901
    Frees the `pwd` memory previously allocated with :c:func:`uv_os_get_passwd`.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.9.0
Packit b5b901
Packit Service e08953
.. c:function:: uint64_t uv_get_free_memory(void)
Packit Service e08953
Packit Service e08953
    Gets memory information (in bytes).
Packit Service e08953
Packit b5b901
.. c:function:: uint64_t uv_get_total_memory(void)
Packit b5b901
Packit b5b901
    Gets memory information (in bytes).
Packit b5b901
Packit Service e08953
.. c:function:: uint64_t uv_get_constrained_memory(void)
Packit Service e08953
Packit Service e08953
    Gets the amount of memory available to the process (in bytes) based on
Packit Service e08953
    limits imposed by the OS. If there is no such constraint, or the constraint
Packit Service e08953
    is unknown, `0` is returned. Note that it is not unusual for this value to
Packit Service e08953
    be less than or greater than :c:func:`uv_get_total_memory`.
Packit Service e08953
Packit Service e08953
    .. note::
Packit Service e08953
        This function currently only returns a non-zero value on Linux, based
Packit Service e08953
        on cgroups if it is present.
Packit Service e08953
Packit Service e08953
    .. versionadded:: 1.29.0
Packit Service e08953
Packit b5b901
.. c:function:: uint64_t uv_hrtime(void)
Packit b5b901
Packit b5b901
    Returns the current high-resolution real time. This is expressed in
Packit b5b901
    nanoseconds. It is relative to an arbitrary time in the past. It is not
Packit b5b901
    related to the time of day and therefore not subject to clock drift. The
Packit b5b901
    primary use is for measuring performance between intervals.
Packit b5b901
Packit b5b901
    .. note::
Packit b5b901
        Not every platform can support nanosecond resolution; however, this value will always
Packit b5b901
        be in nanoseconds.
Packit b5b901
Packit b5b901
.. c:function:: void uv_print_all_handles(uv_loop_t* loop, FILE* stream)
Packit b5b901
Packit b5b901
    Prints all handles associated with the given `loop` to the given `stream`.
Packit b5b901
Packit b5b901
    Example:
Packit b5b901
Packit b5b901
    ::
Packit b5b901
Packit b5b901
        uv_print_all_handles(uv_default_loop(), stderr);
Packit b5b901
        /*
Packit b5b901
        [--I] signal   0x1a25ea8
Packit b5b901
        [-AI] async    0x1a25cf0
Packit b5b901
        [R--] idle     0x1a7a8c8
Packit b5b901
        */
Packit b5b901
Packit b5b901
    The format is `[flags] handle-type handle-address`. For `flags`:
Packit b5b901
Packit b5b901
    - `R` is printed for a handle that is referenced
Packit b5b901
    - `A` is printed for a handle that is active
Packit b5b901
    - `I` is printed for a handle that is internal
Packit b5b901
Packit b5b901
    .. warning::
Packit b5b901
        This function is meant for ad hoc debugging, there is no API/ABI
Packit b5b901
        stability guarantees.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.8.0
Packit b5b901
Packit b5b901
.. c:function:: void uv_print_active_handles(uv_loop_t* loop, FILE* stream)
Packit b5b901
Packit b5b901
    This is the same as :c:func:`uv_print_all_handles` except only active handles
Packit b5b901
    are printed.
Packit b5b901
Packit b5b901
    .. warning::
Packit b5b901
        This function is meant for ad hoc debugging, there is no API/ABI
Packit b5b901
        stability guarantees.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.8.0
Packit b5b901
Packit Service e08953
.. c:function:: int uv_os_environ(uv_env_item_t** envitems, int* count)
Packit Service e08953
Packit Service e08953
    Retrieves all environment variables. This function will allocate memory
Packit Service e08953
    which must be freed by calling :c:func:`uv_os_free_environ`.
Packit Service e08953
Packit Service e08953
    .. warning::
Packit Service e08953
        This function is not thread safe.
Packit Service e08953
Packit Service e08953
    .. versionadded:: 1.31.0
Packit Service e08953
Packit Service e08953
.. c:function:: void uv_os_free_environ(uv_env_item_t* envitems, int count);
Packit Service e08953
Packit Service e08953
    Frees the memory allocated for the environment variables by
Packit Service e08953
    :c:func:`uv_os_environ`.
Packit Service e08953
Packit Service e08953
    .. versionadded:: 1.31.0
Packit Service e08953
Packit b5b901
.. c:function:: int uv_os_getenv(const char* name, char* buffer, size_t* size)
Packit b5b901
Packit b5b901
    Retrieves the environment variable specified by `name`, copies its value
Packit b5b901
    into `buffer`, and sets `size` to the string length of the value. When
Packit b5b901
    calling this function, `size` must be set to the amount of storage available
Packit b5b901
    in `buffer`, including the null terminator. If the environment variable
Packit b5b901
    exceeds the storage available in `buffer`, `UV_ENOBUFS` is returned, and
Packit b5b901
    `size` is set to the amount of storage required to hold the value. If no
Packit b5b901
    matching environment variable exists, `UV_ENOENT` is returned.
Packit b5b901
Packit b5b901
    .. warning::
Packit b5b901
        This function is not thread safe.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.12.0
Packit b5b901
Packit b5b901
.. c:function:: int uv_os_setenv(const char* name, const char* value)
Packit b5b901
Packit b5b901
    Creates or updates the environment variable specified by `name` with
Packit b5b901
    `value`.
Packit b5b901
Packit b5b901
    .. warning::
Packit b5b901
        This function is not thread safe.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.12.0
Packit b5b901
Packit b5b901
.. c:function:: int uv_os_unsetenv(const char* name)
Packit b5b901
Packit b5b901
    Deletes the environment variable specified by `name`. If no such environment
Packit b5b901
    variable exists, this function returns successfully.
Packit b5b901
Packit b5b901
    .. warning::
Packit b5b901
        This function is not thread safe.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.12.0
Packit b5b901
Packit b5b901
.. c:function:: int uv_os_gethostname(char* buffer, size_t* size)
Packit b5b901
Packit b5b901
    Returns the hostname as a null-terminated string in `buffer`, and sets
Packit b5b901
    `size` to the string length of the hostname. When calling this function,
Packit b5b901
    `size` must be set to the amount of storage available in `buffer`, including
Packit b5b901
    the null terminator. If the hostname exceeds the storage available in
Packit b5b901
    `buffer`, `UV_ENOBUFS` is returned, and `size` is set to the amount of
Packit b5b901
    storage required to hold the value.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.12.0
Packit b5b901
Packit Service e08953
    .. versionchanged:: 1.26.0 `UV_MAXHOSTNAMESIZE` is available and represents
Packit Service e08953
                               the maximum `buffer` size required to store a
Packit Service e08953
                               hostname and terminating `nul` character.
Packit Service e08953
Packit b5b901
.. c:function:: int uv_os_getpriority(uv_pid_t pid, int* priority)
Packit b5b901
Packit b5b901
    Retrieves the scheduling priority of the process specified by `pid`. The
Packit b5b901
    returned value of `priority` is between -20 (high priority) and 19 (low
Packit b5b901
    priority).
Packit b5b901
Packit b5b901
    .. note::
Packit b5b901
        On Windows, the returned priority will equal one of the `UV_PRIORITY`
Packit b5b901
        constants.
Packit b5b901
Packit b5b901
    .. versionadded:: 1.23.0
Packit b5b901
Packit b5b901
.. c:function:: int uv_os_setpriority(uv_pid_t pid, int priority)
Packit b5b901
Packit b5b901
    Sets the scheduling priority of the process specified by `pid`. The
Packit b5b901
    `priority` value range is between -20 (high priority) and 19 (low priority).
Packit b5b901
    The constants `UV_PRIORITY_LOW`, `UV_PRIORITY_BELOW_NORMAL`,
Packit b5b901
    `UV_PRIORITY_NORMAL`, `UV_PRIORITY_ABOVE_NORMAL`, `UV_PRIORITY_HIGH`, and
Packit b5b901
    `UV_PRIORITY_HIGHEST` are also provided for convenience.
Packit b5b901
Packit b5b901
    .. note::
Packit b5b901
        On Windows, this function utilizes `SetPriorityClass()`. The `priority`
Packit b5b901
        argument is mapped to a Windows priority class. When retrieving the
Packit b5b901
        process priority, the result will equal one of the `UV_PRIORITY`
Packit b5b901
        constants, and not necessarily the exact value of `priority`.
Packit b5b901
Packit b5b901
    .. note::
Packit b5b901
        On Windows, setting `PRIORITY_HIGHEST` will only work for elevated user,
Packit b5b901
        for others it will be silently reduced to `PRIORITY_HIGH`.
Packit b5b901
Packit Service e08953
    .. note::
Packit Service e08953
        On IBM i PASE, the highest process priority is -10. The constant
Packit Service e08953
        `UV_PRIORITY_HIGHEST` is -10, `UV_PRIORITY_HIGH` is -7, 
Packit Service e08953
        `UV_PRIORITY_ABOVE_NORMAL` is -4, `UV_PRIORITY_NORMAL` is 0,
Packit Service e08953
        `UV_PRIORITY_BELOW_NORMAL` is 15 and `UV_PRIORITY_LOW` is 39.
Packit Service e08953
Packit Service e08953
    .. note::
Packit Service e08953
        On IBM i PASE, you are not allowed to change your priority unless you
Packit Service e08953
        have the \*JOBCTL special authority (even to lower it).
Packit Service e08953
Packit b5b901
    .. versionadded:: 1.23.0
Packit Service e08953
Packit Service e08953
.. c:function:: int uv_os_uname(uv_utsname_t* buffer)
Packit Service e08953
Packit Service e08953
    Retrieves system information in `buffer`. The populated data includes the
Packit Service e08953
    operating system name, release, version, and machine. On non-Windows
Packit Service e08953
    systems, `uv_os_uname()` is a thin wrapper around :man:`uname(2)`. Returns
Packit Service e08953
    zero on success, and a non-zero error value otherwise.
Packit Service e08953
Packit Service e08953
    .. versionadded:: 1.25.0
Packit Service e08953
Packit Service e08953
.. c:function:: int uv_gettimeofday(uv_timeval64_t* tv)
Packit Service e08953
Packit Service e08953
    Cross-platform implementation of :man:`gettimeofday(2)`. The timezone
Packit Service e08953
    argument to `gettimeofday()` is not supported, as it is considered obsolete.
Packit Service e08953
Packit Service e08953
    .. versionadded:: 1.28.0
Packit Service e08953
Packit Service e08953
.. c:function:: int uv_random(uv_loop_t* loop, uv_random_t* req, void* buf, size_t buflen, unsigned int flags, uv_random_cb cb)
Packit Service e08953
Packit Service e08953
    Fill `buf` with exactly `buflen` cryptographically strong random bytes
Packit Service e08953
    acquired from the system CSPRNG. `flags` is reserved for future extension
Packit Service e08953
    and must currently be 0.
Packit Service e08953
Packit Service e08953
    Short reads are not possible. When less than `buflen` random bytes are
Packit Service e08953
    available, a non-zero error value is returned or passed to the callback.
Packit Service e08953
Packit Service e08953
    The synchronous version may block indefinitely when not enough entropy
Packit Service e08953
    is available. The asynchronous version may not ever finish when the system
Packit Service e08953
    is low on entropy.
Packit Service e08953
Packit Service e08953
    Sources of entropy:
Packit Service e08953
Packit Service e08953
    - Windows: `RtlGenRandom <https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/nf-ntsecapi-rtlgenrandom>_`.
Packit Service e08953
    - Linux, Android: :man:`getrandom(2)` if available, or :man:`urandom(4)`
Packit Service e08953
      after reading from `/dev/random` once, or the `KERN_RANDOM`
Packit Service e08953
      :man:`sysctl(2)`.
Packit Service e08953
    - FreeBSD: `getrandom(2) <https://www.freebsd.org/cgi/man.cgi?query=getrandom&sektion=2>_`,
Packit Service e08953
      or `/dev/urandom` after reading from `/dev/random` once.
Packit Service e08953
    - NetBSD: `KERN_ARND` `sysctl(3) <https://netbsd.gw.com/cgi-bin/man-cgi?sysctl+3+NetBSD-current>_`
Packit Service e08953
    - macOS, OpenBSD: `getentropy(2) <https://man.openbsd.org/getentropy.2>_`
Packit Service e08953
      if available, or `/dev/urandom` after reading from `/dev/random` once.
Packit Service e08953
    - AIX: `/dev/random`.
Packit Service e08953
    - IBM i: `/dev/urandom`.
Packit Service e08953
    - Other UNIX: `/dev/urandom` after reading from `/dev/random` once.
Packit Service e08953
Packit Service e08953
    :returns: 0 on success, or an error code < 0 on failure. The contents of
Packit Service e08953
        `buf` is undefined after an error.
Packit Service e08953
Packit Service e08953
    .. note::
Packit Service e08953
        When using the synchronous version, both `loop` and `req` parameters
Packit Service e08953
        are not used and can be set to `NULL`.
Packit Service e08953
Packit Service e08953
    .. versionadded:: 1.33.0
Packit Service e08953
Packit Service e08953
.. c:function:: void uv_sleep(unsigned int msec)
Packit Service e08953
Packit Service e08953
    Causes the calling thread to sleep for `msec` milliseconds.
Packit Service e08953
Packit Service e08953
    .. versionadded:: 1.34.0