Blame docs/src/misc.rst

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