Rizin
unix-like reverse engineering framework and cli tools
|
#include "uv-common.h"
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <sys/socket.h>
#include <poll.h>
Go to the source code of this file.
Classes | |
struct | uv__stream_queued_fds_s |
Macros | |
#define | UV__PATH_MAX 8192 |
#define | ACCESS_ONCE(type, var) (*(volatile type*) &(var)) |
#define | ROUND_UP(a, b) ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a)) |
#define | UNREACHABLE() |
#define | SAVE_ERRNO(block) |
#define | UV_UNUSED(declaration) declaration |
#define | UV__POLLRDHUP 0x2000 |
#define | UV__POLLPRI 0 |
#define | uv__cloexec uv__cloexec_fcntl |
#define | uv__nonblock uv__nonblock_fcntl |
#define | uv__stream_fd(handle) ((handle)->io_watcher.fd) |
#define | UV__F_NONBLOCK 1 |
#define | HAVE_MMSG 0 |
Typedefs | |
typedef struct uv__stream_queued_fds_s | uv__stream_queued_fds_t |
typedef int(* | uv__peersockfunc) (int, struct sockaddr *, socklen_t *) |
Enumerations | |
enum | { UV_LOOP_BLOCK_SIGPROF = 1 } |
enum | { UV__EXCLUDE_IFPHYS , UV__EXCLUDE_IFADDR } |
enum | uv_clocktype_t { UV_CLOCK_PRECISE = 0 , UV_CLOCK_FAST = 1 } |
Definition at line 79 of file internal.h.
#define HAVE_MMSG 0 |
Definition at line 340 of file internal.h.
Definition at line 82 of file internal.h.
#define SAVE_ERRNO | ( | block | ) |
Definition at line 92 of file internal.h.
#define UNREACHABLE | ( | ) |
Definition at line 85 of file internal.h.
#define uv__cloexec uv__cloexec_fcntl |
Definition at line 169 of file internal.h.
#define UV__F_NONBLOCK 1 |
Definition at line 288 of file internal.h.
#define uv__nonblock uv__nonblock_fcntl |
Definition at line 170 of file internal.h.
#define UV__PATH_MAX 8192 |
Definition at line 68 of file internal.h.
#define UV__POLLPRI 0 |
Definition at line 122 of file internal.h.
#define UV__POLLRDHUP 0x2000 |
Definition at line 116 of file internal.h.
#define uv__stream_fd | ( | handle | ) | ((handle)->io_watcher.fd) |
Definition at line 282 of file internal.h.
#define UV_UNUSED | ( | declaration | ) | declaration |
Definition at line 109 of file internal.h.
Definition at line 321 of file internal.h.
typedef struct uv__stream_queued_fds_s uv__stream_queued_fds_t |
Definition at line 1 of file internal.h.
anonymous enum |
anonymous enum |
enum uv_clocktype_t |
Definition at line 489 of file core.c.
References accept, assert(), EINTR, err, NULL, sockfd, uv__cloexec, uv__close(), UV__ERR, and uv__nonblock.
Referenced by uv__emfile_trick(), and uv__server_io().
void uv__async_close | ( | uv_async_t * | handle | ) |
Definition at line 115 of file async.c.
References handle, QUEUE_REMOVE, uv__async_spin(), and uv__handle_stop.
Referenced by uv_close().
Definition at line 230 of file async.c.
References loop, uv__async_start(), and uv__async_stop().
Referenced by uv_loop_fork().
void uv__async_stop | ( | uv_loop_t * | loop | ) |
Definition at line 240 of file async.c.
References loop, uv__close(), and uv__io_stop().
Referenced by uv__async_fork(), and uv__loop_close().
void uv__check_close | ( | uv_check_t * | handle | ) |
Referenced by uv_close().
Definition at line 639 of file core.c.
References EINTR, F_GETFD, F_SETFD, fcntl, fd, FD_CLOEXEC, flags, r, and UV__ERR.
Referenced by uv__process_child_init().
Definition at line 569 of file core.c.
References assert(), epoll_file_close(), fd, SAVE_ERRNO, STDERR_FILENO, and uv__close_nocheckstdio().
Referenced by mkdtemp(), new_socket(), uv__accept(), uv__async_stop(), uv__dup2_cloexec(), uv__emfile_trick(), uv__fs_mkstemp(), uv__fs_open(), uv__interface_addresses_v6(), uv__io_fork(), uv__loop_close(), uv__make_pipe(), uv__make_socketpair(), uv__open_cloexec(), uv__open_file(), uv__platform_loop_delete(), uv__platform_loop_init(), uv__process_child_init(), uv__process_open_stream(), uv__random_readpath(), uv__set_phys_addr(), uv__signal_cleanup(), uv__signal_loop_cleanup(), uv__signal_loop_fork(), uv__socket(), uv__stream_close(), uv__stream_recv_cmsg(), uv__udp_close(), uv_accept(), uv_fs_event_stop(), uv_interface_addresses(), uv_pipe_bind(), uv_resident_set_memory(), uv_spawn(), and uv_tty_init().
Definition at line 530 of file core.c.
References close, fd, and syscall.
Referenced by uv__close_nocheckstdio(), and uv__fs_close().
Definition at line 550 of file core.c.
References assert(), EINPROGRESS, fd, uv__close_nocancel(), and UV__ERR.
Referenced by uv__close(), uv__fs_copyfile(), uv__slurp(), uv_fs_event_start(), and uv_spawn().
Definition at line 1031 of file core.c.
References dup2, err, O_CLOEXEC, oldfd, r, uv__cloexec, uv__close(), and UV__ERR.
Referenced by uv_tty_init().
Definition at line 965 of file core.c.
References fd, loop, and NULL.
Referenced by uv_pipe_open(), uv_poll_init(), uv_tcp_open(), and uv_udp_open().
void uv__fs_event_close | ( | uv_fs_event_t * | handle | ) |
Definition at line 863 of file aix.c.
References handle, UNREACHABLE, and uv_fs_event_stop().
Referenced by uv_close().
int uv__getiovmax | ( | void | ) |
Definition at line 215 of file core.c.
References uv__load_relaxed, and uv__store_relaxed.
Referenced by uv__fs_read(), uv__fs_write_all(), and uv__write().
int uv__getpwuid_r | ( | uv_passwd_t * | pwd | ) |
int uv__getsockpeername | ( | const uv_handle_t * | handle, |
uv__peersockfunc | func, | ||
struct sockaddr * | name, | ||
int * | namelen | ||
) |
Definition at line 1490 of file core.c.
References fd, handle, int, r, UV__ERR, and uv_fileno().
Referenced by uv__pipe_getsockpeername(), uv_tcp_getpeername(), uv_tcp_getsockname(), uv_udp_getpeername(), and uv_udp_getsockname().
uv_handle_type uv__handle_type | ( | int | fd | ) |
Definition at line 958 of file stream.c.
References AF_INET, AF_INET6, AF_UNIX, fd, len, memset(), SO_TYPE, SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET, type, and UV_UNKNOWN_HANDLE.
Referenced by uv_pipe_pending_type().
uint64_t uv__hrtime | ( | uv_clocktype_t | type | ) |
Definition at line 43 of file aix-common.c.
References CLOCK_MONOTONIC_COARSE, done, G, NANOSEC, once, time_func, timebase, TOD_RES, timespec::tv_nsec, timespec::tv_sec, type, uv__hrtime_init_once(), uv__load_relaxed, uv__store_relaxed, UV_CLOCK_FAST, and uv_once().
Referenced by uv_cond_timedwait(), uv_hrtime(), UV_UNUSED(), and uv_update_time().
void uv__idle_close | ( | uv_idle_t * | handle | ) |
Referenced by uv_close().
Definition at line 958 of file core.c.
References assert(), UV__POLLPRI, UV__POLLRDHUP, and w.
Referenced by uv__read(), uv__stream_close(), uv__stream_destroy(), uv__stream_eof(), uv__udp_finish_close(), uv__udp_recv_start(), uv__udp_run_completed(), uv__write(), uv_read_stop(), and uv_try_write().
Definition at line 115 of file aix.c.
References e, EAGAIN, EEXIST, EINTR, epoll_ctl(), EPOLL_CTL_ADD, EPOLL_CTL_DEL, fd, loop, memset(), NULL, p, pc, poll, and UV__ERR.
Referenced by uv_poll_init().
Definition at line 942 of file core.c.
References loop, QUEUE_REMOVE, uv__io_stop(), uv__platform_invalidate_fd(), UV__POLLPRI, UV__POLLRDHUP, and w.
Referenced by uv__stream_close(), uv__udp_close(), and uv_fs_event_stop().
Definition at line 952 of file core.c.
References loop, QUEUE_EMPTY, QUEUE_INSERT_TAIL, and w.
Referenced by uv__tcp_connect(), uv__udp_sendmsg(), uv__write_req_finish(), and uv_pipe_connect().
Definition at line 108 of file aix.c.
References err, loop, NULL, uv__close(), uv__free(), uv__inotify_fork(), uv__io_stop(), uv__kqueue_init(), uv__platform_loop_delete(), uv__platform_loop_init(), and uv__store_relaxed.
Referenced by uv_loop_fork().
Definition at line 865 of file core.c.
References assert(), cb, fd, NULL, QUEUE_INIT, and w.
Referenced by init_inotify(), uv__async_start(), uv__signal_loop_once_init(), uv__stream_init(), uv__udp_init_ex(), uv_fs_event_start(), and uv_poll_init().
Definition at line 133 of file aix.c.
References ARRAY_SIZE, assert(), container_of, count, e, EBADF, EEXIST, EINTR, EINVAL, ENOENT, epoll_ctl(), EPOLL_CTL_ADD, EPOLL_CTL_DEL, EPOLL_CTL_MOD, epoll_wait(), err, EV_OOBAND, epoll_event::events, fd, epoll_event::fd, filter(), flags, i, epoll_event::is_msg, loop, memset(), nfds, NULL, op, os390_message_queue_handler(), pc, poll, QUEUE_DATA, QUEUE_EMPTY, QUEUE_HEAD, QUEUE_INIT, QUEUE_INSERT_TAIL, QUEUE_REMOVE, SAVE_ERRNO, timeout, timespec::tv_nsec, timespec::tv_sec, uv__fs_event(), uv__get_internal_fields, uv__load_relaxed, uv__metrics_set_provider_entry_time(), uv__metrics_update_idle_time(), uv__platform_invalidate_fd(), uv__pollfds_add(), uv__pollfds_del(), UV__POLLPRI, UV__POLLRDHUP, uv__store_relaxed, UV_LOOP_BLOCK_SIGPROF, UV_METRICS_IDLE_TIME, w, and x.
Referenced by uv_run().
Definition at line 882 of file core.c.
References assert(), INT_MAX, loop, maybe_resize(), NULL, QUEUE_EMPTY, QUEUE_INSERT_TAIL, UV__POLLPRI, UV__POLLRDHUP, and w.
Referenced by init_inotify(), uv__async_start(), uv__read(), uv__server_io(), uv__signal_loop_once_init(), uv__tcp_connect(), uv__udp_recv_start(), uv__udp_send(), uv__write(), uv_accept(), uv_fs_event_start(), uv_pipe_connect(), uv_pipe_listen(), uv_poll_start(), uv_read_start(), uv_shutdown(), uv_tcp_listen(), and uv_write2().
Definition at line 910 of file core.c.
References assert(), loop, NULL, QUEUE_EMPTY, QUEUE_INIT, QUEUE_INSERT_TAIL, QUEUE_REMOVE, UV__POLLPRI, UV__POLLRDHUP, and w.
Referenced by uv__async_stop(), uv__drain(), uv__io_close(), uv__io_fork(), uv__platform_loop_delete(), uv__poll_io(), uv__poll_stop(), uv__read(), uv__server_io(), uv__signal_loop_fork(), uv__stream_connect(), uv__stream_eof(), uv__udp_run_completed(), uv__write(), uv_read_stop(), and uv_try_write().
Definition at line 51 of file kqueue.c.
References loop, uv__cloexec, and UV__ERR.
Referenced by uv__io_fork(), and uv__platform_loop_init().
void uv__make_close_pending | ( | uv_handle_t * | handle | ) |
Definition at line 208 of file core.c.
References assert(), handle, UV_HANDLE_CLOSED, and UV_HANDLE_CLOSING.
Referenced by timer_close_cb(), uv__finish_close(), uv__fs_poll_close(), and uv_close().
Definition at line 142 of file process.c.
References fail, flags, O_CLOEXEC, pipe, uv__cloexec, uv__close(), UV__ERR, UV__F_NONBLOCK, and uv__nonblock.
Referenced by uv__async_start(), uv__signal_global_reinit(), uv__signal_loop_once_init(), and uv_spawn().
Definition at line 608 of file core.c.
References EINTR, F_GETFL, F_SETFL, fcntl, fd, flags, O_NONBLOCK, r, and UV__ERR.
Referenced by uv__process_child_init(), and uv_poll_init().
Definition at line 1003 of file core.c.
References err, fd, flags, O_CLOEXEC, path, uv__cloexec, uv__close(), and UV__ERR.
Referenced by uv__emfile_trick(), uv__open_file(), uv__random_readpath(), uv__slurp(), uv__stream_init(), uv_resident_set_memory(), and uv_tty_init().
FILE* uv__open_file | ( | const char * | path | ) |
Definition at line 473 of file core.c.
References fd, benchmark::FILE, NULL, O_RDONLY, path, uv__close(), and uv__open_cloexec().
Referenced by read_cpufreq(), read_models(), and uv_cpu_info().
void uv__pipe_close | ( | uv_pipe_t * | handle | ) |
Definition at line 120 of file pipe.c.
References handle, NULL, unlink, uv__free(), and uv__stream_close().
Referenced by uv_close().
Definition at line 1280 of file aix.c.
References assert(), epoll_ctl(), EPOLL_CTL_DEL, epoll_event::events, fd, i, loop, memset(), nfds, NULL, pc, and uv__pollfds_del().
Referenced by uv__io_close(), uv__io_poll(), and uv__poll_stop().
void uv__platform_loop_delete | ( | uv_loop_t * | loop | ) |
Definition at line 95 of file aix.c.
References epoll_queue_close(), loop, NULL, uv__close(), uv__free(), uv__fsevents_loop_delete(), and uv__io_stop().
Referenced by uv__io_fork(), uv__loop_close(), and uv_loop_init().
Definition at line 81 of file aix.c.
References EINVAL, epoll_create1(), err, fd, loop, NULL, O_CLOEXEC, uv__cloexec, uv__close(), UV__ERR, and uv__kqueue_init().
Referenced by uv__io_fork(), and uv_loop_init().
void uv__poll_close | ( | uv_poll_t * | handle | ) |
Definition at line 148 of file poll.c.
References handle, and uv__poll_stop().
Referenced by uv_close().
void uv__prepare_close | ( | uv_prepare_t * | handle | ) |
Referenced by uv_close().
void uv__process_close | ( | uv_process_t * | handle | ) |
Definition at line 590 of file process.c.
References handle, QUEUE_EMPTY, QUEUE_REMOVE, uv__handle_stop, and uv_signal_stop().
Referenced by uv_close().
Definition at line 86 of file random-devurandom.c.
References buflen, once, status, uv__random_devurandom_init(), uv__random_readpath(), and uv_once().
Referenced by uv__random().
Definition at line 39 of file random-getentropy.c.
References buflen, NULL, once, pos, UV__ERR, uv__getentropy, uv__random_getentropy_init(), and uv_once().
Referenced by uv__random().
Definition at line 56 of file random-getrandom.c.
References buflen, EINTR, n, pos, UV__ERR, uv__getrandom, and uv__random_getrandom_init().
Referenced by uv__random().
Definition at line 32 of file random-devurandom.c.
References buflen, EINTR, fd, fstat, n, O_RDONLY, path, pos, read(), s, uv__close(), UV__ERR, and uv__open_cloexec().
Referenced by uv__random(), uv__random_devurandom(), and uv__random_devurandom_init().
Definition at line 238 of file netbsd.c.
References args, ARRAY_SIZE, buflen, count, len, memcpy(), memset(), n, name, NULL, p, req, syscall, and UV__ERR.
Referenced by uv__random().
Definition at line 670 of file core.c.
References CMSG_DATA, CMSG_FIRSTHDR, cmsghdr::cmsg_len, CMSG_NXTHDR, cmsghdr::cmsg_type, EINVAL, test_evm::end, fd, flags, msg, NULL, SCM_RIGHTS, uv__cloexec, UV__ERR, uv__load_relaxed, and uv__store_relaxed.
Referenced by uv__read().
Definition at line 1540 of file core.c.
References access, buflen, getenv(), memcpy(), NULL, prog, snprintf, UV__ERR, uv__free(), UV__PATH_MAX, uv__strdup(), and X_OK.
Referenced by uv_exepath(), and uv_setup_args().
Definition at line 528 of file stream.c.
References assert(), container_of, err, loop, nanosleep, NULL, timeout, uv__accept(), uv__emfile_trick(), UV__ERR, uv__io_start(), uv__io_stop(), uv__stream_fd, UV_DEC_BACKLOG, UV_HANDLE_CLOSING, UV_HANDLE_TCP_SINGLE_ACCEPT, and w.
Referenced by uv_pipe_listen(), and uv_tcp_listen().
void uv__signal_close | ( | uv_signal_t * | handle | ) |
Definition at line 335 of file signal.c.
References handle, and uv__signal_stop().
Referenced by uv_close().
void uv__signal_global_once_init | ( | void | ) |
Definition at line 111 of file signal.c.
References uv__signal_global_init_guard, and uv_once().
Referenced by uv_loop_init().
void uv__signal_loop_cleanup | ( | uv_loop_t * | loop | ) |
Definition at line 291 of file signal.c.
References handle, uv_loop_s::handle_queue, loop, QUEUE_DATA, QUEUE_FOREACH, uv__close(), and uv__signal_stop().
Referenced by uv__loop_close(), and uv_loop_init().
Definition at line 281 of file signal.c.
References loop, uv__close(), uv__io_stop(), and uv__signal_loop_once_init().
Referenced by uv_loop_fork().
Definition at line 436 of file core.c.
References domain, EINVAL, err, socket, sockfd, SOL_SOCKET, type, uv__cloexec, uv__close(), UV__ERR, and uv__nonblock.
Referenced by new_socket(), uv__udp_bind(), uv__udp_init_ex(), uv_pipe_bind(), and uv_pipe_connect().
void uv__stream_close | ( | uv_stream_t * | handle | ) |
Definition at line 1633 of file stream.c.
References assert(), uv__stream_queued_fds_s::fds, handle, i, NULL, uv__stream_queued_fds_s::offset, s, STDERR_FILENO, uv__close(), uv__free(), uv__handle_stop, uv__io_active(), uv__io_close(), uv__stream_osx_interrupt_select(), uv_close(), UV_HANDLE_READABLE, UV_HANDLE_WRITABLE, uv_read_stop(), uv_sem_destroy(), uv_sem_post(), and uv_thread_join().
Referenced by uv__pipe_close(), uv__process_close_stream(), uv__tcp_close(), and uv_close().
void uv__stream_destroy | ( | uv_stream_t * | stream | ) |
Definition at line 458 of file stream.c.
References assert(), NULL, uv__io_active(), uv__req_unregister, uv__stream_flush_write_queue(), uv__write_callbacks(), and UV_HANDLE_CLOSED.
Referenced by uv__finish_close().
void uv__stream_init | ( | uv_loop_t * | loop, |
uv_stream_t * | stream, | ||
uv_handle_type | type | ||
) |
Definition at line 85 of file stream.c.
References err, loop, NULL, O_RDONLY, QUEUE_INIT, type, uv__handle_init, uv__io_init(), uv__open_cloexec(), and uv__stream_io().
Referenced by uv_pipe_init(), uv_tcp_init_ex(), and uv_tty_init().
int uv__stream_open | ( | uv_stream_t * | stream, |
int | fd, | ||
int | flags | ||
) |
Definition at line 406 of file stream.c.
References assert(), EINVAL, ENOTSOCK, fd, flags, SO_OOBINLINE, SOL_SOCKET, UV__ERR, uv__tcp_keepalive(), uv__tcp_nodelay(), UV_HANDLE_TCP_KEEPALIVE, and UV_HANDLE_TCP_NODELAY.
Referenced by new_socket(), uv__process_open_stream(), uv_accept(), uv_pipe_connect(), uv_pipe_open(), uv_tcp_open(), and uv_tty_init().
void uv__tcp_close | ( | uv_tcp_t * | handle | ) |
Definition at line 459 of file tcp.c.
References handle, and uv__stream_close().
Referenced by uv_close().
Definition at line 380 of file tcp.c.
References fd, SO_KEEPALIVE, SOL_SOCKET, TCP_KEEPALIVE, and UV__ERR.
Referenced by uv__stream_open(), uv_tcp_keepalive(), and uv_tcp_set_socket().
Definition at line 373 of file tcp.c.
Referenced by uv__stream_open(), uv_tcp_nodelay(), and uv_tcp_set_socket().
void uv__udp_close | ( | uv_udp_t * | handle | ) |
Definition at line 90 of file udp.c.
References handle, uv__close(), uv__handle_stop, and uv__io_close().
Referenced by uv_close().
void uv__udp_finish_close | ( | uv_udp_t * | handle | ) |
Definition at line 101 of file udp.c.
References assert(), handle, NULL, queue, QUEUE_DATA, QUEUE_EMPTY, QUEUE_HEAD, QUEUE_INSERT_TAIL, QUEUE_REMOVE, req, uv__io_active(), and uv__udp_run_completed().
Referenced by uv__finish_close().
int uv_pipe_listen | ( | uv_pipe_t * | handle, |
int | backlog, | ||
uv_connection_cb | cb | ||
) |
Definition at line 94 of file pipe.c.
References cb, handle, listen, UV__ERR, uv__io_start(), uv__server_io(), and uv__stream_fd.
Referenced by uv_listen().
int uv_tcp_listen | ( | uv_tcp_t * | tcp, |
int | backlog, | ||
uv_connection_cb | cb | ||
) |
Definition at line 328 of file tcp.c.
References AF_INET, cb, err, flags, getenv(), listen, maybe_new_socket(), NULL, UV__ERR, uv__io_start(), uv__load_relaxed, uv__server_io(), uv__store_relaxed, UV_HANDLE_BOUND, UV_HANDLE_TCP_SINGLE_ACCEPT, and val.
Referenced by uv_listen().
UV_UNUSED | ( | static char * | uv__basename_rconst char *path | ) |
UV_UNUSED | ( | static void | uv__update_timeuv_loop_t *loop | ) |