diff options
Diffstat (limited to 'venv/lib/python3.11/site-packages/uvloop/includes')
9 files changed, 882 insertions, 0 deletions
diff --git a/venv/lib/python3.11/site-packages/uvloop/includes/__init__.py b/venv/lib/python3.11/site-packages/uvloop/includes/__init__.py new file mode 100644 index 0000000..2ccf9ca --- /dev/null +++ b/venv/lib/python3.11/site-packages/uvloop/includes/__init__.py @@ -0,0 +1,23 @@ +# flake8: noqa + +# These have to be synced with the stdlib.pxi +import asyncio +import collections +import concurrent.futures +import errno +import functools +import gc +import inspect +import itertools +import os +import signal +import socket +import subprocess +import ssl +import stat +import sys +import threading +import traceback +import time +import warnings +import weakref diff --git a/venv/lib/python3.11/site-packages/uvloop/includes/__pycache__/__init__.cpython-311.pyc b/venv/lib/python3.11/site-packages/uvloop/includes/__pycache__/__init__.cpython-311.pyc Binary files differnew file mode 100644 index 0000000..a4464aa --- /dev/null +++ b/venv/lib/python3.11/site-packages/uvloop/includes/__pycache__/__init__.cpython-311.pyc diff --git a/venv/lib/python3.11/site-packages/uvloop/includes/consts.pxi b/venv/lib/python3.11/site-packages/uvloop/includes/consts.pxi new file mode 100644 index 0000000..f765053 --- /dev/null +++ b/venv/lib/python3.11/site-packages/uvloop/includes/consts.pxi @@ -0,0 +1,25 @@ +DEF UV_STREAM_RECV_BUF_SIZE = 256000 # 250kb + +DEF FLOW_CONTROL_HIGH_WATER = 64 # KiB +DEF FLOW_CONTROL_HIGH_WATER_SSL_READ = 256 # KiB +DEF FLOW_CONTROL_HIGH_WATER_SSL_WRITE = 512 # KiB + +DEF DEFAULT_FREELIST_SIZE = 250 +DEF DNS_PYADDR_TO_SOCKADDR_CACHE_SIZE = 2048 + +DEF DEBUG_STACK_DEPTH = 10 + + +DEF __PROCESS_DEBUG_SLEEP_AFTER_FORK = 1 + + +DEF LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5 + + +# Number of seconds to wait for SSL handshake to complete +# The default timeout matches that of Nginx. +DEF SSL_HANDSHAKE_TIMEOUT = 60.0 +# Number of seconds to wait for SSL shutdown to complete +# The default timeout mimics lingering_time +DEF SSL_SHUTDOWN_TIMEOUT = 30.0 +DEF SSL_READ_MAX_SIZE = 256 * 1024 diff --git a/venv/lib/python3.11/site-packages/uvloop/includes/debug.pxd b/venv/lib/python3.11/site-packages/uvloop/includes/debug.pxd new file mode 100644 index 0000000..a825def --- /dev/null +++ b/venv/lib/python3.11/site-packages/uvloop/includes/debug.pxd @@ -0,0 +1,3 @@ +cdef extern from "includes/debug.h": + + cdef int UVLOOP_DEBUG diff --git a/venv/lib/python3.11/site-packages/uvloop/includes/flowcontrol.pxd b/venv/lib/python3.11/site-packages/uvloop/includes/flowcontrol.pxd new file mode 100644 index 0000000..f22f1a7 --- /dev/null +++ b/venv/lib/python3.11/site-packages/uvloop/includes/flowcontrol.pxd @@ -0,0 +1,23 @@ +# flake8: noqa + + +cdef inline add_flowcontrol_defaults(high, low, int kb): + cdef int h, l + if high is None: + if low is None: + h = kb * 1024 + else: + l = low + h = 4 * l + else: + h = high + if low is None: + l = h // 4 + else: + l = low + + if not h >= l >= 0: + raise ValueError('high (%r) must be >= low (%r) must be >= 0' % + (h, l)) + + return h, l diff --git a/venv/lib/python3.11/site-packages/uvloop/includes/python.pxd b/venv/lib/python3.11/site-packages/uvloop/includes/python.pxd new file mode 100644 index 0000000..454d5c7 --- /dev/null +++ b/venv/lib/python3.11/site-packages/uvloop/includes/python.pxd @@ -0,0 +1,31 @@ +cdef extern from "Python.h": + int PY_VERSION_HEX + + unicode PyUnicode_FromString(const char *) + + void* PyMem_RawMalloc(size_t n) nogil + void* PyMem_RawRealloc(void *p, size_t n) nogil + void* PyMem_RawCalloc(size_t nelem, size_t elsize) nogil + void PyMem_RawFree(void *p) nogil + + object PyUnicode_EncodeFSDefault(object) + void PyErr_SetInterrupt() nogil + + void _Py_RestoreSignals() + + object PyMemoryView_FromMemory(char *mem, ssize_t size, int flags) + object PyMemoryView_FromObject(object obj) + int PyMemoryView_Check(object obj) + + cdef enum: + PyBUF_WRITE + + +cdef extern from "includes/compat.h": + object Context_CopyCurrent() + int Context_Enter(object) except -1 + int Context_Exit(object) except -1 + + void PyOS_BeforeFork() + void PyOS_AfterFork_Parent() + void PyOS_AfterFork_Child() diff --git a/venv/lib/python3.11/site-packages/uvloop/includes/stdlib.pxi b/venv/lib/python3.11/site-packages/uvloop/includes/stdlib.pxi new file mode 100644 index 0000000..e7957fe --- /dev/null +++ b/venv/lib/python3.11/site-packages/uvloop/includes/stdlib.pxi @@ -0,0 +1,175 @@ +# flake8: noqa + + +import asyncio, asyncio.log, asyncio.base_events, \ + asyncio.sslproto, asyncio.coroutines, \ + asyncio.futures, asyncio.transports +import collections.abc +import concurrent.futures +import errno +import functools +import gc +import inspect +import itertools +import os +import signal +import socket +import subprocess +import ssl +import stat +import sys +import threading +import traceback +import time +import warnings +import weakref + + +cdef aio_get_event_loop = asyncio.get_event_loop +cdef aio_CancelledError = asyncio.CancelledError +cdef aio_InvalidStateError = asyncio.InvalidStateError +cdef aio_TimeoutError = asyncio.TimeoutError +cdef aio_Future = asyncio.Future +cdef aio_Task = asyncio.Task +cdef aio_ensure_future = asyncio.ensure_future +cdef aio_gather = asyncio.gather +cdef aio_wait = asyncio.wait +cdef aio_wrap_future = asyncio.wrap_future +cdef aio_logger = asyncio.log.logger +cdef aio_iscoroutine = asyncio.iscoroutine +cdef aio_iscoroutinefunction = asyncio.iscoroutinefunction +cdef aio_BaseProtocol = asyncio.BaseProtocol +cdef aio_Protocol = asyncio.Protocol +cdef aio_isfuture = getattr(asyncio, 'isfuture', None) +cdef aio_get_running_loop = getattr(asyncio, '_get_running_loop', None) +cdef aio_set_running_loop = getattr(asyncio, '_set_running_loop', None) +cdef aio_debug_wrapper = getattr(asyncio.coroutines, 'debug_wrapper', None) +cdef aio_AbstractChildWatcher = asyncio.AbstractChildWatcher +cdef aio_Transport = asyncio.Transport +cdef aio_FlowControlMixin = asyncio.transports._FlowControlMixin + +cdef col_deque = collections.deque +cdef col_Iterable = collections.abc.Iterable +cdef col_Counter = collections.Counter +cdef col_OrderedDict = collections.OrderedDict + +cdef cc_ThreadPoolExecutor = concurrent.futures.ThreadPoolExecutor +cdef cc_Future = concurrent.futures.Future + +cdef errno_EBADF = errno.EBADF +cdef errno_EINVAL = errno.EINVAL + +cdef ft_partial = functools.partial + +cdef gc_disable = gc.disable + +cdef iter_chain = itertools.chain +cdef inspect_isgenerator = inspect.isgenerator + +cdef int has_IPV6_V6ONLY = hasattr(socket, 'IPV6_V6ONLY') +cdef int IPV6_V6ONLY = getattr(socket, 'IPV6_V6ONLY', -1) +cdef int has_SO_REUSEPORT = hasattr(socket, 'SO_REUSEPORT') +cdef int SO_REUSEPORT = getattr(socket, 'SO_REUSEPORT', 0) +cdef int SO_BROADCAST = getattr(socket, 'SO_BROADCAST') +cdef int SOCK_NONBLOCK = getattr(socket, 'SOCK_NONBLOCK', -1) +cdef int socket_AI_CANONNAME = getattr(socket, 'AI_CANONNAME') + +cdef socket_gaierror = socket.gaierror +cdef socket_error = socket.error +cdef socket_timeout = socket.timeout +cdef socket_socket = socket.socket +cdef socket_socketpair = socket.socketpair +cdef socket_getservbyname = socket.getservbyname +cdef socket_AddressFamily = socket.AddressFamily +cdef socket_SocketKind = socket.SocketKind + +cdef int socket_EAI_ADDRFAMILY = getattr(socket, 'EAI_ADDRFAMILY', -1) +cdef int socket_EAI_AGAIN = getattr(socket, 'EAI_AGAIN', -1) +cdef int socket_EAI_BADFLAGS = getattr(socket, 'EAI_BADFLAGS', -1) +cdef int socket_EAI_BADHINTS = getattr(socket, 'EAI_BADHINTS', -1) +cdef int socket_EAI_CANCELED = getattr(socket, 'EAI_CANCELED', -1) +cdef int socket_EAI_FAIL = getattr(socket, 'EAI_FAIL', -1) +cdef int socket_EAI_FAMILY = getattr(socket, 'EAI_FAMILY', -1) +cdef int socket_EAI_MEMORY = getattr(socket, 'EAI_MEMORY', -1) +cdef int socket_EAI_NODATA = getattr(socket, 'EAI_NODATA', -1) +cdef int socket_EAI_NONAME = getattr(socket, 'EAI_NONAME', -1) +cdef int socket_EAI_OVERFLOW = getattr(socket, 'EAI_OVERFLOW', -1) +cdef int socket_EAI_PROTOCOL = getattr(socket, 'EAI_PROTOCOL', -1) +cdef int socket_EAI_SERVICE = getattr(socket, 'EAI_SERVICE', -1) +cdef int socket_EAI_SOCKTYPE = getattr(socket, 'EAI_SOCKTYPE', -1) + + +cdef str os_name = os.name +cdef os_environ = os.environ +cdef os_dup = os.dup +cdef os_set_inheritable = os.set_inheritable +cdef os_get_inheritable = os.get_inheritable +cdef os_close = os.close +cdef os_open = os.open +cdef os_devnull = os.devnull +cdef os_O_RDWR = os.O_RDWR +cdef os_pipe = os.pipe +cdef os_read = os.read +cdef os_remove = os.remove +cdef os_stat = os.stat +cdef os_fspath = os.fspath + +cdef stat_S_ISSOCK = stat.S_ISSOCK + +cdef sys_ignore_environment = sys.flags.ignore_environment +cdef sys_dev_mode = sys.flags.dev_mode +cdef sys_exc_info = sys.exc_info +cdef sys_set_coroutine_wrapper = getattr(sys, 'set_coroutine_wrapper', None) +cdef sys_get_coroutine_wrapper = getattr(sys, 'get_coroutine_wrapper', None) +cdef sys_getframe = sys._getframe +cdef sys_version_info = sys.version_info +cdef sys_getfilesystemencoding = sys.getfilesystemencoding +cdef str sys_platform = sys.platform + +cdef ssl_SSLContext = ssl.SSLContext +cdef ssl_MemoryBIO = ssl.MemoryBIO +cdef ssl_create_default_context = ssl.create_default_context +cdef ssl_SSLError = ssl.SSLError +cdef ssl_SSLAgainErrors = (ssl.SSLWantReadError, ssl.SSLSyscallError) +cdef ssl_SSLZeroReturnError = ssl.SSLZeroReturnError +cdef ssl_CertificateError = ssl.CertificateError +cdef int ssl_SSL_ERROR_WANT_READ = ssl.SSL_ERROR_WANT_READ +cdef int ssl_SSL_ERROR_WANT_WRITE = ssl.SSL_ERROR_WANT_WRITE +cdef int ssl_SSL_ERROR_SYSCALL = ssl.SSL_ERROR_SYSCALL + +cdef threading_Thread = threading.Thread +cdef threading_main_thread = threading.main_thread + +cdef int subprocess_PIPE = subprocess.PIPE +cdef int subprocess_STDOUT = subprocess.STDOUT +cdef int subprocess_DEVNULL = subprocess.DEVNULL +cdef subprocess_SubprocessError = subprocess.SubprocessError + +cdef int signal_NSIG = signal.NSIG +cdef signal_signal = signal.signal +cdef signal_siginterrupt = signal.siginterrupt +cdef signal_set_wakeup_fd = signal.set_wakeup_fd +cdef signal_default_int_handler = signal.default_int_handler +cdef signal_SIG_DFL = signal.SIG_DFL + +cdef time_sleep = time.sleep +cdef time_monotonic = time.monotonic + +cdef tb_StackSummary = traceback.StackSummary +cdef tb_walk_stack = traceback.walk_stack +cdef tb_format_list = traceback.format_list + +cdef warnings_warn = warnings.warn + +cdef weakref_WeakValueDictionary = weakref.WeakValueDictionary +cdef weakref_WeakSet = weakref.WeakSet + +cdef py_inf = float('inf') + + +# Cython doesn't clean-up imported objects properly in Py3 mode, +# so we delete refs to all modules manually (except sys) +del asyncio, concurrent, collections, errno +del functools, inspect, itertools, socket, os, threading +del signal, subprocess, ssl +del time, traceback, warnings, weakref diff --git a/venv/lib/python3.11/site-packages/uvloop/includes/system.pxd b/venv/lib/python3.11/site-packages/uvloop/includes/system.pxd new file mode 100644 index 0000000..367fedd --- /dev/null +++ b/venv/lib/python3.11/site-packages/uvloop/includes/system.pxd @@ -0,0 +1,96 @@ +from libc.stdint cimport int8_t, uint64_t + +cdef extern from "arpa/inet.h" nogil: + + int ntohl(int) + int htonl(int) + int ntohs(int) + + +cdef extern from "sys/socket.h" nogil: + + struct sockaddr: + unsigned short sa_family + char sa_data[14] + + struct addrinfo: + int ai_flags + int ai_family + int ai_socktype + int ai_protocol + size_t ai_addrlen + sockaddr* ai_addr + char* ai_canonname + addrinfo* ai_next + + struct sockaddr_in: + unsigned short sin_family + unsigned short sin_port + # ... + + struct sockaddr_in6: + unsigned short sin6_family + unsigned short sin6_port + unsigned long sin6_flowinfo + # ... + unsigned long sin6_scope_id + + struct sockaddr_storage: + unsigned short ss_family + # ... + + const char *gai_strerror(int errcode) + + int socketpair(int domain, int type, int protocol, int socket_vector[2]) + + int setsockopt(int socket, int level, int option_name, + const void *option_value, int option_len) + + +cdef extern from "sys/un.h" nogil: + + struct sockaddr_un: + unsigned short sun_family + char* sun_path + # ... + + +cdef extern from "unistd.h" nogil: + + ssize_t write(int fd, const void *buf, size_t count) + void _exit(int status) + + +cdef extern from "pthread.h": + + int pthread_atfork( + void (*prepare)(), + void (*parent)(), + void (*child)()) + + +cdef extern from "includes/compat.h" nogil: + + cdef int EWOULDBLOCK + + cdef int PLATFORM_IS_APPLE + cdef int PLATFORM_IS_LINUX + + struct epoll_event: + # We don't use the fields + pass + + int EPOLL_CTL_DEL + int epoll_ctl(int epfd, int op, int fd, epoll_event *event) + object MakeUnixSockPyAddr(sockaddr_un *addr) + + +cdef extern from "includes/fork_handler.h": + + uint64_t MAIN_THREAD_ID + int8_t MAIN_THREAD_ID_SET + ctypedef void (*OnForkHandler)() + void handleAtFork() + void setForkHandler(OnForkHandler handler) + void resetForkHandler() + void setMainThreadID(uint64_t id) diff --git a/venv/lib/python3.11/site-packages/uvloop/includes/uv.pxd b/venv/lib/python3.11/site-packages/uvloop/includes/uv.pxd new file mode 100644 index 0000000..8765130 --- /dev/null +++ b/venv/lib/python3.11/site-packages/uvloop/includes/uv.pxd @@ -0,0 +1,506 @@ +from libc.stdint cimport uint16_t, uint32_t, uint64_t, int64_t +from posix.types cimport gid_t, uid_t +from posix.unistd cimport getuid + +from . cimport system + +# This is an internal enum UV_HANDLE_READABLE from uv-common.h, used only by +# handles/pipe.pyx to temporarily workaround a libuv issue libuv/libuv#2058, +# before there is a proper fix in libuv. In short, libuv disallowed feeding a +# write-only pipe to uv_read_start(), which was needed by uvloop to detect a +# broken pipe without having to send anything on the write-only end. We're +# setting UV_HANDLE_READABLE on pipe_t to workaround this limitation +# temporarily, please see also #317. +cdef enum: + UV_INTERNAL_HANDLE_READABLE = 0x00004000 + +cdef extern from "uv.h" nogil: + cdef int UV_TCP_IPV6ONLY + + cdef int UV_EACCES + cdef int UV_EAGAIN + cdef int UV_EALREADY + cdef int UV_EBUSY + cdef int UV_ECONNABORTED + cdef int UV_ECONNREFUSED + cdef int UV_ECONNRESET + cdef int UV_ECANCELED + cdef int UV_EEXIST + cdef int UV_EINTR + cdef int UV_EINVAL + cdef int UV_EISDIR + cdef int UV_ENOENT + cdef int UV_EOF + cdef int UV_EPERM + cdef int UV_EPIPE + cdef int UV_ESHUTDOWN + cdef int UV_ESRCH + cdef int UV_ETIMEDOUT + cdef int UV_EBADF + cdef int UV_ENOBUFS + + cdef int UV_EAI_ADDRFAMILY + cdef int UV_EAI_AGAIN + cdef int UV_EAI_BADFLAGS + cdef int UV_EAI_BADHINTS + cdef int UV_EAI_CANCELED + cdef int UV_EAI_FAIL + cdef int UV_EAI_FAMILY + cdef int UV_EAI_MEMORY + cdef int UV_EAI_NODATA + cdef int UV_EAI_NONAME + cdef int UV_EAI_OVERFLOW + cdef int UV_EAI_PROTOCOL + cdef int UV_EAI_SERVICE + cdef int UV_EAI_SOCKTYPE + + cdef int SOL_SOCKET + cdef int SO_ERROR + cdef int SO_REUSEADDR + cdef int SO_REUSEPORT + cdef int AF_INET + cdef int AF_INET6 + cdef int AF_UNIX + cdef int AF_UNSPEC + cdef int AI_PASSIVE + cdef int AI_NUMERICHOST + cdef int INET6_ADDRSTRLEN + cdef int IPPROTO_IPV6 + cdef int SOCK_STREAM + cdef int SOCK_DGRAM + cdef int IPPROTO_TCP + cdef int IPPROTO_UDP + + cdef int SIGINT + cdef int SIGHUP + cdef int SIGCHLD + cdef int SIGKILL + cdef int SIGTERM + + ctypedef int uv_os_sock_t + ctypedef int uv_file + ctypedef int uv_os_fd_t + + ctypedef struct uv_buf_t: + char* base + size_t len + + ctypedef struct uv_loop_t: + void* data + # ... + + ctypedef struct uv_handle_t: + void* data + uv_loop_t* loop + unsigned int flags + # ... + + ctypedef struct uv_idle_t: + void* data + uv_loop_t* loop + # ... + + ctypedef struct uv_check_t: + void* data + uv_loop_t* loop + # ... + + ctypedef struct uv_signal_t: + void* data + uv_loop_t* loop + # ... + + ctypedef struct uv_async_t: + void* data + uv_loop_t* loop + # ... + + ctypedef struct uv_timer_t: + void* data + uv_loop_t* loop + # ... + + ctypedef struct uv_stream_t: + void* data + size_t write_queue_size + uv_loop_t* loop + # ... + + ctypedef struct uv_tcp_t: + void* data + uv_loop_t* loop + # ... + + ctypedef struct uv_pipe_t: + void* data + uv_loop_t* loop + # ... + + ctypedef struct uv_udp_t: + void* data + uv_loop_t* loop + size_t send_queue_size + size_t send_queue_count + # ... + + ctypedef struct uv_udp_send_t: + void* data + uv_udp_t* handle + + ctypedef struct uv_poll_t: + void* data + uv_loop_t* loop + # ... + + ctypedef struct uv_req_t: + # Only cancellation of uv_fs_t, uv_getaddrinfo_t, + # uv_getnameinfo_t and uv_work_t requests is + # currently supported. + void* data + uv_req_type type + # ... + + ctypedef struct uv_connect_t: + void* data + + ctypedef struct uv_getaddrinfo_t: + void* data + # ... + + ctypedef struct uv_getnameinfo_t: + void* data + # ... + + ctypedef struct uv_write_t: + void* data + # ... + + ctypedef struct uv_shutdown_t: + void* data + # ... + + ctypedef struct uv_process_t: + void* data + int pid + # ... + + ctypedef struct uv_fs_event_t: + void* data + # ... + + ctypedef enum uv_req_type: + UV_UNKNOWN_REQ = 0, + UV_REQ, + UV_CONNECT, + UV_WRITE, + UV_SHUTDOWN, + UV_UDP_SEND, + UV_FS, + UV_WORK, + UV_GETADDRINFO, + UV_GETNAMEINFO, + UV_REQ_TYPE_PRIVATE, + UV_REQ_TYPE_MAX + + ctypedef enum uv_run_mode: + UV_RUN_DEFAULT = 0, + UV_RUN_ONCE, + UV_RUN_NOWAIT + + ctypedef enum uv_poll_event: + UV_READABLE = 1, + UV_WRITABLE = 2, + UV_DISCONNECT = 4 + + ctypedef enum uv_udp_flags: + UV_UDP_IPV6ONLY = 1, + UV_UDP_PARTIAL = 2 + + ctypedef enum uv_membership: + UV_LEAVE_GROUP = 0, + UV_JOIN_GROUP + + cpdef enum uv_fs_event: + UV_RENAME = 1, + UV_CHANGE = 2 + + const char* uv_strerror(int err) + const char* uv_err_name(int err) + + ctypedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg) with gil + + ctypedef void (*uv_close_cb)(uv_handle_t* handle) with gil + ctypedef void (*uv_idle_cb)(uv_idle_t* handle) with gil + ctypedef void (*uv_check_cb)(uv_check_t* handle) with gil + ctypedef void (*uv_signal_cb)(uv_signal_t* handle, int signum) with gil + ctypedef void (*uv_async_cb)(uv_async_t* handle) with gil + ctypedef void (*uv_timer_cb)(uv_timer_t* handle) with gil + ctypedef void (*uv_connection_cb)(uv_stream_t* server, int status) with gil + ctypedef void (*uv_alloc_cb)(uv_handle_t* handle, + size_t suggested_size, + uv_buf_t* buf) with gil + ctypedef void (*uv_read_cb)(uv_stream_t* stream, + ssize_t nread, + const uv_buf_t* buf) with gil + ctypedef void (*uv_write_cb)(uv_write_t* req, int status) with gil + ctypedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, + int status, + system.addrinfo* res) with gil + ctypedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, + int status, + const char* hostname, + const char* service) with gil + ctypedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status) with gil + ctypedef void (*uv_poll_cb)(uv_poll_t* handle, + int status, int events) with gil + + ctypedef void (*uv_connect_cb)(uv_connect_t* req, int status) with gil + + ctypedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status) with gil + ctypedef void (*uv_udp_recv_cb)(uv_udp_t* handle, + ssize_t nread, + const uv_buf_t* buf, + const system.sockaddr* addr, + unsigned flags) with gil + ctypedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, + const char *filename, + int events, + int status) with gil + + # Generic request functions + int uv_cancel(uv_req_t* req) + + # Generic handler functions + int uv_is_active(const uv_handle_t* handle) + void uv_close(uv_handle_t* handle, uv_close_cb close_cb) + int uv_is_closing(const uv_handle_t* handle) + int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd) + void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) + + # Loop functions + int uv_loop_init(uv_loop_t* loop) + int uv_loop_close(uv_loop_t* loop) + int uv_loop_alive(uv_loop_t* loop) + int uv_loop_fork(uv_loop_t* loop) + int uv_backend_fd(uv_loop_t* loop) + + void uv_update_time(uv_loop_t* loop) + uint64_t uv_now(const uv_loop_t*) + + int uv_run(uv_loop_t*, uv_run_mode mode) nogil + void uv_stop(uv_loop_t*) + + # Idle handler + int uv_idle_init(uv_loop_t*, uv_idle_t* idle) + int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb) + int uv_idle_stop(uv_idle_t* idle) + + # Check handler + int uv_check_init(uv_loop_t*, uv_check_t* idle) + int uv_check_start(uv_check_t* check, uv_check_cb cb) + int uv_check_stop(uv_check_t* check) + + # Signal handler + int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle) + int uv_signal_start(uv_signal_t* handle, + uv_signal_cb signal_cb, + int signum) + int uv_signal_stop(uv_signal_t* handle) + + # Async handler + int uv_async_init(uv_loop_t*, + uv_async_t* async_, + uv_async_cb async_cb) + int uv_async_send(uv_async_t* async_) + + # Timer handler + int uv_timer_init(uv_loop_t*, uv_timer_t* handle) + int uv_timer_start(uv_timer_t* handle, + uv_timer_cb cb, + uint64_t timeout, + uint64_t repeat) + int uv_timer_stop(uv_timer_t* handle) + + # DNS + int uv_getaddrinfo(uv_loop_t* loop, + uv_getaddrinfo_t* req, + uv_getaddrinfo_cb getaddrinfo_cb, + const char* node, + const char* service, + const system.addrinfo* hints) + + void uv_freeaddrinfo(system.addrinfo* ai) + + int uv_getnameinfo(uv_loop_t* loop, + uv_getnameinfo_t* req, + uv_getnameinfo_cb getnameinfo_cb, + const system.sockaddr* addr, + int flags) + + int uv_ip4_name(const system.sockaddr_in* src, char* dst, size_t size) + int uv_ip6_name(const system.sockaddr_in6* src, char* dst, size_t size) + + # Streams + + int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) + int uv_accept(uv_stream_t* server, uv_stream_t* client) + int uv_read_start(uv_stream_t* stream, + uv_alloc_cb alloc_cb, + uv_read_cb read_cb) + int uv_read_stop(uv_stream_t*) + int uv_write(uv_write_t* req, uv_stream_t* handle, + uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb) + + int uv_try_write(uv_stream_t* handle, uv_buf_t bufs[], unsigned int nbufs) + + int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb) + + int uv_is_readable(const uv_stream_t* handle) + int uv_is_writable(const uv_stream_t* handle) + + # TCP + + int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags) + int uv_tcp_nodelay(uv_tcp_t* handle, int enable) + int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) + int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) + int uv_tcp_bind(uv_tcp_t* handle, system.sockaddr* addr, + unsigned int flags) + + int uv_tcp_getsockname(const uv_tcp_t* handle, system.sockaddr* name, + int* namelen) + int uv_tcp_getpeername(const uv_tcp_t* handle, system.sockaddr* name, + int* namelen) + + int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle, + const system.sockaddr* addr, uv_connect_cb cb) + + # Pipes + + int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) + int uv_pipe_open(uv_pipe_t* handle, uv_file file) + int uv_pipe_bind(uv_pipe_t* handle, const char* name) + + void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, + const char* name, uv_connect_cb cb) + + # UDP + + int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) + int uv_udp_connect(uv_udp_t* handle, const system.sockaddr* addr) + int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) + int uv_udp_bind(uv_udp_t* handle, const system.sockaddr* addr, + unsigned int flags) + int uv_udp_send(uv_udp_send_t* req, uv_udp_t* handle, + const uv_buf_t bufs[], unsigned int nbufs, + const system.sockaddr* addr, uv_udp_send_cb send_cb) + int uv_udp_try_send(uv_udp_t* handle, + const uv_buf_t bufs[], unsigned int nbufs, + const system.sockaddr* addr) + int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, + uv_udp_recv_cb recv_cb) + int uv_udp_recv_stop(uv_udp_t* handle) + int uv_udp_set_broadcast(uv_udp_t* handle, int on) + + # Polling + + int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) + int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, + uv_os_sock_t socket) + int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb) + int uv_poll_stop(uv_poll_t* poll) + + # FS Event + + int uv_fs_event_init(uv_loop_t *loop, uv_fs_event_t *handle) + int uv_fs_event_start(uv_fs_event_t *handle, uv_fs_event_cb cb, + const char *path, unsigned int flags) + int uv_fs_event_stop(uv_fs_event_t *handle) + + # Misc + + ctypedef struct uv_timeval_t: + long tv_sec + long tv_usec + + ctypedef struct uv_rusage_t: + uv_timeval_t ru_utime # user CPU time used + uv_timeval_t ru_stime # system CPU time used + uint64_t ru_maxrss # maximum resident set size + uint64_t ru_ixrss # integral shared memory size + uint64_t ru_idrss # integral unshared data size + uint64_t ru_isrss # integral unshared stack size + uint64_t ru_minflt # page reclaims (soft page faults) + uint64_t ru_majflt # page faults (hard page faults) + uint64_t ru_nswap # swaps + uint64_t ru_inblock # block input operations + uint64_t ru_oublock # block output operations + uint64_t ru_msgsnd # IPC messages sent + uint64_t ru_msgrcv # IPC messages received + uint64_t ru_nsignals # signals received + uint64_t ru_nvcsw # voluntary context switches + uint64_t ru_nivcsw # involuntary context switches + + int uv_getrusage(uv_rusage_t* rusage) + + int uv_ip4_addr(const char* ip, int port, system.sockaddr_in* addr) + int uv_ip6_addr(const char* ip, int port, system.sockaddr_in6* addr) + + # Memory Allocation + + ctypedef void* (*uv_malloc_func)(size_t size) + ctypedef void* (*uv_realloc_func)(void* ptr, size_t size) + ctypedef void* (*uv_calloc_func)(size_t count, size_t size) + ctypedef void (*uv_free_func)(void* ptr) + + int uv_replace_allocator(uv_malloc_func malloc_func, + uv_realloc_func realloc_func, + uv_calloc_func calloc_func, + uv_free_func free_func) + + # Process + + ctypedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, + int term_signal) with gil + + ctypedef enum uv_process_flags: + UV_PROCESS_SETUID = 1, + UV_PROCESS_SETGID = 2, + UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = 4, + UV_PROCESS_DETACHED = 8, + UV_PROCESS_WINDOWS_HIDE = 16 + + ctypedef enum uv_stdio_flags: + UV_IGNORE = 0x00, + UV_CREATE_PIPE = 0x01, + UV_INHERIT_FD = 0x02, + UV_INHERIT_STREAM = 0x04, + UV_READABLE_PIPE = 0x10, + UV_WRITABLE_PIPE = 0x20 + + ctypedef union uv_stdio_container_data_u: + uv_stream_t* stream + int fd + + ctypedef struct uv_stdio_container_t: + uv_stdio_flags flags + uv_stdio_container_data_u data + + ctypedef struct uv_process_options_t: + uv_exit_cb exit_cb + char* file + char** args + char** env + char* cwd + unsigned int flags + int stdio_count + uv_stdio_container_t* stdio + uid_t uid + gid_t gid + + int uv_spawn(uv_loop_t* loop, uv_process_t* handle, + const uv_process_options_t* options) + + int uv_process_kill(uv_process_t* handle, int signum) + + unsigned int uv_version() |