Rizin
unix-like reverse engineering framework and cli tools
uv.h File Reference
#include "uv/errno.h"
#include "uv/version.h"
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
#include "uv/unix.h"

Go to the source code of this file.

Classes

struct  uv_timespec_t
 
struct  uv_stat_t
 
struct  uv_req_s
 
struct  uv_shutdown_s
 
struct  uv_handle_s
 
struct  uv_stream_s
 
struct  uv_write_s
 
struct  uv_tcp_s
 
struct  uv_connect_s
 
struct  uv_udp_s
 
struct  uv_udp_send_s
 
struct  uv_tty_s
 
struct  uv_pipe_s
 
struct  uv_poll_s
 
struct  uv_prepare_s
 
struct  uv_check_s
 
struct  uv_idle_s
 
struct  uv_async_s
 
struct  uv_timer_s
 
struct  uv_getaddrinfo_s
 
struct  uv_getnameinfo_s
 
struct  uv_stdio_container_s
 
struct  uv_process_options_s
 
struct  uv_process_s
 
struct  uv_work_s
 
struct  uv_cpu_times_s
 
struct  uv_cpu_info_s
 
struct  uv_interface_address_s
 
struct  uv_passwd_s
 
struct  uv_utsname_s
 
struct  uv_statfs_s
 
struct  uv_dirent_s
 
struct  uv_timeval_t
 
struct  uv_timeval64_t
 
struct  uv_rusage_t
 
struct  uv_env_item_s
 
struct  uv_dir_s
 
struct  uv_fs_s
 
struct  uv_fs_event_s
 
struct  uv_fs_poll_s
 
struct  uv_signal_s
 
struct  uv_random_s
 
struct  uv_thread_options_s
 
union  uv_any_handle
 
union  uv_any_req
 
struct  uv_loop_s
 

Macros

#define UV_EXTERN   /* nothing */
 
#define UV_ERRNO_MAP(XX)
 
#define UV_HANDLE_TYPE_MAP(XX)
 
#define UV_REQ_TYPE_MAP(XX)
 
#define XX(code, _)   UV_ ## code = UV__ ## code,
 
#define XX(uc, lc)   UV_##uc,
 
#define XX(uc, lc)   UV_##uc,
 
#define UV_REQ_FIELDS
 
#define UV_HANDLE_FIELDS
 
#define UV_STREAM_FIELDS
 
#define UV_PRIORITY_LOW   19
 
#define UV_PRIORITY_BELOW_NORMAL   10
 
#define UV_PRIORITY_NORMAL   0
 
#define UV_PRIORITY_ABOVE_NORMAL   -7
 
#define UV_PRIORITY_HIGH   -14
 
#define UV_PRIORITY_HIGHEST   -20
 
#define UV_MAXHOSTNAMESIZE   256
 
#define UV_FS_COPYFILE_EXCL   0x0001
 
#define UV_FS_COPYFILE_FICLONE   0x0002
 
#define UV_FS_COPYFILE_FICLONE_FORCE   0x0004
 
#define UV_FS_SYMLINK_DIR   0x0001
 
#define UV_FS_SYMLINK_JUNCTION   0x0002
 
#define UV_IF_NAMESIZE   (16 + 1)
 
#define XX(_, name)   uv_ ## name ## _t name;
 

Typedefs

typedef struct uv_loop_s uv_loop_t
 
typedef struct uv_handle_s uv_handle_t
 
typedef struct uv_dir_s uv_dir_t
 
typedef struct uv_stream_s uv_stream_t
 
typedef struct uv_tcp_s uv_tcp_t
 
typedef struct uv_udp_s uv_udp_t
 
typedef struct uv_pipe_s uv_pipe_t
 
typedef struct uv_tty_s uv_tty_t
 
typedef struct uv_poll_s uv_poll_t
 
typedef struct uv_timer_s uv_timer_t
 
typedef struct uv_prepare_s uv_prepare_t
 
typedef struct uv_check_s uv_check_t
 
typedef struct uv_idle_s uv_idle_t
 
typedef struct uv_async_s uv_async_t
 
typedef struct uv_process_s uv_process_t
 
typedef struct uv_fs_event_s uv_fs_event_t
 
typedef struct uv_fs_poll_s uv_fs_poll_t
 
typedef struct uv_signal_s uv_signal_t
 
typedef struct uv_req_s uv_req_t
 
typedef struct uv_getaddrinfo_s uv_getaddrinfo_t
 
typedef struct uv_getnameinfo_s uv_getnameinfo_t
 
typedef struct uv_shutdown_s uv_shutdown_t
 
typedef struct uv_write_s uv_write_t
 
typedef struct uv_connect_s uv_connect_t
 
typedef struct uv_udp_send_s uv_udp_send_t
 
typedef struct uv_fs_s uv_fs_t
 
typedef struct uv_work_s uv_work_t
 
typedef struct uv_random_s uv_random_t
 
typedef struct uv_env_item_s uv_env_item_t
 
typedef struct uv_cpu_info_s uv_cpu_info_t
 
typedef struct uv_interface_address_s uv_interface_address_t
 
typedef struct uv_dirent_s uv_dirent_t
 
typedef struct uv_passwd_s uv_passwd_t
 
typedef struct uv_utsname_s uv_utsname_t
 
typedef struct uv_statfs_s uv_statfs_t
 
typedef void *(* uv_malloc_func) (size_t size)
 
typedef void *(* uv_realloc_func) (void *ptr, size_t size)
 
typedef void *(* uv_calloc_func) (size_t count, size_t size)
 
typedef void(* uv_free_func) (void *ptr)
 
typedef void(* uv_alloc_cb) (uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf)
 
typedef void(* uv_read_cb) (uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
 
typedef void(* uv_write_cb) (uv_write_t *req, int status)
 
typedef void(* uv_connect_cb) (uv_connect_t *req, int status)
 
typedef void(* uv_shutdown_cb) (uv_shutdown_t *req, int status)
 
typedef void(* uv_connection_cb) (uv_stream_t *server, int status)
 
typedef void(* uv_close_cb) (uv_handle_t *handle)
 
typedef void(* uv_poll_cb) (uv_poll_t *handle, int status, int events)
 
typedef void(* uv_timer_cb) (uv_timer_t *handle)
 
typedef void(* uv_async_cb) (uv_async_t *handle)
 
typedef void(* uv_prepare_cb) (uv_prepare_t *handle)
 
typedef void(* uv_check_cb) (uv_check_t *handle)
 
typedef void(* uv_idle_cb) (uv_idle_t *handle)
 
typedef void(* uv_exit_cb) (uv_process_t *, int64_t exit_status, int term_signal)
 
typedef void(* uv_walk_cb) (uv_handle_t *handle, void *arg)
 
typedef void(* uv_fs_cb) (uv_fs_t *req)
 
typedef void(* uv_work_cb) (uv_work_t *req)
 
typedef void(* uv_after_work_cb) (uv_work_t *req, int status)
 
typedef void(* uv_getaddrinfo_cb) (uv_getaddrinfo_t *req, int status, struct addrinfo *res)
 
typedef void(* uv_getnameinfo_cb) (uv_getnameinfo_t *req, int status, const char *hostname, const char *service)
 
typedef void(* uv_random_cb) (uv_random_t *req, int status, void *buf, size_t buflen)
 
typedef void(* uv_fs_event_cb) (uv_fs_event_t *handle, const char *filename, int events, int status)
 
typedef void(* uv_fs_poll_cb) (uv_fs_poll_t *handle, int status, const uv_stat_t *prev, const uv_stat_t *curr)
 
typedef void(* uv_signal_cb) (uv_signal_t *handle, int signum)
 
typedef void(* uv_udp_send_cb) (uv_udp_send_t *req, int status)
 
typedef void(* uv_udp_recv_cb) (uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags)
 
typedef struct uv_stdio_container_s uv_stdio_container_t
 
typedef struct uv_process_options_s uv_process_options_t
 
typedef void(* uv_thread_cb) (void *arg)
 
typedef struct uv_thread_options_s uv_thread_options_t
 

Enumerations

enum  uv_errno_t { UV_ERRNO_MAX = UV__EOF - 1 }
 
enum  uv_handle_type { UV_UNKNOWN_HANDLE = 0 , UV_FILE , UV_HANDLE_TYPE_MAX }
 
enum  uv_req_type { UV_UNKNOWN_REQ = 0 , UV_REQ_TYPE_MAX }
 
enum  uv_loop_option { UV_LOOP_BLOCK_SIGNAL = 0 , UV_METRICS_IDLE_TIME }
 
enum  uv_run_mode { UV_RUN_DEFAULT = 0 , UV_RUN_ONCE , UV_RUN_NOWAIT }
 
enum  uv_membership { UV_LEAVE_GROUP = 0 , UV_JOIN_GROUP }
 
enum  uv_tcp_flags { UV_TCP_IPV6ONLY = 1 }
 
enum  uv_udp_flags {
  UV_UDP_IPV6ONLY = 1 , UV_UDP_PARTIAL = 2 , UV_UDP_REUSEADDR = 4 , UV_UDP_MMSG_CHUNK = 8 ,
  UV_UDP_MMSG_FREE = 16 , UV_UDP_RECVMMSG = 256
}
 
enum  uv_tty_mode_t { UV_TTY_MODE_NORMAL , UV_TTY_MODE_RAW , UV_TTY_MODE_IO }
 
enum  uv_tty_vtermstate_t { UV_TTY_SUPPORTED , UV_TTY_UNSUPPORTED }
 
enum  uv_poll_event { UV_READABLE = 1 , UV_WRITABLE = 2 , UV_DISCONNECT = 4 , UV_PRIORITIZED = 8 }
 
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 , UV_OVERLAPPED_PIPE = 0x40
}
 
enum  uv_process_flags {
  UV_PROCESS_SETUID = (1 << 0) , UV_PROCESS_SETGID = (1 << 1) , UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2) , UV_PROCESS_DETACHED = (1 << 3) ,
  UV_PROCESS_WINDOWS_HIDE = (1 << 4) , UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5) , UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6)
}
 
enum  uv_dirent_type_t {
  UV_DIRENT_UNKNOWN , UV_DIRENT_FILE , UV_DIRENT_DIR , UV_DIRENT_LINK ,
  UV_DIRENT_FIFO , UV_DIRENT_SOCKET , UV_DIRENT_CHAR , UV_DIRENT_BLOCK
}
 
enum  uv_fs_type {
  UV_FS_UNKNOWN = -1 , UV_FS_CUSTOM , UV_FS_OPEN , UV_FS_CLOSE ,
  UV_FS_READ , UV_FS_WRITE , UV_FS_SENDFILE , UV_FS_STAT ,
  UV_FS_LSTAT , UV_FS_FSTAT , UV_FS_FTRUNCATE , UV_FS_UTIME ,
  UV_FS_FUTIME , UV_FS_ACCESS , UV_FS_CHMOD , UV_FS_FCHMOD ,
  UV_FS_FSYNC , UV_FS_FDATASYNC , UV_FS_UNLINK , UV_FS_RMDIR ,
  UV_FS_MKDIR , UV_FS_MKDTEMP , UV_FS_RENAME , UV_FS_SCANDIR ,
  UV_FS_LINK , UV_FS_SYMLINK , UV_FS_READLINK , UV_FS_CHOWN ,
  UV_FS_FCHOWN , UV_FS_REALPATH , UV_FS_COPYFILE , UV_FS_LCHOWN ,
  UV_FS_OPENDIR , UV_FS_READDIR , UV_FS_CLOSEDIR , UV_FS_STATFS ,
  UV_FS_MKSTEMP , UV_FS_LUTIME
}
 
enum  uv_fs_event { UV_RENAME = 1 , UV_CHANGE = 2 }
 
enum  uv_fs_event_flags { UV_FS_EVENT_WATCH_ENTRY = 1 , UV_FS_EVENT_STAT = 2 , UV_FS_EVENT_RECURSIVE = 4 }
 
enum  uv_thread_create_flags { UV_THREAD_NO_FLAGS = 0x00 , UV_THREAD_HAS_STACK_SIZE = 0x01 }
 

Functions

UV_EXTERN unsigned int uv_version (void)
 
UV_EXTERN const char * uv_version_string (void)
 
UV_EXTERN void uv_library_shutdown (void)
 
UV_EXTERN int uv_replace_allocator (uv_malloc_func malloc_func, uv_realloc_func realloc_func, uv_calloc_func calloc_func, uv_free_func free_func)
 
UV_EXTERN uv_loop_tuv_default_loop (void)
 
UV_EXTERN int uv_loop_init (uv_loop_t *loop)
 
UV_EXTERN int uv_loop_close (uv_loop_t *loop)
 
UV_EXTERN uv_loop_tuv_loop_new (void)
 
UV_EXTERN void uv_loop_delete (uv_loop_t *)
 
UV_EXTERN size_t uv_loop_size (void)
 
UV_EXTERN int uv_loop_alive (const uv_loop_t *loop)
 
UV_EXTERN int uv_loop_configure (uv_loop_t *loop, uv_loop_option option,...)
 
UV_EXTERN int uv_loop_fork (uv_loop_t *loop)
 
UV_EXTERN int uv_run (uv_loop_t *, uv_run_mode mode)
 
UV_EXTERN void uv_stop (uv_loop_t *)
 
UV_EXTERN void uv_ref (uv_handle_t *)
 
UV_EXTERN void uv_unref (uv_handle_t *)
 
UV_EXTERN int uv_has_ref (const uv_handle_t *)
 
UV_EXTERN void uv_update_time (uv_loop_t *)
 
UV_EXTERN uint64_t uv_now (const uv_loop_t *)
 
UV_EXTERN int uv_backend_fd (const uv_loop_t *)
 
UV_EXTERN int uv_backend_timeout (const uv_loop_t *)
 
UV_EXTERN int uv_translate_sys_error (int sys_errno)
 
UV_EXTERN const char * uv_strerror (int err)
 
UV_EXTERN char * uv_strerror_r (int err, char *buf, size_t buflen)
 
UV_EXTERN const char * uv_err_name (int err)
 
UV_EXTERN char * uv_err_name_r (int err, char *buf, size_t buflen)
 
UV_PRIVATE_REQ_TYPES UV_EXTERN int uv_shutdown (uv_shutdown_t *req, uv_stream_t *handle, uv_shutdown_cb cb)
 
UV_EXTERN size_t uv_handle_size (uv_handle_type type)
 
UV_EXTERN uv_handle_type uv_handle_get_type (const uv_handle_t *handle)
 
UV_EXTERN const char * uv_handle_type_name (uv_handle_type type)
 
UV_EXTERN void * uv_handle_get_data (const uv_handle_t *handle)
 
UV_EXTERN uv_loop_tuv_handle_get_loop (const uv_handle_t *handle)
 
UV_EXTERN void uv_handle_set_data (uv_handle_t *handle, void *data)
 
UV_EXTERN size_t uv_req_size (uv_req_type type)
 
UV_EXTERN void * uv_req_get_data (const uv_req_t *req)
 
UV_EXTERN void uv_req_set_data (uv_req_t *req, void *data)
 
UV_EXTERN uv_req_type uv_req_get_type (const uv_req_t *req)
 
UV_EXTERN const char * uv_req_type_name (uv_req_type type)
 
UV_EXTERN int uv_is_active (const uv_handle_t *handle)
 
UV_EXTERN void uv_walk (uv_loop_t *loop, uv_walk_cb walk_cb, void *arg)
 
UV_EXTERN void uv_print_all_handles (uv_loop_t *loop, FILE *stream)
 
UV_EXTERN void uv_print_active_handles (uv_loop_t *loop, FILE *stream)
 
UV_EXTERN void uv_close (uv_handle_t *handle, uv_close_cb close_cb)
 
UV_EXTERN int uv_send_buffer_size (uv_handle_t *handle, int *value)
 
UV_EXTERN int uv_recv_buffer_size (uv_handle_t *handle, int *value)
 
UV_EXTERN int uv_fileno (const uv_handle_t *handle, uv_os_fd_t *fd)
 
UV_EXTERN uv_buf_t uv_buf_init (char *base, unsigned int len)
 
UV_EXTERN size_t uv_stream_get_write_queue_size (const uv_stream_t *stream)
 
UV_EXTERN int uv_listen (uv_stream_t *stream, int backlog, uv_connection_cb cb)
 
UV_EXTERN int uv_accept (uv_stream_t *server, uv_stream_t *client)
 
UV_EXTERN int uv_read_start (uv_stream_t *, uv_alloc_cb alloc_cb, uv_read_cb read_cb)
 
UV_EXTERN int uv_read_stop (uv_stream_t *)
 
UV_EXTERN int uv_write (uv_write_t *req, uv_stream_t *handle, const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb)
 
UV_EXTERN int uv_write2 (uv_write_t *req, uv_stream_t *handle, const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t *send_handle, uv_write_cb cb)
 
UV_EXTERN int uv_try_write (uv_stream_t *handle, const uv_buf_t bufs[], unsigned int nbufs)
 
UV_EXTERN int uv_is_readable (const uv_stream_t *handle)
 
UV_EXTERN int uv_is_writable (const uv_stream_t *handle)
 
UV_EXTERN int uv_stream_set_blocking (uv_stream_t *handle, int blocking)
 
UV_EXTERN int uv_is_closing (const uv_handle_t *handle)
 
UV_EXTERN int uv_tcp_init (uv_loop_t *, uv_tcp_t *handle)
 
UV_EXTERN int uv_tcp_init_ex (uv_loop_t *, uv_tcp_t *handle, unsigned int flags)
 
UV_EXTERN int uv_tcp_open (uv_tcp_t *handle, uv_os_sock_t sock)
 
UV_EXTERN int uv_tcp_nodelay (uv_tcp_t *handle, int enable)
 
UV_EXTERN int uv_tcp_keepalive (uv_tcp_t *handle, int enable, unsigned int delay)
 
UV_EXTERN int uv_tcp_simultaneous_accepts (uv_tcp_t *handle, int enable)
 
UV_EXTERN int uv_tcp_bind (uv_tcp_t *handle, const struct sockaddr *addr, unsigned int flags)
 
UV_EXTERN int uv_tcp_getsockname (const uv_tcp_t *handle, struct sockaddr *name, int *namelen)
 
UV_EXTERN int uv_tcp_getpeername (const uv_tcp_t *handle, struct sockaddr *name, int *namelen)
 
UV_EXTERN int uv_tcp_close_reset (uv_tcp_t *handle, uv_close_cb close_cb)
 
UV_EXTERN int uv_tcp_connect (uv_connect_t *req, uv_tcp_t *handle, const struct sockaddr *addr, uv_connect_cb cb)
 
UV_EXTERN int uv_udp_init (uv_loop_t *, uv_udp_t *handle)
 
UV_EXTERN int uv_udp_init_ex (uv_loop_t *, uv_udp_t *handle, unsigned int flags)
 
UV_EXTERN int uv_udp_open (uv_udp_t *handle, uv_os_sock_t sock)
 
UV_EXTERN int uv_udp_bind (uv_udp_t *handle, const struct sockaddr *addr, unsigned int flags)
 
UV_EXTERN int uv_udp_connect (uv_udp_t *handle, const struct sockaddr *addr)
 
UV_EXTERN int uv_udp_getpeername (const uv_udp_t *handle, struct sockaddr *name, int *namelen)
 
UV_EXTERN int uv_udp_getsockname (const uv_udp_t *handle, struct sockaddr *name, int *namelen)
 
UV_EXTERN int uv_udp_set_membership (uv_udp_t *handle, const char *multicast_addr, const char *interface_addr, uv_membership membership)
 
UV_EXTERN int uv_udp_set_source_membership (uv_udp_t *handle, const char *multicast_addr, const char *interface_addr, const char *source_addr, uv_membership membership)
 
UV_EXTERN int uv_udp_set_multicast_loop (uv_udp_t *handle, int on)
 
UV_EXTERN int uv_udp_set_multicast_ttl (uv_udp_t *handle, int ttl)
 
UV_EXTERN int uv_udp_set_multicast_interface (uv_udp_t *handle, const char *interface_addr)
 
UV_EXTERN int uv_udp_set_broadcast (uv_udp_t *handle, int on)
 
UV_EXTERN int uv_udp_set_ttl (uv_udp_t *handle, int ttl)
 
UV_EXTERN int uv_udp_send (uv_udp_send_t *req, uv_udp_t *handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr *addr, uv_udp_send_cb send_cb)
 
UV_EXTERN int uv_udp_try_send (uv_udp_t *handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr *addr)
 
UV_EXTERN int uv_udp_recv_start (uv_udp_t *handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb)
 
UV_EXTERN int uv_udp_using_recvmmsg (const uv_udp_t *handle)
 
UV_EXTERN int uv_udp_recv_stop (uv_udp_t *handle)
 
UV_EXTERN size_t uv_udp_get_send_queue_size (const uv_udp_t *handle)
 
UV_EXTERN size_t uv_udp_get_send_queue_count (const uv_udp_t *handle)
 
UV_EXTERN int uv_tty_init (uv_loop_t *, uv_tty_t *, uv_file fd, int readable)
 
UV_EXTERN int uv_tty_set_mode (uv_tty_t *, uv_tty_mode_t mode)
 
UV_EXTERN int uv_tty_reset_mode (void)
 
UV_EXTERN int uv_tty_get_winsize (uv_tty_t *, int *width, int *height)
 
UV_EXTERN void uv_tty_set_vterm_state (uv_tty_vtermstate_t state)
 
UV_EXTERN int uv_tty_get_vterm_state (uv_tty_vtermstate_t *state)
 
UV_EXTERN uv_handle_type uv_guess_handle (uv_file file)
 
UV_EXTERN int uv_pipe_init (uv_loop_t *, uv_pipe_t *handle, int ipc)
 
UV_EXTERN int uv_pipe_open (uv_pipe_t *, uv_file file)
 
UV_EXTERN int uv_pipe_bind (uv_pipe_t *handle, const char *name)
 
UV_EXTERN void uv_pipe_connect (uv_connect_t *req, uv_pipe_t *handle, const char *name, uv_connect_cb cb)
 
UV_EXTERN int uv_pipe_getsockname (const uv_pipe_t *handle, char *buffer, size_t *size)
 
UV_EXTERN int uv_pipe_getpeername (const uv_pipe_t *handle, char *buffer, size_t *size)
 
UV_EXTERN void uv_pipe_pending_instances (uv_pipe_t *handle, int count)
 
UV_EXTERN int uv_pipe_pending_count (uv_pipe_t *handle)
 
UV_EXTERN uv_handle_type uv_pipe_pending_type (uv_pipe_t *handle)
 
UV_EXTERN int uv_pipe_chmod (uv_pipe_t *handle, int flags)
 
UV_EXTERN int uv_poll_init (uv_loop_t *loop, uv_poll_t *handle, int fd)
 
UV_EXTERN int uv_poll_init_socket (uv_loop_t *loop, uv_poll_t *handle, uv_os_sock_t socket)
 
UV_EXTERN int uv_poll_start (uv_poll_t *handle, int events, uv_poll_cb cb)
 
UV_EXTERN int uv_poll_stop (uv_poll_t *handle)
 
UV_EXTERN int uv_prepare_init (uv_loop_t *, uv_prepare_t *prepare)
 
UV_EXTERN int uv_prepare_start (uv_prepare_t *prepare, uv_prepare_cb cb)
 
UV_EXTERN int uv_prepare_stop (uv_prepare_t *prepare)
 
UV_EXTERN int uv_check_init (uv_loop_t *, uv_check_t *check)
 
UV_EXTERN int uv_check_start (uv_check_t *check, uv_check_cb cb)
 
UV_EXTERN int uv_check_stop (uv_check_t *check)
 
UV_EXTERN int uv_idle_init (uv_loop_t *, uv_idle_t *idle)
 
UV_EXTERN int uv_idle_start (uv_idle_t *idle, uv_idle_cb cb)
 
UV_EXTERN int uv_idle_stop (uv_idle_t *idle)
 
UV_EXTERN int uv_async_init (uv_loop_t *, uv_async_t *async, uv_async_cb async_cb)
 
UV_EXTERN int uv_async_send (uv_async_t *async)
 
UV_EXTERN int uv_timer_init (uv_loop_t *, uv_timer_t *handle)
 
UV_EXTERN int uv_timer_start (uv_timer_t *handle, uv_timer_cb cb, uint64_t timeout, uint64_t repeat)
 
UV_EXTERN int uv_timer_stop (uv_timer_t *handle)
 
UV_EXTERN int uv_timer_again (uv_timer_t *handle)
 
UV_EXTERN void uv_timer_set_repeat (uv_timer_t *handle, uint64_t repeat)
 
UV_EXTERN uint64_t uv_timer_get_repeat (const uv_timer_t *handle)
 
UV_EXTERN uint64_t uv_timer_get_due_in (const uv_timer_t *handle)
 
UV_EXTERN int uv_getaddrinfo (uv_loop_t *loop, uv_getaddrinfo_t *req, uv_getaddrinfo_cb getaddrinfo_cb, const char *node, const char *service, const struct addrinfo *hints)
 
UV_EXTERN void uv_freeaddrinfo (struct addrinfo *ai)
 
UV_EXTERN int uv_getnameinfo (uv_loop_t *loop, uv_getnameinfo_t *req, uv_getnameinfo_cb getnameinfo_cb, const struct sockaddr *addr, int flags)
 
UV_EXTERN int uv_spawn (uv_loop_t *loop, uv_process_t *handle, const uv_process_options_t *options)
 
UV_EXTERN int uv_process_kill (uv_process_t *, int signum)
 
UV_EXTERN int uv_kill (int pid, int signum)
 
UV_EXTERN uv_pid_t uv_process_get_pid (const uv_process_t *)
 
UV_EXTERN int uv_queue_work (uv_loop_t *loop, uv_work_t *req, uv_work_cb work_cb, uv_after_work_cb after_work_cb)
 
UV_EXTERN int uv_cancel (uv_req_t *req)
 
UV_EXTERN char ** uv_setup_args (int argc, char **argv)
 
UV_EXTERN int uv_get_process_title (char *buffer, size_t size)
 
UV_EXTERN int uv_set_process_title (const char *title)
 
UV_EXTERN int uv_resident_set_memory (size_t *rss)
 
UV_EXTERN int uv_uptime (double *uptime)
 
UV_EXTERN uv_os_fd_t uv_get_osfhandle (int fd)
 
UV_EXTERN int uv_open_osfhandle (uv_os_fd_t os_fd)
 
UV_EXTERN int uv_getrusage (uv_rusage_t *rusage)
 
UV_EXTERN int uv_os_homedir (char *buffer, size_t *size)
 
UV_EXTERN int uv_os_tmpdir (char *buffer, size_t *size)
 
UV_EXTERN int uv_os_get_passwd (uv_passwd_t *pwd)
 
UV_EXTERN void uv_os_free_passwd (uv_passwd_t *pwd)
 
UV_EXTERN uv_pid_t uv_os_getpid (void)
 
UV_EXTERN uv_pid_t uv_os_getppid (void)
 
UV_EXTERN int uv_os_getpriority (uv_pid_t pid, int *priority)
 
UV_EXTERN int uv_os_setpriority (uv_pid_t pid, int priority)
 
UV_EXTERN int uv_cpu_info (uv_cpu_info_t **cpu_infos, int *count)
 
UV_EXTERN void uv_free_cpu_info (uv_cpu_info_t *cpu_infos, int count)
 
UV_EXTERN int uv_interface_addresses (uv_interface_address_t **addresses, int *count)
 
UV_EXTERN void uv_free_interface_addresses (uv_interface_address_t *addresses, int count)
 
UV_EXTERN int uv_os_environ (uv_env_item_t **envitems, int *count)
 
UV_EXTERN void uv_os_free_environ (uv_env_item_t *envitems, int count)
 
UV_EXTERN int uv_os_getenv (const char *name, char *buffer, size_t *size)
 
UV_EXTERN int uv_os_setenv (const char *name, const char *value)
 
UV_EXTERN int uv_os_unsetenv (const char *name)
 
UV_EXTERN int uv_os_gethostname (char *buffer, size_t *size)
 
UV_EXTERN int uv_os_uname (uv_utsname_t *buffer)
 
UV_EXTERN uint64_t uv_metrics_idle_time (uv_loop_t *loop)
 
UV_EXTERN uv_fs_type uv_fs_get_type (const uv_fs_t *)
 
UV_EXTERN ssize_t uv_fs_get_result (const uv_fs_t *)
 
UV_EXTERN int uv_fs_get_system_error (const uv_fs_t *)
 
UV_EXTERN void * uv_fs_get_ptr (const uv_fs_t *)
 
UV_EXTERN const char * uv_fs_get_path (const uv_fs_t *)
 
UV_EXTERN uv_stat_tuv_fs_get_statbuf (uv_fs_t *)
 
UV_EXTERN void uv_fs_req_cleanup (uv_fs_t *req)
 
UV_EXTERN int uv_fs_close (uv_loop_t *loop, uv_fs_t *req, uv_file file, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_open (uv_loop_t *loop, uv_fs_t *req, const char *path, int flags, int mode, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_read (uv_loop_t *loop, uv_fs_t *req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_unlink (uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_write (uv_loop_t *loop, uv_fs_t *req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_copyfile (uv_loop_t *loop, uv_fs_t *req, const char *path, const char *new_path, int flags, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_mkdir (uv_loop_t *loop, uv_fs_t *req, const char *path, int mode, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_mkdtemp (uv_loop_t *loop, uv_fs_t *req, const char *tpl, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_mkstemp (uv_loop_t *loop, uv_fs_t *req, const char *tpl, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_rmdir (uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_scandir (uv_loop_t *loop, uv_fs_t *req, const char *path, int flags, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_scandir_next (uv_fs_t *req, uv_dirent_t *ent)
 
UV_EXTERN int uv_fs_opendir (uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_readdir (uv_loop_t *loop, uv_fs_t *req, uv_dir_t *dir, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_closedir (uv_loop_t *loop, uv_fs_t *req, uv_dir_t *dir, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_stat (uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_fstat (uv_loop_t *loop, uv_fs_t *req, uv_file file, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_rename (uv_loop_t *loop, uv_fs_t *req, const char *path, const char *new_path, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_fsync (uv_loop_t *loop, uv_fs_t *req, uv_file file, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_fdatasync (uv_loop_t *loop, uv_fs_t *req, uv_file file, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_ftruncate (uv_loop_t *loop, uv_fs_t *req, uv_file file, int64_t offset, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_sendfile (uv_loop_t *loop, uv_fs_t *req, uv_file out_fd, uv_file in_fd, int64_t in_offset, size_t length, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_access (uv_loop_t *loop, uv_fs_t *req, const char *path, int mode, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_chmod (uv_loop_t *loop, uv_fs_t *req, const char *path, int mode, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_utime (uv_loop_t *loop, uv_fs_t *req, const char *path, double atime, double mtime, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_futime (uv_loop_t *loop, uv_fs_t *req, uv_file file, double atime, double mtime, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_lutime (uv_loop_t *loop, uv_fs_t *req, const char *path, double atime, double mtime, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_lstat (uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_link (uv_loop_t *loop, uv_fs_t *req, const char *path, const char *new_path, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_symlink (uv_loop_t *loop, uv_fs_t *req, const char *path, const char *new_path, int flags, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_readlink (uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_realpath (uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_fchmod (uv_loop_t *loop, uv_fs_t *req, uv_file file, int mode, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_chown (uv_loop_t *loop, uv_fs_t *req, const char *path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_fchown (uv_loop_t *loop, uv_fs_t *req, uv_file file, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_lchown (uv_loop_t *loop, uv_fs_t *req, const char *path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_statfs (uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
 
UV_EXTERN int uv_fs_poll_init (uv_loop_t *loop, uv_fs_poll_t *handle)
 
UV_EXTERN int uv_fs_poll_start (uv_fs_poll_t *handle, uv_fs_poll_cb poll_cb, const char *path, unsigned int interval)
 
UV_EXTERN int uv_fs_poll_stop (uv_fs_poll_t *handle)
 
UV_EXTERN int uv_fs_poll_getpath (uv_fs_poll_t *handle, char *buffer, size_t *size)
 
UV_EXTERN int uv_signal_init (uv_loop_t *loop, uv_signal_t *handle)
 
UV_EXTERN int uv_signal_start (uv_signal_t *handle, uv_signal_cb signal_cb, int signum)
 
UV_EXTERN int uv_signal_start_oneshot (uv_signal_t *handle, uv_signal_cb signal_cb, int signum)
 
UV_EXTERN int uv_signal_stop (uv_signal_t *handle)
 
UV_EXTERN void uv_loadavg (double avg[3])
 
UV_EXTERN int uv_fs_event_init (uv_loop_t *loop, uv_fs_event_t *handle)
 
UV_EXTERN int uv_fs_event_start (uv_fs_event_t *handle, uv_fs_event_cb cb, const char *path, unsigned int flags)
 
UV_EXTERN int uv_fs_event_stop (uv_fs_event_t *handle)
 
UV_EXTERN int uv_fs_event_getpath (uv_fs_event_t *handle, char *buffer, size_t *size)
 
UV_EXTERN int uv_ip4_addr (const char *ip, int port, struct sockaddr_in *addr)
 
UV_EXTERN int uv_ip6_addr (const char *ip, int port, struct sockaddr_in6 *addr)
 
UV_EXTERN int uv_ip4_name (const struct sockaddr_in *src, char *dst, size_t size)
 
UV_EXTERN int uv_ip6_name (const struct sockaddr_in6 *src, char *dst, size_t size)
 
UV_EXTERN int uv_inet_ntop (int af, const void *src, char *dst, size_t size)
 
UV_EXTERN int uv_inet_pton (int af, const char *src, void *dst)
 
UV_EXTERN int uv_random (uv_loop_t *loop, uv_random_t *req, void *buf, size_t buflen, unsigned flags, uv_random_cb cb)
 
UV_EXTERN int uv_if_indextoname (unsigned int ifindex, char *buffer, size_t *size)
 
UV_EXTERN int uv_if_indextoiid (unsigned int ifindex, char *buffer, size_t *size)
 
UV_EXTERN int uv_exepath (char *buffer, size_t *size)
 
UV_EXTERN int uv_cwd (char *buffer, size_t *size)
 
UV_EXTERN int uv_chdir (const char *dir)
 
UV_EXTERN uint64_t uv_get_free_memory (void)
 
UV_EXTERN uint64_t uv_get_total_memory (void)
 
UV_EXTERN uint64_t uv_get_constrained_memory (void)
 
UV_EXTERN uint64_t uv_hrtime (void)
 
UV_EXTERN void uv_sleep (unsigned int msec)
 
UV_EXTERN void uv_disable_stdio_inheritance (void)
 
UV_EXTERN int uv_dlopen (const char *filename, uv_lib_t *lib)
 
UV_EXTERN void uv_dlclose (uv_lib_t *lib)
 
UV_EXTERN int uv_dlsym (uv_lib_t *lib, const char *name, void **ptr)
 
UV_EXTERN const char * uv_dlerror (const uv_lib_t *lib)
 
UV_EXTERN int uv_mutex_init (uv_mutex_t *handle)
 
UV_EXTERN int uv_mutex_init_recursive (uv_mutex_t *handle)
 
UV_EXTERN void uv_mutex_destroy (uv_mutex_t *handle)
 
UV_EXTERN void uv_mutex_lock (uv_mutex_t *handle)
 
UV_EXTERN int uv_mutex_trylock (uv_mutex_t *handle)
 
UV_EXTERN void uv_mutex_unlock (uv_mutex_t *handle)
 
UV_EXTERN int uv_rwlock_init (uv_rwlock_t *rwlock)
 
UV_EXTERN void uv_rwlock_destroy (uv_rwlock_t *rwlock)
 
UV_EXTERN void uv_rwlock_rdlock (uv_rwlock_t *rwlock)
 
UV_EXTERN int uv_rwlock_tryrdlock (uv_rwlock_t *rwlock)
 
UV_EXTERN void uv_rwlock_rdunlock (uv_rwlock_t *rwlock)
 
UV_EXTERN void uv_rwlock_wrlock (uv_rwlock_t *rwlock)
 
UV_EXTERN int uv_rwlock_trywrlock (uv_rwlock_t *rwlock)
 
UV_EXTERN void uv_rwlock_wrunlock (uv_rwlock_t *rwlock)
 
UV_EXTERN int uv_sem_init (uv_sem_t *sem, unsigned int value)
 
UV_EXTERN void uv_sem_destroy (uv_sem_t *sem)
 
UV_EXTERN void uv_sem_post (uv_sem_t *sem)
 
UV_EXTERN void uv_sem_wait (uv_sem_t *sem)
 
UV_EXTERN int uv_sem_trywait (uv_sem_t *sem)
 
UV_EXTERN int uv_cond_init (uv_cond_t *cond)
 
UV_EXTERN void uv_cond_destroy (uv_cond_t *cond)
 
UV_EXTERN void uv_cond_signal (uv_cond_t *cond)
 
UV_EXTERN void uv_cond_broadcast (uv_cond_t *cond)
 
UV_EXTERN int uv_barrier_init (uv_barrier_t *barrier, unsigned int count)
 
UV_EXTERN void uv_barrier_destroy (uv_barrier_t *barrier)
 
UV_EXTERN int uv_barrier_wait (uv_barrier_t *barrier)
 
UV_EXTERN void uv_cond_wait (uv_cond_t *cond, uv_mutex_t *mutex)
 
UV_EXTERN int uv_cond_timedwait (uv_cond_t *cond, uv_mutex_t *mutex, uint64_t timeout)
 
UV_EXTERN void uv_once (uv_once_t *guard, void(*callback)(void))
 
UV_EXTERN int uv_key_create (uv_key_t *key)
 
UV_EXTERN void uv_key_delete (uv_key_t *key)
 
UV_EXTERN void * uv_key_get (uv_key_t *key)
 
UV_EXTERN void uv_key_set (uv_key_t *key, void *value)
 
UV_EXTERN int uv_gettimeofday (uv_timeval64_t *tv)
 
UV_EXTERN int uv_thread_create (uv_thread_t *tid, uv_thread_cb entry, void *arg)
 
UV_EXTERN int uv_thread_create_ex (uv_thread_t *tid, const uv_thread_options_t *params, uv_thread_cb entry, void *arg)
 
UV_EXTERN uv_thread_t uv_thread_self (void)
 
UV_EXTERN int uv_thread_join (uv_thread_t *tid)
 
UV_EXTERN int uv_thread_equal (const uv_thread_t *t1, const uv_thread_t *t2)
 
UV_EXTERN void * uv_loop_get_data (const uv_loop_t *)
 
UV_EXTERN void uv_loop_set_data (uv_loop_t *, void *data)
 

Macro Definition Documentation

◆ UV_ERRNO_MAP

#define UV_ERRNO_MAP (   XX)

Definition at line 70 of file uv.h.

◆ UV_EXTERN

#define UV_EXTERN   /* nothing */

Definition at line 49 of file uv.h.

◆ UV_FS_COPYFILE_EXCL

#define UV_FS_COPYFILE_EXCL   0x0001

Definition at line 1358 of file uv.h.

◆ UV_FS_COPYFILE_FICLONE

#define UV_FS_COPYFILE_FICLONE   0x0002

Definition at line 1364 of file uv.h.

◆ UV_FS_COPYFILE_FICLONE_FORCE

#define UV_FS_COPYFILE_FICLONE_FORCE   0x0004

Definition at line 1370 of file uv.h.

◆ UV_FS_SYMLINK_DIR

#define UV_FS_SYMLINK_DIR   0x0001

Definition at line 1489 of file uv.h.

◆ UV_FS_SYMLINK_JUNCTION

#define UV_FS_SYMLINK_JUNCTION   0x0002

Definition at line 1495 of file uv.h.

◆ UV_HANDLE_FIELDS

#define UV_HANDLE_FIELDS
Value:
/* public */ \
void* data; \
/* read-only */ \
uv_loop_t* loop; \
uv_handle_type type; \
/* private */ \
uv_close_cb close_cb; \
void* handle_queue[2]; \
union { \
int fd; \
void* reserved[4]; \
} u; \
UV_HANDLE_PRIVATE_FIELDS \
@ reserved
Definition: lm32_isa.h:94
int type
Definition: mipsasm.c:17
uv_loop_t * loop
Definition: main.c:7
static const z80_opcode fd[]
Definition: z80_tab.h:997

Definition at line 428 of file uv.h.

◆ UV_HANDLE_TYPE_MAP

#define UV_HANDLE_TYPE_MAP (   XX)
Value:
XX(ASYNC, async) \
XX(CHECK, check) \
XX(FS_EVENT, fs_event) \
XX(FS_POLL, fs_poll) \
XX(HANDLE, handle) \
XX(IDLE, idle) \
XX(NAMED_PIPE, pipe) \
XX(POLL, poll) \
XX(PREPARE, prepare) \
XX(PROCESS, process) \
XX(STREAM, stream) \
XX(TCP, tcp) \
XX(TIMER, timer) \
XX(TTY, tty) \
XX(UDP, udp) \
XX(SIGNAL, signal) \
static mcore_handle handle
Definition: asm_mcore.c:8
lzma_check check
Definition: container.h:292
@ CHECK
Definition: inflate.h:47
voidpf stream
Definition: ioapi.h:138
static const char struct stat static buf struct stat static buf static vhangup int struct rusage static rusage struct sysinfo static info unsigned static __unused struct utsname static buf const char static size const char static name static pid unsigned static persona static fsgid const void static flags const struct iovec static count static fd const void static len static munlockall struct sched_param static p static sched_yield static policy const struct timespec struct timespec static rem uid_t uid_t uid_t static suid poll
Definition: sflib.h:196
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment signal
Definition: sflib.h:79
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname pipe
Definition: sflib.h:73
uv_async_t async
Definition: main.c:8
uv_tty_t tty
Definition: main.c:7
#define XX(code, _)
Definition: uv.h:1769
DWORD * HANDLE
static zip_compression_status_t process(void *ud, zip_uint8_t *data, zip_uint64_t *length)

Definition at line 152 of file uv.h.

◆ UV_IF_NAMESIZE

#define UV_IF_NAMESIZE   (16 + 1)

Definition at line 1668 of file uv.h.

◆ UV_MAXHOSTNAMESIZE

#define UV_MAXHOSTNAMESIZE   256

Definition at line 1248 of file uv.h.

◆ UV_PRIORITY_ABOVE_NORMAL

#define UV_PRIORITY_ABOVE_NORMAL   -7

Definition at line 1213 of file uv.h.

◆ UV_PRIORITY_BELOW_NORMAL

#define UV_PRIORITY_BELOW_NORMAL   10

Definition at line 1211 of file uv.h.

◆ UV_PRIORITY_HIGH

#define UV_PRIORITY_HIGH   -14

Definition at line 1214 of file uv.h.

◆ UV_PRIORITY_HIGHEST

#define UV_PRIORITY_HIGHEST   -20

Definition at line 1215 of file uv.h.

◆ UV_PRIORITY_LOW

#define UV_PRIORITY_LOW   19

Definition at line 1210 of file uv.h.

◆ UV_PRIORITY_NORMAL

#define UV_PRIORITY_NORMAL   0

Definition at line 1212 of file uv.h.

◆ UV_REQ_FIELDS

#define UV_REQ_FIELDS
Value:
/* public */ \
void* data; \
/* read-only */ \
uv_req_type type; \
/* private */ \
void* reserved[6]; \
UV_REQ_PRIVATE_FIELDS \

Definition at line 397 of file uv.h.

◆ UV_REQ_TYPE_MAP

#define UV_REQ_TYPE_MAP (   XX)
Value:
XX(REQ, req) \
XX(CONNECT, connect) \
XX(WRITE, write) \
XX(SHUTDOWN, shutdown) \
XX(UDP_SEND, udp_send) \
XX(FS, fs) \
XX(WORK, work) \
XX(GETADDRINFO, getaddrinfo) \
XX(GETNAMEINFO, getnameinfo) \
XX(RANDOM, random) \
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec req
Definition: sflib.h:128
static static fork write
Definition: sflib.h:33

Definition at line 170 of file uv.h.

◆ UV_STREAM_FIELDS

#define UV_STREAM_FIELDS
Value:
/* number of bytes queued for writing */ \
size_t write_queue_size; \
uv_alloc_cb alloc_cb; \
uv_read_cb read_cb; \
/* private */ \
UV_STREAM_PRIVATE_FIELDS

Definition at line 479 of file uv.h.

◆ XX [1/4]

#define XX (   _,
  name 
)    uv_ ## name ## _t name;

Definition at line 1769 of file uv.h.

◆ XX [2/4]

#define XX (   code,
  _ 
)    UV_ ## code = UV__ ## code,

Definition at line 1769 of file uv.h.

◆ XX [3/4]

#define XX (   uc,
  lc 
)    UV_##uc,

Definition at line 1769 of file uv.h.

◆ XX [4/4]

#define XX (   uc,
  lc 
)    UV_##uc,

Definition at line 1769 of file uv.h.

Typedef Documentation

◆ uv_after_work_cb

typedef void(* uv_after_work_cb) (uv_work_t *req, int status)

Definition at line 330 of file uv.h.

◆ uv_alloc_cb

typedef void(* uv_alloc_cb) (uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf)

Definition at line 309 of file uv.h.

◆ uv_async_cb

typedef void(* uv_async_cb) (uv_async_t *handle)

Definition at line 322 of file uv.h.

◆ uv_async_t

typedef struct uv_async_s uv_async_t

Definition at line 1 of file uv.h.

◆ uv_calloc_func

typedef void*(* uv_calloc_func) (size_t count, size_t size)

Definition at line 266 of file uv.h.

◆ uv_check_cb

typedef void(* uv_check_cb) (uv_check_t *handle)

Definition at line 324 of file uv.h.

◆ uv_check_t

typedef struct uv_check_s uv_check_t

Definition at line 1 of file uv.h.

◆ uv_close_cb

typedef void(* uv_close_cb) (uv_handle_t *handle)

Definition at line 319 of file uv.h.

◆ uv_connect_cb

typedef void(* uv_connect_cb) (uv_connect_t *req, int status)

Definition at line 316 of file uv.h.

◆ uv_connect_t

typedef struct uv_connect_s uv_connect_t

Definition at line 1 of file uv.h.

◆ uv_connection_cb

typedef void(* uv_connection_cb) (uv_stream_t *server, int status)

Definition at line 318 of file uv.h.

◆ uv_cpu_info_t

typedef struct uv_cpu_info_s uv_cpu_info_t

Definition at line 1 of file uv.h.

◆ uv_dir_t

typedef struct uv_dir_s uv_dir_t

Definition at line 1 of file uv.h.

◆ uv_dirent_t

typedef struct uv_dirent_s uv_dirent_t

Definition at line 1 of file uv.h.

◆ uv_env_item_t

typedef struct uv_env_item_s uv_env_item_t

Definition at line 1 of file uv.h.

◆ uv_exit_cb

typedef void(* uv_exit_cb) (uv_process_t *, int64_t exit_status, int term_signal)

Definition at line 326 of file uv.h.

◆ uv_free_func

typedef void(* uv_free_func) (void *ptr)

Definition at line 267 of file uv.h.

◆ uv_fs_cb

typedef void(* uv_fs_cb) (uv_fs_t *req)

Definition at line 328 of file uv.h.

◆ uv_fs_event_cb

typedef void(* uv_fs_event_cb) (uv_fs_event_t *handle, const char *filename, int events, int status)

Definition at line 369 of file uv.h.

◆ uv_fs_event_t

typedef struct uv_fs_event_s uv_fs_event_t

Definition at line 1 of file uv.h.

◆ uv_fs_poll_cb

typedef void(* uv_fs_poll_cb) (uv_fs_poll_t *handle, int status, const uv_stat_t *prev, const uv_stat_t *curr)

Definition at line 374 of file uv.h.

◆ uv_fs_poll_t

typedef struct uv_fs_poll_s uv_fs_poll_t

Definition at line 1 of file uv.h.

◆ uv_fs_t

typedef struct uv_fs_s uv_fs_t

Definition at line 1 of file uv.h.

◆ uv_getaddrinfo_cb

typedef void(* uv_getaddrinfo_cb) (uv_getaddrinfo_t *req, int status, struct addrinfo *res)

Definition at line 331 of file uv.h.

◆ uv_getaddrinfo_t

Definition at line 1 of file uv.h.

◆ uv_getnameinfo_cb

typedef void(* uv_getnameinfo_cb) (uv_getnameinfo_t *req, int status, const char *hostname, const char *service)

Definition at line 334 of file uv.h.

◆ uv_getnameinfo_t

Definition at line 1 of file uv.h.

◆ uv_handle_t

typedef struct uv_handle_s uv_handle_t

Definition at line 1 of file uv.h.

◆ uv_idle_cb

typedef void(* uv_idle_cb) (uv_idle_t *handle)

Definition at line 325 of file uv.h.

◆ uv_idle_t

typedef struct uv_idle_s uv_idle_t

Definition at line 1 of file uv.h.

◆ uv_interface_address_t

Definition at line 1 of file uv.h.

◆ uv_loop_t

typedef struct uv_loop_s uv_loop_t

Definition at line 1 of file uv.h.

◆ uv_malloc_func

typedef void*(* uv_malloc_func) (size_t size)

Definition at line 264 of file uv.h.

◆ uv_passwd_t

typedef struct uv_passwd_s uv_passwd_t

Definition at line 1 of file uv.h.

◆ uv_pipe_t

typedef struct uv_pipe_s uv_pipe_t

Definition at line 1 of file uv.h.

◆ uv_poll_cb

typedef void(* uv_poll_cb) (uv_poll_t *handle, int status, int events)

Definition at line 320 of file uv.h.

◆ uv_poll_t

typedef struct uv_poll_s uv_poll_t

Definition at line 1 of file uv.h.

◆ uv_prepare_cb

typedef void(* uv_prepare_cb) (uv_prepare_t *handle)

Definition at line 323 of file uv.h.

◆ uv_prepare_t

typedef struct uv_prepare_s uv_prepare_t

Definition at line 1 of file uv.h.

◆ uv_process_options_t

◆ uv_process_t

typedef struct uv_process_s uv_process_t

Definition at line 1 of file uv.h.

◆ uv_random_cb

typedef void(* uv_random_cb) (uv_random_t *req, int status, void *buf, size_t buflen)

Definition at line 338 of file uv.h.

◆ uv_random_t

typedef struct uv_random_s uv_random_t

Definition at line 1 of file uv.h.

◆ uv_read_cb

typedef void(* uv_read_cb) (uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)

Definition at line 312 of file uv.h.

◆ uv_realloc_func

typedef void*(* uv_realloc_func) (void *ptr, size_t size)

Definition at line 265 of file uv.h.

◆ uv_req_t

typedef struct uv_req_s uv_req_t

Definition at line 1 of file uv.h.

◆ uv_shutdown_cb

typedef void(* uv_shutdown_cb) (uv_shutdown_t *req, int status)

Definition at line 317 of file uv.h.

◆ uv_shutdown_t

typedef struct uv_shutdown_s uv_shutdown_t

Definition at line 1 of file uv.h.

◆ uv_signal_cb

typedef void(* uv_signal_cb) (uv_signal_t *handle, int signum)

Definition at line 379 of file uv.h.

◆ uv_signal_t

typedef struct uv_signal_s uv_signal_t

Definition at line 1 of file uv.h.

◆ uv_statfs_t

typedef struct uv_statfs_s uv_statfs_t

Definition at line 1 of file uv.h.

◆ uv_stdio_container_t

◆ uv_stream_t

typedef struct uv_stream_s uv_stream_t

Definition at line 1 of file uv.h.

◆ uv_tcp_t

typedef struct uv_tcp_s uv_tcp_t

Definition at line 1 of file uv.h.

◆ uv_thread_cb

typedef void(* uv_thread_cb) (void *arg)

Definition at line 1743 of file uv.h.

◆ uv_thread_options_t

Definition at line 1745 of file uv.h.

◆ uv_timer_cb

typedef void(* uv_timer_cb) (uv_timer_t *handle)

Definition at line 321 of file uv.h.

◆ uv_timer_t

typedef struct uv_timer_s uv_timer_t

Definition at line 1 of file uv.h.

◆ uv_tty_t

typedef struct uv_tty_s uv_tty_t

Definition at line 1 of file uv.h.

◆ uv_udp_recv_cb

typedef void(* uv_udp_recv_cb) (uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags)

Definition at line 631 of file uv.h.

◆ uv_udp_send_cb

typedef void(* uv_udp_send_cb) (uv_udp_send_t *req, int status)

Definition at line 630 of file uv.h.

◆ uv_udp_send_t

typedef struct uv_udp_send_s uv_udp_send_t

Definition at line 1 of file uv.h.

◆ uv_udp_t

typedef struct uv_udp_s uv_udp_t

Definition at line 1 of file uv.h.

◆ uv_utsname_t

typedef struct uv_utsname_s uv_utsname_t

Definition at line 1 of file uv.h.

◆ uv_walk_cb

typedef void(* uv_walk_cb) (uv_handle_t *handle, void *arg)

Definition at line 327 of file uv.h.

◆ uv_work_cb

typedef void(* uv_work_cb) (uv_work_t *req)

Definition at line 329 of file uv.h.

◆ uv_work_t

typedef struct uv_work_s uv_work_t

Definition at line 1 of file uv.h.

◆ uv_write_cb

typedef void(* uv_write_cb) (uv_write_t *req, int status)

Definition at line 315 of file uv.h.

◆ uv_write_t

typedef struct uv_write_s uv_write_t

Definition at line 1 of file uv.h.

Enumeration Type Documentation

◆ uv_dirent_type_t

Enumerator
UV_DIRENT_UNKNOWN 
UV_DIRENT_FILE 
UV_DIRENT_DIR 
UV_DIRENT_LINK 
UV_DIRENT_FIFO 
UV_DIRENT_SOCKET 
UV_DIRENT_CHAR 
UV_DIRENT_BLOCK 

Definition at line 1139 of file uv.h.

1139  {
1142  UV_DIRENT_DIR,
uv_dirent_type_t
Definition: uv.h:1139
@ UV_DIRENT_FIFO
Definition: uv.h:1144
@ UV_DIRENT_CHAR
Definition: uv.h:1146
@ UV_DIRENT_DIR
Definition: uv.h:1142
@ UV_DIRENT_UNKNOWN
Definition: uv.h:1140
@ UV_DIRENT_BLOCK
Definition: uv.h:1147
@ UV_DIRENT_LINK
Definition: uv.h:1143
@ UV_DIRENT_FILE
Definition: uv.h:1141
@ UV_DIRENT_SOCKET
Definition: uv.h:1145

◆ uv_errno_t

enum uv_errno_t
Enumerator
UV_ERRNO_MAX 

Definition at line 182 of file uv.h.

182  {
183 #define XX(code, _) UV_ ## code = UV__ ## code,
185 #undef XX
186  UV_ERRNO_MAX = UV__EOF - 1
187 } uv_errno_t;
#define UV__EOF
Definition: errno.h:32
#define UV_ERRNO_MAP(XX)
Definition: uv.h:70
uv_errno_t
Definition: uv.h:182
@ UV_ERRNO_MAX
Definition: uv.h:186

◆ uv_fs_event

Enumerator
UV_RENAME 
UV_CHANGE 

Definition at line 1540 of file uv.h.

1540  {
1541  UV_RENAME = 1,
1542  UV_CHANGE = 2
1543 };
@ UV_CHANGE
Definition: uv.h:1542
@ UV_RENAME
Definition: uv.h:1541

◆ uv_fs_event_flags

Enumerator
UV_FS_EVENT_WATCH_ENTRY 
UV_FS_EVENT_STAT 
UV_FS_EVENT_RECURSIVE 

Definition at line 1596 of file uv.h.

1596  {
1597  /*
1598  * By default, if the fs event watcher is given a directory name, we will
1599  * watch for all events in that directory. This flags overrides this behavior
1600  * and makes fs_event report only changes to the directory entry itself. This
1601  * flag does not affect individual files watched.
1602  * This flag is currently not implemented yet on any backend.
1603  */
1605 
1606  /*
1607  * By default uv_fs_event will try to use a kernel interface such as inotify
1608  * or kqueue to detect events. This may not work on remote filesystems such
1609  * as NFS mounts. This flag makes fs_event fall back to calling stat() on a
1610  * regular interval.
1611  * This flag is currently not implemented yet on any backend.
1612  */
1613  UV_FS_EVENT_STAT = 2,
1614 
1615  /*
1616  * By default, event watcher, when watching directory, is not registering
1617  * (is ignoring) changes in it's subdirectories.
1618  * This flag will override this behaviour on platforms that support it.
1619  */
1621 };
@ UV_FS_EVENT_RECURSIVE
Definition: uv.h:1620
@ UV_FS_EVENT_STAT
Definition: uv.h:1613
@ UV_FS_EVENT_WATCH_ENTRY
Definition: uv.h:1604

◆ uv_fs_type

enum uv_fs_type
Enumerator
UV_FS_UNKNOWN 
UV_FS_CUSTOM 
UV_FS_OPEN 
UV_FS_CLOSE 
UV_FS_READ 
UV_FS_WRITE 
UV_FS_SENDFILE 
UV_FS_STAT 
UV_FS_LSTAT 
UV_FS_FSTAT 
UV_FS_FTRUNCATE 
UV_FS_UTIME 
UV_FS_FUTIME 
UV_FS_ACCESS 
UV_FS_CHMOD 
UV_FS_FCHMOD 
UV_FS_FSYNC 
UV_FS_FDATASYNC 
UV_FS_UNLINK 
UV_FS_RMDIR 
UV_FS_MKDIR 
UV_FS_MKDTEMP 
UV_FS_RENAME 
UV_FS_SCANDIR 
UV_FS_LINK 
UV_FS_SYMLINK 
UV_FS_READLINK 
UV_FS_CHOWN 
UV_FS_FCHOWN 
UV_FS_REALPATH 
UV_FS_COPYFILE 
UV_FS_LCHOWN 
UV_FS_OPENDIR 
UV_FS_READDIR 
UV_FS_CLOSEDIR 
UV_FS_STATFS 
UV_FS_MKSTEMP 
UV_FS_LUTIME 

Definition at line 1257 of file uv.h.

1257  {
1258  UV_FS_UNKNOWN = -1,
1259  UV_FS_CUSTOM,
1260  UV_FS_OPEN,
1261  UV_FS_CLOSE,
1262  UV_FS_READ,
1263  UV_FS_WRITE,
1265  UV_FS_STAT,
1266  UV_FS_LSTAT,
1267  UV_FS_FSTAT,
1269  UV_FS_UTIME,
1270  UV_FS_FUTIME,
1271  UV_FS_ACCESS,
1272  UV_FS_CHMOD,
1273  UV_FS_FCHMOD,
1274  UV_FS_FSYNC,
1276  UV_FS_UNLINK,
1277  UV_FS_RMDIR,
1278  UV_FS_MKDIR,
1279  UV_FS_MKDTEMP,
1280  UV_FS_RENAME,
1281  UV_FS_SCANDIR,
1282  UV_FS_LINK,
1283  UV_FS_SYMLINK,
1285  UV_FS_CHOWN,
1286  UV_FS_FCHOWN,
1289  UV_FS_LCHOWN,
1290  UV_FS_OPENDIR,
1291  UV_FS_READDIR,
1293  UV_FS_STATFS,
1294  UV_FS_MKSTEMP,
1295  UV_FS_LUTIME
1296 } uv_fs_type;
uv_fs_type
Definition: uv.h:1257
@ UV_FS_STATFS
Definition: uv.h:1293
@ UV_FS_CUSTOM
Definition: uv.h:1259
@ UV_FS_SYMLINK
Definition: uv.h:1283
@ UV_FS_FDATASYNC
Definition: uv.h:1275
@ UV_FS_FCHMOD
Definition: uv.h:1273
@ UV_FS_SCANDIR
Definition: uv.h:1281
@ UV_FS_FTRUNCATE
Definition: uv.h:1268
@ UV_FS_READDIR
Definition: uv.h:1291
@ UV_FS_SENDFILE
Definition: uv.h:1264
@ UV_FS_OPENDIR
Definition: uv.h:1290
@ UV_FS_RENAME
Definition: uv.h:1280
@ UV_FS_READLINK
Definition: uv.h:1284
@ UV_FS_LUTIME
Definition: uv.h:1295
@ UV_FS_STAT
Definition: uv.h:1265
@ UV_FS_CHOWN
Definition: uv.h:1285
@ UV_FS_FUTIME
Definition: uv.h:1270
@ UV_FS_CHMOD
Definition: uv.h:1272
@ UV_FS_REALPATH
Definition: uv.h:1287
@ UV_FS_UNKNOWN
Definition: uv.h:1258
@ UV_FS_UNLINK
Definition: uv.h:1276
@ UV_FS_MKSTEMP
Definition: uv.h:1294
@ UV_FS_RMDIR
Definition: uv.h:1277
@ UV_FS_CLOSEDIR
Definition: uv.h:1292
@ UV_FS_MKDTEMP
Definition: uv.h:1279
@ UV_FS_CLOSE
Definition: uv.h:1261
@ UV_FS_FSYNC
Definition: uv.h:1274
@ UV_FS_FCHOWN
Definition: uv.h:1286
@ UV_FS_READ
Definition: uv.h:1262
@ UV_FS_COPYFILE
Definition: uv.h:1288
@ UV_FS_MKDIR
Definition: uv.h:1278
@ UV_FS_UTIME
Definition: uv.h:1269
@ UV_FS_ACCESS
Definition: uv.h:1271
@ UV_FS_FSTAT
Definition: uv.h:1267
@ UV_FS_LCHOWN
Definition: uv.h:1289
@ UV_FS_LSTAT
Definition: uv.h:1266
@ UV_FS_OPEN
Definition: uv.h:1260
@ UV_FS_WRITE
Definition: uv.h:1263
@ UV_FS_LINK
Definition: uv.h:1282

◆ uv_handle_type

Enumerator
UV_UNKNOWN_HANDLE 
UV_FILE 
UV_HANDLE_TYPE_MAX 

Definition at line 189 of file uv.h.

189  {
190  UV_UNKNOWN_HANDLE = 0,
191 #define XX(uc, lc) UV_##uc,
193 #undef XX
194  UV_FILE,
uv_handle_type
Definition: uv.h:189
@ UV_FILE
Definition: uv.h:194
@ UV_HANDLE_TYPE_MAX
Definition: uv.h:195
@ UV_UNKNOWN_HANDLE
Definition: uv.h:190
#define UV_HANDLE_TYPE_MAP(XX)
Definition: uv.h:152

◆ uv_loop_option

Enumerator
UV_LOOP_BLOCK_SIGNAL 
UV_METRICS_IDLE_TIME 

Definition at line 249 of file uv.h.

249  {
uv_loop_option
Definition: uv.h:249
@ UV_LOOP_BLOCK_SIGNAL
Definition: uv.h:250
@ UV_METRICS_IDLE_TIME
Definition: uv.h:251

◆ uv_membership

Enumerator
UV_LEAVE_GROUP 
UV_JOIN_GROUP 

Definition at line 382 of file uv.h.

382  {
383  UV_LEAVE_GROUP = 0,
385 } uv_membership;
uv_membership
Definition: uv.h:382
@ UV_JOIN_GROUP
Definition: uv.h:384
@ UV_LEAVE_GROUP
Definition: uv.h:383

◆ uv_poll_event

Enumerator
UV_READABLE 
UV_WRITABLE 
UV_DISCONNECT 
UV_PRIORITIZED 

Definition at line 799 of file uv.h.

799  {
800  UV_READABLE = 1,
801  UV_WRITABLE = 2,
802  UV_DISCONNECT = 4,
803  UV_PRIORITIZED = 8
804 };
@ UV_WRITABLE
Definition: uv.h:801
@ UV_DISCONNECT
Definition: uv.h:802
@ UV_PRIORITIZED
Definition: uv.h:803
@ UV_READABLE
Definition: uv.h:800

◆ uv_process_flags

Enumerator
UV_PROCESS_SETUID 
UV_PROCESS_SETGID 
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS 
UV_PROCESS_DETACHED 
UV_PROCESS_WINDOWS_HIDE 
UV_PROCESS_WINDOWS_HIDE_CONSOLE 
UV_PROCESS_WINDOWS_HIDE_GUI 

Definition at line 999 of file uv.h.

999  {
1000  /*
1001  * Set the child process' user id. The user id is supplied in the `uid` field
1002  * of the options struct. This does not work on windows; setting this flag
1003  * will cause uv_spawn() to fail.
1004  */
1005  UV_PROCESS_SETUID = (1 << 0),
1006  /*
1007  * Set the child process' group id. The user id is supplied in the `gid`
1008  * field of the options struct. This does not work on windows; setting this
1009  * flag will cause uv_spawn() to fail.
1010  */
1011  UV_PROCESS_SETGID = (1 << 1),
1012  /*
1013  * Do not wrap any arguments in quotes, or perform any other escaping, when
1014  * converting the argument list into a command line string. This option is
1015  * only meaningful on Windows systems. On Unix it is silently ignored.
1016  */
1018  /*
1019  * Spawn the child process in a detached state - this will make it a process
1020  * group leader, and will effectively enable the child to keep running after
1021  * the parent exits. Note that the child process will still keep the
1022  * parent's event loop alive unless the parent process calls uv_unref() on
1023  * the child's process handle.
1024  */
1025  UV_PROCESS_DETACHED = (1 << 3),
1026  /*
1027  * Hide the subprocess window that would normally be created. This option is
1028  * only meaningful on Windows systems. On Unix it is silently ignored.
1029  */
1030  UV_PROCESS_WINDOWS_HIDE = (1 << 4),
1031  /*
1032  * Hide the subprocess console window that would normally be created. This
1033  * option is only meaningful on Windows systems. On Unix it is silently
1034  * ignored.
1035  */
1037  /*
1038  * Hide the subprocess GUI window that would normally be created. This
1039  * option is only meaningful on Windows systems. On Unix it is silently
1040  * ignored.
1041  */
1042  UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6)
1043 };
@ UV_PROCESS_WINDOWS_HIDE_CONSOLE
Definition: uv.h:1036
@ UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS
Definition: uv.h:1017
@ UV_PROCESS_WINDOWS_HIDE
Definition: uv.h:1030
@ UV_PROCESS_SETUID
Definition: uv.h:1005
@ UV_PROCESS_SETGID
Definition: uv.h:1011
@ UV_PROCESS_DETACHED
Definition: uv.h:1025
@ UV_PROCESS_WINDOWS_HIDE_GUI
Definition: uv.h:1042

◆ uv_req_type

Enumerator
UV_UNKNOWN_REQ 
UV_REQ_TYPE_MAX 

Definition at line 198 of file uv.h.

198  {
199  UV_UNKNOWN_REQ = 0,
200 #define XX(uc, lc) UV_##uc,
202 #undef XX
205 } uv_req_type;
#define UV_REQ_TYPE_PRIVATE
Definition: unix.h:256
#define UV_REQ_TYPE_MAP(XX)
Definition: uv.h:170
uv_req_type
Definition: uv.h:198
@ UV_REQ_TYPE_MAX
Definition: uv.h:204
@ UV_UNKNOWN_REQ
Definition: uv.h:199

◆ uv_run_mode

Enumerator
UV_RUN_DEFAULT 
UV_RUN_ONCE 
UV_RUN_NOWAIT 

Definition at line 254 of file uv.h.

254  {
255  UV_RUN_DEFAULT = 0,
256  UV_RUN_ONCE,
258 } uv_run_mode;
uv_run_mode
Definition: uv.h:254
@ UV_RUN_NOWAIT
Definition: uv.h:257
@ UV_RUN_ONCE
Definition: uv.h:256
@ UV_RUN_DEFAULT
Definition: uv.h:255

◆ uv_stdio_flags

Enumerator
UV_IGNORE 
UV_CREATE_PIPE 
UV_INHERIT_FD 
UV_INHERIT_STREAM 
UV_READABLE_PIPE 
UV_WRITABLE_PIPE 
UV_OVERLAPPED_PIPE 

Definition at line 921 of file uv.h.

921  {
922  UV_IGNORE = 0x00,
923  UV_CREATE_PIPE = 0x01,
924  UV_INHERIT_FD = 0x02,
925  UV_INHERIT_STREAM = 0x04,
926 
927  /*
928  * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE
929  * determine the direction of flow, from the child process' perspective. Both
930  * flags may be specified to create a duplex data stream.
931  */
932  UV_READABLE_PIPE = 0x10,
933  UV_WRITABLE_PIPE = 0x20,
934 
935  /*
936  * Open the child pipe handle in overlapped mode on Windows.
937  * On Unix it is silently ignored.
938  */
939  UV_OVERLAPPED_PIPE = 0x40
uv_stdio_flags
Definition: uv.h:921
@ UV_INHERIT_FD
Definition: uv.h:924
@ UV_CREATE_PIPE
Definition: uv.h:923
@ UV_WRITABLE_PIPE
Definition: uv.h:933
@ UV_IGNORE
Definition: uv.h:922
@ UV_OVERLAPPED_PIPE
Definition: uv.h:939
@ UV_INHERIT_STREAM
Definition: uv.h:925
@ UV_READABLE_PIPE
Definition: uv.h:932

◆ uv_tcp_flags

Enumerator
UV_TCP_IPV6ONLY 

Definition at line 562 of file uv.h.

562  {
563  /* Used with uv_tcp_bind, when an IPv6 address is used. */
564  UV_TCP_IPV6ONLY = 1
565 };
@ UV_TCP_IPV6ONLY
Definition: uv.h:564

◆ uv_thread_create_flags

Enumerator
UV_THREAD_NO_FLAGS 
UV_THREAD_HAS_STACK_SIZE 

Definition at line 1747 of file uv.h.

1747  {
1748  UV_THREAD_NO_FLAGS = 0x00,
uv_thread_create_flags
Definition: uv.h:1747
@ UV_THREAD_HAS_STACK_SIZE
Definition: uv.h:1749
@ UV_THREAD_NO_FLAGS
Definition: uv.h:1748

◆ uv_tty_mode_t

Enumerator
UV_TTY_MODE_NORMAL 
UV_TTY_MODE_RAW 
UV_TTY_MODE_IO 

Definition at line 720 of file uv.h.

720  {
721  /* Initial/normal terminal mode */
723  /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */
725  /* Binary-safe I/O mode for IPC (Unix-only) */
727 } uv_tty_mode_t;
uv_tty_mode_t
Definition: uv.h:720
@ UV_TTY_MODE_IO
Definition: uv.h:726
@ UV_TTY_MODE_NORMAL
Definition: uv.h:722
@ UV_TTY_MODE_RAW
Definition: uv.h:724

◆ uv_tty_vtermstate_t

Enumerator
UV_TTY_SUPPORTED 
UV_TTY_UNSUPPORTED 

Definition at line 729 of file uv.h.

729  {
730  /*
731  * The console supports handling of virtual terminal sequences
732  * (Windows10 new console, ConEmu)
733  */
735  /* The console cannot process the virtual terminal sequence. (Legacy
736  * console)
737  */
uv_tty_vtermstate_t
Definition: uv.h:729
@ UV_TTY_UNSUPPORTED
Definition: uv.h:738
@ UV_TTY_SUPPORTED
Definition: uv.h:734

◆ uv_udp_flags

Enumerator
UV_UDP_IPV6ONLY 
UV_UDP_PARTIAL 
UV_UDP_REUSEADDR 
UV_UDP_MMSG_CHUNK 
UV_UDP_MMSG_FREE 
UV_UDP_RECVMMSG 

Definition at line 595 of file uv.h.

595  {
596  /* Disables dual stack mode. */
597  UV_UDP_IPV6ONLY = 1,
598  /*
599  * Indicates message was truncated because read buffer was too small. The
600  * remainder was discarded by the OS. Used in uv_udp_recv_cb.
601  */
602  UV_UDP_PARTIAL = 2,
603  /*
604  * Indicates if SO_REUSEADDR will be set when binding the handle.
605  * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other
606  * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that
607  * multiple threads or processes can bind to the same address without error
608  * (provided they all set the flag) but only the last one to bind will receive
609  * any traffic, in effect "stealing" the port from the previous listener.
610  */
611  UV_UDP_REUSEADDR = 4,
612  /*
613  * Indicates that the message was received by recvmmsg, so the buffer provided
614  * must not be freed by the recv_cb callback.
615  */
616  UV_UDP_MMSG_CHUNK = 8,
617  /*
618  * Indicates that the buffer provided has been fully utilized by recvmmsg and
619  * that it should now be freed by the recv_cb callback. When this flag is set
620  * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL.
621  */
622  UV_UDP_MMSG_FREE = 16,
623 
624  /*
625  * Indicates that recvmmsg should be used, if available.
626  */
627  UV_UDP_RECVMMSG = 256
628 };
@ UV_UDP_PARTIAL
Definition: uv.h:602
@ UV_UDP_MMSG_FREE
Definition: uv.h:622
@ UV_UDP_MMSG_CHUNK
Definition: uv.h:616
@ UV_UDP_IPV6ONLY
Definition: uv.h:597
@ UV_UDP_RECVMMSG
Definition: uv.h:627
@ UV_UDP_REUSEADDR
Definition: uv.h:611

Function Documentation

◆ uv_accept()

UV_EXTERN int uv_accept ( uv_stream_t server,
uv_stream_t client 
)

Definition at line 591 of file stream.c.

591  {
592  int err;
593 
594  assert(server->loop == client->loop);
595 
596  if (server->accepted_fd == -1)
597  return UV_EAGAIN;
598 
599  switch (client->type) {
600  case UV_NAMED_PIPE:
601  case UV_TCP:
602  err = uv__stream_open(client,
603  server->accepted_fd,
605  if (err) {
606  /* TODO handle error */
607  uv__close(server->accepted_fd);
608  goto done;
609  }
610  break;
611 
612  case UV_UDP:
613  err = uv_udp_open((uv_udp_t*) client, server->accepted_fd);
614  if (err) {
615  uv__close(server->accepted_fd);
616  goto done;
617  }
618  break;
619 
620  default:
621  return UV_EINVAL;
622  }
623 
624  client->flags |= UV_HANDLE_BOUND;
625 
626 done:
627  /* Process queued fds */
628  if (server->queued_fds != NULL) {
629  uv__stream_queued_fds_t* queued_fds;
630 
631  queued_fds = server->queued_fds;
632 
633  /* Read first */
634  server->accepted_fd = queued_fds->fds[0];
635 
636  /* All read, free */
637  assert(queued_fds->offset > 0);
638  if (--queued_fds->offset == 0) {
639  uv__free(queued_fds);
640  server->queued_fds = NULL;
641  } else {
642  /* Shift rest */
643  memmove(queued_fds->fds,
644  queued_fds->fds + 1,
645  queued_fds->offset * sizeof(*queued_fds->fds));
646  }
647  } else {
648  server->accepted_fd = -1;
649  if (err == 0)
650  uv__io_start(server->loop, &server->io_watcher, POLLIN);
651  }
652  return err;
653 }
static bool err
Definition: armass.c:435
#define NULL
Definition: cris-opc.c:27
struct tab * done
Definition: enough.c:233
assert(limit<=UINT32_MAX/2)
unsigned int offset
Definition: internal.h:153
Definition: uv.h:638
void uv__io_start(uv_loop_t *loop, uv__io_t *w, unsigned int events)
Definition: core.c:882
int uv__close(int fd)
Definition: core.c:569
int uv__stream_open(uv_stream_t *stream, int fd, int flags)
Definition: stream.c:406
void uv__free(void *ptr)
Definition: uv-common.c:81
@ UV_HANDLE_WRITABLE
Definition: uv-common.h:93
@ UV_HANDLE_BOUND
Definition: uv-common.h:91
@ UV_HANDLE_READABLE
Definition: uv-common.h:92
UV_EXTERN int uv_udp_open(uv_udp_t *handle, uv_os_sock_t sock)
Definition: udp.c:991

References assert(), done, err, uv__stream_queued_fds_s::fds, NULL, uv__stream_queued_fds_s::offset, uv__close(), uv__free(), uv__io_start(), uv__stream_open(), UV_HANDLE_BOUND, UV_HANDLE_READABLE, UV_HANDLE_WRITABLE, uv_pipe_accept(), uv_tcp_accept(), uv_translate_sys_error(), and uv_udp_open().

Referenced by on_new_connection().

◆ uv_async_init()

UV_EXTERN int uv_async_init ( uv_loop_t loop,
uv_async_t async,
uv_async_cb  async_cb 
)

Definition at line 45 of file async.c.

45  {
46  int err;
47 
49  if (err)
50  return err;
51 
52  uv__handle_init(loop, (uv_handle_t*)handle, UV_ASYNC);
53  handle->async_cb = async_cb;
54  handle->pending = 0;
55 
56  QUEUE_INSERT_TAIL(&loop->async_handles, &handle->queue);
58 
59  return 0;
60 }
#define QUEUE_INSERT_TAIL(h, q)
Definition: queue.h:92
static int uv__async_start(uv_loop_t *loop)
Definition: async.c:202
#define uv__handle_init(loop_, h, type_)
Definition: uv-common.h:301
#define uv__handle_start(h)
Definition: uv-common.h:258

References err, handle, loop, QUEUE_INSERT_TAIL, req, uv__async_start(), uv__handle_init, uv__handle_start, and UV_REQ_INIT.

Referenced by main(), and uv_loop_init().

◆ uv_async_send()

UV_EXTERN int uv_async_send ( uv_async_t async)

Definition at line 63 of file async.c.

63  {
64  /* Do a cheap read first. */
65  if (ACCESS_ONCE(int, handle->pending) != 0)
66  return 0;
67 
68  /* Tell the other thread we're busy with the handle. */
69  if (cmpxchgi(&handle->pending, 0, 1) != 0)
70  return 0;
71 
72  /* Wake up the other thread's event loop. */
73  uv__async_send(handle->loop);
74 
75  /* Tell the other thread we're done. */
76  if (cmpxchgi(&handle->pending, 1, 2) != 1)
77  abort();
78 
79  return 0;
80 }
#define ACCESS_ONCE(type, var)
Definition: internal.h:79
static void uv__async_send(uv_loop_t *loop)
Definition: async.c:168

References ACCESS_ONCE, assert(), handle, loop, POST_COMPLETION_FOR_REQ, uv__async_send(), uv__atomic_exchange_set(), and UV_HANDLE_CLOSING.

Referenced by fake_download(), uv__work_cancel(), and worker().

◆ uv_backend_fd()

UV_EXTERN int uv_backend_fd ( const uv_loop_t loop)

Definition at line 328 of file core.c.

328  {
329  return loop->backend_fd;
330 }

References loop.

◆ uv_backend_timeout()

UV_EXTERN int uv_backend_timeout ( const uv_loop_t loop)

Definition at line 333 of file core.c.

333  {
334  if (loop->stop_flag != 0)
335  return 0;
336 
338  return 0;
339 
340  if (!QUEUE_EMPTY(&loop->idle_handles))
341  return 0;
342 
343  if (!QUEUE_EMPTY(&loop->pending_queue))
344  return 0;
345 
346  if (loop->closing_handles)
347  return 0;
348 
349  return uv__next_timeout(loop);
350 }
#define QUEUE_EMPTY(q)
Definition: queue.h:39
unsigned int stop_flag
Definition: uv.h:1793
int uv__next_timeout(const uv_loop_t *loop)
Definition: timer.c:141
#define uv__has_active_handles(loop)
Definition: uv-common.h:237
#define uv__has_active_reqs(loop)
Definition: uv-common.h:221

References loop, QUEUE_EMPTY, uv_loop_s::stop_flag, uv__has_active_handles, uv__has_active_reqs, and uv__next_timeout().

Referenced by uv_run().

◆ uv_barrier_destroy()

UV_EXTERN void uv_barrier_destroy ( uv_barrier_t barrier)

Definition at line 118 of file thread.c.

118  {
119  struct _uv_barrier* b;
120 
121  b = barrier->b;
122  uv_mutex_lock(&b->mutex);
123 
124  assert(b->in == 0);
125  assert(b->out == 0);
126 
127  if (b->in != 0 || b->out != 0)
128  abort();
129 
130  uv_mutex_unlock(&b->mutex);
131  uv_mutex_destroy(&b->mutex);
132  uv_cond_destroy(&b->cond);
133 
134  uv__free(barrier->b);
135  barrier->b = NULL;
136 }
#define b(i)
Definition: sha256.c:42
struct _uv_barrier * b
Definition: unix.h:157
void uv_mutex_unlock(uv_mutex_t *mutex)
Definition: thread.c:350
void uv_mutex_destroy(uv_mutex_t *mutex)
Definition: thread.c:324
void uv_cond_destroy(uv_cond_t *cond)
Definition: thread.c:735
void uv_mutex_lock(uv_mutex_t *mutex)
Definition: thread.c:330

References assert(), uv_barrier_t::b, b, uv_barrier_t::mutex, NULL, uv_barrier_t::turnstile1, uv_barrier_t::turnstile2, uv__free(), uv_cond_destroy(), uv_mutex_destroy(), uv_mutex_lock(), uv_mutex_unlock(), and uv_sem_destroy().

Referenced by main().

◆ uv_barrier_init()

UV_EXTERN int uv_barrier_init ( uv_barrier_t barrier,
unsigned int  count 
)

Definition at line 55 of file thread.c.

55  {
56  struct _uv_barrier* b;
57  int rc;
58 
59  if (barrier == NULL || count == 0)
60  return UV_EINVAL;
61 
62  b = uv__malloc(sizeof(*b));
63  if (b == NULL)
64  return UV_ENOMEM;
65 
66  b->in = 0;
67  b->out = 0;
68  b->threshold = count;
69 
70  rc = uv_mutex_init(&b->mutex);
71  if (rc != 0)
72  goto error2;
73 
74  rc = uv_cond_init(&b->cond);
75  if (rc != 0)
76  goto error;
77 
78  barrier->b = b;
79  return 0;
80 
81 error:
82  uv_mutex_destroy(&b->mutex);
83 error2:
84  uv__free(b);
85  return rc;
86 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
int uv_cond_init(uv_cond_t *cond)
Definition: thread.c:704
int uv_mutex_init(uv_mutex_t *mutex)
Definition: thread.c:282
void error(const char *msg)
Definition: untgz.c:593
void * uv__malloc(size_t size)
Definition: uv-common.c:75

References uv_barrier_t::b, b, count, uv_barrier_t::count, err, error(), uv_barrier_t::mutex, uv_barrier_t::n, NULL, uv_barrier_t::turnstile1, uv_barrier_t::turnstile2, uv__free(), uv__malloc(), uv_cond_init(), uv_mutex_destroy(), uv_mutex_init(), uv_sem_destroy(), and uv_sem_init().

Referenced by main().

◆ uv_barrier_wait()

UV_EXTERN int uv_barrier_wait ( uv_barrier_t barrier)

Definition at line 89 of file thread.c.

89  {
90  struct _uv_barrier* b;
91  int last;
92 
93  if (barrier == NULL || barrier->b == NULL)
94  return UV_EINVAL;
95 
96  b = barrier->b;
97  uv_mutex_lock(&b->mutex);
98 
99  if (++b->in == b->threshold) {
100  b->in = 0;
101  b->out = b->threshold;
102  uv_cond_signal(&b->cond);
103  } else {
104  do
105  uv_cond_wait(&b->cond, &b->mutex);
106  while (b->in != 0);
107  }
108 
109  last = (--b->out == 0);
110  if (!last)
111  uv_cond_signal(&b->cond); /* Not needed for last thread. */
112 
113  uv_mutex_unlock(&b->mutex);
114  return last;
115 }
void uv_cond_signal(uv_cond_t *cond)
Definition: thread.c:769
void uv_cond_wait(uv_cond_t *cond, uv_mutex_t *mutex)
Definition: thread.c:779

References uv_barrier_t::b, b, uv_barrier_t::count, uv_barrier_t::mutex, uv_barrier_t::n, NULL, uv_barrier_t::turnstile1, uv_barrier_t::turnstile2, uv_cond_signal(), uv_cond_wait(), uv_mutex_lock(), uv_mutex_unlock(), uv_sem_post(), and uv_sem_wait().

Referenced by main(), reader(), and writer().

◆ uv_buf_init()

◆ uv_cancel()

UV_EXTERN int uv_cancel ( uv_req_t req)

Definition at line 358 of file threadpool.c.

358  {
359  struct uv__work* wreq;
360  uv_loop_t* loop;
361 
362  switch (req->type) {
363  case UV_FS:
364  loop = ((uv_fs_t*) req)->loop;
365  wreq = &((uv_fs_t*) req)->work_req;
366  break;
367  case UV_GETADDRINFO:
368  loop = ((uv_getaddrinfo_t*) req)->loop;
369  wreq = &((uv_getaddrinfo_t*) req)->work_req;
370  break;
371  case UV_GETNAMEINFO:
372  loop = ((uv_getnameinfo_t*) req)->loop;
373  wreq = &((uv_getnameinfo_t*) req)->work_req;
374  break;
375  case UV_RANDOM:
376  loop = ((uv_random_t*) req)->loop;
377  wreq = &((uv_random_t*) req)->work_req;
378  break;
379  case UV_WORK:
380  loop = ((uv_work_t*) req)->loop;
381  wreq = &((uv_work_t*) req)->work_req;
382  break;
383  default:
384  return UV_EINVAL;
385  }
386 
387  return uv__work_cancel(loop, req, wreq);
388 }
Definition: uv.h:1306
Definition: uv.h:1780
Definition: uv.h:1066
static int uv__work_cancel(uv_loop_t *loop, uv_req_t *req, struct uv__work *w)
Definition: threadpool.c:269

References loop, req, and uv__work_cancel().

Referenced by signal_handler().

◆ uv_chdir()

UV_EXTERN int uv_chdir ( const char *  dir)

Definition at line 747 of file core.c.

747  {
748  if (chdir(dir))
749  return UV__ERR(errno);
750 
751  return 0;
752 }
static static fork const void static count static fd const char const char static newpath chdir
Definition: sflib.h:33
#define UV__ERR(x)
Definition: errno.h:29

References chdir, L, NULL, UV__ERR, uv__free(), uv__malloc(), and uv_translate_sys_error().

◆ uv_check_init()

UV_EXTERN int uv_check_init ( uv_loop_t ,
uv_check_t check 
)

◆ uv_check_start()

UV_EXTERN int uv_check_start ( uv_check_t check,
uv_check_cb  cb 
)

◆ uv_check_stop()

UV_EXTERN int uv_check_stop ( uv_check_t check)

Referenced by uv_close().

◆ uv_close()

UV_EXTERN void uv_close ( uv_handle_t handle,
uv_close_cb  close_cb 
)

Definition at line 108 of file core.c.

108  {
110 
111  handle->flags |= UV_HANDLE_CLOSING;
112  handle->close_cb = close_cb;
113 
114  switch (handle->type) {
115  case UV_NAMED_PIPE:
117  break;
118 
119  case UV_TTY:
121  break;
122 
123  case UV_TCP:
125  break;
126 
127  case UV_UDP:
129  break;
130 
131  case UV_PREPARE:
133  break;
134 
135  case UV_CHECK:
137  break;
138 
139  case UV_IDLE:
141  break;
142 
143  case UV_ASYNC:
145  break;
146 
147  case UV_TIMER:
149  break;
150 
151  case UV_PROCESS:
153  break;
154 
155  case UV_FS_EVENT:
157  break;
158 
159  case UV_POLL:
161  break;
162 
163  case UV_FS_POLL:
165  /* Poll handles use file system requests, and one of them may still be
166  * running. The poll code will call uv__make_close_pending() for us. */
167  return;
168 
169  case UV_SIGNAL:
171  break;
172 
173  default:
174  assert(0);
175  }
176 
178 }
void uv__fs_event_close(uv_fs_event_t *handle)
Definition: aix.c:863
void uv__fs_poll_close(uv_fs_poll_t *handle)
Definition: fs-poll.c:164
Definition: uv.h:844
Definition: uv.h:824
Definition: uv.h:834
Definition: uv.h:767
Definition: uv.h:793
Definition: uv.h:547
Definition: uv.h:860
void uv__make_close_pending(uv_handle_t *handle)
Definition: core.c:208
void uv__prepare_close(uv_prepare_t *handle)
void uv__udp_close(uv_udp_t *handle)
Definition: udp.c:90
void uv__poll_close(uv_poll_t *handle)
Definition: poll.c:148
void uv__idle_close(uv_idle_t *handle)
void uv__signal_close(uv_signal_t *handle)
Definition: signal.c:335
void uv__check_close(uv_check_t *handle)
void uv__pipe_close(uv_pipe_t *handle)
Definition: pipe.c:120
void uv__process_close(uv_process_t *handle)
Definition: process.c:590
void uv__stream_close(uv_stream_t *handle)
Definition: stream.c:1633
void uv__tcp_close(uv_tcp_t *handle)
Definition: tcp.c:459
void uv__timer_close(uv_timer_t *handle)
Definition: timer.c:182
void uv__async_close(uv_async_t *handle)
Definition: async.c:115
@ UV_HANDLE_CLOSING
Definition: uv-common.h:74
#define uv__is_closing(h)
Definition: uv-common.h:255

References assert(), cb, handle, loop, uv__async_close(), uv__check_close(), uv__fs_event_close(), uv__fs_poll_close(), uv__handle_closing, uv__idle_close(), uv__is_closing, uv__make_close_pending(), uv__pipe_close(), uv__poll_close(), uv__prepare_close(), uv__process_close(), uv__signal_close(), uv__stream_close(), uv__tcp_close(), uv__timer_close(), uv__udp_close(), uv_async_close(), uv_check_stop(), uv_fs_event_close(), UV_HANDLE_CLOSING, uv_idle_stop(), uv_pipe_close(), uv_poll_close(), uv_prepare_stop(), uv_process_close(), uv_signal_close(), uv_tcp_close(), uv_timer_stop(), uv_tty_close(), uv_udp_close(), and uv_want_endgame().

Referenced by after(), cleanup_handles(), close_process_handle(), destroy_curl_context(), echo_read(), eof_timer_destroy(), on_exit(), on_new_connection(), on_read(), poll_cb(), read_stdin(), uv__stream_close(), uv_fs_poll_stop(), and uv_tcp_close_reset().

◆ uv_cond_broadcast()

UV_EXTERN void uv_cond_broadcast ( uv_cond_t cond)

Definition at line 774 of file thread.c.

774  {
775  if (pthread_cond_broadcast(cond))
776  abort();
777 }
#define cond(bop, top, mask, flags)

References cond.

◆ uv_cond_destroy()

UV_EXTERN void uv_cond_destroy ( uv_cond_t cond)

Definition at line 735 of file thread.c.

735  {
736 #if defined(__APPLE__) && defined(__MACH__)
737  /* It has been reported that destroying condition variables that have been
738  * signalled but not waited on can sometimes result in application crashes.
739  * See https://codereview.chromium.org/1323293005.
740  */
741  pthread_mutex_t mutex;
742  struct timespec ts;
743  int err;
744 
745  if (pthread_mutex_init(&mutex, NULL))
746  abort();
747 
748  if (pthread_mutex_lock(&mutex))
749  abort();
750 
751  ts.tv_sec = 0;
752  ts.tv_nsec = 1;
753 
754  err = pthread_cond_timedwait_relative_np(cond, &mutex, &ts);
755  if (err != 0 && err != ETIMEDOUT)
756  abort();
757 
758  if (pthread_mutex_unlock(&mutex))
759  abort();
760 
761  if (pthread_mutex_destroy(&mutex))
762  abort();
763 #endif /* defined(__APPLE__) && defined(__MACH__) */
764 
765  if (pthread_cond_destroy(cond))
766  abort();
767 }
#define ETIMEDOUT
Definition: sftypes.h:170
static uv_mutex_t mutex
Definition: threadpool.c:34

References cond, err, ETIMEDOUT, mutex, NULL, timespec::tv_nsec, and timespec::tv_sec.

Referenced by uv__custom_sem_destroy(), uv__threadpool_cleanup(), and uv_barrier_destroy().

◆ uv_cond_init()

UV_EXTERN int uv_cond_init ( uv_cond_t cond)

Definition at line 704 of file thread.c.

704  {
705  pthread_condattr_t attr;
706  int err;
707 
708  err = pthread_condattr_init(&attr);
709  if (err)
710  return UV__ERR(err);
711 
712  err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
713  if (err)
714  goto error2;
715 
716  err = pthread_cond_init(cond, &attr);
717  if (err)
718  goto error2;
719 
720  err = pthread_condattr_destroy(&attr);
721  if (err)
722  goto error;
723 
724  return 0;
725 
726 error:
727  pthread_cond_destroy(cond);
728 error2:
729  pthread_condattr_destroy(&attr);
730  return UV__ERR(err);
731 }

References cond, err, error(), and UV__ERR.

Referenced by init_threads(), uv__custom_sem_init(), and uv_barrier_init().

◆ uv_cond_signal()

UV_EXTERN void uv_cond_signal ( uv_cond_t cond)

Definition at line 769 of file thread.c.

769  {
770  if (pthread_cond_signal(cond))
771  abort();
772 }

References cond.

Referenced by post(), uv__custom_sem_post(), uv_barrier_wait(), and worker().

◆ uv_cond_timedwait()

UV_EXTERN int uv_cond_timedwait ( uv_cond_t cond,
uv_mutex_t mutex,
uint64_t  timeout 
)

Definition at line 785 of file thread.c.

785  {
786  int r;
787  struct timespec ts;
788 #if defined(__MVS__)
789  struct timeval tv;
790 #endif
791 
792 #if defined(__APPLE__) && defined(__MACH__)
793  ts.tv_sec = timeout / NANOSEC;
794  ts.tv_nsec = timeout % NANOSEC;
795  r = pthread_cond_timedwait_relative_np(cond, mutex, &ts);
796 #else
797 #if defined(__MVS__)
798  if (gettimeofday(&tv, NULL))
799  abort();
800  timeout += tv.tv_sec * NANOSEC + tv.tv_usec * 1e3;
801 #else
803 #endif
804  ts.tv_sec = timeout / NANOSEC;
805  ts.tv_nsec = timeout % NANOSEC;
806  r = pthread_cond_timedwait(cond, mutex, &ts);
807 #endif
808 
809 
810  if (r == 0)
811  return 0;
812 
813  if (r == ETIMEDOUT)
814  return UV_ETIMEDOUT;
815 
816  abort();
817 #ifndef __SUNPRO_C
818  return UV_EINVAL; /* Satisfy the compiler. */
819 #endif
820 }
uint64_t uv__hrtime(uv_clocktype_t type)
Definition: aix-common.c:43
#define r
Definition: crypto_rc6.c:12
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval tv
Definition: sflib.h:79
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog gettimeofday
Definition: sflib.h:79
uv_timer_t timeout
Definition: main.c:9
@ UV_CLOCK_PRECISE
Definition: internal.h:147
#define NANOSEC
Definition: thread.c:45

References cond, DWORD, ETIMEDOUT, gettimeofday, mutex, NANOSEC, NULL, r, timeout, tv, timespec::tv_nsec, timespec::tv_sec, uv__hrtime(), and UV_CLOCK_PRECISE.

◆ uv_cond_wait()

UV_EXTERN void uv_cond_wait ( uv_cond_t cond,
uv_mutex_t mutex 
)

Definition at line 779 of file thread.c.

779  {
780  if (pthread_cond_wait(cond, mutex))
781  abort();
782 }

References cond, and mutex.

Referenced by uv__custom_sem_wait(), uv_barrier_wait(), and worker().

◆ uv_cpu_info()

UV_EXTERN int uv_cpu_info ( uv_cpu_info_t **  cpu_infos,
int count 
)

Definition at line 1044 of file aix.c.

1044  {
1045  uv_cpu_info_t* cpu_info;
1046  perfstat_cpu_total_t ps_total;
1047  perfstat_cpu_t* ps_cpus;
1048  perfstat_id_t cpu_id;
1049  int result, ncpus, idx = 0;
1050 
1051  result = perfstat_cpu_total(NULL, &ps_total, sizeof(ps_total), 1);
1052  if (result == -1) {
1053  return UV_ENOSYS;
1054  }
1055 
1056  ncpus = result = perfstat_cpu(NULL, NULL, sizeof(perfstat_cpu_t), 0);
1057  if (result == -1) {
1058  return UV_ENOSYS;
1059  }
1060 
1061  ps_cpus = (perfstat_cpu_t*) uv__malloc(ncpus * sizeof(perfstat_cpu_t));
1062  if (!ps_cpus) {
1063  return UV_ENOMEM;
1064  }
1065 
1066  /* TODO(bnoordhuis) Check uv__strscpy() return value. */
1067  uv__strscpy(cpu_id.name, FIRST_CPU, sizeof(cpu_id.name));
1068  result = perfstat_cpu(&cpu_id, ps_cpus, sizeof(perfstat_cpu_t), ncpus);
1069  if (result == -1) {
1070  uv__free(ps_cpus);
1071  return UV_ENOSYS;
1072  }
1073 
1074  *cpu_infos = (uv_cpu_info_t*) uv__malloc(ncpus * sizeof(uv_cpu_info_t));
1075  if (!*cpu_infos) {
1076  uv__free(ps_cpus);
1077  return UV_ENOMEM;
1078  }
1079 
1080  *count = ncpus;
1081 
1082  cpu_info = *cpu_infos;
1083  while (idx < ncpus) {
1084  cpu_info->speed = (int)(ps_total.processorHZ / 1000000);
1085  cpu_info->model = uv__strdup(ps_total.description);
1086  cpu_info->cpu_times.user = ps_cpus[idx].user;
1087  cpu_info->cpu_times.sys = ps_cpus[idx].sys;
1088  cpu_info->cpu_times.idle = ps_cpus[idx].idle;
1089  cpu_info->cpu_times.irq = ps_cpus[idx].wait;
1090  cpu_info->cpu_times.nice = 0;
1091  cpu_info++;
1092  idx++;
1093  }
1094 
1095  uv__free(ps_cpus);
1096  return 0;
1097 }
unsigned ncpus
int idx
Definition: setup.py:197
static int
Definition: sfsocketcall.h:114
ssize_t uv__strscpy(char *d, const char *s, size_t n)
Definition: strscpy.c:25
struct uv_cpu_times_s cpu_times
Definition: uv.h:1093
char * model
Definition: uv.h:1091
int speed
Definition: uv.h:1092
uint64_t nice
Definition: uv.h:1084
uint64_t sys
Definition: uv.h:1085
uint64_t idle
Definition: uv.h:1086
uint64_t user
Definition: uv.h:1083
uint64_t irq
Definition: uv.h:1087
char * uv__strdup(const char *s)
Definition: uv-common.c:55

References ARRAY_SIZE, assert(), data_area_ptr::assign, count, CP_IDLE, CP_INTR, CP_NICE, CP_SYS, CP_USER, CPCMODEL_LENGTH, uv_cpu_info_s::cpu_times, CPUSTATES, CSD_NUMBER_ONLINE_CPUS, CSD_OFFSET, CVT_PTR, CVTOPCTP_OFFSET, data_area_ptr::deref, DWORD, EINPROGRESS, EINTR, err, error(), benchmark::FILE, i, uv_cpu_times_s::idle, _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION::IdleTime, setup::idx, info(), int, _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION::InterruptTime, uv_cpu_times_s::irq, _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION::KernelTime, L, len, long, memcpy(), memset(), uv_cpu_info_s::model, ncpus, uv_cpu_times_s::nice, NT_SUCCESS, NULL, out, pNtQuerySystemInformation, pRtlNtStatusToDosError, RCTLACS_OFFSET, read_models(), read_speeds(), read_times(), RMCTRCT_OFFSET, uv_cpu_info_s::speed, status, strdup(), strings(), uv_cpu_times_s::sys, SystemProcessorPerformanceInformation, type, u_int64_t, ULONG, uv_cpu_times_s::user, _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION::UserTime, uv__calloc(), uv__convert_utf16_to_utf8(), uv__cpu_num(), UV__ERR, uv__free(), uv__get_cpu_speed(), uv__malloc(), uv__once_init(), uv__open_file(), uv__strdup(), uv__strscpy(), uv_free_cpu_info(), uv_translate_sys_error(), and which.

Referenced by setup_workers().

◆ uv_cwd()

UV_EXTERN int uv_cwd ( char *  buffer,
size_t size 
)

Definition at line 708 of file core.c.

708  {
709  char scratch[1 + UV__PATH_MAX];
710 
711  if (buffer == NULL || size == NULL)
712  return UV_EINVAL;
713 
714  /* Try to read directly into the user's buffer first... */
715  if (getcwd(buffer, *size) != NULL)
716  goto fixup;
717 
718  if (errno != ERANGE)
719  return UV__ERR(errno);
720 
721  /* ...or into scratch space if the user's buffer is too small
722  * so we can report how much space to provide on the next try.
723  */
724  if (getcwd(scratch, sizeof(scratch)) == NULL)
725  return UV__ERR(errno);
726 
727  buffer = scratch;
728 
729 fixup:
730 
731  *size = strlen(buffer);
732 
733  if (*size > 1 && buffer[*size - 1] == '/') {
734  *size -= 1;
735  buffer[*size] = '\0';
736  }
737 
738  if (buffer == scratch) {
739  *size += 1;
740  return UV_ENOBUFS;
741  }
742 
743  return 0;
744 }
voidpf void uLong size
Definition: ioapi.h:138
#define ERANGE
Definition: sftypes.h:144
Definition: buffer.h:15
#define UV__PATH_MAX
Definition: internal.h:68

References DWORD, ERANGE, INT_MAX, L, NULL, r, UV__ERR, uv__free(), uv__malloc(), UV__PATH_MAX, and uv_translate_sys_error().

◆ uv_default_loop()

UV_EXTERN uv_loop_t* uv_default_loop ( void  )

Definition at line 763 of file uv-common.c.

763  {
764  if (default_loop_ptr != NULL)
765  return default_loop_ptr;
766 
768  return NULL;
769 
771  return default_loop_ptr;
772 }
static uv_loop_t * default_loop_ptr
Definition: uv-common.c:760
static uv_loop_t default_loop_struct
Definition: uv-common.c:759
UV_EXTERN int uv_loop_init(uv_loop_t *loop)
Definition: loop.c:30

References default_loop_ptr, default_loop_struct, NULL, and uv_loop_init().

Referenced by idle_cb(), main(), on_open(), on_read(), on_write(), and uv__print_handles().

◆ uv_disable_stdio_inheritance()

UV_EXTERN void uv_disable_stdio_inheritance ( void  )

Definition at line 755 of file core.c.

755  {
756  int fd;
757 
758  /* Set the CLOEXEC flag on all open descriptors. Unconditionally try the
759  * first 16 file descriptors. After that, bail out after the first error.
760  */
761  for (fd = 0; ; fd++)
762  if (uv__cloexec(fd, 1) && fd > 15)
763  break;
764 }
#define uv__cloexec
Definition: internal.h:169

References fd, handle, HANDLE, INVALID_HANDLE_VALUE, NULL, si, uv__cloexec, uv__stdio_noinherit(), and uv__stdio_verify().

◆ uv_dlclose()

UV_EXTERN void uv_dlclose ( uv_lib_t lib)

Definition at line 41 of file dl.c.

41  {
42  uv__free(lib->errmsg);
43  lib->errmsg = NULL;
44 
45  if (lib->handle) {
46  /* Ignore errors. No good way to signal them without leaking memory. */
47  dlclose(lib->handle);
48  lib->handle = NULL;
49  }
50 }
char * errmsg
Definition: unix.h:220
void * handle
Definition: unix.h:219

References uv_lib_t::errmsg, uv_lib_t::handle, NULL, and uv__free().

◆ uv_dlerror()

UV_EXTERN const char* uv_dlerror ( const uv_lib_t lib)

Definition at line 60 of file dl.c.

60  {
61  return lib->errmsg ? lib->errmsg : "no error";
62 }

References uv_lib_t::errmsg.

Referenced by main().

◆ uv_dlopen()

UV_EXTERN int uv_dlopen ( const char *  filename,
uv_lib_t lib 
)

Definition at line 33 of file dl.c.

33  {
34  dlerror(); /* Reset error status. */
35  lib->errmsg = NULL;
36  lib->handle = dlopen(filename, RTLD_LAZY);
37  return lib->handle ? 0 : uv__dlerror(lib);
38 }
const char * filename
Definition: ioapi.h:137
static int uv__dlerror(uv_lib_t *lib)
Definition: dl.c:65

References ARRAY_SIZE, uv_lib_t::errmsg, uv_lib_t::handle, NULL, and uv__dlerror().

Referenced by main().

◆ uv_dlsym()

UV_EXTERN int uv_dlsym ( uv_lib_t lib,
const char *  name,
void **  ptr 
)

Definition at line 53 of file dl.c.

53  {
54  dlerror(); /* Reset error status. */
55  *ptr = dlsym(lib->handle, name);
56  return uv__dlerror(lib);
57 }
Definition: z80asm.h:102

References uv_lib_t::handle, and uv__dlerror().

Referenced by main().

◆ uv_err_name()

UV_EXTERN const char* uv_err_name ( int  err)

Definition at line 189 of file uv-common.c.

189  {
190  switch (err) {
192  }
193  return uv__unknown_err_code(err);
194 }
#define UV_ERR_NAME_GEN(name, _)
Definition: uv-common.c:188
static const char * uv__unknown_err_code(int err)
Definition: uv-common.c:165

References err, uv__unknown_err_code(), UV_ERR_NAME_GEN, and UV_ERRNO_MAP.

Referenced by echo_read(), echo_write(), main(), on_connect(), on_new_connection(), on_read(), and on_resolved().

◆ uv_err_name_r()

UV_EXTERN char* uv_err_name_r ( int  err,
char *  buf,
size_t  buflen 
)

Definition at line 178 of file uv-common.c.

178  {
179  switch (err) {
181  default: snprintf(buf, buflen, "Unknown system error %d", err);
182  }
183  return buf;
184 }
snprintf
Definition: kernel.h:364
ut64 buflen
Definition: core.c:76
#define UV_ERR_NAME_GEN_R(name, _)
Definition: uv-common.c:175

References buflen, err, snprintf, UV_ERR_NAME_GEN_R, and UV_ERRNO_MAP.

◆ uv_exepath()

UV_EXTERN int uv_exepath ( char *  buffer,
size_t size 
)

Definition at line 60 of file aix-common.c.

60  {
61  int res;
62  char args[UV__PATH_MAX];
63  size_t cached_len;
64  struct procsinfo pi;
65 
66  if (buffer == NULL || size == NULL || *size == 0)
67  return UV_EINVAL;
68 
71  if (original_exepath != NULL) {
72  cached_len = strlen(original_exepath);
73  *size -= 1;
74  if (*size > cached_len)
75  *size = cached_len;
77  buffer[*size] = '\0';
79  return 0;
80  }
82  pi.pi_pid = getpid();
83  res = getargs(&pi, sizeof(pi), args, sizeof(args));
84 
85  if (res < 0)
86  return UV_EINVAL;
87 
88  return uv__search_path(args, buffer, size);
89 }
uv_once_t process_title_mutex_once
Definition: aix.c:70
void init_process_title_mutex_once(void)
Definition: aix.c:76
char * original_exepath
Definition: aix.c:68
uv_mutex_t process_title_mutex
Definition: aix.c:69
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
int args
Definition: mipsasm.c:18
int uv__search_path(const char *prog, char *buf, size_t *buflen)
Definition: core.c:1540
UV_EXTERN void uv_mutex_lock(uv_mutex_t *handle)
Definition: thread.c:330
UV_EXTERN void uv_once(uv_once_t *guard, void(*callback)(void))
Definition: thread.c:419
UV_EXTERN void uv_mutex_unlock(uv_mutex_t *handle)
Definition: thread.c:350

References args, ARRAY_SIZE, assert(), ENOMEM, err, error(), find_path(), getexe(), init_process_title_mutex_once(), int, L, memcpy(), n, NULL, original_exepath, out, path, pid, process_title_mutex, process_title_mutex_once, readlink, snprintf, status, UV__ERR, uv__free(), uv__malloc(), UV__PATH_MAX, uv__reallocf(), uv__search_path(), uv__strscpy(), uv_mutex_lock(), uv_mutex_unlock(), uv_once(), and uv_translate_sys_error().

Referenced by invoke_cgi_script(), main(), and setup_workers().

◆ uv_fileno()

UV_EXTERN int uv_fileno ( const uv_handle_t handle,
uv_os_fd_t fd 
)

Definition at line 767 of file core.c.

767  {
768  int fd_out;
769 
770  switch (handle->type) {
771  case UV_TCP:
772  case UV_NAMED_PIPE:
773  case UV_TTY:
774  fd_out = uv__stream_fd((uv_stream_t*) handle);
775  break;
776 
777  case UV_UDP:
778  fd_out = ((uv_udp_t *) handle)->io_watcher.fd;
779  break;
780 
781  case UV_POLL:
782  fd_out = ((uv_poll_t *) handle)->io_watcher.fd;
783  break;
784 
785  default:
786  return UV_EINVAL;
787  }
788 
789  if (uv__is_closing(handle) || fd_out == -1)
790  return UV_EBADF;
791 
792  *fd = fd_out;
793  return 0;
794 }
#define uv__stream_fd(handle)
Definition: internal.h:282

References fd, handle, INVALID_HANDLE_VALUE, socket, uv__is_closing, uv__stream_fd, and uv_is_closing().

Referenced by on_new_connection(), and uv__getsockpeername().

◆ uv_free_cpu_info()

UV_EXTERN void uv_free_cpu_info ( uv_cpu_info_t cpu_infos,
int  count 
)

Definition at line 846 of file uv-common.c.

846  {
847  int i;
848 
849  for (i = 0; i < count; i++)
850  uv__free(cpu_infos[i].model);
851 
852  uv__free(cpu_infos);
853 }
lzma_index ** i
Definition: index.h:629

References count, i, and uv__free().

Referenced by setup_workers(), and uv_cpu_info().

◆ uv_free_interface_addresses()

UV_EXTERN void uv_free_interface_addresses ( uv_interface_address_t addresses,
int  count 
)

Definition at line 1268 of file aix.c.

1269  {
1270  int i;
1271 
1272  for (i = 0; i < count; ++i) {
1273  uv__free(addresses[i].name);
1274  }
1275 
1276  uv__free(addresses);
1277 }

References count, i, and uv__free().

Referenced by main(), and uv_interface_addresses().

◆ uv_freeaddrinfo()

UV_EXTERN void uv_freeaddrinfo ( struct addrinfo *  ai)

Definition at line 223 of file getaddrinfo.c.

223  {
224  if (ai)
225  freeaddrinfo(ai);
226 }

References uv__free().

Referenced by on_resolved().

◆ uv_fs_access()

UV_EXTERN int uv_fs_access ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
int  mode,
uv_fs_cb  cb 
)

Definition at line 1659 of file fs.c.

1663  {
1664  INIT(ACCESS);
1665  PATH;
1666  req->flags = flags;
1667  POST;
1668 }
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
#define POST
Definition: fs.c:145
#define PATH
Definition: fs.c:112
#define INIT(subtype)
Definition: fs.c:96

References cb, err, flags, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_ACCESS.

◆ uv_fs_chmod()

UV_EXTERN int uv_fs_chmod ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
int  mode,
uv_fs_cb  cb 
)

Definition at line 1671 of file fs.c.

1675  {
1676  INIT(CHMOD);
1677  PATH;
1678  req->mode = mode;
1679  POST;
1680 }
const char int mode
Definition: ioapi.h:137

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_CHMOD.

◆ uv_fs_chown()

UV_EXTERN int uv_fs_chown ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
uv_uid_t  uid,
uv_gid_t  gid,
uv_fs_cb  cb 
)

Definition at line 1683 of file fs.c.

1688  {
1689  INIT(CHOWN);
1690  PATH;
1691  req->uid = uid;
1692  req->gid = gid;
1693  POST;
1694 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_CHOWN.

◆ uv_fs_close()

UV_EXTERN int uv_fs_close ( uv_loop_t loop,
uv_fs_t req,
uv_file  file,
uv_fs_cb  cb 
)

Definition at line 1697 of file fs.c.

1697  {
1698  INIT(CLOSE);
1699  req->file = file;
1700  POST;
1701 }
static int file
Definition: z80asm.c:58

References fd, file, INIT, POST, req, and UV_FS_CLOSE.

Referenced by on_read().

◆ uv_fs_closedir()

UV_EXTERN int uv_fs_closedir ( uv_loop_t loop,
uv_fs_t req,
uv_dir_t dir,
uv_fs_cb  cb 
)

Definition at line 1933 of file fs.c.

1936  {
1937  INIT(CLOSEDIR);
1938 
1939  if (dir == NULL)
1940  return UV_EINVAL;
1941 
1942  req->ptr = dir;
1943  POST;
1944 }

References INIT, NULL, POST, req, SET_REQ_UV_ERROR, and UV_FS_CLOSEDIR.

◆ uv_fs_copyfile()

UV_EXTERN int uv_fs_copyfile ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
const char *  new_path,
int  flags,
uv_fs_cb  cb 
)

Definition at line 2103 of file fs.c.

2108  {
2109  INIT(COPYFILE);
2110 
2111  if (flags & ~(UV_FS_COPYFILE_EXCL |
2114  return UV_EINVAL;
2115  }
2116 
2117  PATH2;
2118  req->flags = flags;
2119  POST;
2120 }
#define PATH2
Definition: fs.c:125
#define UV_FS_COPYFILE_FICLONE_FORCE
Definition: uv.h:1370
#define UV_FS_COPYFILE_EXCL
Definition: uv.h:1358
#define UV_FS_COPYFILE_FICLONE
Definition: uv.h:1364

References cb, err, flags, fs__capture_path(), INIT, NULL, path, PATH2, POST, req, SET_REQ_UV_ERROR, SET_REQ_WIN32_ERROR, UV_FS_COPYFILE, UV_FS_COPYFILE_EXCL, UV_FS_COPYFILE_FICLONE, and UV_FS_COPYFILE_FICLONE_FORCE.

◆ uv_fs_event_getpath()

UV_EXTERN int uv_fs_event_getpath ( uv_fs_event_t handle,
char *  buffer,
size_t size 
)

Definition at line 592 of file uv-common.c.

592  {
593  size_t required_len;
594 
595  if (!uv__is_active(handle)) {
596  *size = 0;
597  return UV_EINVAL;
598  }
599 
600  required_len = strlen(handle->path);
601  if (required_len >= *size) {
602  *size = required_len + 1;
603  return UV_ENOBUFS;
604  }
605 
606  memcpy(buffer, handle->path, required_len);
607  *size = required_len;
608  buffer[required_len] = '\0';
609 
610  return 0;
611 }
#define uv__is_active(h)
Definition: uv-common.h:252

References handle, memcpy(), and uv__is_active.

Referenced by run_command().

◆ uv_fs_event_init()

UV_EXTERN int uv_fs_event_init ( uv_loop_t loop,
uv_fs_event_t handle 
)

Definition at line 757 of file aix.c.

757  {
758 #ifdef HAVE_SYS_AHAFS_EVPRODS_H
759  uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT);
760  return 0;
761 #else
762  return UV_ENOSYS;
763 #endif
764 }

References handle, INVALID_HANDLE_VALUE, loop, NULL, uv__handle_init, and UV_REQ_INIT.

Referenced by main().

◆ uv_fs_event_start()

UV_EXTERN int uv_fs_event_start ( uv_fs_event_t handle,
uv_fs_event_cb  cb,
const char *  path,
unsigned int  flags 
)

Definition at line 767 of file aix.c.

770  {
771 #ifdef HAVE_SYS_AHAFS_EVPRODS_H
772  int fd, rc, str_offset = 0;
773  char cwd[PATH_MAX];
774  char absolute_path[PATH_MAX];
775  char readlink_cwd[PATH_MAX];
776  struct timeval zt;
777  fd_set pollfd;
778 
779 
780  /* Figure out whether filename is absolute or not */
781  if (filename[0] == '\0') {
782  /* Missing a pathname */
783  return UV_ENOENT;
784  }
785  else if (filename[0] == '/') {
786  /* We have absolute pathname */
787  /* TODO(bnoordhuis) Check uv__strscpy() return value. */
788  uv__strscpy(absolute_path, filename, sizeof(absolute_path));
789  } else {
790  /* We have a relative pathname, compose the absolute pathname */
791  snprintf(cwd, sizeof(cwd), "/proc/%lu/cwd", (unsigned long) getpid());
792  rc = readlink(cwd, readlink_cwd, sizeof(readlink_cwd) - 1);
793  if (rc < 0)
794  return rc;
795  /* readlink does not null terminate our string */
796  readlink_cwd[rc] = '\0';
797 
798  if (filename[0] == '.' && filename[1] == '/')
799  str_offset = 2;
800 
801  snprintf(absolute_path, sizeof(absolute_path), "%s%s", readlink_cwd,
802  filename + str_offset);
803  }
804 
805  if (uv__is_ahafs_mounted() < 0) /* /aha checks failed */
806  return UV_ENOSYS;
807 
808  /* Setup ahafs */
809  rc = uv__setup_ahafs((const char *)absolute_path, &fd);
810  if (rc != 0)
811  return rc;
812 
813  /* Setup/Initialize all the libuv routines */
815  uv__io_init(&handle->event_watcher, uv__ahafs_event, fd);
816  handle->path = uv__strdup(filename);
817  handle->cb = cb;
818  handle->dir_filename = NULL;
819 
820  uv__io_start(handle->loop, &handle->event_watcher, POLLIN);
821 
822  /* AHAFS wants someone to poll for it to start mointoring.
823  * so kick-start it so that we don't miss an event in the
824  * eventuality of an event that occurs in the current loop. */
825  do {
826  memset(&zt, 0, sizeof(zt));
827  FD_ZERO(&pollfd);
828  FD_SET(fd, &pollfd);
829  rc = select(fd + 1, &pollfd, NULL, NULL, &zt);
830  } while (rc == -1 && errno == EINTR);
831  return 0;
832 #else
833  return UV_ENOSYS;
834 #endif
835 }
static static sync static getppid static getegid const char static filename char static len readlink
Definition: sflib.h:65
return memset(p, 0, total)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz select
Definition: sflib.h:108
#define FD_ZERO(set)
Definition: sftypes.h:204
#define FD_SET(d, set)
Definition: sftypes.h:212
#define EINTR
Definition: sftypes.h:114
Definition: sftypes.h:75
void uv__io_init(uv__io_t *w, uv__io_cb cb, int fd)
Definition: core.c:865
static const char * cb[]
Definition: z80_tab.h:176

References assert(), CAST, cb, test-lz4-speed::cwd, DWORD, EINTR, err, error(), FALSE, fd, FD_SET, FD_ZERO, find_watcher(), flags, fstat, handle, init_inotify(), INVALID_HANDLE_VALUE, len, memcpy(), memset(), uv__os390_epoll::msg_queue, NULL, O_RDONLY, path, QUEUE_INIT, QUEUE_INSERT_TAIL, r, RB_INSERT, readlink, select, snprintf, TRUE, uv__close_nocheckstdio(), UV__ERR, uv__free(), uv__fs_event(), uv__fsevents_init(), uv__handle_start, uv__handle_stop, uv__io_init(), uv__io_start(), uv__is_active, uv__load_relaxed, uv__malloc(), uv__strdup(), uv__strscpy(), uv_directory_watcher_buffer_size, uv_fatal_error(), UV_FS_EVENT_RECURSIVE, uv_split_path(), uv_translate_sys_error(), and w.

Referenced by main(), and uv__inotify_fork().

◆ uv_fs_event_stop()

UV_EXTERN int uv_fs_event_stop ( uv_fs_event_t handle)

Definition at line 838 of file aix.c.

838  {
839 #ifdef HAVE_SYS_AHAFS_EVPRODS_H
840  if (!uv__is_active(handle))
841  return 0;
842 
843  uv__io_close(handle->loop, &handle->event_watcher);
845 
846  if (uv__path_is_a_directory(handle->path) == 0) {
847  uv__free(handle->dir_filename);
848  handle->dir_filename = NULL;
849  }
850 
851  uv__free(handle->path);
852  handle->path = NULL;
853  uv__close(handle->event_watcher.fd);
854  handle->event_watcher.fd = -1;
855 
856  return 0;
857 #else
858  return UV_ENOSYS;
859 #endif
860 }
void uv__io_close(uv_loop_t *loop, uv__io_t *w)
Definition: core.c:942
#define uv__handle_stop(h)
Definition: uv-common.h:266

References assert(), EALREADY, ENOENT, find_watcher(), handle, INVALID_HANDLE_VALUE, maybe_free_watcher_list(), memcpy(), uv__os390_epoll::msg_queue, NULL, QUEUE_REMOVE, r, uv__close(), uv__free(), uv__fsevents_close(), uv__handle_stop, uv__io_close(), uv__is_active, uv__load_relaxed, and w.

Referenced by uv__fs_event_close(), uv__inotify_fork(), and uv_fs_event_close().

◆ uv_fs_fchmod()

UV_EXTERN int uv_fs_fchmod ( uv_loop_t loop,
uv_fs_t req,
uv_file  file,
int  mode,
uv_fs_cb  cb 
)

Definition at line 1704 of file fs.c.

1708  {
1709  INIT(FCHMOD);
1710  req->file = file;
1711  req->mode = mode;
1712  POST;
1713 }

References fd, file, INIT, POST, req, and UV_FS_FCHMOD.

◆ uv_fs_fchown()

UV_EXTERN int uv_fs_fchown ( uv_loop_t loop,
uv_fs_t req,
uv_file  file,
uv_uid_t  uid,
uv_gid_t  gid,
uv_fs_cb  cb 
)

Definition at line 1716 of file fs.c.

1721  {
1722  INIT(FCHOWN);
1723  req->file = file;
1724  req->uid = uid;
1725  req->gid = gid;
1726  POST;
1727 }

References file, INIT, POST, req, and UV_FS_FCHOWN.

◆ uv_fs_fdatasync()

UV_EXTERN int uv_fs_fdatasync ( uv_loop_t loop,
uv_fs_t req,
uv_file  file,
uv_fs_cb  cb 
)

Definition at line 1744 of file fs.c.

1744  {
1745  INIT(FDATASYNC);
1746  req->file = file;
1747  POST;
1748 }

References fd, file, INIT, POST, req, and UV_FS_FDATASYNC.

◆ uv_fs_fstat()

UV_EXTERN int uv_fs_fstat ( uv_loop_t loop,
uv_fs_t req,
uv_file  file,
uv_fs_cb  cb 
)

Definition at line 1751 of file fs.c.

1751  {
1752  INIT(FSTAT);
1753  req->file = file;
1754  POST;
1755 }

References fd, file, INIT, POST, req, and UV_FS_FSTAT.

◆ uv_fs_fsync()

UV_EXTERN int uv_fs_fsync ( uv_loop_t loop,
uv_fs_t req,
uv_file  file,
uv_fs_cb  cb 
)

Definition at line 1758 of file fs.c.

1758  {
1759  INIT(FSYNC);
1760  req->file = file;
1761  POST;
1762 }

References fd, file, INIT, POST, req, and UV_FS_FSYNC.

◆ uv_fs_ftruncate()

UV_EXTERN int uv_fs_ftruncate ( uv_loop_t loop,
uv_fs_t req,
uv_file  file,
int64_t  offset,
uv_fs_cb  cb 
)

Definition at line 1765 of file fs.c.

1769  {
1770  INIT(FTRUNCATE);
1771  req->file = file;
1772  req->off = off;
1773  POST;
1774 }
int off
Definition: pal.c:13

References fd, file, INIT, off, POST, req, and UV_FS_FTRUNCATE.

◆ uv_fs_futime()

UV_EXTERN int uv_fs_futime ( uv_loop_t loop,
uv_fs_t req,
uv_file  file,
double  atime,
double  mtime,
uv_fs_cb  cb 
)

Definition at line 1777 of file fs.c.

1782  {
1783  INIT(FUTIME);
1784  req->file = file;
1785  req->atime = atime;
1786  req->mtime = mtime;
1787  POST;
1788 }

References fd, file, INIT, POST, req, and UV_FS_FUTIME.

◆ uv_fs_get_path()

UV_EXTERN const char* uv_fs_get_path ( const uv_fs_t req)

Definition at line 105 of file uv-data-getter-setters.c.

105  {
106  return req->path;
107 }

References req.

◆ uv_fs_get_ptr()

UV_EXTERN void* uv_fs_get_ptr ( const uv_fs_t req)

Definition at line 101 of file uv-data-getter-setters.c.

101  {
102  return req->ptr;
103 }

References req.

◆ uv_fs_get_result()

UV_EXTERN ssize_t uv_fs_get_result ( const uv_fs_t req)

Definition at line 97 of file uv-data-getter-setters.c.

97  {
98  return req->result;
99 }

References req.

◆ uv_fs_get_statbuf()

UV_EXTERN uv_stat_t* uv_fs_get_statbuf ( uv_fs_t req)

Definition at line 109 of file uv-data-getter-setters.c.

109  {
110  return &req->statbuf;
111 }

References req.

◆ uv_fs_get_system_error()

UV_EXTERN int uv_fs_get_system_error ( const uv_fs_t req)

Definition at line 2132 of file fs.c.

2132  {
2133  return -req->result;
2134 }

References req.

◆ uv_fs_get_type()

UV_EXTERN uv_fs_type uv_fs_get_type ( const uv_fs_t req)

Definition at line 93 of file uv-data-getter-setters.c.

93  {
94  return req->fs_type;
95 }

References req.

◆ uv_fs_lchown()

UV_EXTERN int uv_fs_lchown ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
uv_uid_t  uid,
uv_gid_t  gid,
uv_fs_cb  cb 
)

Definition at line 1730 of file fs.c.

1735  {
1736  INIT(LCHOWN);
1737  PATH;
1738  req->uid = uid;
1739  req->gid = gid;
1740  POST;
1741 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_LCHOWN.

◆ uv_fs_link()

UV_EXTERN int uv_fs_link ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
const char *  new_path,
uv_fs_cb  cb 
)

Definition at line 1811 of file fs.c.

1815  {
1816  INIT(LINK);
1817  PATH2;
1818  POST;
1819 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH2, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_LINK.

◆ uv_fs_lstat()

UV_EXTERN int uv_fs_lstat ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
uv_fs_cb  cb 
)

Definition at line 1804 of file fs.c.

1804  {
1805  INIT(LSTAT);
1806  PATH;
1807  POST;
1808 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_LSTAT.

◆ uv_fs_lutime()

UV_EXTERN int uv_fs_lutime ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
double  atime,
double  mtime,
uv_fs_cb  cb 
)

Definition at line 1790 of file fs.c.

1795  {
1796  INIT(LUTIME);
1797  PATH;
1798  req->atime = atime;
1799  req->mtime = mtime;
1800  POST;
1801 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_LUTIME.

◆ uv_fs_mkdir()

UV_EXTERN int uv_fs_mkdir ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
int  mode,
uv_fs_cb  cb 
)

Definition at line 1822 of file fs.c.

1826  {
1827  INIT(MKDIR);
1828  PATH;
1829  req->mode = mode;
1830  POST;
1831 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_MKDIR.

◆ uv_fs_mkdtemp()

UV_EXTERN int uv_fs_mkdtemp ( uv_loop_t loop,
uv_fs_t req,
const char *  tpl,
uv_fs_cb  cb 
)

Definition at line 1834 of file fs.c.

1837  {
1838  INIT(MKDTEMP);
1839  req->path = uv__strdup(tpl);
1840  if (req->path == NULL)
1841  return UV_ENOMEM;
1842  POST;
1843 }

References err, fs__capture_path(), INIT, NULL, POST, req, SET_REQ_WIN32_ERROR, TRUE, uv__strdup(), and UV_FS_MKDTEMP.

◆ uv_fs_mkstemp()

UV_EXTERN int uv_fs_mkstemp ( uv_loop_t loop,
uv_fs_t req,
const char *  tpl,
uv_fs_cb  cb 
)

Definition at line 1846 of file fs.c.

1849  {
1850  INIT(MKSTEMP);
1851  req->path = uv__strdup(tpl);
1852  if (req->path == NULL)
1853  return UV_ENOMEM;
1854  POST;
1855 }

References err, fs__capture_path(), INIT, NULL, POST, req, SET_REQ_WIN32_ERROR, TRUE, uv__strdup(), and UV_FS_MKSTEMP.

◆ uv_fs_open()

UV_EXTERN int uv_fs_open ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
int  flags,
int  mode,
uv_fs_cb  cb 
)

Definition at line 1858 of file fs.c.

1863  {
1864  INIT(OPEN);
1865  PATH;
1866  req->flags = flags;
1867  req->mode = mode;
1868  POST;
1869 }

References cb, err, flags, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_OPEN.

Referenced by main(), and uv__fs_copyfile().

◆ uv_fs_opendir()

UV_EXTERN int uv_fs_opendir ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
uv_fs_cb  cb 
)

Definition at line 1911 of file fs.c.

1914  {
1915  INIT(OPENDIR);
1916  PATH;
1917  POST;
1918 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_OPENDIR.

◆ uv_fs_poll_getpath()

UV_EXTERN int uv_fs_poll_getpath ( uv_fs_poll_t handle,
char *  buffer,
size_t size 
)

Definition at line 138 of file fs-poll.c.

138  {
139  struct poll_ctx* ctx;
140  size_t required_len;
141 
142  if (!uv_is_active((uv_handle_t*)handle)) {
143  *size = 0;
144  return UV_EINVAL;
145  }
146 
147  ctx = handle->poll_ctx;
148  assert(ctx != NULL);
149 
150  required_len = strlen(ctx->path);
151  if (required_len >= *size) {
152  *size = required_len + 1;
153  return UV_ENOBUFS;
154  }
155 
156  memcpy(buffer, ctx->path, required_len);
157  *size = required_len;
158  buffer[required_len] = '\0';
159 
160  return 0;
161 }
UV_EXTERN int uv_is_active(const uv_handle_t *handle)
Definition: core.c:430

References assert(), handle, memcpy(), NULL, and uv_is_active().

◆ uv_fs_poll_init()

UV_EXTERN int uv_fs_poll_init ( uv_loop_t loop,
uv_fs_poll_t handle 
)

Definition at line 59 of file fs-poll.c.

59  {
60  uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_POLL);
61  handle->poll_ctx = NULL;
62  return 0;
63 }

References handle, loop, NULL, and uv__handle_init.

◆ uv_fs_poll_start()

UV_EXTERN int uv_fs_poll_start ( uv_fs_poll_t handle,
uv_fs_poll_cb  poll_cb,
const char *  path,
unsigned int  interval 
)

Definition at line 66 of file fs-poll.c.

69  {
70  struct poll_ctx* ctx;
71  uv_loop_t* loop;
72  size_t len;
73  int err;
74 
76  return 0;
77 
78  loop = handle->loop;
79  len = strlen(path);
80  ctx = uv__calloc(1, sizeof(*ctx) + len);
81 
82  if (ctx == NULL)
83  return UV_ENOMEM;
84 
85  ctx->loop = loop;
86  ctx->poll_cb = cb;
87  ctx->interval = interval ? interval : 1;
88  ctx->start_time = uv_now(loop);
89  ctx->parent_handle = handle;
90  memcpy(ctx->path, path, len + 1);
91 
92  err = uv_timer_init(loop, &ctx->timer_handle);
93  if (err < 0)
94  goto error;
95 
96  ctx->timer_handle.flags |= UV_HANDLE_INTERNAL;
97  uv__handle_unref(&ctx->timer_handle);
98 
99  err = uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb);
100  if (err < 0)
101  goto error;
102 
103  if (handle->poll_ctx != NULL)
104  ctx->previous = handle->poll_ctx;
105  handle->poll_ctx = ctx;
107 
108  return 0;
109 
110 error:
111  uv__free(ctx);
112  return err;
113 }
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35
static void poll_cb(uv_fs_t *req)
Definition: fs-poll.c:185
unsigned int interval
Definition: fs-poll.c:40
void * uv__calloc(size_t count, size_t size)
Definition: uv-common.c:92
@ UV_HANDLE_INTERNAL
Definition: uv-common.h:78
#define uv__handle_unref(h)
Definition: uv-common.h:283
UV_EXTERN int uv_timer_init(uv_loop_t *, uv_timer_t *handle)
Definition: timer.c:58
UV_EXTERN int uv_fs_stat(uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
Definition: fs.c:2000
UV_EXTERN uint64_t uv_now(const uv_loop_t *)
Definition: uv-common.c:567

References cb, err, error(), handle, poll_ctx::interval, len, loop, memcpy(), NULL, path, poll_cb(), uv__calloc(), uv__free(), uv__handle_start, uv__handle_unref, uv_fs_stat(), UV_HANDLE_INTERNAL, uv_is_active(), uv_now(), and uv_timer_init().

◆ uv_fs_poll_stop()

UV_EXTERN int uv_fs_poll_stop ( uv_fs_poll_t handle)

Definition at line 116 of file fs-poll.c.

116  {
117  struct poll_ctx* ctx;
118 
120  return 0;
121 
122  ctx = handle->poll_ctx;
123  assert(ctx != NULL);
124  assert(ctx->parent_handle == handle);
125 
126  /* Close the timer if it's active. If it's inactive, there's a stat request
127  * in progress and poll_cb will take care of the cleanup.
128  */
129  if (uv_is_active((uv_handle_t*)&ctx->timer_handle))
130  uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
131 
133 
134  return 0;
135 }
static void timer_close_cb(uv_handle_t *handle)
Definition: fs-poll.c:234
UV_EXTERN void uv_close(uv_handle_t *handle, uv_close_cb close_cb)
Definition: core.c:108

References assert(), handle, NULL, timer_close_cb(), uv__handle_stop, uv_close(), and uv_is_active().

Referenced by uv__fs_poll_close().

◆ uv_fs_read()

UV_EXTERN int uv_fs_read ( uv_loop_t loop,
uv_fs_t req,
uv_file  file,
const uv_buf_t  bufs[],
unsigned int  nbufs,
int64_t  offset,
uv_fs_cb  cb 
)

Definition at line 1872 of file fs.c.

1877  {
1878  INIT(READ);
1879 
1880  if (bufs == NULL || nbufs == 0)
1881  return UV_EINVAL;
1882 
1883  req->file = file;
1884 
1885  req->nbufs = nbufs;
1886  req->bufs = req->bufsml;
1887  if (nbufs > ARRAY_SIZE(req->bufsml))
1888  req->bufs = uv__malloc(nbufs * sizeof(*bufs));
1889 
1890  if (req->bufs == NULL)
1891  return UV_ENOMEM;
1892 
1893  memcpy(req->bufs, bufs, nbufs * sizeof(*bufs));
1894 
1895  req->off = off;
1896  POST;
1897 }
#define ARRAY_SIZE(a)
#define READ(x, i)
Definition: bflt.c:22
static char bufs[4][128]
Buffers for uint64_to_str() and uint64_to_nicestr()
Definition: util.c:18

References ARRAY_SIZE, bufs, fd, file, INIT, memcpy(), NULL, off, POST, READ, req, SET_REQ_UV_ERROR, uv__malloc(), and UV_FS_READ.

Referenced by main(), on_open(), on_type(), and on_write().

◆ uv_fs_readdir()

UV_EXTERN int uv_fs_readdir ( uv_loop_t loop,
uv_fs_t req,
uv_dir_t dir,
uv_fs_cb  cb 
)

Definition at line 1920 of file fs.c.

1923  {
1924  INIT(READDIR);
1925 
1926  if (dir == NULL || dir->dir == NULL || dir->dirents == NULL)
1927  return UV_EINVAL;
1928 
1929  req->ptr = dir;
1930  POST;
1931 }
uv_dirent_t * dirents
Definition: uv.h:1299

References uv_dir_s::dirents, INIT, INVALID_HANDLE_VALUE, NULL, POST, req, SET_REQ_UV_ERROR, and UV_FS_READDIR.

◆ uv_fs_readlink()

UV_EXTERN int uv_fs_readlink ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
uv_fs_cb  cb 
)

Definition at line 1946 of file fs.c.

1949  {
1950  INIT(READLINK);
1951  PATH;
1952  POST;
1953 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_READLINK.

◆ uv_fs_realpath()

UV_EXTERN int uv_fs_realpath ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
uv_fs_cb  cb 
)

Definition at line 1956 of file fs.c.

1959  {
1960  INIT(REALPATH);
1961  PATH;
1962  POST;
1963 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_UV_ERROR, SET_REQ_WIN32_ERROR, and UV_FS_REALPATH.

◆ uv_fs_rename()

UV_EXTERN int uv_fs_rename ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
const char *  new_path,
uv_fs_cb  cb 
)

Definition at line 1966 of file fs.c.

1970  {
1971  INIT(RENAME);
1972  PATH2;
1973  POST;
1974 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH2, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_RENAME.

◆ uv_fs_req_cleanup()

UV_EXTERN void uv_fs_req_cleanup ( uv_fs_t req)

Definition at line 2070 of file fs.c.

2070  {
2071  if (req == NULL)
2072  return;
2073 
2074  /* Only necessary for asychronous requests, i.e., requests with a callback.
2075  * Synchronous ones don't copy their arguments and have req->path and
2076  * req->new_path pointing to user-owned memory. UV_FS_MKDTEMP and
2077  * UV_FS_MKSTEMP are the exception to the rule, they always allocate memory.
2078  */
2079  if (req->path != NULL &&
2080  (req->cb != NULL ||
2081  req->fs_type == UV_FS_MKDTEMP || req->fs_type == UV_FS_MKSTEMP))
2082  uv__free((void*) req->path); /* Memory is shared with req->new_path. */
2083 
2084  req->path = NULL;
2085  req->new_path = NULL;
2086 
2087  if (req->fs_type == UV_FS_READDIR && req->ptr != NULL)
2089 
2090  if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL)
2092 
2093  if (req->bufs != req->bufsml)
2094  uv__free(req->bufs);
2095  req->bufs = NULL;
2096 
2097  if (req->fs_type != UV_FS_OPENDIR && req->ptr != &req->statbuf)
2098  uv__free(req->ptr);
2099  req->ptr = NULL;
2100 }
void uv__fs_scandir_cleanup(uv_fs_t *req)
Definition: uv-common.c:635
void uv__fs_readdir_cleanup(uv_fs_t *req)
Definition: uv-common.c:724

References NULL, req, uv__free(), uv__fs_readdir_cleanup(), uv__fs_scandir_cleanup(), UV_FS_CLEANEDUP, UV_FS_FREE_PATHS, UV_FS_FREE_PTR, UV_FS_MKDTEMP, UV_FS_MKSTEMP, UV_FS_OPENDIR, UV_FS_READDIR, and UV_FS_SCANDIR.

Referenced by main(), poll_cb(), and uv__fs_copyfile().

◆ uv_fs_rmdir()

UV_EXTERN int uv_fs_rmdir ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
uv_fs_cb  cb 
)

Definition at line 1977 of file fs.c.

1977  {
1978  INIT(RMDIR);
1979  PATH;
1980  POST;
1981 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_RMDIR.

◆ uv_fs_scandir()

UV_EXTERN int uv_fs_scandir ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
int  flags,
uv_fs_cb  cb 
)

Definition at line 1900 of file fs.c.

1904  {
1905  INIT(SCANDIR);
1906  PATH;
1907  req->flags = flags;
1908  POST;
1909 }

References cb, err, flags, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_SCANDIR.

◆ uv_fs_scandir_next()

UV_EXTERN int uv_fs_scandir_next ( uv_fs_t req,
uv_dirent_t ent 
)

Definition at line 651 of file uv-common.c.

651  {
652  uv__dirent_t** dents;
653  uv__dirent_t* dent;
654  unsigned int* nbufs;
655 
656  /* Check to see if req passed */
657  if (req->result < 0)
658  return req->result;
659 
660  /* Ptr will be null if req was canceled or no files found */
661  if (!req->ptr)
662  return UV_EOF;
663 
664  nbufs = uv__get_nbufs(req);
665  assert(nbufs);
666 
667  dents = req->ptr;
668 
669  /* Free previous entity */
670  if (*nbufs > 0)
671  uv__fs_scandir_free(dents[*nbufs - 1]);
672 
673  /* End was already reached */
674  if (*nbufs == (unsigned int) req->result) {
675  uv__fs_scandir_free(dents);
676  req->ptr = NULL;
677  return UV_EOF;
678  }
679 
680  dent = dents[(*nbufs)++];
681 
682  ent->name = dent->d_name;
683  ent->type = uv__fs_get_dirent_type(dent);
684 
685  return 0;
686 }
Definition: sftypes.h:48
char d_name[256]
Definition: sftypes.h:52
uv_dirent_type_t type
Definition: uv.h:1152
const char * name
Definition: uv.h:1151
#define uv__fs_scandir_free
Definition: uv-common.c:632
static unsigned int * uv__get_nbufs(uv_fs_t *req)
Definition: uv-common.c:617
uv_dirent_type_t uv__fs_get_dirent_type(uv__dirent_t *dent)
Definition: uv-common.c:688

References assert(), dirent::d_name, uv_dirent_s::name, NULL, req, uv_dirent_s::type, uv__fs_get_dirent_type(), uv__fs_scandir_free, and uv__get_nbufs().

◆ uv_fs_sendfile()

UV_EXTERN int uv_fs_sendfile ( uv_loop_t loop,
uv_fs_t req,
uv_file  out_fd,
uv_file  in_fd,
int64_t  in_offset,
size_t  length,
uv_fs_cb  cb 
)

Definition at line 1984 of file fs.c.

1990  {
1991  INIT(SENDFILE);
1992  req->flags = in_fd; /* hack */
1993  req->file = out_fd;
1994  req->off = off;
1995  req->bufsml[0].len = len;
1996  POST;
1997 }

References INIT, len, length, off, POST, req, and UV_FS_SENDFILE.

Referenced by uv__fs_copyfile().

◆ uv_fs_stat()

UV_EXTERN int uv_fs_stat ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
uv_fs_cb  cb 
)

Definition at line 2000 of file fs.c.

2000  {
2001  INIT(STAT);
2002  PATH;
2003  POST;
2004 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_STAT.

Referenced by timer_cb(), and uv_fs_poll_start().

◆ uv_fs_statfs()

UV_EXTERN int uv_fs_statfs ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
uv_fs_cb  cb 
)

Definition at line 2123 of file fs.c.

2126  {
2127  INIT(STATFS);
2128  PATH;
2129  POST;
2130 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_STATFS.

◆ uv_fs_symlink()

UV_EXTERN int uv_fs_symlink ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
const char *  new_path,
int  flags,
uv_fs_cb  cb 
)

Definition at line 2007 of file fs.c.

2012  {
2013  INIT(SYMLINK);
2014  PATH2;
2015  req->flags = flags;
2016  POST;
2017 }

References cb, err, flags, fs__capture_path(), INIT, NULL, path, PATH2, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_SYMLINK.

◆ uv_fs_unlink()

UV_EXTERN int uv_fs_unlink ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
uv_fs_cb  cb 
)

Definition at line 2020 of file fs.c.

2020  {
2021  INIT(UNLINK);
2022  PATH;
2023  POST;
2024 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_UNLINK.

Referenced by remove_sock(), and uv__fs_copyfile().

◆ uv_fs_utime()

UV_EXTERN int uv_fs_utime ( uv_loop_t loop,
uv_fs_t req,
const char *  path,
double  atime,
double  mtime,
uv_fs_cb  cb 
)

Definition at line 2027 of file fs.c.

2032  {
2033  INIT(UTIME);
2034  PATH;
2035  req->atime = atime;
2036  req->mtime = mtime;
2037  POST;
2038 }

References cb, err, fs__capture_path(), INIT, NULL, path, PATH, POST, req, SET_REQ_WIN32_ERROR, and UV_FS_UTIME.

◆ uv_fs_write()

UV_EXTERN int uv_fs_write ( uv_loop_t loop,
uv_fs_t req,
uv_file  file,
const uv_buf_t  bufs[],
unsigned int  nbufs,
int64_t  offset,
uv_fs_cb  cb 
)

Definition at line 2041 of file fs.c.

2047  {
2048  INIT(WRITE);
2049 
2050  if (bufs == NULL || nbufs == 0)
2051  return UV_EINVAL;
2052 
2053  req->file = file;
2054 
2055  req->nbufs = nbufs;
2056  req->bufs = req->bufsml;
2057  if (nbufs > ARRAY_SIZE(req->bufsml))
2058  req->bufs = uv__malloc(nbufs * sizeof(*bufs));
2059 
2060  if (req->bufs == NULL)
2061  return UV_ENOMEM;
2062 
2063  memcpy(req->bufs, bufs, nbufs * sizeof(*bufs));
2064 
2065  req->off = off;
2066  POST;
2067 }

References ARRAY_SIZE, bufs, fd, file, INIT, memcpy(), NULL, off, POST, req, SET_REQ_UV_ERROR, uv__malloc(), and UV_FS_WRITE.

Referenced by on_read().

◆ uv_get_constrained_memory()

UV_EXTERN uint64_t uv_get_constrained_memory ( void  )

Definition at line 387 of file aix.c.

387  {
388  return 0; /* Memory constraints are unknown. */
389 }

References uv__read_cgroups_uint64().

◆ uv_get_free_memory()

UV_EXTERN uint64_t uv_get_free_memory ( void  )

Definition at line 367 of file aix.c.

367  {
368  perfstat_memory_total_t mem_total;
369  int result = perfstat_memory_total(NULL, &mem_total, sizeof(mem_total), 1);
370  if (result == -1) {
371  return 0;
372  }
373  return mem_total.real_free * 4096;
374 }

References ARRAY_SIZE, data_area_ptr::assign, count, CVT_PTR, CVTRCEP_OFFSET, data_area_ptr::deref, get_ibmi_system_status(), get_mem_info(), info(), SSTS0200::main_storage_size, NULL, RCEAFC_OFFSET, status, sysinfo, UV__ERR, uv__read_proc_meminfo(), and which.

◆ uv_get_osfhandle()

UV_EXTERN uv_os_fd_t uv_get_osfhandle ( int  fd)

Definition at line 1389 of file core.c.

1389  {
1390  return fd;
1391 }

References fd, and uv__get_osfhandle().

◆ uv_get_process_title()

UV_EXTERN int uv_get_process_title ( char *  buffer,
size_t  size 
)

Definition at line 960 of file aix.c.

960  {
961  size_t len;
962  if (buffer == NULL || size == 0)
963  return UV_EINVAL;
964 
965  /* If uv_setup_args wasn't called, we can't continue. */
966  if (process_argv == NULL)
967  return UV_ENOBUFS;
968 
971 
972  len = strlen(process_argv[0]);
973  if (size <= len) {
975  return UV_ENOBUFS;
976  }
977 
979  buffer[len] = '\0';
980 
982 
983  return 0;
984 }
static char ** process_argv
Definition: aix.c:72
uv_once_t process_title_mutex_once
Definition: aix.c:70
void init_process_title_mutex_once(void)
Definition: aix.c:76
uv_mutex_t process_title_mutex
Definition: aix.c:69

References args_mem, assert(), init_process_title_mutex_once(), len, uv__process_title::len, memcpy(), NULL, process_argv, process_title, process_title_lock, process_title_mutex, process_title_mutex_once, uv__process_title::str, uv__get_process_title(), uv__once_init(), uv_mutex_lock(), uv_mutex_unlock(), uv_once(), and uv_translate_sys_error().

◆ uv_get_total_memory()

UV_EXTERN uint64_t uv_get_total_memory ( void  )

Definition at line 377 of file aix.c.

377  {
378  perfstat_memory_total_t mem_total;
379  int result = perfstat_memory_total(NULL, &mem_total, sizeof(mem_total), 1);
380  if (result == -1) {
381  return 0;
382  }
383  return mem_total.real_total * 4096;
384 }

References ARRAY_SIZE, data_area_ptr::assign, CVT_PTR, CVTRCEP_OFFSET, data_area_ptr::deref, get_ibmi_system_status(), get_mem_info(), info(), SSTS0200::main_storage_size, NULL, RCEPOOL_OFFSET, status, sysinfo, UV__ERR, uv__read_proc_meminfo(), and which.

◆ uv_getaddrinfo()

UV_EXTERN int uv_getaddrinfo ( uv_loop_t loop,
uv_getaddrinfo_t req,
uv_getaddrinfo_cb  getaddrinfo_cb,
const char *  node,
const char *  service,
const struct addrinfo *  hints 
)

Definition at line 141 of file getaddrinfo.c.

146  {
147  char hostname_ascii[256];
148  size_t hostname_len;
149  size_t service_len;
150  size_t hints_len;
151  size_t len;
152  char* buf;
153  long rc;
154 
155  if (req == NULL || (hostname == NULL && service == NULL))
156  return UV_EINVAL;
157 
158  /* FIXME(bnoordhuis) IDNA does not seem to work z/OS,
159  * probably because it uses EBCDIC rather than ASCII.
160  */
161 #ifdef __MVS__
162  (void) &hostname_ascii;
163 #else
164  if (hostname != NULL) {
165  rc = uv__idna_toascii(hostname,
166  hostname + strlen(hostname),
167  hostname_ascii,
168  hostname_ascii + sizeof(hostname_ascii));
169  if (rc < 0)
170  return rc;
171  hostname = hostname_ascii;
172  }
173 #endif
174 
175  hostname_len = hostname ? strlen(hostname) + 1 : 0;
176  service_len = service ? strlen(service) + 1 : 0;
177  hints_len = hints ? sizeof(*hints) : 0;
178  buf = uv__malloc(hostname_len + service_len + hints_len);
179 
180  if (buf == NULL)
181  return UV_ENOMEM;
182 
183  uv__req_init(loop, req, UV_GETADDRINFO);
184  req->loop = loop;
185  req->cb = cb;
186  req->addrinfo = NULL;
187  req->hints = NULL;
188  req->service = NULL;
189  req->hostname = NULL;
190  req->retcode = 0;
191 
192  /* order matters, see uv_getaddrinfo_done() */
193  len = 0;
194 
195  if (hints) {
196  req->hints = memcpy(buf + len, hints, sizeof(*hints));
197  len += sizeof(*hints);
198  }
199 
200  if (service) {
201  req->service = memcpy(buf + len, service, service_len);
202  len += service_len;
203  }
204 
205  if (hostname)
206  req->hostname = memcpy(buf + len, hostname, hostname_len);
207 
208  if (cb) {
210  &req->work_req,
214  return 0;
215  } else {
216  uv__getaddrinfo_work(&req->work_req);
217  uv__getaddrinfo_done(&req->work_req, 0);
218  return req->retcode;
219  }
220 }
long uv__idna_toascii(const char *s, const char *se, char *d, char *de)
Definition: idna.c:250
void uv__work_submit(uv_loop_t *loop, struct uv__work *w, enum uv__work_kind kind, void(*work)(struct uv__work *w), void(*done)(struct uv__work *w, int status))
Definition: threadpool.c:256
static void uv__getaddrinfo_work(struct uv__work *w)
Definition: getaddrinfo.c:101
static void uv__getaddrinfo_done(struct uv__work *w, int status)
Definition: getaddrinfo.c:111
@ UV__WORK_SLOW_IO
Definition: uv-common.h:194
#define uv__req_init(loop, req, typ)
Definition: uv-common.h:329

References ALIGNED_SIZE, cb, err, error(), len, loop, memcpy(), NULL, req, uv__free(), uv__getaddrinfo_done(), uv__getaddrinfo_work(), uv__idna_toascii(), uv__malloc(), uv__req_init, uv__req_register, UV__WORK_SLOW_IO, uv__work_submit(), UV_REQ_INIT, and uv_translate_sys_error().

Referenced by main().

◆ uv_getnameinfo()

UV_EXTERN int uv_getnameinfo ( uv_loop_t loop,
uv_getnameinfo_t req,
uv_getnameinfo_cb  getnameinfo_cb,
const struct sockaddr addr,
int  flags 
)

Definition at line 81 of file getnameinfo.c.

85  {
86  if (req == NULL || addr == NULL)
87  return UV_EINVAL;
88 
89  if (addr->sa_family == AF_INET) {
90  memcpy(&req->storage,
91  addr,
92  sizeof(struct sockaddr_in));
93  } else if (addr->sa_family == AF_INET6) {
94  memcpy(&req->storage,
95  addr,
96  sizeof(struct sockaddr_in6));
97  } else {
98  return UV_EINVAL;
99  }
100 
101  uv__req_init(loop, (uv_req_t*)req, UV_GETNAMEINFO);
102 
103  req->getnameinfo_cb = getnameinfo_cb;
104  req->flags = flags;
105  req->type = UV_GETNAMEINFO;
106  req->loop = loop;
107  req->retcode = 0;
108 
109  if (getnameinfo_cb) {
111  &req->work_req,
115  return 0;
116  } else {
117  uv__getnameinfo_work(&req->work_req);
118  uv__getnameinfo_done(&req->work_req, 0);
119  return req->retcode;
120  }
121 }
#define AF_INET
Definition: sftypes.h:287
#define AF_INET6
Definition: sftypes.h:295
Definition: uv.h:407
static void uv__getnameinfo_work(struct uv__work *w)
Definition: getnameinfo.c:31
static void uv__getnameinfo_done(struct uv__work *w, int status)
Definition: getnameinfo.c:55
static int addr
Definition: z80asm.c:58

References addr, AF_INET, AF_INET6, flags, loop, memcpy(), NULL, req, uv__getnameinfo_done(), uv__getnameinfo_work(), uv__req_init, uv__req_register, UV__WORK_SLOW_IO, uv__work_submit(), and UV_REQ_INIT.

◆ uv_getrusage()

UV_EXTERN int uv_getrusage ( uv_rusage_t rusage)

Definition at line 970 of file core.c.

970  {
971  struct rusage usage;
972 
973  if (getrusage(RUSAGE_SELF, &usage))
974  return UV__ERR(errno);
975 
976  rusage->ru_utime.tv_sec = usage.ru_utime.tv_sec;
977  rusage->ru_utime.tv_usec = usage.ru_utime.tv_usec;
978 
979  rusage->ru_stime.tv_sec = usage.ru_stime.tv_sec;
980  rusage->ru_stime.tv_usec = usage.ru_stime.tv_usec;
981 
982 #if !defined(__MVS__) && !defined(__HAIKU__)
983  rusage->ru_maxrss = usage.ru_maxrss;
984  rusage->ru_ixrss = usage.ru_ixrss;
985  rusage->ru_idrss = usage.ru_idrss;
986  rusage->ru_isrss = usage.ru_isrss;
987  rusage->ru_minflt = usage.ru_minflt;
988  rusage->ru_majflt = usage.ru_majflt;
989  rusage->ru_nswap = usage.ru_nswap;
990  rusage->ru_inblock = usage.ru_inblock;
991  rusage->ru_oublock = usage.ru_oublock;
992  rusage->ru_msgsnd = usage.ru_msgsnd;
993  rusage->ru_msgrcv = usage.ru_msgrcv;
994  rusage->ru_nsignals = usage.ru_nsignals;
995  rusage->ru_nvcsw = usage.ru_nvcsw;
996  rusage->ru_nivcsw = usage.ru_nivcsw;
997 #endif
998 
999  return 0;
1000 }
void usage(const char *message)
long ru_nvcsw
Definition: sftypes.h:3485
long ru_nswap
Definition: sftypes.h:3479
struct timeval ru_utime
Definition: sftypes.h:3471
long ru_minflt
Definition: sftypes.h:3477
long ru_nivcsw
Definition: sftypes.h:3486
struct timeval ru_stime
Definition: sftypes.h:3472
long ru_isrss
Definition: sftypes.h:3476
long ru_majflt
Definition: sftypes.h:3478
long ru_idrss
Definition: sftypes.h:3475
long ru_nsignals
Definition: sftypes.h:3484
long ru_msgsnd
Definition: sftypes.h:3482
long ru_ixrss
Definition: sftypes.h:3474
long ru_inblock
Definition: sftypes.h:3480
long ru_msgrcv
Definition: sftypes.h:3483
long ru_maxrss
Definition: sftypes.h:3473
long ru_oublock
Definition: sftypes.h:3481
long tv_sec
Definition: sftypes.h:84
long tv_usec
Definition: sftypes.h:85

References memset(), rusage::ru_idrss, rusage::ru_inblock, uv_rusage_t::ru_inblock, rusage::ru_isrss, rusage::ru_ixrss, rusage::ru_majflt, uv_rusage_t::ru_majflt, rusage::ru_maxrss, uv_rusage_t::ru_maxrss, rusage::ru_minflt, rusage::ru_msgrcv, rusage::ru_msgsnd, rusage::ru_nivcsw, rusage::ru_nsignals, rusage::ru_nswap, rusage::ru_nvcsw, rusage::ru_oublock, uv_rusage_t::ru_oublock, rusage::ru_stime, uv_rusage_t::ru_stime, rusage::ru_utime, uv_rusage_t::ru_utime, timeval::tv_sec, uv_timeval_t::tv_sec, timeval::tv_usec, uv_timeval_t::tv_usec, usage(), UV__ERR, and uv_translate_sys_error().

◆ uv_gettimeofday()

UV_EXTERN int uv_gettimeofday ( uv_timeval64_t tv)

Definition at line 1512 of file core.c.

1512  {
1513  struct timeval time;
1514 
1515  if (tv == NULL)
1516  return UV_EINVAL;
1517 
1518  if (gettimeofday(&time, NULL) != 0)
1519  return UV__ERR(errno);
1520 
1521  tv->tv_sec = (int64_t) time.tv_sec;
1522  tv->tv_usec = (int32_t) time.tv_usec;
1523  return 0;
1524 }
static static fork const void static count static fd const char const char static newpath char char char static envp time
Definition: sflib.h:42
long int64_t
Definition: sftypes.h:32
int int32_t
Definition: sftypes.h:33

References gettimeofday, NULL, time, tv, and UV__ERR.

◆ uv_guess_handle()

UV_EXTERN uv_handle_type uv_guess_handle ( uv_file  file)

Definition at line 315 of file tty.c.

315  {
316  struct sockaddr sa;
317  struct stat s;
318  socklen_t len;
319  int type;
320 
321  if (file < 0)
322  return UV_UNKNOWN_HANDLE;
323 
324  if (isatty(file))
325  return UV_TTY;
326 
327  if (fstat(file, &s))
328  return UV_UNKNOWN_HANDLE;
329 
330  if (S_ISREG(s.st_mode))
331  return UV_FILE;
332 
333  if (S_ISCHR(s.st_mode))
334  return UV_FILE; /* XXX UV_NAMED_PIPE? */
335 
336  if (S_ISFIFO(s.st_mode))
337  return UV_NAMED_PIPE;
338 
339  if (!S_ISSOCK(s.st_mode))
340  return UV_UNKNOWN_HANDLE;
341 
342  len = sizeof(type);
343  if (getsockopt(file, SOL_SOCKET, SO_TYPE, &type, &len))
344  return UV_UNKNOWN_HANDLE;
345 
346  len = sizeof(sa);
347  if (getsockname(file, &sa, &len))
348  return UV_UNKNOWN_HANDLE;
349 
350  if (type == SOCK_DGRAM)
351  if (sa.sa_family == AF_INET || sa.sa_family == AF_INET6)
352  return UV_UDP;
353 
354  if (type == SOCK_STREAM) {
355 #if defined(_AIX) || defined(__DragonFly__)
356  /* on AIX/DragonFly the getsockname call returns an empty sa structure
357  * for sockets of type AF_UNIX. For all other types it will
358  * return a properly filled in structure.
359  */
360  if (len == 0)
361  return UV_NAMED_PIPE;
362 #endif /* defined(_AIX) || defined(__DragonFly__) */
363 
364  if (sa.sa_family == AF_INET || sa.sa_family == AF_INET6)
365  return UV_TCP;
366  if (sa.sa_family == AF_UNIX)
367  return UV_NAMED_PIPE;
368  }
369 
370  return UV_UNKNOWN_HANDLE;
371 }
#define S_ISREG(mode)
Definition: compat.h:191
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset fstat
Definition: sflib.h:107
static RzSocket * s
Definition: rtr.c:28
#define AF_UNIX
Definition: sftypes.h:285
unsigned int socklen_t
Definition: sftypes.h:219
@ SOCK_DGRAM
Definition: sftypes.h:227
@ SOCK_STREAM
Definition: sftypes.h:224
#define SO_TYPE
Definition: sftypes.h:431
#define SOL_SOCKET
Definition: sftypes.h:427
Definition: gzappend.c:170
Definition: sftypes.h:80

References AF_INET, AF_INET6, AF_UNIX, DWORD, fstat, handle, HANDLE, len, s, S_ISREG, SO_TYPE, SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET, type, uv__get_osfhandle(), UV_FILE, and UV_UNKNOWN_HANDLE.

Referenced by main(), and uv_tty_init().

◆ uv_handle_get_data()

UV_EXTERN void* uv_handle_get_data ( const uv_handle_t handle)

Definition at line 40 of file uv-data-getter-setters.c.

40  {
41  return handle->data;
42 }

References handle.

◆ uv_handle_get_loop()

UV_EXTERN uv_loop_t* uv_handle_get_loop ( const uv_handle_t handle)

Definition at line 44 of file uv-data-getter-setters.c.

44  {
45  return handle->loop;
46 }

References handle.

◆ uv_handle_get_type()

UV_EXTERN uv_handle_type uv_handle_get_type ( const uv_handle_t handle)

Definition at line 36 of file uv-data-getter-setters.c.

36  {
37  return handle->type;
38 }

References handle.

◆ uv_handle_set_data()

UV_EXTERN void uv_handle_set_data ( uv_handle_t handle,
void *  data 
)

Definition at line 48 of file uv-data-getter-setters.c.

48  {
49  handle->data = data;
50 }

References handle.

◆ uv_handle_size()

UV_EXTERN size_t uv_handle_size ( uv_handle_type  type)

Definition at line 133 of file uv-common.c.

133  {
134  switch (type) {
136  default:
137  return -1;
138  }
139 }
#define XX(uc, lc)
Definition: uv-common.c:131

References type, UV_HANDLE_TYPE_MAP, and XX.

◆ uv_handle_type_name()

UV_EXTERN const char* uv_handle_type_name ( uv_handle_type  type)

Definition at line 24 of file uv-data-getter-setters.c.

24  {
25  switch (type) {
26 #define XX(uc,lc) case UV_##uc: return #lc;
28 #undef XX
29  case UV_FILE: return "file";
30  case UV_HANDLE_TYPE_MAX:
31  case UV_UNKNOWN_HANDLE: return NULL;
32  }
33  return NULL;
34 }
#define XX(uc, lc)

References NULL, type, UV_FILE, UV_HANDLE_TYPE_MAP, UV_HANDLE_TYPE_MAX, UV_UNKNOWN_HANDLE, and XX.

◆ uv_has_ref()

UV_EXTERN int uv_has_ref ( const uv_handle_t handle)

Definition at line 557 of file uv-common.c.

557  {
558  return uv__has_ref(handle);
559 }
#define uv__has_ref(h)
Definition: uv-common.h:292

References handle, and uv__has_ref.

◆ uv_hrtime()

UV_EXTERN uint64_t uv_hrtime ( void  )

◆ uv_idle_init()

UV_EXTERN int uv_idle_init ( uv_loop_t ,
uv_idle_t idle 
)

Referenced by main().

◆ uv_idle_start()

UV_EXTERN int uv_idle_start ( uv_idle_t idle,
uv_idle_cb  cb 
)

Referenced by main(), and on_type().

◆ uv_idle_stop()

UV_EXTERN int uv_idle_stop ( uv_idle_t idle)

◆ uv_if_indextoiid()

UV_EXTERN int uv_if_indextoiid ( unsigned int  ifindex,
char *  buffer,
size_t size 
)

Definition at line 253 of file getaddrinfo.c.

253  {
254  return uv_if_indextoname(ifindex, buffer, size);
255 }
int uv_if_indextoname(unsigned int ifindex, char *buffer, size_t *size)
Definition: getaddrinfo.c:229

References NULL, r, snprintf, uv_if_indextoname(), and uv_translate_sys_error().

◆ uv_if_indextoname()

UV_EXTERN int uv_if_indextoname ( unsigned int  ifindex,
char *  buffer,
size_t size 
)

Definition at line 229 of file getaddrinfo.c.

229  {
230  char ifname_buf[UV_IF_NAMESIZE];
231  size_t len;
232 
233  if (buffer == NULL || size == NULL || *size == 0)
234  return UV_EINVAL;
235 
236  if (if_indextoname(ifindex, ifname_buf) == NULL)
237  return UV__ERR(errno);
238 
239  len = strnlen(ifname_buf, sizeof(ifname_buf));
240 
241  if (*size <= len) {
242  *size = len + 1;
243  return UV_ENOBUFS;
244  }
245 
246  memcpy(buffer, ifname_buf, len);
247  buffer[len] = '\0';
248  *size = len;
249 
250  return 0;
251 }
size_t strnlen(const char *str, size_t maxlen)
#define UV_IF_NAMESIZE
Definition: uv.h:1668

References ARRAY_SIZE, DWORD, len, memcpy(), NDIS_IF_MAX_STRING_SIZE, NULL, r, strnlen(), UV__ERR, UV_IF_NAMESIZE, and uv_translate_sys_error().

Referenced by uv_if_indextoiid().

◆ uv_inet_ntop()

UV_EXTERN int uv_inet_ntop ( int  af,
const void *  src,
char *  dst,
size_t  size 
)

Definition at line 40 of file inet.c.

40  {
41  switch (af) {
42  case AF_INET:
43  return (inet_ntop4(src, dst, size));
44  case AF_INET6:
45  return (inet_ntop6(src, dst, size));
46  default:
47  return UV_EAFNOSUPPORT;
48  }
49  /* NOTREACHED */
50 }
lzma_index * src
Definition: index.h:567
static int inet_ntop6(const unsigned char *src, char *dst, size_t size)
Definition: inet.c:67
static int inet_ntop4(const unsigned char *src, char *dst, size_t size)
Definition: inet.c:53
char * dst
Definition: lz4.h:724

References AF_INET, AF_INET6, dst, inet_ntop4(), inet_ntop6(), and src.

Referenced by uv_ip4_name(), and uv_ip6_name().

◆ uv_inet_pton()

UV_EXTERN int uv_inet_pton ( int  af,
const char *  src,
void *  dst 
)

Definition at line 150 of file inet.c.

150  {
151  if (src == NULL || dst == NULL)
152  return UV_EINVAL;
153 
154  switch (af) {
155  case AF_INET:
156  return (inet_pton4(src, dst));
157  case AF_INET6: {
158  int len;
159  char tmp[UV__INET6_ADDRSTRLEN], *s, *p;
160  s = (char*) src;
161  p = strchr(src, '%');
162  if (p != NULL) {
163  s = tmp;
164  len = p - src;
165  if (len > UV__INET6_ADDRSTRLEN-1)
166  return UV_EINVAL;
167  memcpy(s, src, len);
168  s[len] = '\0';
169  }
170  return inet_pton6(s, dst);
171  }
172  default:
173  return UV_EAFNOSUPPORT;
174  }
175  /* NOTREACHED */
176 }
static int inet_pton6(const char *src, unsigned char *dst)
Definition: inet.c:218
#define UV__INET6_ADDRSTRLEN
Definition: inet.c:31
static int inet_pton4(const char *src, unsigned char *dst)
Definition: inet.c:179
void * p
Definition: libc.cpp:67

References AF_INET, AF_INET6, dst, inet_pton4(), inet_pton6(), len, memcpy(), NULL, p, s, src, autogen_x86imm::tmp, and UV__INET6_ADDRSTRLEN.

Referenced by uv__udp_set_membership4(), uv__udp_set_source_membership4(), uv_ip4_addr(), and uv_ip6_addr().

◆ uv_interface_addresses()

UV_EXTERN int uv_interface_addresses ( uv_interface_address_t **  addresses,
int count 
)

Definition at line 1100 of file aix.c.

1100  {
1101  uv_interface_address_t* address;
1102  int sockfd, sock6fd, inet6, i, r, size = 1;
1103  struct ifconf ifc;
1104  struct ifreq *ifr, *p, flg;
1105  struct in6_ifreq if6;
1106  struct sockaddr_dl* sa_addr;
1107 
1108  ifc.ifc_req = NULL;
1109  sock6fd = -1;
1110  r = 0;
1111  *count = 0;
1112  *addresses = NULL;
1113 
1114  if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
1115  r = UV__ERR(errno);
1116  goto cleanup;
1117  }
1118 
1119  if (0 > (sock6fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP))) {
1120  r = UV__ERR(errno);
1121  goto cleanup;
1122  }
1123 
1124  if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) {
1125  r = UV__ERR(errno);
1126  goto cleanup;
1127  }
1128 
1129  ifc.ifc_req = (struct ifreq*)uv__malloc(size);
1130  if (ifc.ifc_req == NULL) {
1131  r = UV_ENOMEM;
1132  goto cleanup;
1133  }
1134  ifc.ifc_len = size;
1135  if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) {
1136  r = UV__ERR(errno);
1137  goto cleanup;
1138  }
1139 
1140 #define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p))
1141 
1142  /* Count all up and running ipv4/ipv6 addresses */
1143  ifr = ifc.ifc_req;
1144  while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
1145  p = ifr;
1146  ifr = (struct ifreq*)
1147  ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
1148 
1149  if (!(p->ifr_addr.sa_family == AF_INET6 ||
1150  p->ifr_addr.sa_family == AF_INET))
1151  continue;
1152 
1153  memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
1154  if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
1155  r = UV__ERR(errno);
1156  goto cleanup;
1157  }
1158 
1159  if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
1160  continue;
1161 
1162  (*count)++;
1163  }
1164 
1165  if (*count == 0)
1166  goto cleanup;
1167 
1168  /* Alloc the return interface structs */
1169  *addresses = uv__calloc(*count, sizeof(**addresses));
1170  if (!(*addresses)) {
1171  r = UV_ENOMEM;
1172  goto cleanup;
1173  }
1174  address = *addresses;
1175 
1176  ifr = ifc.ifc_req;
1177  while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
1178  p = ifr;
1179  ifr = (struct ifreq*)
1180  ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
1181 
1182  if (!(p->ifr_addr.sa_family == AF_INET6 ||
1183  p->ifr_addr.sa_family == AF_INET))
1184  continue;
1185 
1186  inet6 = (p->ifr_addr.sa_family == AF_INET6);
1187 
1188  memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
1189  if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1)
1190  goto syserror;
1191 
1192  if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
1193  continue;
1194 
1195  /* All conditions above must match count loop */
1196 
1197  address->name = uv__strdup(p->ifr_name);
1198 
1199  if (inet6)
1200  address->address.address6 = *((struct sockaddr_in6*) &p->ifr_addr);
1201  else
1202  address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr);
1203 
1204  if (inet6) {
1205  memset(&if6, 0, sizeof(if6));
1206  r = uv__strscpy(if6.ifr_name, p->ifr_name, sizeof(if6.ifr_name));
1207  if (r == UV_E2BIG)
1208  goto cleanup;
1209  r = 0;
1210  memcpy(&if6.ifr_Addr, &p->ifr_addr, sizeof(if6.ifr_Addr));
1211  if (ioctl(sock6fd, SIOCGIFNETMASK6, &if6) == -1)
1212  goto syserror;
1213  address->netmask.netmask6 = *((struct sockaddr_in6*) &if6.ifr_Addr);
1214  /* Explicitly set family as the ioctl call appears to return it as 0. */
1215  address->netmask.netmask6.sin6_family = AF_INET6;
1216  } else {
1217  if (ioctl(sockfd, SIOCGIFNETMASK, p) == -1)
1218  goto syserror;
1219  address->netmask.netmask4 = *((struct sockaddr_in*) &p->ifr_addr);
1220  /* Explicitly set family as the ioctl call appears to return it as 0. */
1221  address->netmask.netmask4.sin_family = AF_INET;
1222  }
1223 
1224  address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0;
1225 
1226  address++;
1227  }
1228 
1229  /* Fill in physical addresses. */
1230  ifr = ifc.ifc_req;
1231  while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
1232  p = ifr;
1233  ifr = (struct ifreq*)
1234  ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
1235 
1236  if (p->ifr_addr.sa_family != AF_LINK)
1237  continue;
1238 
1239  address = *addresses;
1240  for (i = 0; i < *count; i++) {
1241  if (strcmp(address->name, p->ifr_name) == 0) {
1242  sa_addr = (struct sockaddr_dl*) &p->ifr_addr;
1243  memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
1244  }
1245  address++;
1246  }
1247  }
1248 
1249 #undef ADDR_SIZE
1250  goto cleanup;
1251 
1252 syserror:
1253  uv_free_interface_addresses(*addresses, *count);
1254  *addresses = NULL;
1255  *count = 0;
1256  r = UV_ENOSYS;
1257 
1258 cleanup:
1259  if (sockfd != -1)
1260  uv__close(sockfd);
1261  if (sock6fd != -1)
1262  uv__close(sock6fd);
1263  uv__free(ifc.ifc_req);
1264  return r;
1265 }
#define ADDR_SIZE(p)
void uv_free_interface_addresses(uv_interface_address_t *addresses, int count)
Definition: aix.c:1268
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd socket
Definition: sflib.h:79
static static sync static getppid static getegid const char static filename ioctl
Definition: sflib.h:62
void cleanup(void)
Definition: enough.c:244
static sockfd
Definition: sfsocketcall.h:114
struct sockaddr_in6 netmask6
Definition: uv.h:1106
struct sockaddr_in6 address6
Definition: uv.h:1102
struct sockaddr_in netmask4
Definition: uv.h:1105
union uv_interface_address_s::@399 netmask
union uv_interface_address_s::@398 address
struct sockaddr_in address4
Definition: uv.h:1101
char phys_addr[6]
Definition: uv.h:1098

References ADDR_SIZE, uv_interface_address_s::address, uv_interface_address_s::address4, uv_interface_address_s::address6, address_prefix_match(), AF_INET, AF_INET6, AF_UNSPEC, assert(), cleanup(), count, FALSE, flags, freeifaddrs(), get_ibmi_physical_address(), getifaddrs(), i, ifaddrs::ifa_addr, ifaddrs::ifa_flags, ifaddrs::ifa_name, ifaddrs::ifa_netmask, ifaddrs::ifa_next, INT_MAX, ioctl, uv_interface_address_s::is_internal, is_windows_version_or_greater(), memcpy(), memset(), uv_interface_address_s::name, uv_interface_address_s::netmask, uv_interface_address_s::netmask4, uv_interface_address_s::netmask6, NULL, p, uv_interface_address_s::phys_addr, prefix, r, in_addr::s_addr, sockaddr_in6::sin6_addr, sockaddr_in::sin_addr, SOCK_DGRAM, socket, sockfd, ULONG, uv__calloc(), uv__close(), UV__ERR, UV__EXCLUDE_IFADDR, UV__EXCLUDE_IFPHYS, uv__free(), uv__ifaddr_exclude(), uv__interface_addresses_v6(), uv__malloc(), uv__set_phys_addr(), uv__strdup(), uv__strscpy(), uv_free_interface_addresses(), and uv_translate_sys_error().

Referenced by main().

◆ uv_ip4_addr()

UV_EXTERN int uv_ip4_addr ( const char *  ip,
int  port,
struct sockaddr_in addr 
)

Definition at line 221 of file uv-common.c.

221  {
222  memset(addr, 0, sizeof(*addr));
223  addr->sin_family = AF_INET;
224  addr->sin_port = htons(port);
225 #ifdef SIN6_LEN
226  addr->sin_len = sizeof(*addr);
227 #endif
228  return uv_inet_pton(AF_INET, ip, &(addr->sin_addr.s_addr));
229 }
#define ip
#define htons(x)
Definition: sftypes.h:475
UV_EXTERN int uv_inet_pton(int af, const char *src, void *dst)
Definition: inet.c:150

References addr, AF_INET, htons, ip, memset(), and uv_inet_pton().

Referenced by main(), uv_udp_set_membership(), uv_udp_set_multicast_interface(), uv_udp_set_source_membership(), and uv_winsock_init().

◆ uv_ip4_name()

UV_EXTERN int uv_ip4_name ( const struct sockaddr_in src,
char *  dst,
size_t  size 
)

Definition at line 267 of file uv-common.c.

267  {
268  return uv_inet_ntop(AF_INET, &src->sin_addr, dst, size);
269 }
UV_EXTERN int uv_inet_ntop(int af, const void *src, char *dst, size_t size)
Definition: inet.c:40

References AF_INET, dst, src, and uv_inet_ntop().

Referenced by main(), on_read(), and on_resolved().

◆ uv_ip6_addr()

UV_EXTERN int uv_ip6_addr ( const char *  ip,
int  port,
struct sockaddr_in6 addr 
)

Definition at line 232 of file uv-common.c.

232  {
233  char address_part[40];
234  size_t address_part_size;
235  const char* zone_index;
236 
237  memset(addr, 0, sizeof(*addr));
238  addr->sin6_family = AF_INET6;
239  addr->sin6_port = htons(port);
240 #ifdef SIN6_LEN
241  addr->sin6_len = sizeof(*addr);
242 #endif
243 
244  zone_index = strchr(ip, '%');
245  if (zone_index != NULL) {
246  address_part_size = zone_index - ip;
247  if (address_part_size >= sizeof(address_part))
248  address_part_size = sizeof(address_part) - 1;
249 
250  memcpy(address_part, ip, address_part_size);
251  address_part[address_part_size] = '\0';
252  ip = address_part;
253 
254  zone_index++; /* skip '%' */
255  /* NOTE: unknown interface (id=0) is silently ignored */
256 #ifdef _WIN32
257  addr->sin6_scope_id = atoi(zone_index);
258 #else
259  addr->sin6_scope_id = if_nametoindex(zone_index);
260 #endif
261  }
262 
263  return uv_inet_pton(AF_INET6, ip, &addr->sin6_addr);
264 }

References addr, AF_INET6, htons, ip, memcpy(), memset(), NULL, and uv_inet_pton().

Referenced by uv__udp_set_membership6(), uv__udp_set_source_membership6(), uv_udp_set_membership(), uv_udp_set_multicast_interface(), uv_udp_set_source_membership(), and uv_winsock_init().

◆ uv_ip6_name()

UV_EXTERN int uv_ip6_name ( const struct sockaddr_in6 src,
char *  dst,
size_t  size 
)

Definition at line 272 of file uv-common.c.

272  {
273  return uv_inet_ntop(AF_INET6, &src->sin6_addr, dst, size);
274 }

References AF_INET6, dst, src, and uv_inet_ntop().

Referenced by main().

◆ uv_is_active()

UV_EXTERN int uv_is_active ( const uv_handle_t handle)

Definition at line 430 of file core.c.

430  {
431  return uv__is_active(handle);
432 }

References handle, uv__is_active, UV_HANDLE_ACTIVE, and UV_HANDLE_CLOSING.

Referenced by poll_cb(), uv_fs_poll_getpath(), uv_fs_poll_start(), and uv_fs_poll_stop().

◆ uv_is_closing()

UV_EXTERN int uv_is_closing ( const uv_handle_t handle)

Definition at line 323 of file core.c.

323  {
324  return uv__is_closing(handle);
325 }

References handle, uv__is_closing, UV_HANDLE_CLOSED, and UV_HANDLE_CLOSING.

Referenced by uv_fileno().

◆ uv_is_readable()

UV_EXTERN int uv_is_readable ( const uv_stream_t handle)

Definition at line 1606 of file stream.c.

1606  {
1607  return !!(stream->flags & UV_HANDLE_READABLE);
1608 }

References handle, and UV_HANDLE_READABLE.

◆ uv_is_writable()

UV_EXTERN int uv_is_writable ( const uv_stream_t handle)

Definition at line 1611 of file stream.c.

1611  {
1612  return !!(stream->flags & UV_HANDLE_WRITABLE);
1613 }

References handle, and UV_HANDLE_WRITABLE.

◆ uv_key_create()

UV_EXTERN int uv_key_create ( uv_key_t key)

Definition at line 823 of file thread.c.

823  {
824  return UV__ERR(pthread_key_create(key, NULL));
825 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Definition: sflib.h:118

References key, NULL, and UV__ERR.

Referenced by uv__init_current_thread_key().

◆ uv_key_delete()

UV_EXTERN void uv_key_delete ( uv_key_t key)

Definition at line 828 of file thread.c.

828  {
829  if (pthread_key_delete(*key))
830  abort();
831 }

References FALSE, and key.

◆ uv_key_get()

UV_EXTERN void* uv_key_get ( uv_key_t key)

Definition at line 834 of file thread.c.

834  {
835  return pthread_getspecific(*key);
836 }

References key, NULL, and value.

Referenced by uv_thread_self().

◆ uv_key_set()

UV_EXTERN void uv_key_set ( uv_key_t key,
void *  value 
)

Definition at line 839 of file thread.c.

839  {
840  if (pthread_setspecific(*key, value))
841  abort();
842 }
static int value
Definition: cmd_api.c:93

References FALSE, key, and value.

Referenced by uv__thread_start().

◆ uv_kill()

UV_EXTERN int uv_kill ( int  pid,
int  signum 
)

Definition at line 582 of file process.c.

582  {
583  if (kill(pid, signum))
584  return UV__ERR(errno);
585  else
586  return 0;
587 }
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc kill
Definition: sflib.h:64
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
Definition: sflib.h:64
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment signum
Definition: sflib.h:79

References err, FALSE, HANDLE, kill, NULL, pid, signum, UV__ERR, uv__kill(), and uv_translate_sys_error().

Referenced by uv_process_kill().

◆ uv_library_shutdown()

UV_EXTERN void uv_library_shutdown ( void  )

Definition at line 859 of file uv-common.c.

859  {
860  static int was_shutdown;
861 
862  if (uv__load_relaxed(&was_shutdown))
863  return;
864 
868  uv__store_relaxed(&was_shutdown, 1);
869 }
void uv__process_title_cleanup(void)
Definition: aix.c:987
void uv__signal_cleanup(void)
Definition: signal.c:80
void uv__threadpool_cleanup(void)
Definition: threadpool.c:163
#define uv__load_relaxed(p)
Definition: uv-common.h:67
#define uv__store_relaxed(p, v)
Definition: uv-common.h:68

References uv__load_relaxed, uv__process_title_cleanup(), uv__signal_cleanup(), uv__store_relaxed, and uv__threadpool_cleanup().

◆ uv_listen()

UV_EXTERN int uv_listen ( uv_stream_t stream,
int  backlog,
uv_connection_cb  cb 
)

Definition at line 656 of file stream.c.

656  {
657  int err;
658 
659  switch (stream->type) {
660  case UV_TCP:
661  err = uv_tcp_listen((uv_tcp_t*)stream, backlog, cb);
662  break;
663 
664  case UV_NAMED_PIPE:
665  err = uv_pipe_listen((uv_pipe_t*)stream, backlog, cb);
666  break;
667 
668  default:
669  err = UV_EINVAL;
670  }
671 
672  if (err == 0)
674 
675  return err;
676 }
int uv_pipe_listen(uv_pipe_t *handle, int backlog, uv_connection_cb cb)
Definition: pipe.c:94
int uv_tcp_listen(uv_tcp_t *tcp, int backlog, uv_connection_cb cb)
Definition: tcp.c:328

References assert(), cb, err, uv__handle_start, uv_pipe_listen(), uv_tcp_listen(), and uv_translate_sys_error().

Referenced by main().

◆ uv_loadavg()

UV_EXTERN void uv_loadavg ( double  avg[3])

Definition at line 392 of file aix.c.

392  {
393  perfstat_cpu_total_t ps_total;
394  int result = perfstat_cpu_total(NULL, &ps_total, sizeof(ps_total), 1);
395  if (result == -1) {
396  avg[0] = 0.; avg[1] = 0.; avg[2] = 0.;
397  return;
398  }
399  avg[0] = ps_total.loadavg[0] / (double)(1 << SBITS);
400  avg[1] = ps_total.loadavg[1] / (double)(1 << SBITS);
401  avg[2] = ps_total.loadavg[2] / (double)(1 << SBITS);
402 }

References ARRAY_SIZE, get_ibmi_system_status(), info(), test-lz4-speed::loadavg, NULL, SSTS0200::percent_processing_unit_used, sysinfo, uv__slurp(), and which.

◆ uv_loop_alive()

UV_EXTERN int uv_loop_alive ( const uv_loop_t loop)

Definition at line 360 of file core.c.

360  {
361  return uv__loop_alive(loop);
362 }
static int uv__loop_alive(const uv_loop_t *loop)
Definition: core.c:353

References loop, and uv__loop_alive().

◆ uv_loop_close()

UV_EXTERN int uv_loop_close ( uv_loop_t loop)

Definition at line 791 of file uv-common.c.

791  {
792  QUEUE* q;
793  uv_handle_t* h;
794 #ifndef NDEBUG
795  void* saved_data;
796 #endif
797 
799  return UV_EBUSY;
800 
802  h = QUEUE_DATA(q, uv_handle_t, handle_queue);
803  if (!(h->flags & UV_HANDLE_INTERNAL))
804  return UV_EBUSY;
805  }
806 
808 
809 #ifndef NDEBUG
810  saved_data = loop->data;
811  memset(loop, -1, sizeof(*loop));
812  loop->data = saved_data;
813 #endif
814  if (loop == default_loop_ptr)
816 
817  return 0;
818 }
void uv__loop_close(uv_loop_t *loop)
Definition: loop.c:165
#define QUEUE_FOREACH(q, h)
Definition: queue.h:36
#define QUEUE_DATA(ptr, type, field)
Definition: queue.h:30
void * QUEUE[2]
Definition: queue.h:21
#define h(i)
Definition: sha256.c:48
void * data
Definition: uv.h:1782
void * handle_queue[2]
Definition: uv.h:1785

References uv_loop_s::data, default_loop_ptr, h, uv_loop_s::handle_queue, loop, memset(), NULL, QUEUE_DATA, QUEUE_FOREACH, uv__has_active_reqs, uv__loop_close(), and UV_HANDLE_INTERNAL.

Referenced by main(), and uv_loop_delete().

◆ uv_loop_configure()

UV_EXTERN int uv_loop_configure ( uv_loop_t loop,
uv_loop_option  option,
  ... 
)

Definition at line 746 of file uv-common.c.

746  {
747  va_list ap;
748  int err;
749 
750  va_start(ap, option);
751  /* Any platform-agnostic options should be handled here. */
753  va_end(ap);
754 
755  return err;
756 }
int uv__loop_configure(uv_loop_t *loop, uv_loop_option option, va_list ap)
Definition: loop.c:211
Definition: getopt.h:84

References err, loop, and uv__loop_configure().

◆ uv_loop_delete()

UV_EXTERN void uv_loop_delete ( uv_loop_t loop)

Definition at line 821 of file uv-common.c.

821  {
822  uv_loop_t* default_loop;
823  int err;
824 
825  default_loop = default_loop_ptr;
826 
828  (void) err; /* Squelch compiler warnings. */
829  assert(err == 0);
830  if (loop != default_loop)
831  uv__free(loop);
832 }
int uv_loop_close(uv_loop_t *loop)
Definition: uv-common.c:791

References assert(), default_loop_ptr, err, loop, uv__free(), and uv_loop_close().

◆ uv_loop_fork()

UV_EXTERN int uv_loop_fork ( uv_loop_t loop)

Definition at line 132 of file loop.c.

132  {
133  int err;
134  unsigned int i;
135  uv__io_t* w;
136 
137  err = uv__io_fork(loop);
138  if (err)
139  return err;
140 
142  if (err)
143  return err;
144 
146  if (err)
147  return err;
148 
149  /* Rearm all the watchers that aren't re-queued by the above. */
150  for (i = 0; i < loop->nwatchers; i++) {
151  w = loop->watchers[i];
152  if (w == NULL)
153  continue;
154 
155  if (w->pevents != 0 && QUEUE_EMPTY(&w->watcher_queue)) {
156  w->events = 0; /* Force re-registration in uv__io_poll. */
157  QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
158  }
159  }
160 
161  return 0;
162 }
int uv__io_fork(uv_loop_t *loop)
Definition: aix.c:108
#define w
Definition: crypto_rc6.c:13
Definition: unix.h:96
int uv__signal_loop_fork(uv_loop_t *loop)
Definition: signal.c:281
int uv__async_fork(uv_loop_t *loop)
Definition: async.c:230

References err, i, loop, NULL, QUEUE_EMPTY, QUEUE_INSERT_TAIL, uv__async_fork(), uv__io_fork(), uv__signal_loop_fork(), and w.

◆ uv_loop_get_data()

UV_EXTERN void* uv_loop_get_data ( const uv_loop_t loop)

Definition at line 113 of file uv-data-getter-setters.c.

113  {
114  return loop->data;
115 }

References uv_loop_s::data, and loop.

◆ uv_loop_init()

UV_EXTERN int uv_loop_init ( uv_loop_t loop)

Definition at line 30 of file loop.c.

30  {
32  void* saved_data;
33  int err;
34 
35 
36  saved_data = loop->data;
37  memset(loop, 0, sizeof(*loop));
38  loop->data = saved_data;
39 
40  lfields = (uv__loop_internal_fields_t*) uv__calloc(1, sizeof(*lfields));
41  if (lfields == NULL)
42  return UV_ENOMEM;
43  loop->internal_fields = lfields;
44 
45  err = uv_mutex_init(&lfields->loop_metrics.lock);
46  if (err)
47  goto fail_metrics_mutex_init;
48 
49  heap_init((struct heap*) &loop->timer_heap);
50  QUEUE_INIT(&loop->wq);
51  QUEUE_INIT(&loop->idle_handles);
52  QUEUE_INIT(&loop->async_handles);
53  QUEUE_INIT(&loop->check_handles);
54  QUEUE_INIT(&loop->prepare_handles);
56 
57  loop->active_handles = 0;
58  loop->active_reqs.count = 0;
59  loop->nfds = 0;
60  loop->watchers = NULL;
61  loop->nwatchers = 0;
62  QUEUE_INIT(&loop->pending_queue);
63  QUEUE_INIT(&loop->watcher_queue);
64 
65  loop->closing_handles = NULL;
66  uv__update_time(loop);
67  loop->async_io_watcher.fd = -1;
68  loop->async_wfd = -1;
69  loop->signal_pipefd[0] = -1;
70  loop->signal_pipefd[1] = -1;
71  loop->backend_fd = -1;
72  loop->emfile_fd = -1;
73 
74  loop->timer_counter = 0;
75  loop->stop_flag = 0;
76 
78  if (err)
79  goto fail_platform_init;
80 
82  err = uv_signal_init(loop, &loop->child_watcher);
83  if (err)
84  goto fail_signal_init;
85 
86  uv__handle_unref(&loop->child_watcher);
87  loop->child_watcher.flags |= UV_HANDLE_INTERNAL;
88  QUEUE_INIT(&loop->process_handles);
89 
90  err = uv_rwlock_init(&loop->cloexec_lock);
91  if (err)
92  goto fail_rwlock_init;
93 
94  err = uv_mutex_init(&loop->wq_mutex);
95  if (err)
96  goto fail_mutex_init;
97 
98  err = uv_async_init(loop, &loop->wq_async, uv__work_done);
99  if (err)
100  goto fail_async_init;
101 
102  uv__handle_unref(&loop->wq_async);
103  loop->wq_async.flags |= UV_HANDLE_INTERNAL;
104 
105  return 0;
106 
107 fail_async_init:
108  uv_mutex_destroy(&loop->wq_mutex);
109 
110 fail_mutex_init:
111  uv_rwlock_destroy(&loop->cloexec_lock);
112 
113 fail_rwlock_init:
115 
116 fail_signal_init:
118 
119 fail_platform_init:
121 
122 fail_metrics_mutex_init:
123  uv__free(lfields);
125 
126  uv__free(loop->watchers);
127  loop->nwatchers = 0;
128  return err;
129 }
int uv__platform_loop_init(uv_loop_t *loop)
Definition: aix.c:81
void uv__platform_loop_delete(uv_loop_t *loop)
Definition: aix.c:95
#define QUEUE_INIT(q)
Definition: queue.h:45
Definition: heap-inl.h:40
uv__loop_metrics_t loop_metrics
Definition: uv-common.h:365
uv_mutex_t lock
Definition: uv-common.h:357
void * internal_fields
Definition: uv.h:1791
union uv_loop_s::@400 active_reqs
unsigned int count
Definition: uv.h:1788
unsigned int active_handles
Definition: uv.h:1784
void uv__signal_loop_cleanup(uv_loop_t *loop)
Definition: signal.c:291
void uv__signal_global_once_init(void)
Definition: signal.c:111
void uv__work_done(uv_async_t *handle)
Definition: threadpool.c:295
UV_EXTERN int uv_rwlock_init(uv_rwlock_t *rwlock)
Definition: thread.c:356
UV_EXTERN void uv_mutex_destroy(uv_mutex_t *handle)
Definition: thread.c:324
UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t *rwlock)
Definition: thread.c:361
UV_EXTERN int uv_async_init(uv_loop_t *, uv_async_t *async, uv_async_cb async_cb)
Definition: async.c:45
UV_EXTERN int uv_signal_init(uv_loop_t *loop, uv_signal_t *handle)
Definition: signal.c:319
UV_EXTERN int uv_mutex_init(uv_mutex_t *handle)
Definition: thread.c:282

References uv_loop_s::active_handles, uv_loop_s::active_reqs, uv_loop_s::count, uv_loop_s::data, err, uv_loop_s::handle_queue, uv_loop_s::internal_fields, INVALID_HANDLE_VALUE, uv__loop_metrics_s::lock, loop, uv__loop_internal_fields_s::loop_metrics, memset(), NULL, QUEUE_INIT, uv_loop_s::stop_flag, timer_heap(), uv__calloc(), uv__free(), uv__handle_unref, uv__loops_add(), uv__malloc(), uv__once_init(), uv__platform_loop_delete(), uv__platform_loop_init(), uv__signal_global_once_init(), uv__signal_loop_cleanup(), uv__work_done(), uv_async_init(), UV_HANDLE_INTERNAL, uv_mutex_destroy(), uv_mutex_init(), uv_rwlock_destroy(), uv_rwlock_init(), uv_signal_init(), uv_translate_sys_error(), and uv_update_time().

Referenced by create_loop(), main(), uv_default_loop(), and uv_loop_new().

◆ uv_loop_new()

UV_EXTERN uv_loop_t* uv_loop_new ( void  )

Definition at line 775 of file uv-common.c.

775  {
776  uv_loop_t* loop;
777 
778  loop = uv__malloc(sizeof(*loop));
779  if (loop == NULL)
780  return NULL;
781 
782  if (uv_loop_init(loop)) {
783  uv__free(loop);
784  return NULL;
785  }
786 
787  return loop;
788 }

References loop, NULL, uv__free(), uv__malloc(), and uv_loop_init().

◆ uv_loop_set_data()

UV_EXTERN void uv_loop_set_data ( uv_loop_t loop,
void *  data 
)

Definition at line 117 of file uv-data-getter-setters.c.

117  {
118  loop->data = data;
119 }

References uv_loop_s::data, and loop.

◆ uv_loop_size()

UV_EXTERN size_t uv_loop_size ( void  )

Definition at line 152 of file uv-common.c.

152  {
153  return sizeof(uv_loop_t);
154 }
struct uv_loop_s uv_loop_t
Definition: uv.h:209

◆ uv_metrics_idle_time()

UV_EXTERN uint64_t uv_metrics_idle_time ( uv_loop_t loop)

Definition at line 914 of file uv-common.c.

914  {
915  uv__loop_metrics_t* loop_metrics;
916  uint64_t entry_time;
917  uint64_t idle_time;
918 
919  loop_metrics = uv__get_loop_metrics(loop);
920  uv_mutex_lock(&loop_metrics->lock);
921  idle_time = loop_metrics->provider_idle_time;
922  entry_time = loop_metrics->provider_entry_time;
923  uv_mutex_unlock(&loop_metrics->lock);
924 
925  if (entry_time > 0)
926  idle_time += uv_hrtime() - entry_time;
927  return idle_time;
928 }
unsigned long uint64_t
Definition: sftypes.h:28
uint64_t provider_idle_time
Definition: uv-common.h:356
uint64_t provider_entry_time
Definition: uv-common.h:355
#define uv__get_loop_metrics(loop)
Definition: uv-common.h:339
UV_EXTERN uint64_t uv_hrtime(void)
Definition: core.c:103

References uv__loop_metrics_s::lock, loop, uv__loop_metrics_s::provider_entry_time, uv__loop_metrics_s::provider_idle_time, uv__get_loop_metrics, uv_hrtime(), uv_mutex_lock(), and uv_mutex_unlock().

◆ uv_mutex_destroy()

UV_EXTERN void uv_mutex_destroy ( uv_mutex_t handle)

Definition at line 324 of file thread.c.

324  {
325  if (pthread_mutex_destroy(mutex))
326  abort();
327 }

References mutex.

Referenced by child_fork(), uv__custom_sem_destroy(), uv__custom_sem_init(), uv__loop_close(), uv__threadpool_cleanup(), uv_barrier_destroy(), uv_barrier_init(), and uv_loop_init().

◆ uv_mutex_init()

UV_EXTERN int uv_mutex_init ( uv_mutex_t handle)

Definition at line 282 of file thread.c.

282  {
283 #if defined(NDEBUG) || !defined(PTHREAD_MUTEX_ERRORCHECK)
284  return UV__ERR(pthread_mutex_init(mutex, NULL));
285 #else
286  pthread_mutexattr_t attr;
287  int err;
288 
289  if (pthread_mutexattr_init(&attr))
290  abort();
291 
292  if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK))
293  abort();
294 
295  err = pthread_mutex_init(mutex, &attr);
296 
297  if (pthread_mutexattr_destroy(&attr))
298  abort();
299 
300  return UV__ERR(err);
301 #endif
302 }

References err, mutex, NULL, and UV__ERR.

Referenced by epoll_init(), init_process_title_mutex_once(), init_threads(), uv__custom_sem_init(), uv__fd_hash_init(), uv__loops_init(), uv_barrier_init(), uv_console_init(), uv_loop_init(), and uv_mutex_init_recursive().

◆ uv_mutex_init_recursive()

UV_EXTERN int uv_mutex_init_recursive ( uv_mutex_t handle)

Definition at line 305 of file thread.c.

305  {
306  pthread_mutexattr_t attr;
307  int err;
308 
309  if (pthread_mutexattr_init(&attr))
310  abort();
311 
312  if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE))
313  abort();
314 
315  err = pthread_mutex_init(mutex, &attr);
316 
317  if (pthread_mutexattr_destroy(&attr))
318  abort();
319 
320  return UV__ERR(err);
321 }

References err, mutex, UV__ERR, and uv_mutex_init().

◆ uv_mutex_lock()

◆ uv_mutex_trylock()

UV_EXTERN int uv_mutex_trylock ( uv_mutex_t handle)

Definition at line 336 of file thread.c.

336  {
337  int err;
338 
339  err = pthread_mutex_trylock(mutex);
340  if (err) {
341  if (err != EBUSY && err != EAGAIN)
342  abort();
343  return UV_EBUSY;
344  }
345 
346  return 0;
347 }
#define EBUSY
Definition: sftypes.h:126
#define EAGAIN
Definition: sftypes.h:121

References EAGAIN, EBUSY, err, and mutex.

Referenced by uv__custom_sem_trywait().

◆ uv_mutex_unlock()

◆ uv_now()

UV_EXTERN uint64_t uv_now ( const uv_loop_t loop)

Definition at line 567 of file uv-common.c.

567  {
568  return loop->time;
569 }

References loop.

Referenced by poll_cb(), timer_cb(), and uv_fs_poll_start().

◆ uv_once()

◆ uv_open_osfhandle()

UV_EXTERN int uv_open_osfhandle ( uv_os_fd_t  os_fd)

Definition at line 1393 of file core.c.

1393  {
1394  return os_fd;
1395 }

◆ uv_os_environ()

UV_EXTERN int uv_os_environ ( uv_env_item_t **  envitems,
int count 
)

Definition at line 1255 of file core.c.

1255  {
1256  int i, j, cnt;
1257  uv_env_item_t* envitem;
1258 
1259  *envitems = NULL;
1260  *count = 0;
1261 
1262  for (i = 0; environ[i] != NULL; i++);
1263 
1264  *envitems = uv__calloc(i, sizeof(**envitems));
1265 
1266  if (*envitems == NULL)
1267  return UV_ENOMEM;
1268 
1269  for (j = 0, cnt = 0; j < i; j++) {
1270  char* buf;
1271  char* ptr;
1272 
1273  if (environ[j] == NULL)
1274  break;
1275 
1276  buf = uv__strdup(environ[j]);
1277  if (buf == NULL)
1278  goto fail;
1279 
1280  ptr = strchr(buf, '=');
1281  if (ptr == NULL) {
1282  uv__free(buf);
1283  continue;
1284  }
1285 
1286  *ptr = '\0';
1287 
1288  envitem = &(*envitems)[cnt];
1289  envitem->name = buf;
1290  envitem->value = ptr + 1;
1291 
1292  cnt++;
1293  }
1294 
1295  *count = cnt;
1296  return 0;
1297 
1298 fail:
1299  for (i = 0; i < cnt; i++) {
1300  envitem = &(*envitems)[cnt];
1301  uv__free(envitem->name);
1302  }
1303  uv__free(*envitems);
1304 
1305  *envitems = NULL;
1306  *count = 0;
1307  return UV_ENOMEM;
1308 }
char * value
Definition: uv.h:1231
char * name
Definition: uv.h:1230
char ** environ
ut8 * buf
Definition: core.c:75
#define fail(test)
Definition: tests.h:29

References buf, count, env, environ, fail, i, L, uv_env_item_s::name, NULL, uv__calloc(), uv__convert_utf16_to_utf8(), uv__free(), uv__strdup(), and uv_env_item_s::value.

◆ uv_os_free_environ()

UV_EXTERN void uv_os_free_environ ( uv_env_item_t envitems,
int  count 
)

Definition at line 835 of file uv-common.c.

835  {
836  int i;
837 
838  for (i = 0; i < count; i++) {
839  uv__free(envitems[i].name);
840  }
841 
842  uv__free(envitems);
843 }

References count, i, and uv__free().

◆ uv_os_free_passwd()

UV_EXTERN void uv_os_free_passwd ( uv_passwd_t pwd)

Definition at line 1228 of file core.c.

1228  {
1229  if (pwd == NULL)
1230  return;
1231 
1232  /*
1233  The memory for name, shell, and homedir are allocated in a single
1234  uv__malloc() call. The base of the pointer is stored in pwd->username, so
1235  that is the field that needs to be freed.
1236  */
1237  uv__free(pwd->username);
1238  pwd->username = NULL;
1239  pwd->shell = NULL;
1240  pwd->homedir = NULL;
1241 }
char * username
Definition: uv.h:1111
char * homedir
Definition: uv.h:1115
char * shell
Definition: uv.h:1114

References uv_passwd_s::homedir, NULL, uv_passwd_s::shell, uv_passwd_s::username, and uv__free().

Referenced by uv_os_homedir().

◆ uv_os_get_passwd()

UV_EXTERN int uv_os_get_passwd ( uv_passwd_t pwd)

Definition at line 1244 of file core.c.

1244  {
1245  return uv__getpwuid_r(pwd);
1246 }
int uv__getpwuid_r(uv_passwd_t *pwd)
Definition: core.c:1146

References uv__getpwuid_r().

◆ uv_os_getenv()

UV_EXTERN int uv_os_getenv ( const char *  name,
char *  buffer,
size_t size 
)

Definition at line 1311 of file core.c.

1311  {
1312  char* var;
1313  size_t len;
1314 
1315  if (name == NULL || buffer == NULL || size == NULL || *size == 0)
1316  return UV_EINVAL;
1317 
1318  var = getenv(name);
1319 
1320  if (var == NULL)
1321  return UV_ENOENT;
1322 
1323  len = strlen(var);
1324 
1325  if (len >= *size) {
1326  *size = len + 1;
1327  return UV_ENOBUFS;
1328  }
1329 
1330  memcpy(buffer, var, len + 1);
1331  *size = len;
1332 
1333  return 0;
1334 }
char * getenv()

References ARRAY_SIZE, DWORD, fail, getenv(), len, memcpy(), NULL, r, uv__convert_utf8_to_utf16(), uv__free(), uv__malloc(), and uv_translate_sys_error().

Referenced by uv_os_homedir().

◆ uv_os_gethostname()

UV_EXTERN int uv_os_gethostname ( char *  buffer,
size_t size 
)

Definition at line 1359 of file core.c.

1359  {
1360  /*
1361  On some platforms, if the input buffer is not large enough, gethostname()
1362  succeeds, but truncates the result. libuv can detect this and return ENOBUFS
1363  instead by creating a large enough buffer and comparing the hostname length
1364  to the size input.
1365  */
1366  char buf[UV_MAXHOSTNAMESIZE];
1367  size_t len;
1368 
1369  if (buffer == NULL || size == NULL || *size == 0)
1370  return UV_EINVAL;
1371 
1372  if (gethostname(buf, sizeof(buf)) != 0)
1373  return UV__ERR(errno);
1374 
1375  buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */
1376  len = strlen(buf);
1377 
1378  if (len >= *size) {
1379  *size = len + 1;
1380  return UV_ENOBUFS;
1381  }
1382 
1383  memcpy(buffer, buf, len + 1);
1384  *size = len;
1385  return 0;
1386 }
#define UV_MAXHOSTNAMESIZE
Definition: uv.h:1248

References buf, len, memcpy(), NULL, UV__ERR, uv__once_init(), UV_MAXHOSTNAMESIZE, and uv_translate_sys_error().

◆ uv_os_getpid()

UV_EXTERN uv_pid_t uv_os_getpid ( void  )

Definition at line 1397 of file core.c.

1397  {
1398  return getpid();
1399 }

◆ uv_os_getppid()

UV_EXTERN uv_pid_t uv_os_getppid ( void  )

Definition at line 1402 of file core.c.

1402  {
1403  return getppid();
1404 }

References DWORD, handle, and HANDLE.

Referenced by uv_pipe_open().

◆ uv_os_getpriority()

UV_EXTERN int uv_os_getpriority ( uv_pid_t  pid,
int priority 
)

Definition at line 1407 of file core.c.

1407  {
1408  int r;
1409 
1410  if (priority == NULL)
1411  return UV_EINVAL;
1412 
1413  errno = 0;
1414  r = getpriority(PRIO_PROCESS, (int) pid);
1415 
1416  if (r == -1 && errno != 0)
1417  return UV__ERR(errno);
1418 
1419  *priority = r;
1420  return 0;
1421 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol getpriority
Definition: sflib.h:79

References getpriority, handle, HANDLE, NULL, pid, r, UV__ERR, uv__get_handle(), UV_PRIORITY_ABOVE_NORMAL, UV_PRIORITY_BELOW_NORMAL, UV_PRIORITY_HIGH, UV_PRIORITY_HIGHEST, UV_PRIORITY_LOW, UV_PRIORITY_NORMAL, and uv_translate_sys_error().

◆ uv_os_homedir()

UV_EXTERN int uv_os_homedir ( char *  buffer,
size_t size 
)

Definition at line 1059 of file core.c.

1059  {
1060  uv_passwd_t pwd;
1061  size_t len;
1062  int r;
1063 
1064  /* Check if the HOME environment variable is set first. The task of
1065  performing input validation on buffer and size is taken care of by
1066  uv_os_getenv(). */
1067  r = uv_os_getenv("HOME", buffer, size);
1068 
1069  if (r != UV_ENOENT)
1070  return r;
1071 
1072  /* HOME is not set, so call uv__getpwuid_r() */
1073  r = uv__getpwuid_r(&pwd);
1074 
1075  if (r != 0) {
1076  return r;
1077  }
1078 
1079  len = strlen(pwd.homedir);
1080 
1081  if (len >= *size) {
1082  *size = len + 1;
1083  uv_os_free_passwd(&pwd);
1084  return UV_ENOBUFS;
1085  }
1086 
1087  memcpy(buffer, pwd.homedir, len + 1);
1088  *size = len;
1089  uv_os_free_passwd(&pwd);
1090 
1091  return 0;
1092 }
void uv_os_free_passwd(uv_passwd_t *pwd)
Definition: core.c:1228
int uv_os_getenv(const char *name, char *buffer, size_t *size)
Definition: core.c:1311

References uv_passwd_s::homedir, len, memcpy(), r, uv__getpwuid_r(), uv_os_free_passwd(), and uv_os_getenv().

◆ uv_os_setenv()

UV_EXTERN int uv_os_setenv ( const char *  name,
const char *  value 
)

Definition at line 1337 of file core.c.

1337  {
1338  if (name == NULL || value == NULL)
1339  return UV_EINVAL;
1340 
1341  if (setenv(name, value, 1) != 0)
1342  return UV__ERR(errno);
1343 
1344  return 0;
1345 }

References NULL, r, uv__convert_utf8_to_utf16(), UV__ERR, uv__free(), uv_translate_sys_error(), and value.

◆ uv_os_setpriority()

UV_EXTERN int uv_os_setpriority ( uv_pid_t  pid,
int  priority 
)

Definition at line 1424 of file core.c.

1424  {
1425  if (priority < UV_PRIORITY_HIGHEST || priority > UV_PRIORITY_LOW)
1426  return UV_EINVAL;
1427 
1428  if (setpriority(PRIO_PROCESS, (int) pid, priority) != 0)
1429  return UV__ERR(errno);
1430 
1431  return 0;
1432 }
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf static nsops static fd const char static length unsigned struct dirent unsigned static count const char const char static newpath const char static pathname const char const char static newpath const char const char static newpath const char static mode const char static group const char static group struct timeval struct timezone static tz struct tms static buf static getuid static getgid static getegid static getppid static setsid static egid static suid static pid static fsgid static data const char static dev unsigned static persona const char struct statfs static buf unsigned char static buf setpriority
Definition: sflib.h:173
#define UV_PRIORITY_LOW
Definition: uv.h:1210

References handle, HANDLE, pid, r, setpriority, UV__ERR, uv__get_handle(), UV_PRIORITY_ABOVE_NORMAL, UV_PRIORITY_BELOW_NORMAL, UV_PRIORITY_HIGH, UV_PRIORITY_LOW, UV_PRIORITY_NORMAL, and uv_translate_sys_error().

◆ uv_os_tmpdir()

UV_EXTERN int uv_os_tmpdir ( char *  buffer,
size_t size 
)

Definition at line 1095 of file core.c.

1095  {
1096  const char* buf;
1097  size_t len;
1098 
1099  if (buffer == NULL || size == NULL || *size == 0)
1100  return UV_EINVAL;
1101 
1102 #define CHECK_ENV_VAR(name) \
1103  do { \
1104  buf = getenv(name); \
1105  if (buf != NULL) \
1106  goto return_buffer; \
1107  } \
1108  while (0)
1109 
1110  /* Check the TMPDIR, TMP, TEMP, and TEMPDIR environment variables in order */
1111  CHECK_ENV_VAR("TMPDIR");
1112  CHECK_ENV_VAR("TMP");
1113  CHECK_ENV_VAR("TEMP");
1114  CHECK_ENV_VAR("TEMPDIR");
1115 
1116 #undef CHECK_ENV_VAR
1117 
1118  /* No temp environment variables defined */
1119  #if defined(__ANDROID__)
1120  buf = "/data/local/tmp";
1121  #else
1122  buf = "/tmp";
1123  #endif
1124 
1125 return_buffer:
1126  len = strlen(buf);
1127 
1128  if (len >= *size) {
1129  *size = len + 1;
1130  return UV_ENOBUFS;
1131  }
1132 
1133  /* The returned directory should not have a trailing slash. */
1134  if (len > 1 && buf[len - 1] == '/') {
1135  len--;
1136  }
1137 
1138  memcpy(buffer, buf, len + 1);
1139  buffer[len] = '\0';
1140  *size = len;
1141 
1142  return 0;
1143 }
#define CHECK_ENV_VAR(name)

References buf, CHECK_ENV_VAR, DWORD, L, len, memcpy(), NULL, path, uv__free(), uv__malloc(), and uv_translate_sys_error().

◆ uv_os_uname()

UV_EXTERN int uv_os_uname ( uv_utsname_t buffer)

Definition at line 1435 of file core.c.

1435  {
1436  struct utsname buf;
1437  int r;
1438 
1439  if (buffer == NULL)
1440  return UV_EINVAL;
1441 
1442  if (uname(&buf) == -1) {
1443  r = UV__ERR(errno);
1444  goto error;
1445  }
1446 
1447  r = uv__strscpy(buffer->sysname, buf.sysname, sizeof(buffer->sysname));
1448  if (r == UV_E2BIG)
1449  goto error;
1450 
1451 #ifdef _AIX
1452  r = snprintf(buffer->release,
1453  sizeof(buffer->release),
1454  "%s.%s",
1455  buf.version,
1456  buf.release);
1457  if (r >= sizeof(buffer->release)) {
1458  r = UV_E2BIG;
1459  goto error;
1460  }
1461 #else
1462  r = uv__strscpy(buffer->release, buf.release, sizeof(buffer->release));
1463  if (r == UV_E2BIG)
1464  goto error;
1465 #endif
1466 
1467  r = uv__strscpy(buffer->version, buf.version, sizeof(buffer->version));
1468  if (r == UV_E2BIG)
1469  goto error;
1470 
1471 #if defined(_AIX) || defined(__PASE__)
1472  r = uv__strscpy(buffer->machine, "ppc64", sizeof(buffer->machine));
1473 #else
1474  r = uv__strscpy(buffer->machine, buf.machine, sizeof(buffer->machine));
1475 #endif
1476 
1477  if (r == UV_E2BIG)
1478  goto error;
1479 
1480  return 0;
1481 
1482 error:
1483  buffer->sysname[0] = '\0';
1484  buffer->release[0] = '\0';
1485  buffer->version[0] = '\0';
1486  buffer->machine[0] = '\0';
1487  return r;
1488 }
static const char struct stat static buf struct stat static buf static vhangup int struct rusage static rusage struct sysinfo static info unsigned static __unused uname
Definition: sflib.h:153

References assert(), DWORD, error(), L, NULL, pRtlGetVersion, PVOID, r, snprintf, uname, UV__ERR, uv__once_init(), uv__strscpy(), and uv_translate_sys_error().

◆ uv_os_unsetenv()

UV_EXTERN int uv_os_unsetenv ( const char *  name)

Definition at line 1348 of file core.c.

1348  {
1349  if (name == NULL)
1350  return UV_EINVAL;
1351 
1352  if (unsetenv(name) != 0)
1353  return UV__ERR(errno);
1354 
1355  return 0;
1356 }

References NULL, r, uv__convert_utf8_to_utf16(), UV__ERR, uv__free(), and uv_translate_sys_error().

◆ uv_pipe_bind()

UV_EXTERN int uv_pipe_bind ( uv_pipe_t handle,
const char *  name 
)

Definition at line 43 of file pipe.c.

43  {
44  struct sockaddr_un saddr;
45  const char* pipe_fname;
46  int sockfd;
47  int err;
48 
49  pipe_fname = NULL;
50 
51  /* Already bound? */
52  if (uv__stream_fd(handle) >= 0)
53  return UV_EINVAL;
54 
55  /* Make a copy of the file name, it outlives this function's scope. */
56  pipe_fname = uv__strdup(name);
57  if (pipe_fname == NULL)
58  return UV_ENOMEM;
59 
60  /* We've got a copy, don't touch the original any more. */
61  name = NULL;
62 
64  if (err < 0)
65  goto err_socket;
66  sockfd = err;
67 
68  memset(&saddr, 0, sizeof saddr);
69  uv__strscpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path));
70  saddr.sun_family = AF_UNIX;
71 
72  if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr)) {
73  err = UV__ERR(errno);
74  /* Convert ENOENT to EACCES for compatibility with Windows. */
75  if (err == UV_ENOENT)
76  err = UV_EACCES;
77 
79  goto err_socket;
80  }
81 
82  /* Success. */
83  handle->flags |= UV_HANDLE_BOUND;
84  handle->pipe_fname = pipe_fname; /* Is a strdup'ed copy. */
85  handle->io_watcher.fd = sockfd;
86  return 0;
87 
88 err_socket:
89  uv__free((void*)pipe_fname);
90  return err;
91 }
static bind
Definition: sfsocketcall.h:114
int uv__socket(int domain, int type, int protocol)
Definition: core.c:436

References AF_UNIX, bind, default_pending_pipe_instances, err, error(), handle, i, INVALID_HANDLE_VALUE, loop, memset(), NULL, pipe_alloc_accept(), req, SOCK_STREAM, sockfd, sockaddr_un::sun_path, TRUE, uv__close(), UV__ERR, uv__free(), uv__malloc(), uv__socket(), uv__strdup(), uv__stream_fd, uv__strscpy(), uv_fatal_error(), UV_HANDLE_BOUND, UV_HANDLE_PIPESERVER, UV_REQ_INIT, and uv_translate_sys_error().

Referenced by main().

◆ uv_pipe_chmod()

UV_EXTERN int uv_pipe_chmod ( uv_pipe_t handle,
int  flags 
)

Definition at line 326 of file pipe.c.

326  {
327  unsigned desired_mode;
328  struct stat pipe_stat;
329  char* name_buffer;
330  size_t name_len;
331  int r;
332 
333  if (handle == NULL || uv__stream_fd(handle) == -1)
334  return UV_EBADF;
335 
336  if (mode != UV_READABLE &&
337  mode != UV_WRITABLE &&
339  return UV_EINVAL;
340 
341  /* Unfortunately fchmod does not work on all platforms, we will use chmod. */
342  name_len = 0;
343  r = uv_pipe_getsockname(handle, NULL, &name_len);
344  if (r != UV_ENOBUFS)
345  return r;
346 
347  name_buffer = uv__malloc(name_len);
348  if (name_buffer == NULL)
349  return UV_ENOMEM;
350 
351  r = uv_pipe_getsockname(handle, name_buffer, &name_len);
352  if (r != 0) {
353  uv__free(name_buffer);
354  return r;
355  }
356 
357  /* stat must be used as fstat has a bug on Darwin */
358  if (stat(name_buffer, &pipe_stat) == -1) {
359  uv__free(name_buffer);
360  return -errno;
361  }
362 
363  desired_mode = 0;
364  if (mode & UV_READABLE)
365  desired_mode |= S_IRUSR | S_IRGRP | S_IROTH;
366  if (mode & UV_WRITABLE)
367  desired_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
368 
369  /* Exit early if pipe already has desired mode. */
370  if ((pipe_stat.st_mode & desired_mode) == desired_mode) {
371  uv__free(name_buffer);
372  return 0;
373  }
374 
375  pipe_stat.st_mode |= desired_mode;
376 
377  r = chmod(name_buffer, pipe_stat.st_mode);
378  uv__free(name_buffer);
379 
380  return r != -1 ? 0 : UV__ERR(errno);
381 }
static static fork const void static count static fd const char const char static newpath const char static path chmod
Definition: sflib.h:35
static stat
Definition: sflib.h:131
int uv_pipe_getsockname(const uv_pipe_t *handle, char *buffer, size_t *size)
Definition: pipe.c:284

References chmod, done, error(), handle, INVALID_HANDLE_VALUE, memset(), NULL, r, stat, UV__ERR, uv__free(), uv__malloc(), uv__stream_fd, uv_pipe_getsockname(), UV_READABLE, uv_translate_sys_error(), and UV_WRITABLE.

◆ uv_pipe_connect()

UV_EXTERN void uv_pipe_connect ( uv_connect_t req,
uv_pipe_t handle,
const char *  name,
uv_connect_cb  cb 
)

Definition at line 173 of file pipe.c.

176  {
177  struct sockaddr_un saddr;
178  int new_sock;
179  int err;
180  int r;
181 
182  new_sock = (uv__stream_fd(handle) == -1);
183 
184  if (new_sock) {
186  if (err < 0)
187  goto out;
188  handle->io_watcher.fd = err;
189  }
190 
191  memset(&saddr, 0, sizeof saddr);
192  uv__strscpy(saddr.sun_path, name, sizeof(saddr.sun_path));
193  saddr.sun_family = AF_UNIX;
194 
195  do {
196  r = connect(uv__stream_fd(handle),
197  (struct sockaddr*)&saddr, sizeof saddr);
198  }
199  while (r == -1 && errno == EINTR);
200 
201  if (r == -1 && errno != EINPROGRESS) {
202  err = UV__ERR(errno);
203 #if defined(__CYGWIN__) || defined(__MSYS__)
204  /* EBADF is supposed to mean that the socket fd is bad, but
205  Cygwin reports EBADF instead of ENOTSOCK when the file is
206  not a socket. We do not expect to see a bad fd here
207  (e.g. due to new_sock), so translate the error. */
208  if (err == UV_EBADF)
209  err = UV_ENOTSOCK;
210 #endif
211  goto out;
212  }
213 
214  err = 0;
215  if (new_sock) {
219  }
220 
221  if (err == 0)
222  uv__io_start(handle->loop, &handle->io_watcher, POLLOUT);
223 
224 out:
225  handle->delayed_error = err;
226  handle->connect_req = req;
227 
228  uv__req_init(handle->loop, req, UV_CONNECT);
229  req->handle = (uv_stream_t*)handle;
230  req->cb = cb;
231  QUEUE_INIT(&req->queue);
232 
233  /* Force callback to run on next tick in case of error. */
234  if (err)
235  uv__io_feed(handle->loop, &handle->io_watcher);
236 
237 }
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
#define EINPROGRESS
Definition: sftypes.h:175
void uv__io_feed(uv_loop_t *loop, uv__io_t *w)
Definition: core.c:952
int uv__stream_open(uv_stream_t *, int fd, int flags)
Definition: stream.c:406

References AF_UNIX, assert(), cb, DWORD, EINPROGRESS, EINTR, err, error(), handle, HANDLE, INVALID_HANDLE_VALUE, loop, memset(), NULL, open_named_pipe(), out, pipe_connect_thread_proc(), QUEUE_INIT, r, REGISTER_HANDLE_REQ, req, SET_REQ_ERROR, SET_REQ_SUCCESS, SOCK_STREAM, sockaddr_un::sun_path, UV__ERR, uv__free(), uv__io_feed(), uv__io_start(), uv__malloc(), uv__req_init, uv__socket(), uv__stream_fd, uv__stream_open(), uv__strscpy(), uv_fatal_error(), UV_HANDLE_READABLE, UV_HANDLE_WRITABLE, uv_insert_pending_req(), UV_REQ_INIT, and uv_set_pipe_handle().

◆ uv_pipe_getpeername()

UV_EXTERN int uv_pipe_getpeername ( const uv_pipe_t handle,
char *  buffer,
size_t size 
)

Definition at line 289 of file pipe.c.

289  {
290  return uv__pipe_getsockpeername(handle, getpeername, buffer, size);
291 }
static int uv__pipe_getsockpeername(const uv_pipe_t *handle, uv__peersockfunc func, char *buffer, size_t *size)
Definition: pipe.c:240

References handle, INVALID_HANDLE_VALUE, uv__pipe_getname(), uv__pipe_getsockpeername(), and UV_HANDLE_BOUND.

◆ uv_pipe_getsockname()

UV_EXTERN int uv_pipe_getsockname ( const uv_pipe_t handle,
char *  buffer,
size_t size 
)

Definition at line 284 of file pipe.c.

284  {
285  return uv__pipe_getsockpeername(handle, getsockname, buffer, size);
286 }

References handle, INVALID_HANDLE_VALUE, uv__pipe_getname(), uv__pipe_getsockpeername(), UV_HANDLE_BOUND, and UV_HANDLE_CONNECTION.

Referenced by uv_pipe_chmod().

◆ uv_pipe_init()

UV_EXTERN int uv_pipe_init ( uv_loop_t loop,
uv_pipe_t handle,
int  ipc 
)

Definition at line 33 of file pipe.c.

33  {
34  uv__stream_init(loop, (uv_stream_t*)handle, UV_NAMED_PIPE);
35  handle->shutdown_req = NULL;
36  handle->connect_req = NULL;
37  handle->pipe_fname = NULL;
38  handle->ipc = ipc;
39  return 0;
40 }
void uv__stream_init(uv_loop_t *loop, uv_stream_t *stream, uv_handle_type type)
Definition: stream.c:85

References handle, INVALID_HANDLE_VALUE, loop, NULL, QUEUE_INIT, uv__stream_init(), and uv_stream_init().

Referenced by main(), on_new_connection(), and setup_workers().

◆ uv_pipe_open()

UV_EXTERN int uv_pipe_open ( uv_pipe_t handle,
uv_file  file 
)

Definition at line 137 of file pipe.c.

137  {
138  int flags;
139  int mode;
140  int err;
141  flags = 0;
142 
143  if (uv__fd_exists(handle->loop, fd))
144  return UV_EEXIST;
145 
146  do
147  mode = fcntl(fd, F_GETFL);
148  while (mode == -1 && errno == EINTR);
149 
150  if (mode == -1)
151  return UV__ERR(errno); /* according to docs, must be EBADF */
152 
153  err = uv__nonblock(fd, 1);
154  if (err)
155  return err;
156 
157 #if defined(__APPLE__)
158  err = uv__stream_try_select((uv_stream_t*) handle, &fd);
159  if (err)
160  return err;
161 #endif /* defined(__APPLE__) */
162 
163  mode &= O_ACCMODE;
164  if (mode != O_WRONLY)
166  if (mode != O_RDONLY)
168 
170 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags fcntl
Definition: sflib.h:79
#define F_GETFL
Definition: sftypes.h:506
#define O_WRONLY
Definition: sftypes.h:487
#define O_ACCMODE
Definition: sftypes.h:485
#define O_RDONLY
Definition: sftypes.h:486
int uv__fd_exists(uv_loop_t *loop, int fd)
Definition: core.c:965
#define uv__nonblock
Definition: internal.h:170

References access, assert(), DWORD, EINTR, err, F_GETFL, FALSE, fcntl, fd, FileAccessInformation, flags, handle, HANDLE, INVALID_HANDLE_VALUE, O_ACCMODE, O_RDONLY, O_WRONLY, pipe, pNtQueryInformationFile, STATUS_SUCCESS, UV__ERR, uv__fd_exists(), uv__get_osfhandle(), uv__nonblock, uv__once_init(), uv__stream_open(), UV_HANDLE_NON_OVERLAPPED_PIPE, UV_HANDLE_READABLE, UV_HANDLE_WRITABLE, uv_os_getppid(), uv_pipe_connection_init(), uv_set_pipe_handle(), and uv_translate_sys_error().

Referenced by main().

◆ uv_pipe_pending_count()

UV_EXTERN int uv_pipe_pending_count ( uv_pipe_t handle)

Definition at line 298 of file pipe.c.

298  {
299  uv__stream_queued_fds_t* queued_fds;
300 
301  if (!handle->ipc)
302  return 0;
303 
304  if (handle->accepted_fd == -1)
305  return 0;
306 
307  if (handle->queued_fds == NULL)
308  return 1;
309 
310  queued_fds = handle->queued_fds;
311  return queued_fds->offset + 1;
312 }

References handle, NULL, and uv__stream_queued_fds_s::offset.

Referenced by on_new_connection().

◆ uv_pipe_pending_instances()

UV_EXTERN void uv_pipe_pending_instances ( uv_pipe_t handle,
int  count 
)

Definition at line 294 of file pipe.c.

294  {
295 }

References count, handle, UV_HANDLE_BOUND, and UV_HANDLE_PIPESERVER.

◆ uv_pipe_pending_type()

UV_EXTERN uv_handle_type uv_pipe_pending_type ( uv_pipe_t handle)

Definition at line 315 of file pipe.c.

315  {
316  if (!handle->ipc)
317  return UV_UNKNOWN_HANDLE;
318 
319  if (handle->accepted_fd == -1)
320  return UV_UNKNOWN_HANDLE;
321  else
322  return uv__handle_type(handle->accepted_fd);
323 }
uv_handle_type uv__handle_type(int fd)
Definition: stream.c:958

References handle, uv__handle_type(), and UV_UNKNOWN_HANDLE.

Referenced by on_new_connection().

◆ uv_poll_init()

UV_EXTERN int uv_poll_init ( uv_loop_t loop,
uv_poll_t handle,
int  fd 
)

Definition at line 68 of file poll.c.

68  {
69  int err;
70 
71  if (uv__fd_exists(loop, fd))
72  return UV_EEXIST;
73 
75  if (err)
76  return err;
77 
78  /* If ioctl(FIONBIO) reports ENOTTY, try fcntl(F_GETFL) + fcntl(F_SETFL).
79  * Workaround for e.g. kqueue fds not supporting ioctls.
80  */
81  err = uv__nonblock(fd, 1);
82  if (err == UV_ENOTTY)
85 
86  if (err)
87  return err;
88 
89  uv__handle_init(loop, (uv_handle_t*) handle, UV_POLL);
90  uv__io_init(&handle->io_watcher, uv__poll_io, fd);
91  handle->poll_cb = NULL;
92  return 0;
93 }
int uv__io_check_fd(uv_loop_t *loop, int fd)
Definition: aix.c:115
int uv__nonblock_ioctl(int fd, int set)
Definition: core.c:578
int uv__nonblock_fcntl(int fd, int set)
Definition: core.c:608
static void uv__poll_io(uv_loop_t *loop, uv__io_t *w, unsigned int events)
Definition: poll.c:30

References err, fd, handle, loop, NULL, uv__fd_exists(), uv__get_osfhandle(), uv__handle_init, uv__io_check_fd(), uv__io_init(), uv__nonblock, uv__nonblock_fcntl(), uv__nonblock_ioctl(), uv__poll_io(), and uv_poll_init_socket().

Referenced by uv_poll_init_socket().

◆ uv_poll_init_socket()

UV_EXTERN int uv_poll_init_socket ( uv_loop_t loop,
uv_poll_t handle,
uv_os_sock_t  socket 
)

Definition at line 96 of file poll.c.

97  {
98  return uv_poll_init(loop, handle, socket);
99 }
int uv_poll_init(uv_loop_t *loop, uv_poll_t *handle, int fd)
Definition: poll.c:68

References assert(), bytes, DWORD, FIONBIO, handle, len, loop, NULL, SIO_BASE_HANDLE, socket, SOL_SOCKET, uv__fast_poll_get_peer_socket(), uv__handle_init, UV_HANDLE_POLL_SLOW, uv_poll_init(), UV_REQ_INIT, and uv_translate_sys_error().

Referenced by create_curl_context(), and uv_poll_init().

◆ uv_poll_start()

UV_EXTERN int uv_poll_start ( uv_poll_t handle,
int  events,
uv_poll_cb  cb 
)

Definition at line 118 of file poll.c.

118  {
119  int events;
120 
121  assert((pevents & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT |
122  UV_PRIORITIZED)) == 0);
124 
126 
127  if (pevents == 0)
128  return 0;
129 
130  events = 0;
131  if (pevents & UV_READABLE)
132  events |= POLLIN;
133  if (pevents & UV_PRIORITIZED)
134  events |= UV__POLLPRI;
135  if (pevents & UV_WRITABLE)
136  events |= POLLOUT;
137  if (pevents & UV_DISCONNECT)
138  events |= UV__POLLRDHUP;
139 
140  uv__io_start(handle->loop, &handle->io_watcher, events);
142  handle->poll_cb = poll_cb;
143 
144  return 0;
145 }
#define UV__POLLRDHUP
Definition: internal.h:116
#define UV__POLLPRI
Definition: internal.h:122
static void uv__poll_stop(uv_poll_t *handle)
Definition: poll.c:102

References assert(), cb, handle, poll_cb(), uv__handle_start, uv__io_start(), uv__is_closing, uv__poll_set(), uv__poll_stop(), UV__POLLPRI, UV__POLLRDHUP, UV_DISCONNECT, UV_PRIORITIZED, UV_READABLE, and UV_WRITABLE.

Referenced by handle_socket().

◆ uv_poll_stop()

UV_EXTERN int uv_poll_stop ( uv_poll_t handle)

Definition at line 111 of file poll.c.

111  {
114  return 0;
115 }

References assert(), handle, uv__is_closing, uv__poll_set(), and uv__poll_stop().

Referenced by handle_socket().

◆ uv_prepare_init()

UV_EXTERN int uv_prepare_init ( uv_loop_t ,
uv_prepare_t prepare 
)

Referenced by main().

◆ uv_prepare_start()

UV_EXTERN int uv_prepare_start ( uv_prepare_t prepare,
uv_prepare_cb  cb 
)

Referenced by main().

◆ uv_prepare_stop()

UV_EXTERN int uv_prepare_stop ( uv_prepare_t prepare)

Referenced by uv_close().

◆ uv_print_active_handles()

UV_EXTERN void uv_print_active_handles ( uv_loop_t loop,
FILE *  stream 
)

Definition at line 542 of file uv-common.c.

542  {
544 }
static void uv__print_handles(uv_loop_t *loop, int only_active, FILE *stream)
Definition: uv-common.c:505

References loop, and uv__print_handles().

◆ uv_print_all_handles()

UV_EXTERN void uv_print_all_handles ( uv_loop_t loop,
FILE *  stream 
)

Definition at line 537 of file uv-common.c.

537  {
539 }

References loop, and uv__print_handles().

◆ uv_process_get_pid()

UV_EXTERN uv_pid_t uv_process_get_pid ( const uv_process_t proc)

Definition at line 89 of file uv-data-getter-setters.c.

89  {
90  return proc->pid;
91 }
struct Proc * proc

References proc.

◆ uv_process_kill()

UV_EXTERN int uv_process_kill ( uv_process_t process,
int  signum 
)

Definition at line 577 of file process.c.

577  {
578  return uv_kill(process->pid, signum);
579 }
int uv_kill(int pid, int signum)
Definition: process.c:582

References err, INVALID_HANDLE_VALUE, process(), signum, uv__kill(), and uv_kill().

◆ uv_queue_work()

UV_EXTERN int uv_queue_work ( uv_loop_t loop,
uv_work_t req,
uv_work_cb  work_cb,
uv_after_work_cb  after_work_cb 
)

Definition at line 338 of file threadpool.c.

341  {
342  if (work_cb == NULL)
343  return UV_EINVAL;
344 
345  uv__req_init(loop, req, UV_WORK);
346  req->loop = loop;
347  req->work_cb = work_cb;
348  req->after_work_cb = after_work_cb;
350  &req->work_req,
351  UV__WORK_CPU,
354  return 0;
355 }
static void uv__queue_done(struct uv__work *w, int err)
Definition: threadpool.c:325
static void uv__queue_work(struct uv__work *w)
Definition: threadpool.c:318
@ UV__WORK_CPU
Definition: uv-common.h:192

References loop, NULL, req, uv__queue_done(), uv__queue_work(), uv__req_init, UV__WORK_CPU, and uv__work_submit().

Referenced by main().

◆ uv_random()

UV_EXTERN int uv_random ( uv_loop_t loop,
uv_random_t req,
void *  buf,
size_t  buflen,
unsigned  flags,
uv_random_cb  cb 
)

Definition at line 94 of file random.c.

99  {
100  if (buflen > 0x7FFFFFFFu)
101  return UV_E2BIG;
102 
103  if (flags != 0)
104  return UV_EINVAL;
105 
106  if (cb == NULL)
107  return uv__random(buf, buflen);
108 
109  uv__req_init(loop, req, UV_RANDOM);
110  req->loop = loop;
111  req->status = 0;
112  req->cb = cb;
113  req->buf = buf;
114  req->buflen = buflen;
115 
117  &req->work_req,
118  UV__WORK_CPU,
121 
122  return 0;
123 }
static int uv__random(void *buf, size_t buflen)
Definition: random.c:31
static void uv__random_work(struct uv__work *w)
Definition: random.c:73
static void uv__random_done(struct uv__work *w, int status)
Definition: random.c:81

References buflen, cb, flags, loop, NULL, req, uv__random(), uv__random_done(), uv__random_work(), uv__req_init, UV__WORK_CPU, and uv__work_submit().

◆ uv_read_start()

UV_EXTERN int uv_read_start ( uv_stream_t stream,
uv_alloc_cb  alloc_cb,
uv_read_cb  read_cb 
)

Definition at line 1555 of file stream.c.

1557  {
1558  assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE ||
1559  stream->type == UV_TTY);
1560 
1561  if (stream->flags & UV_HANDLE_CLOSING)
1562  return UV_EINVAL;
1563 
1564  if (!(stream->flags & UV_HANDLE_READABLE))
1565  return UV_ENOTCONN;
1566 
1567  /* The UV_HANDLE_READING flag is irrelevant of the state of the tcp - it just
1568  * expresses the desired state of the user.
1569  */
1570  stream->flags |= UV_HANDLE_READING;
1571 
1572  /* TODO: try to do the read inline? */
1573  /* TODO: keep track of tcp state. If we've gotten a EOF then we should
1574  * not start the IO watcher.
1575  */
1576  assert(uv__stream_fd(stream) >= 0);
1577  assert(alloc_cb);
1578 
1579  stream->read_cb = read_cb;
1580  stream->alloc_cb = alloc_cb;
1581 
1582  uv__io_start(stream->loop, &stream->io_watcher, POLLIN);
1585 
1586  return 0;
1587 }
static void uv__stream_osx_interrupt_select(uv_stream_t *stream)
Definition: stream.c:123
@ UV_HANDLE_READING
Definition: uv-common.h:90

References assert(), err, handle, uv__handle_start, uv__io_start(), uv__stream_fd, uv__stream_osx_interrupt_select(), UV_HANDLE_CLOSING, UV_HANDLE_READABLE, UV_HANDLE_READING, uv_pipe_read_start(), uv_tcp_read_start(), uv_translate_sys_error(), and uv_tty_read_start().

Referenced by main(), on_connect(), and on_new_connection().

◆ uv_read_stop()

UV_EXTERN int uv_read_stop ( uv_stream_t stream)

Definition at line 1590 of file stream.c.

1590  {
1591  if (!(stream->flags & UV_HANDLE_READING))
1592  return 0;
1593 
1594  stream->flags &= ~UV_HANDLE_READING;
1595  uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
1596  if (!uv__io_active(&stream->io_watcher, POLLOUT))
1599 
1600  stream->read_cb = NULL;
1601  stream->alloc_cb = NULL;
1602  return 0;
1603 }
void uv__io_stop(uv_loop_t *loop, uv__io_t *w, unsigned int events)
Definition: core.c:910
int uv__io_active(const uv__io_t *w, unsigned int events)
Definition: core.c:958

References DECREASE_ACTIVE_COUNT, err, handle, NULL, uv__handle_stop, uv__io_active(), uv__io_stop(), uv__pipe_read_stop(), uv__stream_osx_interrupt_select(), UV_HANDLE_READING, uv_translate_sys_error(), and uv_tty_read_stop().

Referenced by eof_timer_cb(), uv__stream_close(), uv_pipe_read_eof(), and uv_pipe_read_error().

◆ uv_recv_buffer_size()

UV_EXTERN int uv_recv_buffer_size ( uv_handle_t handle,
int value 
)

Definition at line 584 of file uv-common.c.

584  {
586 }
#define SO_RCVBUF
Definition: sftypes.h:436
int uv__socket_sockopt(uv_handle_t *handle, int optname, int *value)
Definition: core.c:180

References handle, SO_RCVBUF, uv__socket_sockopt(), and value.

◆ uv_ref()

UV_EXTERN void uv_ref ( uv_handle_t handle)

Definition at line 547 of file uv-common.c.

547  {
549 }
#define uv__handle_ref(h)
Definition: uv-common.h:274

References handle, and uv__handle_ref.

◆ uv_replace_allocator()

UV_EXTERN int uv_replace_allocator ( uv_malloc_func  malloc_func,
uv_realloc_func  realloc_func,
uv_calloc_func  calloc_func,
uv_free_func  free_func 
)

Definition at line 114 of file uv-common.c.

117  {
118  if (malloc_func == NULL || realloc_func == NULL ||
119  calloc_func == NULL || free_func == NULL) {
120  return UV_EINVAL;
121  }
122 
123  uv__allocator.local_malloc = malloc_func;
124  uv__allocator.local_realloc = realloc_func;
125  uv__allocator.local_calloc = calloc_func;
126  uv__allocator.local_free = free_func;
127 
128  return 0;
129 }
uv_malloc_func local_malloc
Definition: uv-common.c:42
uv_calloc_func local_calloc
Definition: uv-common.c:44
uv_free_func local_free
Definition: uv-common.c:45
uv_realloc_func local_realloc
Definition: uv-common.c:43
static uv__allocator_t uv__allocator
Definition: uv-common.c:48

References uv__allocator_t::local_calloc, uv__allocator_t::local_free, uv__allocator_t::local_malloc, uv__allocator_t::local_realloc, NULL, and uv__allocator.

◆ uv_req_get_data()

UV_EXTERN void* uv_req_get_data ( const uv_req_t req)

Definition at line 69 of file uv-data-getter-setters.c.

69  {
70  return req->data;
71 }

References req.

◆ uv_req_get_type()

UV_EXTERN uv_req_type uv_req_get_type ( const uv_req_t req)

Definition at line 65 of file uv-data-getter-setters.c.

65  {
66  return req->type;
67 }

References req.

◆ uv_req_set_data()

UV_EXTERN void uv_req_set_data ( uv_req_t req,
void *  data 
)

Definition at line 73 of file uv-data-getter-setters.c.

73  {
74  req->data = data;
75 }

References req.

◆ uv_req_size()

UV_EXTERN size_t uv_req_size ( uv_req_type  type)

Definition at line 141 of file uv-common.c.

141  {
142  switch(type) {
144  default:
145  return -1;
146  }
147 }

References type, UV_REQ_TYPE_MAP, and XX.

◆ uv_req_type_name()

UV_EXTERN const char* uv_req_type_name ( uv_req_type  type)

Definition at line 52 of file uv-data-getter-setters.c.

52  {
53  switch (type) {
54 #define XX(uc,lc) case UV_##uc: return #lc;
56 #undef XX
57  case UV_REQ_TYPE_MAX:
58  case UV_UNKNOWN_REQ:
59  default: /* UV_REQ_TYPE_PRIVATE */
60  break;
61  }
62  return NULL;
63 }

References NULL, type, UV_REQ_TYPE_MAP, UV_REQ_TYPE_MAX, UV_UNKNOWN_REQ, and XX.

◆ uv_resident_set_memory()

UV_EXTERN int uv_resident_set_memory ( size_t rss)

Definition at line 993 of file aix.c.

993  {
994  char pp[64];
995  psinfo_t psinfo;
996  int err;
997  int fd;
998 
999  snprintf(pp, sizeof(pp), "/proc/%lu/psinfo", (unsigned long) getpid());
1000 
1001  fd = open(pp, O_RDONLY);
1002  if (fd == -1)
1003  return UV__ERR(errno);
1004 
1005  /* FIXME(bnoordhuis) Handle EINTR. */
1006  err = UV_EINVAL;
1007  if (read(fd, &psinfo, sizeof(psinfo)) == sizeof(psinfo)) {
1008  *rss = (size_t)psinfo.pr_rssize * 1024;
1009  err = 0;
1010  }
1011  uv__close(fd);
1012 
1013  return err;
1014 }
int size_t
Definition: sftypes.h:40
int read(izstream &zs, T *x, Items items)
Definition: zstream.h:115

References ARRAY_SIZE, ASCBRSME, assert(), count, EINTR, err, error(), fd, find_thread(), HANDLE, i, info(), n, NULL, O_RDONLY, pid, PSA_PTR, PSAAOLD, rax, RAXFMCT, read(), s, snprintf, status, uv__close(), UV__ERR, uv__open_cloexec(), uv_translate_sys_error(), and val.

◆ uv_run()

UV_EXTERN int uv_run ( uv_loop_t loop,
uv_run_mode  mode 
)

Definition at line 365 of file core.c.

365  {
366  int timeout;
367  int r;
368  int ran_pending;
369 
370  r = uv__loop_alive(loop);
371  if (!r)
372  uv__update_time(loop);
373 
374  while (r != 0 && loop->stop_flag == 0) {
375  uv__update_time(loop);
377  ran_pending = uv__run_pending(loop);
380 
381  timeout = 0;
382  if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT)
384 
386 
387  /* Run one final update on the provider_idle_time in case uv__io_poll
388  * returned because the timeout expired, but no events were received. This
389  * call will be ignored if the provider_entry_time was either never set (if
390  * the timeout == 0) or was already updated b/c an event was received.
391  */
393 
396 
397  if (mode == UV_RUN_ONCE) {
398  /* UV_RUN_ONCE implies forward progress: at least one callback must have
399  * been invoked when it returns. uv__io_poll() can return without doing
400  * I/O (meaning: no callbacks) when its timeout expires - which means we
401  * have pending timers that satisfy the forward progress constraint.
402  *
403  * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from
404  * the check.
405  */
406  uv__update_time(loop);
408  }
409 
410  r = uv__loop_alive(loop);
411  if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT)
412  break;
413  }
414 
415  /* The if statement lets gcc compile it to a conditional store. Avoids
416  * dirtying a cache line.
417  */
418  if (loop->stop_flag != 0)
419  loop->stop_flag = 0;
420 
421  return r;
422 }
void uv__io_poll(uv_loop_t *loop, int timeout)
Definition: aix.c:133
static int uv__run_pending(uv_loop_t *loop)
Definition: core.c:797
int uv_backend_timeout(const uv_loop_t *loop)
Definition: core.c:333
static void uv__run_closing_handles(uv_loop_t *loop)
Definition: core.c:308
void uv__run_prepare(uv_loop_t *loop)
void uv__run_check(uv_loop_t *loop)
void uv__run_idle(uv_loop_t *loop)
void uv__run_timers(uv_loop_t *loop)
Definition: timer.c:162
void uv__metrics_update_idle_time(uv_loop_t *loop)
Definition: uv-common.c:872

References DWORD, loop, pGetQueuedCompletionStatusEx, r, uv_loop_s::stop_flag, timeout, uv__io_poll(), uv__loop_alive(), uv__metrics_update_idle_time(), uv__poll(), uv__poll_wine(), uv__run_check(), uv__run_closing_handles(), uv__run_idle(), uv__run_pending(), uv__run_prepare(), uv__run_timers(), uv_backend_timeout(), uv_check_invoke(), uv_idle_invoke(), uv_prepare_invoke(), uv_process_endgames(), uv_process_reqs(), UV_RUN_DEFAULT, UV_RUN_NOWAIT, UV_RUN_ONCE, and uv_update_time().

Referenced by main(), thread1_worker(), and thread2_worker().

◆ uv_rwlock_destroy()

UV_EXTERN void uv_rwlock_destroy ( uv_rwlock_t rwlock)

Definition at line 361 of file thread.c.

361  {
362  if (pthread_rwlock_destroy(rwlock))
363  abort();
364 }

References uv_rwlock_t::num_readers_lock_, uv_rwlock_t::state_, and uv_rwlock_t::write_semaphore_.

Referenced by main(), uv__loop_close(), and uv_loop_init().

◆ uv_rwlock_init()

UV_EXTERN int uv_rwlock_init ( uv_rwlock_t rwlock)

Definition at line 356 of file thread.c.

356  {
357  return UV__ERR(pthread_rwlock_init(rwlock, NULL));
358 }

References handle, HANDLE, NULL, uv_rwlock_t::num_readers_, uv_rwlock_t::num_readers_lock_, uv_rwlock_t::state_, UV__ERR, uv_translate_sys_error(), and uv_rwlock_t::write_semaphore_.

Referenced by main(), and uv_loop_init().

◆ uv_rwlock_rdlock()

UV_EXTERN void uv_rwlock_rdlock ( uv_rwlock_t rwlock)

Definition at line 367 of file thread.c.

367  {
368  if (pthread_rwlock_rdlock(rwlock))
369  abort();
370 }

References DWORD, uv_rwlock_t::num_readers_, uv_rwlock_t::num_readers_lock_, r, uv_rwlock_t::state_, uv_fatal_error(), and uv_rwlock_t::write_semaphore_.

Referenced by reader(), uv__fs_mkstemp(), and uv__fs_open().

◆ uv_rwlock_rdunlock()

UV_EXTERN void uv_rwlock_rdunlock ( uv_rwlock_t rwlock)

Definition at line 387 of file thread.c.

387  {
388  if (pthread_rwlock_unlock(rwlock))
389  abort();
390 }

References NULL, uv_rwlock_t::num_readers_, uv_rwlock_t::num_readers_lock_, uv_rwlock_t::state_, uv_fatal_error(), and uv_rwlock_t::write_semaphore_.

Referenced by reader(), uv__fs_mkstemp(), and uv__fs_open().

◆ uv_rwlock_tryrdlock()

UV_EXTERN int uv_rwlock_tryrdlock ( uv_rwlock_t rwlock)

Definition at line 373 of file thread.c.

373  {
374  int err;
375 
376  err = pthread_rwlock_tryrdlock(rwlock);
377  if (err) {
378  if (err != EBUSY && err != EAGAIN)
379  abort();
380  return UV_EBUSY;
381  }
382 
383  return 0;
384 }

References DWORD, EAGAIN, EBUSY, err, uv_rwlock_t::num_readers_, uv_rwlock_t::num_readers_lock_, r, uv_rwlock_t::state_, uv_fatal_error(), and uv_rwlock_t::write_semaphore_.

◆ uv_rwlock_trywrlock()

UV_EXTERN int uv_rwlock_trywrlock ( uv_rwlock_t rwlock)

Definition at line 399 of file thread.c.

399  {
400  int err;
401 
402  err = pthread_rwlock_trywrlock(rwlock);
403  if (err) {
404  if (err != EBUSY && err != EAGAIN)
405  abort();
406  return UV_EBUSY;
407  }
408 
409  return 0;
410 }

References DWORD, EAGAIN, EBUSY, err, r, uv_rwlock_t::state_, uv_fatal_error(), and uv_rwlock_t::write_semaphore_.

◆ uv_rwlock_wrlock()

UV_EXTERN void uv_rwlock_wrlock ( uv_rwlock_t rwlock)

Definition at line 393 of file thread.c.

393  {
394  if (pthread_rwlock_wrlock(rwlock))
395  abort();
396 }

References DWORD, r, uv_rwlock_t::state_, uv_fatal_error(), and uv_rwlock_t::write_semaphore_.

Referenced by uv_spawn(), and writer().

◆ uv_rwlock_wrunlock()

UV_EXTERN void uv_rwlock_wrunlock ( uv_rwlock_t rwlock)

Definition at line 413 of file thread.c.

413  {
414  if (pthread_rwlock_unlock(rwlock))
415  abort();
416 }

References NULL, uv_rwlock_t::state_, uv_fatal_error(), and uv_rwlock_t::write_semaphore_.

Referenced by uv_spawn(), and writer().

◆ uv_sem_destroy()

UV_EXTERN void uv_sem_destroy ( uv_sem_t sem)

Definition at line 662 of file thread.c.

662  {
665  else
666  uv__sem_destroy(sem);
667 }
static void uv__custom_sem_destroy(uv_sem_t *sem_)
Definition: thread.c:551
static void uv__sem_destroy(uv_sem_t *sem)
Definition: thread.c:610
#define platform_needs_custom_semaphore
Definition: thread.c:511

References platform_needs_custom_semaphore, uv__custom_sem_destroy(), and uv__sem_destroy().

Referenced by init_threads(), uv__stream_close(), uv_barrier_destroy(), and uv_barrier_init().

◆ uv_sem_init()

UV_EXTERN int uv_sem_init ( uv_sem_t sem,
unsigned int  value 
)

Definition at line 650 of file thread.c.

650  {
651 #if defined(__GLIBC__) && !defined(__UCLIBC__)
652  uv_once(&glibc_version_check_once, glibc_version_check);
653 #endif
654 
656  return uv__custom_sem_init(sem, value);
657  else
658  return uv__sem_init(sem, value);
659 }
void uv_once(uv_once_t *guard, void(*callback)(void))
Definition: thread.c:419
static int uv__custom_sem_init(uv_sem_t *sem_, unsigned int value)
Definition: thread.c:526
static int uv__sem_init(uv_sem_t *sem, unsigned int value)
Definition: thread.c:603

References INT_MAX, NULL, platform_needs_custom_semaphore, uv__custom_sem_init(), uv__sem_init(), uv_once(), uv_translate_sys_error(), and value.

Referenced by init_threads(), uv_barrier_init(), and uv_console_init().

◆ uv_sem_post()

UV_EXTERN void uv_sem_post ( uv_sem_t sem)

◆ uv_sem_trywait()

UV_EXTERN int uv_sem_trywait ( uv_sem_t sem)

Definition at line 686 of file thread.c.

686  {
688  return uv__custom_sem_trywait(sem);
689  else
690  return uv__sem_trywait(sem);
691 }
static int uv__custom_sem_trywait(uv_sem_t *sem_)
Definition: thread.c:585
static int uv__sem_trywait(uv_sem_t *sem)
Definition: thread.c:634

References DWORD, platform_needs_custom_semaphore, r, uv__custom_sem_trywait(), and uv__sem_trywait().

◆ uv_sem_wait()

UV_EXTERN void uv_sem_wait ( uv_sem_t sem)

Definition at line 678 of file thread.c.

678  {
680  uv__custom_sem_wait(sem);
681  else
682  uv__sem_wait(sem);
683 }
static void uv__custom_sem_wait(uv_sem_t *sem_)
Definition: thread.c:573
static void uv__sem_wait(uv_sem_t *sem)
Definition: thread.c:622

References platform_needs_custom_semaphore, uv__custom_sem_wait(), and uv__sem_wait().

Referenced by init_threads(), uv__cancel_read_console(), uv_barrier_wait(), uv_tty_get_vterm_state(), uv_tty_get_winsize(), uv_tty_init(), uv_tty_set_mode(), uv_tty_set_vterm_state(), and uv_tty_write_bufs().

◆ uv_send_buffer_size()

UV_EXTERN int uv_send_buffer_size ( uv_handle_t handle,
int value 
)

Definition at line 588 of file uv-common.c.

588  {
590 }
#define SO_SNDBUF
Definition: sftypes.h:435

References handle, SO_SNDBUF, uv__socket_sockopt(), and value.

◆ uv_set_process_title()

UV_EXTERN int uv_set_process_title ( const char *  title)

Definition at line 925 of file aix.c.

925  {
926  char* new_title;
927 
928  /* If uv_setup_args wasn't called or failed, we can't continue. */
929  if (process_argv == NULL || args_mem == NULL)
930  return UV_ENOBUFS;
931 
932  /* We cannot free this pointer when libuv shuts down,
933  * the process may still be using it.
934  */
935  new_title = uv__strdup(title);
936  if (new_title == NULL)
937  return UV_ENOMEM;
938 
941 
942  /* If this is the first time this is set,
943  * don't free and set argv[1] to NULL.
944  */
945  if (process_title_ptr != NULL)
947 
948  process_title_ptr = new_title;
949 
951  if (process_argc > 1)
952  process_argv[1] = NULL;
953 
955 
956  return 0;
957 }
static int process_argc
Definition: aix.c:73
static void * args_mem
Definition: aix.c:71
static char * process_title_ptr
Definition: aix.c:74

References args_mem, uv__process_title::cap, done, err, init_process_title_mutex_once(), L, len, uv__process_title::len, length, MAX_TITLE_LENGTH, memcpy(), memset(), NULL, process_argc, process_argv, process_title, process_title_lock, process_title_mutex, process_title_mutex_once, process_title_ptr, setproctitle(), uv__process_title::str, uv__free(), uv__malloc(), uv__once_init(), uv__strdup(), uv_fatal_error(), uv_mutex_lock(), uv_mutex_unlock(), uv_once(), and uv_translate_sys_error().

◆ uv_setup_args()

UV_EXTERN char** uv_setup_args ( int  argc,
char **  argv 
)

Definition at line 872 of file aix.c.

872  {
873  char exepath[UV__PATH_MAX];
874  char** new_argv;
875  size_t size;
876  char* s;
877  int i;
878 
879  if (argc <= 0)
880  return argv;
881 
882  /* Save the original pointer to argv.
883  * AIX uses argv to read the process name.
884  * (Not the memory pointed to by argv[0..n] as on Linux.)
885  */
886  process_argv = argv;
887  process_argc = argc;
888 
889  /* Use argv[0] to determine value for uv_exepath(). */
890  size = sizeof(exepath);
891  if (uv__search_path(argv[0], exepath, &size) == 0) {
894  original_exepath = uv__strdup(exepath);
896  }
897 
898  /* Calculate how much memory we need for the argv strings. */
899  size = 0;
900  for (i = 0; i < argc; i++)
901  size += strlen(argv[i]) + 1;
902 
903  /* Add space for the argv pointers. */
904  size += (argc + 1) * sizeof(char*);
905 
906  new_argv = uv__malloc(size);
907  if (new_argv == NULL)
908  return argv;
909  args_mem = new_argv;
910 
911  /* Copy over the strings and set up the pointer table. */
912  s = (char*) &new_argv[argc + 1];
913  for (i = 0; i < argc; i++) {
914  size = strlen(argv[i]) + 1;
915  memcpy(s, argv[i], size);
916  new_argv[i] = s;
917  s += size;
918  }
919  new_argv[i] = NULL;
920 
921  return new_argv;
922 }
char * original_exepath
Definition: aix.c:68
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40

References args_mem, argv, uv__process_title::cap, i, init_process_title_mutex_once(), uv__process_title::len, loop, memcpy(), NULL, original_exepath, process_argc, process_argv, process_title, process_title_mutex, process_title_mutex_once, s, uv__process_title::str, uv__malloc(), UV__PATH_MAX, uv__search_path(), uv__strdup(), uv_mutex_lock(), uv_mutex_unlock(), and uv_once().

◆ uv_shutdown()

UV_PRIVATE_REQ_TYPES UV_EXTERN int uv_shutdown ( uv_shutdown_t req,
uv_stream_t handle,
uv_shutdown_cb  cb 
)

Definition at line 1259 of file stream.c.

1259  {
1260  assert(stream->type == UV_TCP ||
1261  stream->type == UV_TTY ||
1262  stream->type == UV_NAMED_PIPE);
1263 
1264  if (!(stream->flags & UV_HANDLE_WRITABLE) ||
1265  stream->flags & UV_HANDLE_SHUT ||
1266  stream->flags & UV_HANDLE_SHUTTING ||
1268  return UV_ENOTCONN;
1269  }
1270 
1271  assert(uv__stream_fd(stream) >= 0);
1272 
1273  /* Initialize request */
1274  uv__req_init(stream->loop, req, UV_SHUTDOWN);
1275  req->handle = stream;
1276  req->cb = cb;
1277  stream->shutdown_req = req;
1278  stream->flags |= UV_HANDLE_SHUTTING;
1279 
1280  uv__io_start(stream->loop, &stream->io_watcher, POLLOUT);
1282 
1283  return 0;
1284 }
@ UV_HANDLE_SHUT
Definition: uv-common.h:85
@ UV_HANDLE_SHUTTING
Definition: uv-common.h:84

References assert(), cb, handle, loop, REGISTER_HANDLE_REQ, req, uv__io_start(), uv__is_closing, uv__req_init, uv__stream_fd, uv__stream_osx_interrupt_select(), UV_HANDLE_SHUT, UV_HANDLE_SHUTTING, UV_HANDLE_WRITABLE, UV_REQ_INIT, and uv_want_endgame().

◆ uv_signal_init()

UV_EXTERN int uv_signal_init ( uv_loop_t loop,
uv_signal_t handle 
)

Definition at line 319 of file signal.c.

319  {
320  int err;
321 
323  if (err)
324  return err;
325 
326  uv__handle_init(loop, (uv_handle_t*) handle, UV_SIGNAL);
327  handle->signum = 0;
328  handle->caught_signals = 0;
329  handle->dispatched_signals = 0;
330 
331  return 0;
332 }
static int uv__signal_loop_once_init(uv_loop_t *loop)
Definition: signal.c:261

References err, handle, loop, NULL, uv__handle_init, uv__signal_loop_once_init(), and UV_REQ_INIT.

Referenced by main(), thread1_worker(), thread2_worker(), and uv_loop_init().

◆ uv_signal_start()

UV_EXTERN int uv_signal_start ( uv_signal_t handle,
uv_signal_cb  signal_cb,
int  signum 
)

Definition at line 340 of file signal.c.

340  {
341  return uv__signal_start(handle, signal_cb, signum, 0);
342 }
static int uv__signal_start(uv_signal_t *handle, uv_signal_cb signal_cb, int signum, int oneshot)
Definition: signal.c:352

References handle, signum, and uv__signal_start().

Referenced by main(), thread1_worker(), thread2_worker(), and uv_spawn().

◆ uv_signal_start_oneshot()

UV_EXTERN int uv_signal_start_oneshot ( uv_signal_t handle,
uv_signal_cb  signal_cb,
int  signum 
)

Definition at line 345 of file signal.c.

347  {
348  return uv__signal_start(handle, signal_cb, signum, 1);
349 }

References handle, signum, and uv__signal_start().

◆ uv_signal_stop()

UV_EXTERN int uv_signal_stop ( uv_signal_t handle)

Definition at line 513 of file signal.c.

513  {
516  return 0;
517 }
static void uv__signal_stop(uv_signal_t *handle)
Definition: signal.c:520

References assert(), handle, RB_REMOVE, uv__handle_stop, uv__is_closing, uv__signal_lock, uv__signal_stop(), and uv__signal_tree.

Referenced by signal_handler(), uv__process_close(), uv__signal_start(), uv_process_signal_req(), and uv_signal_close().

◆ uv_sleep()

UV_EXTERN void uv_sleep ( unsigned int  msec)

Definition at line 1526 of file core.c.

1526  {
1527  struct timespec timeout;
1528  int rc;
1529 
1530  timeout.tv_sec = msec / 1000;
1531  timeout.tv_nsec = (msec % 1000) * 1000 * 1000;
1532 
1533  do
1534  rc = nanosleep(&timeout, &timeout);
1535  while (rc == -1 && errno == EINTR);
1536 
1537  assert(rc == 0);
1538 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg nanosleep
Definition: sflib.h:128

References assert(), EINTR, nanosleep, and timeout.

◆ uv_spawn()

UV_EXTERN int uv_spawn ( uv_loop_t loop,
uv_process_t handle,
const uv_process_options_t options 
)

Definition at line 408 of file process.c.

410  {
411 #if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH)
412  /* fork is marked __WATCHOS_PROHIBITED __TVOS_PROHIBITED. */
413  return UV_ENOSYS;
414 #else
415  int signal_pipe[2] = { -1, -1 };
416  int pipes_storage[8][2];
417  int (*pipes)[2];
418  int stdio_count;
419  ssize_t r;
420  pid_t pid;
421  int err;
422  int exec_errorno;
423  int i;
424  int status;
425 
426  assert(options->file != NULL);
427  assert(!(options->flags & ~(UV_PROCESS_DETACHED |
434 
435  uv__handle_init(loop, (uv_handle_t*)process, UV_PROCESS);
436  QUEUE_INIT(&process->queue);
437 
438  stdio_count = options->stdio_count;
439  if (stdio_count < 3)
440  stdio_count = 3;
441 
442  err = UV_ENOMEM;
443  pipes = pipes_storage;
444  if (stdio_count > (int) ARRAY_SIZE(pipes_storage))
445  pipes = uv__malloc(stdio_count * sizeof(*pipes));
446 
447  if (pipes == NULL)
448  goto error;
449 
450  for (i = 0; i < stdio_count; i++) {
451  pipes[i][0] = -1;
452  pipes[i][1] = -1;
453  }
454 
455  for (i = 0; i < options->stdio_count; i++) {
456  err = uv__process_init_stdio(options->stdio + i, pipes[i]);
457  if (err)
458  goto error;
459  }
460 
461  /* This pipe is used by the parent to wait until
462  * the child has called `execve()`. We need this
463  * to avoid the following race condition:
464  *
465  * if ((pid = fork()) > 0) {
466  * kill(pid, SIGTERM);
467  * }
468  * else if (pid == 0) {
469  * execve("/bin/cat", argp, envp);
470  * }
471  *
472  * The parent sends a signal immediately after forking.
473  * Since the child may not have called `execve()` yet,
474  * there is no telling what process receives the signal,
475  * our fork or /bin/cat.
476  *
477  * To avoid ambiguity, we create a pipe with both ends
478  * marked close-on-exec. Then, after the call to `fork()`,
479  * the parent polls the read end until it EOFs or errors with EPIPE.
480  */
481  err = uv__make_pipe(signal_pipe, 0);
482  if (err)
483  goto error;
484 
485  uv_signal_start(&loop->child_watcher, uv__chld, SIGCHLD);
486 
487  /* Acquire write lock to prevent opening new fds in worker threads */
488  uv_rwlock_wrlock(&loop->cloexec_lock);
489  pid = fork();
490 
491  if (pid == -1) {
492  err = UV__ERR(errno);
493  uv_rwlock_wrunlock(&loop->cloexec_lock);
494  uv__close(signal_pipe[0]);
495  uv__close(signal_pipe[1]);
496  goto error;
497  }
498 
499  if (pid == 0) {
500  uv__process_child_init(options, stdio_count, pipes, signal_pipe[1]);
501  abort();
502  }
503 
504  /* Release lock in parent process */
505  uv_rwlock_wrunlock(&loop->cloexec_lock);
506  uv__close(signal_pipe[1]);
507 
508  process->status = 0;
509  exec_errorno = 0;
510  do
511  r = read(signal_pipe[0], &exec_errorno, sizeof(exec_errorno));
512  while (r == -1 && errno == EINTR);
513 
514  if (r == 0)
515  ; /* okay, EOF */
516  else if (r == sizeof(exec_errorno)) {
517  do
518  err = waitpid(pid, &status, 0); /* okay, read errorno */
519  while (err == -1 && errno == EINTR);
520  assert(err == pid);
521  } else if (r == -1 && errno == EPIPE) {
522  do
523  err = waitpid(pid, &status, 0); /* okay, got EPIPE */
524  while (err == -1 && errno == EINTR);
525  assert(err == pid);
526  } else
527  abort();
528 
529  uv__close_nocheckstdio(signal_pipe[0]);
530 
531  for (i = 0; i < options->stdio_count; i++) {
532  err = uv__process_open_stream(options->stdio + i, pipes[i]);
533  if (err == 0)
534  continue;
535 
536  while (i--)
538 
539  goto error;
540  }
541 
542  /* Only activate this handle if exec() happened successfully */
543  if (exec_errorno == 0) {
544  QUEUE_INSERT_TAIL(&loop->process_handles, &process->queue);
546  }
547 
548  process->pid = pid;
549  process->exit_cb = options->exit_cb;
550 
551  if (pipes != pipes_storage)
552  uv__free(pipes);
553 
554  return exec_errorno;
555 
556 error:
557  if (pipes != NULL) {
558  for (i = 0; i < stdio_count; i++) {
559  if (i < options->stdio_count)
560  if (options->stdio[i].flags & (UV_INHERIT_FD | UV_INHERIT_STREAM))
561  continue;
562  if (pipes[i][0] != -1)
563  uv__close_nocheckstdio(pipes[i][0]);
564  if (pipes[i][1] != -1)
565  uv__close_nocheckstdio(pipes[i][1]);
566  }
567 
568  if (pipes != pipes_storage)
569  uv__free(pipes);
570  }
571 
572  return err;
573 #endif
574 }
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
static const char struct stat static buf struct stat static buf static vhangup int status
Definition: sflib.h:145
#define EPIPE
Definition: sftypes.h:142
int pid_t
Definition: sftypes.h:38
int ssize_t
Definition: sftypes.h:39
int uv__close_nocheckstdio(int fd)
Definition: core.c:550
static int uv__process_open_stream(uv_stdio_container_t *container, int pipefds[2])
Definition: process.c:217
static int uv__process_init_stdio(uv_stdio_container_t *container, int fds[2])
Definition: process.c:180
static void uv__chld(uv_signal_t *handle, int signum)
Definition: process.c:48
static void uv__process_child_init(const uv_process_options_t *options, int stdio_count, int(*pipes)[2], int error_fd)
Definition: process.c:267
int uv__make_pipe(int fds[2], int flags)
Definition: process.c:142
static void uv__process_close_stream(uv_stdio_container_t *container)
Definition: process.c:242
UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t *rwlock)
Definition: thread.c:393
UV_EXTERN int uv_signal_start(uv_signal_t *handle, uv_signal_cb signal_cb, int signum)
Definition: signal.c:340
UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t *rwlock)
Definition: thread.c:413

References ARRAY_SIZE, assert(), test-lz4-speed::cwd, uv_stdio_container_s::data, done, DWORD, EINTR, env, EPIPE, err, error(), exit_wait_callback(), find_path(), uv_stdio_container_s::flags, i, info(), int, L, loop, make_program_args(), make_program_env(), NULL, options, path, pid, process(), QUEUE_INIT, QUEUE_INSERT_TAIL, r, read(), search_path(), status, uv_stdio_container_s::stream, uv__chld(), uv__close(), uv__close_nocheckstdio(), UV__ERR, uv__free(), uv__handle_init, uv__handle_start, uv__init_global_job_handle(), uv__make_pipe(), uv__malloc(), uv__process_child_init(), uv__process_close_stream(), uv__process_init_stdio(), uv__process_open_stream(), uv__stdio_create(), uv__stdio_destroy(), uv__stdio_handle(), uv__stdio_size(), UV_CREATE_PIPE, uv_fatal_error(), uv_global_job_handle_, uv_global_job_handle_init_guard_, UV_INHERIT_FD, UV_INHERIT_STREAM, uv_once(), UV_PROCESS_DETACHED, uv_process_init(), UV_PROCESS_SETGID, UV_PROCESS_SETUID, UV_PROCESS_WINDOWS_HIDE, UV_PROCESS_WINDOWS_HIDE_CONSOLE, UV_PROCESS_WINDOWS_HIDE_GUI, UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS, uv_rwlock_wrlock(), uv_rwlock_wrunlock(), uv_signal_start(), uv_translate_sys_error(), and uv_utf8_to_utf16_alloc().

Referenced by invoke_cgi_script(), main(), and setup_workers().

◆ uv_stop()

UV_EXTERN void uv_stop ( uv_loop_t loop)

Definition at line 562 of file uv-common.c.

562  {
563  loop->stop_flag = 1;
564 }

References loop, and uv_loop_s::stop_flag.

Referenced by idle_cb().

◆ uv_stream_get_write_queue_size()

UV_EXTERN size_t uv_stream_get_write_queue_size ( const uv_stream_t stream)

Definition at line 77 of file uv-data-getter-setters.c.

77  {
78  return stream->write_queue_size;
79 }

◆ uv_stream_set_blocking()

UV_EXTERN int uv_stream_set_blocking ( uv_stream_t handle,
int  blocking 
)

Definition at line 1688 of file stream.c.

1688  {
1689  /* Don't need to check the file descriptor, uv__nonblock()
1690  * will fail with EBADF if it's not valid.
1691  */
1692  return uv__nonblock(uv__stream_fd(handle), !blocking);
1693 }

References handle, uv__nonblock, uv__stream_fd, and UV_HANDLE_BLOCKING_WRITES.

◆ uv_strerror()

UV_EXTERN const char* uv_strerror ( int  err)

Definition at line 212 of file uv-common.c.

212  {
213  switch (err) {
215  }
216  return uv__unknown_err_code(err);
217 }
#define UV_STRERROR_GEN(name, msg)
Definition: uv-common.c:211

References err, uv__unknown_err_code(), UV_ERRNO_MAP, and UV_STRERROR_GEN.

Referenced by echo_write(), invoke_cgi_script(), main(), on_new_connection(), on_open(), on_read(), on_send(), on_type(), and on_write().

◆ uv_strerror_r()

UV_EXTERN char* uv_strerror_r ( int  err,
char *  buf,
size_t  buflen 
)

Definition at line 201 of file uv-common.c.

201  {
202  switch (err) {
204  default: snprintf(buf, buflen, "Unknown system error %d", err);
205  }
206  return buf;
207 }
#define UV_STRERROR_GEN_R(name, msg)
Definition: uv-common.c:198

References buflen, err, snprintf, UV_ERRNO_MAP, and UV_STRERROR_GEN_R.

◆ uv_tcp_bind()

UV_EXTERN int uv_tcp_bind ( uv_tcp_t handle,
const struct sockaddr addr,
unsigned int  flags 
)

Definition at line 277 of file uv-common.c.

279  {
280  unsigned int addrlen;
281 
282  if (handle->type != UV_TCP)
283  return UV_EINVAL;
284 
285  if (addr->sa_family == AF_INET)
286  addrlen = sizeof(struct sockaddr_in);
287  else if (addr->sa_family == AF_INET6)
288  addrlen = sizeof(struct sockaddr_in6);
289  else
290  return UV_EINVAL;
291 
292  return uv__tcp_bind(handle, addr, addrlen, flags);
293 }
static const void static count static fd struct stat static buf struct pollfd unsigned static timeout void static offset void static length char static len const struct iovec static count unsigned long static filedes static sched_yield static flags static oldfd static pause unsigned static seconds static protocol struct sockaddr addrlen
Definition: sflib.h:75
int uv__tcp_bind(uv_tcp_t *tcp, const struct sockaddr *addr, unsigned int addrlen, unsigned int flags)
Definition: tcp.c:148

References addr, addrlen, AF_INET, AF_INET6, flags, handle, and uv__tcp_bind().

Referenced by main().

◆ uv_tcp_close_reset()

UV_EXTERN int uv_tcp_close_reset ( uv_tcp_t handle,
uv_close_cb  close_cb 
)

Definition at line 311 of file tcp.c.

311  {
312  int fd;
313  struct linger l = { 1, 0 };
314 
315  /* Disallow setting SO_LINGER to zero due to some platform inconsistencies */
316  if (handle->flags & UV_HANDLE_SHUTTING)
317  return UV_EINVAL;
318 
320  if (0 != setsockopt(fd, SOL_SOCKET, SO_LINGER, &l, sizeof(l)))
321  return UV__ERR(errno);
322 
323  uv_close((uv_handle_t*) handle, close_cb);
324  return 0;
325 }
#define SO_LINGER
Definition: sftypes.h:441

References fd, handle, SO_LINGER, SOL_SOCKET, UV__ERR, uv__stream_fd, uv_close(), UV_HANDLE_SHUTTING, and uv_translate_sys_error().

◆ uv_tcp_connect()

UV_EXTERN int uv_tcp_connect ( uv_connect_t req,
uv_tcp_t handle,
const struct sockaddr addr,
uv_connect_cb  cb 
)

Definition at line 345 of file uv-common.c.

348  {
349  unsigned int addrlen;
350 
351  if (handle->type != UV_TCP)
352  return UV_EINVAL;
353 
354  if (addr->sa_family == AF_INET)
355  addrlen = sizeof(struct sockaddr_in);
356  else if (addr->sa_family == AF_INET6)
357  addrlen = sizeof(struct sockaddr_in6);
358  else
359  return UV_EINVAL;
360 
361  return uv__tcp_connect(req, handle, addr, addrlen, cb);
362 }
int uv__tcp_connect(uv_connect_t *req, uv_tcp_t *handle, const struct sockaddr *addr, unsigned int addrlen, uv_connect_cb cb)
Definition: tcp.c:204

References addr, addrlen, AF_INET, AF_INET6, cb, handle, req, and uv__tcp_connect().

Referenced by on_resolved().

◆ uv_tcp_getpeername()

UV_EXTERN int uv_tcp_getpeername ( const uv_tcp_t handle,
struct sockaddr name,
int namelen 
)

Definition at line 297 of file tcp.c.

299  {
300 
301  if (handle->delayed_error)
302  return handle->delayed_error;
303 
304  return uv__getsockpeername((const uv_handle_t*) handle,
305  getpeername,
306  name,
307  namelen);
308 }
int uv__getsockpeername(const uv_handle_t *handle, uv__peersockfunc func, struct sockaddr *name, int *namelen)
Definition: core.c:1490

References handle, and uv__getsockpeername().

Referenced by uv_tcp_open().

◆ uv_tcp_getsockname()

UV_EXTERN int uv_tcp_getsockname ( const uv_tcp_t handle,
struct sockaddr name,
int namelen 
)

Definition at line 283 of file tcp.c.

285  {
286 
287  if (handle->delayed_error)
288  return handle->delayed_error;
289 
290  return uv__getsockpeername((const uv_handle_t*) handle,
291  getsockname,
292  name,
293  namelen);
294 }

References handle, and uv__getsockpeername().

Referenced by uv_tcp_open().

◆ uv_tcp_init()

UV_EXTERN int uv_tcp_init ( uv_loop_t loop,
uv_tcp_t handle 
)

Definition at line 143 of file tcp.c.

143  {
144  return uv_tcp_init_ex(loop, tcp, AF_UNSPEC);
145 }
#define AF_UNSPEC
Definition: sftypes.h:283
int uv_tcp_init_ex(uv_loop_t *loop, uv_tcp_t *tcp, unsigned int flags)
Definition: tcp.c:114

References AF_UNSPEC, handle, loop, and uv_tcp_init_ex().

Referenced by main(), on_new_connection(), and on_resolved().

◆ uv_tcp_init_ex()

UV_EXTERN int uv_tcp_init_ex ( uv_loop_t loop,
uv_tcp_t handle,
unsigned int  flags 
)

Definition at line 114 of file tcp.c.

114  {
115  int domain;
116 
117  /* Use the lower 8 bits for the domain */
118  domain = flags & 0xFF;
119  if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC)
120  return UV_EINVAL;
121 
122  if (flags & ~0xFF)
123  return UV_EINVAL;
124 
125  uv__stream_init(loop, (uv_stream_t*)tcp, UV_TCP);
126 
127  /* If anything fails beyond this point we need to remove the handle from
128  * the handle queue, since it was added by uv__handle_init in uv_stream_init.
129  */
130 
131  if (domain != AF_UNSPEC) {
132  int err = maybe_new_socket(tcp, domain, 0);
133  if (err) {
134  QUEUE_REMOVE(&tcp->handle_queue);
135  return err;
136  }
137  }
138 
139  return 0;
140 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd domain
Definition: sflib.h:79
#define QUEUE_REMOVE(q)
Definition: queue.h:101
static int maybe_new_socket(uv_tcp_t *handle, int domain, unsigned long flags)
Definition: tcp.c:67

References AF_INET, AF_INET6, AF_UNSPEC, domain, DWORD, err, flags, handle, loop, maybe_new_socket(), NULL, QUEUE_REMOVE, SOCK_STREAM, socket, uv__stream_init(), uv_stream_init(), uv_tcp_set_socket(), and uv_translate_sys_error().

Referenced by uv_tcp_init().

◆ uv_tcp_keepalive()

UV_EXTERN int uv_tcp_keepalive ( uv_tcp_t handle,
int  enable,
unsigned int  delay 
)

Definition at line 428 of file tcp.c.

428  {
429  int err;
430 
431  if (uv__stream_fd(handle) != -1) {
433  if (err)
434  return err;
435  }
436 
437  if (on)
439  else
440  handle->flags &= ~UV_HANDLE_TCP_KEEPALIVE;
441 
442  /* TODO Store delay if uv__stream_fd(handle) == -1 but don't want to enlarge
443  * uv_tcp_t with an int that's almost never used...
444  */
445 
446  return 0;
447 }
int uv__tcp_keepalive(int fd, int on, unsigned int delay)
Definition: tcp.c:380
@ UV_HANDLE_TCP_KEEPALIVE
Definition: uv-common.h:106

References err, handle, uv__stream_fd, uv__tcp_keepalive(), and UV_HANDLE_TCP_KEEPALIVE.

◆ uv_tcp_nodelay()

UV_EXTERN int uv_tcp_nodelay ( uv_tcp_t handle,
int  enable 
)

Definition at line 410 of file tcp.c.

410  {
411  int err;
412 
413  if (uv__stream_fd(handle) != -1) {
415  if (err)
416  return err;
417  }
418 
419  if (on)
420  handle->flags |= UV_HANDLE_TCP_NODELAY;
421  else
422  handle->flags &= ~UV_HANDLE_TCP_NODELAY;
423 
424  return 0;
425 }
int uv__tcp_nodelay(int fd, int on)
Definition: tcp.c:373
@ UV_HANDLE_TCP_NODELAY
Definition: uv-common.h:105

References err, handle, uv__stream_fd, uv__tcp_nodelay(), and UV_HANDLE_TCP_NODELAY.

◆ uv_tcp_open()

UV_EXTERN int uv_tcp_open ( uv_tcp_t handle,
uv_os_sock_t  sock 
)

Definition at line 267 of file tcp.c.

267  {
268  int err;
269 
270  if (uv__fd_exists(handle->loop, sock))
271  return UV_EEXIST;
272 
273  err = uv__nonblock(sock, 1);
274  if (err)
275  return err;
276 
278  sock,
280 }

References err, handle, int, SOL_SOCKET, uv__fd_exists(), uv__nonblock, uv__stream_open(), uv_connection_init(), UV_HANDLE_BOUND, UV_HANDLE_READABLE, UV_HANDLE_WRITABLE, uv_tcp_getpeername(), uv_tcp_getsockname(), uv_tcp_set_socket(), and uv_translate_sys_error().

◆ uv_tcp_simultaneous_accepts()

UV_EXTERN int uv_tcp_simultaneous_accepts ( uv_tcp_t handle,
int  enable 
)

Definition at line 450 of file tcp.c.

450  {
451  if (enable)
453  else
455  return 0;
456 }
@ UV_HANDLE_TCP_SINGLE_ACCEPT
Definition: uv-common.h:107

References handle, UV_HANDLE_CONNECTION, UV_HANDLE_LISTENING, UV_HANDLE_TCP_ACCEPT_STATE_CHANGING, and UV_HANDLE_TCP_SINGLE_ACCEPT.

◆ uv_thread_create()

UV_EXTERN int uv_thread_create ( uv_thread_t tid,
uv_thread_cb  entry,
void *  arg 
)

Definition at line 210 of file thread.c.

210  {
211  uv_thread_options_t params;
212  params.flags = UV_THREAD_NO_FLAGS;
213  return uv_thread_create_ex(tid, &params, entry, arg);
214 }
Definition: zipcmp.c:77
unsigned int flags
Definition: uv.h:1753
int uv_thread_create_ex(uv_thread_t *tid, const uv_thread_options_t *params, void(*entry)(void *arg), void *arg)
Definition: thread.c:216

References uv_thread_options_s::flags, uv_thread_create_ex(), and UV_THREAD_NO_FLAGS.

Referenced by init_threads(), and main().

◆ uv_thread_create_ex()

UV_EXTERN int uv_thread_create_ex ( uv_thread_t tid,
const uv_thread_options_t params,
uv_thread_cb  entry,
void *  arg 
)

Definition at line 216 of file thread.c.

219  {
220  int err;
221  pthread_attr_t* attr;
222  pthread_attr_t attr_storage;
223  size_t pagesize;
224  size_t stack_size;
225 
226  /* Used to squelch a -Wcast-function-type warning. */
227  union {
228  void (*in)(void*);
229  void* (*out)(void*);
230  } f;
231 
232  stack_size =
233  params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;
234 
235  attr = NULL;
236  if (stack_size == 0) {
237  stack_size = thread_stack_size();
238  } else {
239  pagesize = (size_t)getpagesize();
240  /* Round up to the nearest page boundary. */
241  stack_size = (stack_size + pagesize - 1) &~ (pagesize - 1);
242 #ifdef PTHREAD_STACK_MIN
243  if (stack_size < PTHREAD_STACK_MIN)
244  stack_size = PTHREAD_STACK_MIN;
245 #endif
246  }
247 
248  if (stack_size > 0) {
249  attr = &attr_storage;
250 
251  if (pthread_attr_init(attr))
252  abort();
253 
254  if (pthread_attr_setstacksize(attr, stack_size))
255  abort();
256  }
257 
258  f.in = entry;
259  err = pthread_create(tid, attr, f.out, arg);
260 
261  if (attr != NULL)
262  pthread_attr_destroy(attr);
263 
264  return UV__ERR(err);
265 }
const lzma_allocator const uint8_t * in
Definition: block.h:527
#define f(i)
Definition: sha256.c:46
size_t stack_size
Definition: uv.h:1754
static size_t thread_stack_size(void)
Definition: thread.c:171

References arg(), EACCES, EAGAIN, EINVAL, thread_ctx::entry, err, f, uv_thread_options_s::flags, HANDLE, in, NULL, uv_thread_options_s::stack_size, sysinfo, thread_stack_size(), UV__ERR, uv__free(), uv__malloc(), uv__thread_start(), and UV_THREAD_HAS_STACK_SIZE.

Referenced by uv_thread_create().

◆ uv_thread_equal()

UV_EXTERN int uv_thread_equal ( const uv_thread_t t1,
const uv_thread_t t2 
)

Definition at line 277 of file thread.c.

277  {
278  return pthread_equal(*t1, *t2);
279 }

References benchmark::t1.

◆ uv_thread_join()

UV_EXTERN int uv_thread_join ( uv_thread_t tid)

Definition at line 272 of file thread.c.

272  {
273  return UV__ERR(pthread_join(*tid, NULL));
274 }

References NULL, UV__ERR, and uv_translate_sys_error().

Referenced by main(), uv__stream_close(), and uv__threadpool_cleanup().

◆ uv_thread_self()

UV_EXTERN uv_thread_t uv_thread_self ( void  )

Definition at line 268 of file thread.c.

268  {
269  return pthread_self();
270 }

References uv__current_thread_init_guard, uv__current_thread_key, uv__init_current_thread_key(), uv_key_get(), and uv_once().

◆ uv_timer_again()

UV_EXTERN int uv_timer_again ( uv_timer_t handle)

Definition at line 110 of file timer.c.

110  {
111  if (handle->timer_cb == NULL)
112  return UV_EINVAL;
113 
114  if (handle->repeat) {
116  uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat);
117  }
118 
119  return 0;
120 }
int uv_timer_stop(uv_timer_t *handle)
Definition: timer.c:97
int uv_timer_start(uv_timer_t *handle, uv_timer_cb cb, uint64_t timeout, uint64_t repeat)
Definition: timer.c:66

References handle, NULL, uv_timer_start(), and uv_timer_stop().

Referenced by uv__run_timers().

◆ uv_timer_get_due_in()

UV_EXTERN uint64_t uv_timer_get_due_in ( const uv_timer_t handle)

Definition at line 133 of file timer.c.

133  {
134  if (handle->loop->time >= handle->timeout)
135  return 0;
136 
137  return handle->timeout - handle->loop->time;
138 }

References handle.

◆ uv_timer_get_repeat()

UV_EXTERN uint64_t uv_timer_get_repeat ( const uv_timer_t handle)

Definition at line 128 of file timer.c.

128  {
129  return handle->repeat;
130 }

References handle.

◆ uv_timer_init()

UV_EXTERN int uv_timer_init ( uv_loop_t loop,
uv_timer_t handle 
)

Definition at line 58 of file timer.c.

58  {
59  uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER);
60  handle->timer_cb = NULL;
61  handle->repeat = 0;
62  return 0;
63 }

References handle, loop, NULL, and uv__handle_init.

Referenced by eof_timer_init(), main(), and uv_fs_poll_start().

◆ uv_timer_set_repeat()

UV_EXTERN void uv_timer_set_repeat ( uv_timer_t handle,
uint64_t  repeat 
)

Definition at line 123 of file timer.c.

123  {
124  handle->repeat = repeat;
125 }
static void repeat(struct parse *, sopno, int, int)
Definition: regcomp.c:1155

References handle, and repeat().

◆ uv_timer_start()

UV_EXTERN int uv_timer_start ( uv_timer_t handle,
uv_timer_cb  cb,
uint64_t  timeout,
uint64_t  repeat 
)

Definition at line 66 of file timer.c.

69  {
70  uint64_t clamped_timeout;
71 
72  if (uv__is_closing(handle) || cb == NULL)
73  return UV_EINVAL;
74 
75  if (uv__is_active(handle))
77 
78  clamped_timeout = handle->loop->time + timeout;
79  if (clamped_timeout < timeout)
80  clamped_timeout = (uint64_t) -1;
81 
82  handle->timer_cb = cb;
83  handle->timeout = clamped_timeout;
84  handle->repeat = repeat;
85  /* start_id is the second index to be compared in timer_less_than() */
86  handle->start_id = handle->loop->timer_counter++;
87 
88  heap_insert(timer_heap(handle->loop),
89  (struct heap_node*) &handle->heap_node,
92 
93  return 0;
94 }
static struct heap * timer_heap(const uv_loop_t *loop)
Definition: timer.c:29
static int timer_less_than(const struct heap_node *ha, const struct heap_node *hb)
Definition: timer.c:38

References cb, handle, NULL, repeat(), timeout, timer_heap(), timer_less_than(), uv__handle_start, uv__is_active, uv__is_closing, and uv_timer_stop().

Referenced by eof_timer_start(), main(), poll_cb(), start_timeout(), and uv_timer_again().

◆ uv_timer_stop()

UV_EXTERN int uv_timer_stop ( uv_timer_t handle)

Definition at line 97 of file timer.c.

97  {
98  if (!uv__is_active(handle))
99  return 0;
100 
101  heap_remove(timer_heap(handle->loop),
102  (struct heap_node*) &handle->heap_node,
105 
106  return 0;
107 }

References handle, timer_heap(), timer_less_than(), uv__handle_stop, and uv__is_active.

Referenced by curl_perform(), eof_timer_stop(), update(), uv__run_timers(), uv__timer_close(), uv_close(), uv_timer_again(), and uv_timer_start().

◆ uv_translate_sys_error()

UV_EXTERN int uv_translate_sys_error ( int  sys_errno)

Definition at line 1249 of file core.c.

1249  {
1250  /* If < 0 then it's already a libuv error. */
1251  return sys_errno <= 0 ? sys_errno : -sys_errno;
1252 }

Referenced by SOCKOPT_SETTER(), uv__convert_utf16_to_utf8(), uv__convert_utf8_to_utf16(), uv__fast_poll_process_poll_req(), uv__get_handle(), uv__getaddrinfo_done(), uv__getaddrinfo_translate_error(), uv__getnameinfo_work(), uv__getpwuid_r(), uv__kill(), uv__pipe_getname(), uv__slow_poll_process_poll_req(), uv__tcp_bind(), uv__tcp_connect(), uv__tcp_try_write(), uv__tty_try_write(), uv__udp_connect(), uv__udp_disconnect(), uv__udp_init_ex(), uv__udp_recv_start(), uv__udp_send(), uv__udp_set_membership4(), uv__udp_set_membership6(), uv__udp_set_source_membership4(), uv__udp_set_source_membership6(), uv__udp_try_send(), uv_accept(), uv_chdir(), uv_cpu_info(), uv_cwd(), uv_exepath(), uv_fs_event_start(), uv_get_process_title(), uv_getaddrinfo(), uv_getrusage(), uv_if_indextoiid(), uv_if_indextoname(), uv_interface_addresses(), uv_kill(), uv_listen(), uv_os_getenv(), uv_os_gethostname(), uv_os_getpriority(), uv_os_setenv(), uv_os_setpriority(), uv_os_tmpdir(), uv_os_uname(), uv_os_unsetenv(), uv_pipe_bind(), uv_pipe_chmod(), uv_pipe_endgame(), uv_pipe_open(), uv_pipe_read_error(), uv_poll_close(), uv_poll_init_socket(), uv_process_fs_event_req(), uv_process_pipe_connect_req(), uv_process_pipe_write_req(), uv_process_proc_exit(), uv_process_tcp_accept_req(), uv_process_tcp_connect_req(), uv_process_tcp_read_req(), uv_process_tcp_write_req(), uv_process_tty_read_line_req(), uv_process_tty_read_raw_req(), uv_process_tty_write_req(), uv_process_udp_recv_req(), uv_process_udp_send_req(), uv_read_start(), uv_read_stop(), uv_resident_set_memory(), uv_rwlock_init(), uv_sem_init(), uv_set_process_title(), uv_spawn(), uv_tcp_close_reset(), uv_tcp_endgame(), uv_tcp_init_ex(), uv_tcp_open(), uv_thread_join(), uv_tty_get_winsize(), uv_tty_init(), uv_tty_set_mode(), uv_udp_open(), uv_udp_set_broadcast(), uv_udp_set_multicast_interface(), uv_uptime(), uv_write(), and uv_write2().

◆ uv_try_write()

UV_EXTERN int uv_try_write ( uv_stream_t handle,
const uv_buf_t  bufs[],
unsigned int  nbufs 
)

Definition at line 1507 of file stream.c.

1509  {
1510  int r;
1511  int has_pollout;
1512  size_t written;
1513  size_t req_size;
1514  uv_write_t req;
1515 
1516  /* Connecting or already writing some data */
1517  if (stream->connect_req != NULL || stream->write_queue_size != 0)
1518  return UV_EAGAIN;
1519 
1520  has_pollout = uv__io_active(&stream->io_watcher, POLLOUT);
1521 
1522  r = uv_write(&req, stream, bufs, nbufs, uv_try_write_cb);
1523  if (r != 0)
1524  return r;
1525 
1526  /* Remove not written bytes from write queue size */
1527  written = uv__count_bufs(bufs, nbufs);
1528  if (req.bufs != NULL)
1529  req_size = uv__write_req_size(&req);
1530  else
1531  req_size = 0;
1532  written -= req_size;
1533  stream->write_queue_size -= req_size;
1534 
1535  /* Unqueue request, regardless of immediateness */
1536  QUEUE_REMOVE(&req.queue);
1537  uv__req_unregister(stream->loop, &req);
1538  if (req.bufs != req.bufsml)
1539  uv__free(req.bufs);
1540  req.bufs = NULL;
1541 
1542  /* Do not poll for writable, if we wasn't before calling this */
1543  if (!has_pollout) {
1544  uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT);
1546  }
1547 
1548  if (written == 0 && req_size != 0)
1549  return req.error < 0 ? req.error : UV_EAGAIN;
1550  else
1551  return written;
1552 }
Definition: uv.h:525
static size_t uv__write_req_size(uv_write_t *req)
Definition: stream.c:719
void uv_try_write_cb(uv_write_t *req, int status)
Definition: stream.c:1501
int uv_write(uv_write_t *req, uv_stream_t *handle, const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb)
Definition: stream.c:1492
size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs)
Definition: uv-common.c:573
#define uv__req_unregister(loop, req)
Definition: uv-common.h:230

References assert(), bufs, NULL, QUEUE_REMOVE, r, req, uv__count_bufs(), uv__free(), uv__io_active(), uv__io_stop(), uv__req_unregister, uv__stream_osx_interrupt_select(), uv__tcp_try_write(), uv__tty_try_write(), uv__write_req_size(), UV_HANDLE_CLOSING, UV_HANDLE_WRITABLE, uv_try_write_cb(), and uv_write().

◆ uv_tty_get_vterm_state()

UV_EXTERN int uv_tty_get_vterm_state ( uv_tty_vtermstate_t state)

Definition at line 400 of file tty.c.

400  {
401  return UV_ENOTSUP;
402 }

References uv__vterm_state, uv_sem_post(), uv_sem_wait(), and uv_tty_output_lock.

◆ uv_tty_get_winsize()

UV_EXTERN int uv_tty_get_winsize ( uv_tty_t tty,
int width,
int height 
)

Definition at line 297 of file tty.c.

297  {
298  struct winsize ws;
299  int err;
300 
301  do
303  while (err == -1 && errno == EINTR);
304 
305  if (err == -1)
306  return UV__ERR(errno);
307 
308  *width = ws.ws_col;
309  *height = ws.ws_row;
310 
311  return 0;
312 }
#define TIOCGWINSZ
Definition: sftypes.h:721
int width
Definition: main.c:10
int height
Definition: main.c:10

References EINTR, err, height, info(), ioctl, TIOCGWINSZ, tty, UV__ERR, uv__stream_fd, uv_sem_post(), uv_sem_wait(), uv_translate_sys_error(), uv_tty_output_lock, uv_tty_update_virtual_window(), uv_tty_virtual_height, uv_tty_virtual_width, width, winsize::ws_col, and winsize::ws_row.

Referenced by main().

◆ uv_tty_init()

UV_EXTERN int uv_tty_init ( uv_loop_t loop,
uv_tty_t tty,
uv_file  fd,
int  readable 
)

Definition at line 123 of file tty.c.

123  {
125  int flags;
126  int newfd;
127  int r;
128  int saved_flags;
129  int mode;
130  char path[256];
131  (void)unused; /* deprecated parameter is no longer needed */
132 
133  /* File descriptors that refer to files cannot be monitored with epoll.
134  * That restriction also applies to character devices like /dev/random
135  * (but obviously not /dev/tty.)
136  */
138  if (type == UV_FILE || type == UV_UNKNOWN_HANDLE)
139  return UV_EINVAL;
140 
141  flags = 0;
142  newfd = -1;
143 
144  /* Save the fd flags in case we need to restore them due to an error. */
145  do
146  saved_flags = fcntl(fd, F_GETFL);
147  while (saved_flags == -1 && errno == EINTR);
148 
149  if (saved_flags == -1)
150  return UV__ERR(errno);
151  mode = saved_flags & O_ACCMODE;
152 
153  /* Reopen the file descriptor when it refers to a tty. This lets us put the
154  * tty in non-blocking mode without affecting other processes that share it
155  * with us.
156  *
157  * Example: `node | cat` - if we put our fd 0 in non-blocking mode, it also
158  * affects fd 1 of `cat` because both file descriptors refer to the same
159  * struct file in the kernel. When we reopen our fd 0, it points to a
160  * different struct file, hence changing its properties doesn't affect
161  * other processes.
162  */
163  if (type == UV_TTY) {
164  /* Reopening a pty in master mode won't work either because the reopened
165  * pty will be in slave mode (*BSD) or reopening will allocate a new
166  * master/slave pair (Linux). Therefore check if the fd points to a
167  * slave device.
168  */
169  if (uv__tty_is_slave(fd) && ttyname_r(fd, path, sizeof(path)) == 0)
171  else
172  r = -1;
173 
174  if (r < 0) {
175  /* fallback to using blocking writes */
176  if (mode != O_RDONLY)
178  goto skip;
179  }
180 
181  newfd = r;
182 
183  r = uv__dup2_cloexec(newfd, fd);
184  if (r < 0 && r != UV_EINVAL) {
185  /* EINVAL means newfd == fd which could conceivably happen if another
186  * thread called close(fd) between our calls to isatty() and open().
187  * That's a rather unlikely event but let's handle it anyway.
188  */
189  uv__close(newfd);
190  return r;
191  }
192 
193  fd = newfd;
194  }
195 
196 skip:
197  uv__stream_init(loop, (uv_stream_t*) tty, UV_TTY);
198 
199  /* If anything fails beyond this point we need to remove the handle from
200  * the handle queue, since it was added by uv__handle_init in uv_stream_init.
201  */
202 
204  uv__nonblock(fd, 1);
205 
206 #if defined(__APPLE__)
207  r = uv__stream_try_select((uv_stream_t*) tty, &fd);
208  if (r) {
209  int rc = r;
210  if (newfd != -1)
211  uv__close(newfd);
212  QUEUE_REMOVE(&tty->handle_queue);
213  do
214  r = fcntl(fd, F_SETFL, saved_flags);
215  while (r == -1 && errno == EINTR);
216  return rc;
217  }
218 #endif
219 
220  if (mode != O_WRONLY)
222  if (mode != O_RDONLY)
224 
226  tty->mode = UV_TTY_MODE_NORMAL;
227 
228  return 0;
229 }
void skip(file *in, unsigned n)
Definition: gzappend.c:202
#define O_NOCTTY
Definition: sftypes.h:491
#define F_SETFL
Definition: sftypes.h:507
int uv__open_cloexec(const char *path, int flags)
Definition: core.c:1003
int uv__dup2_cloexec(int oldfd, int newfd)
Definition: core.c:1031
static int uv__tty_is_slave(const int fd)
Definition: tty.c:69
uv_handle_type uv_guess_handle(uv_file file)
Definition: tty.c:315
@ UV_HANDLE_BLOCKING_WRITES
Definition: uv-common.h:98

References ANSI_NORMAL, DWORD, EINTR, F_GETFL, F_SETFL, FALSE, fcntl, fd, flags, handle, HANDLE, INVALID_HANDLE_VALUE, loop, memset(), NULL, O_ACCMODE, O_NOCTTY, O_RDONLY, O_WRONLY, path, QUEUE_REMOVE, r, skip(), tty, type, uv__close(), uv__determine_vterm_state(), uv__dup2_cloexec(), UV__ERR, uv__get_osfhandle(), uv__need_check_vterm_state, uv__nonblock, uv__once_init(), uv__open_cloexec(), uv__stream_init(), uv__stream_open(), uv__tty_is_slave(), uv_connection_init(), UV_FILE, uv_guess_handle(), UV_HANDLE_BLOCKING_WRITES, UV_HANDLE_BOUND, UV_HANDLE_READABLE, UV_HANDLE_TTY_READABLE, UV_HANDLE_WRITABLE, uv_null_buf_, uv_sem_post(), uv_sem_wait(), uv_stream_init(), uv_translate_sys_error(), uv_tty_capture_initial_style(), UV_TTY_MODE_NORMAL, uv_tty_output_lock, uv_tty_update_virtual_window(), and UV_UNKNOWN_HANDLE.

Referenced by main().

◆ uv_tty_reset_mode()

UV_EXTERN int uv_tty_reset_mode ( void  )

Definition at line 378 of file tty.c.

378  {
379  int saved_errno;
380  int err;
381 
382  saved_errno = errno;
383  if (!uv_spinlock_trylock(&termios_spinlock))
384  return UV_EBUSY; /* In uv_tty_set_mode(). */
385 
386  err = 0;
387  if (orig_termios_fd != -1)
388  if (tcsetattr(orig_termios_fd, TCSANOW, &orig_termios))
389  err = UV__ERR(errno);
390 
391  uv_spinlock_unlock(&termios_spinlock);
392  errno = saved_errno;
393 
394  return err;
395 }
#define TCSANOW
Definition: sftypes.h:998
static int orig_termios_fd
Definition: tty.c:65
static struct termios orig_termios
Definition: tty.c:66
static uv_spinlock_t termios_spinlock
Definition: tty.c:67

References err, orig_termios, orig_termios_fd, TCSANOW, termios_spinlock, and UV__ERR.

Referenced by main(), and update().

◆ uv_tty_set_mode()

UV_EXTERN int uv_tty_set_mode ( uv_tty_t tty,
uv_tty_mode_t  mode 
)

Definition at line 250 of file tty.c.

250  {
251  struct termios tmp;
252  int fd;
253 
254  if (tty->mode == (int) mode)
255  return 0;
256 
257  fd = uv__stream_fd(tty);
258  if (tty->mode == UV_TTY_MODE_NORMAL && mode != UV_TTY_MODE_NORMAL) {
259  if (tcgetattr(fd, &tty->orig_termios))
260  return UV__ERR(errno);
261 
262  /* This is used for uv_tty_reset_mode() */
263  uv_spinlock_lock(&termios_spinlock);
264  if (orig_termios_fd == -1) {
265  orig_termios = tty->orig_termios;
267  }
268  uv_spinlock_unlock(&termios_spinlock);
269  }
270 
271  tmp = tty->orig_termios;
272  switch (mode) {
273  case UV_TTY_MODE_NORMAL:
274  break;
275  case UV_TTY_MODE_RAW:
276  tmp.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
277  tmp.c_oflag |= (ONLCR);
278  tmp.c_cflag |= (CS8);
279  tmp.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
280  tmp.c_cc[VMIN] = 1;
281  tmp.c_cc[VTIME] = 0;
282  break;
283  case UV_TTY_MODE_IO:
285  break;
286  }
287 
288  /* Apply changes after draining */
289  if (tcsetattr(fd, TCSADRAIN, &tmp))
290  return UV__ERR(errno);
291 
292  tty->mode = mode;
293  return 0;
294 }
#define CS8
Definition: sftypes.h:942
#define BRKINT
Definition: sftypes.h:871
#define ISIG
Definition: sftypes.h:970
#define VMIN
Definition: sftypes.h:857
#define ICANON
Definition: sftypes.h:971
#define VTIME
Definition: sftypes.h:856
#define IXON
Definition: sftypes.h:880
#define ONLCR
Definition: sftypes.h:888
#define ECHO
Definition: sftypes.h:973
#define IEXTEN
Definition: sftypes.h:984
#define INPCK
Definition: sftypes.h:874
#define TCSADRAIN
Definition: sftypes.h:999
#define ICRNL
Definition: sftypes.h:878
#define ISTRIP
Definition: sftypes.h:875
static void uv__tty_make_raw(struct termios *tio)
Definition: tty.c:231

References BRKINT, CS8, DWORD, ECHO, err, fd, flags, ICANON, ICRNL, IEXTEN, INPCK, ISIG, ISTRIP, IXON, NULL, ONLCR, orig_termios, orig_termios_fd, TCSADRAIN, termios_spinlock, autogen_x86imm::tmp, tty, UV__ERR, uv__stream_fd, uv__tty_make_raw(), UV_HANDLE_READING, UV_HANDLE_TTY_RAW, UV_HANDLE_TTY_READABLE, uv_sem_post(), uv_sem_wait(), uv_translate_sys_error(), UV_TTY_MODE_IO, UV_TTY_MODE_NORMAL, UV_TTY_MODE_RAW, uv_tty_output_lock, uv_tty_read_start(), uv_tty_read_stop(), VMIN, and VTIME.

Referenced by main().

◆ uv_tty_set_vterm_state()

UV_EXTERN void uv_tty_set_vterm_state ( uv_tty_vtermstate_t  state)

Definition at line 397 of file tty.c.

397  {
398 }

References FALSE, uv__need_check_vterm_state, uv__vterm_state, uv_sem_post(), uv_sem_wait(), and uv_tty_output_lock.

◆ uv_udp_bind()

UV_EXTERN int uv_udp_bind ( uv_udp_t handle,
const struct sockaddr addr,
unsigned int  flags 
)

Definition at line 326 of file uv-common.c.

328  {
329  unsigned int addrlen;
330 
331  if (handle->type != UV_UDP)
332  return UV_EINVAL;
333 
334  if (addr->sa_family == AF_INET)
335  addrlen = sizeof(struct sockaddr_in);
336  else if (addr->sa_family == AF_INET6)
337  addrlen = sizeof(struct sockaddr_in6);
338  else
339  return UV_EINVAL;
340 
341  return uv__udp_bind(handle, addr, addrlen, flags);
342 }
int uv__udp_bind(uv_udp_t *handle, const struct sockaddr *addr, unsigned int addrlen, unsigned int flags)
Definition: udp.c:508

References addr, addrlen, AF_INET, AF_INET6, flags, handle, and uv__udp_bind().

Referenced by main().

◆ uv_udp_connect()

UV_EXTERN int uv_udp_connect ( uv_udp_t handle,
const struct sockaddr addr 
)

Definition at line 365 of file uv-common.c.

365  {
366  unsigned int addrlen;
367 
368  if (handle->type != UV_UDP)
369  return UV_EINVAL;
370 
371  /* Disconnect the handle */
372  if (addr == NULL) {
373  if (!(handle->flags & UV_HANDLE_UDP_CONNECTED))
374  return UV_ENOTCONN;
375 
376  return uv__udp_disconnect(handle);
377  }
378 
379  if (addr->sa_family == AF_INET)
380  addrlen = sizeof(struct sockaddr_in);
381  else if (addr->sa_family == AF_INET6)
382  addrlen = sizeof(struct sockaddr_in6);
383  else
384  return UV_EINVAL;
385 
386  if (handle->flags & UV_HANDLE_UDP_CONNECTED)
387  return UV_EISCONN;
388 
390 }
int uv__udp_disconnect(uv_udp_t *handle)
Definition: udp.c:629
int uv__udp_connect(uv_udp_t *handle, const struct sockaddr *addr, unsigned int addrlen)
Definition: udp.c:606
@ UV_HANDLE_UDP_CONNECTED
Definition: uv-common.h:114

References addr, addrlen, AF_INET, AF_INET6, handle, NULL, uv__udp_connect(), uv__udp_disconnect(), and UV_HANDLE_UDP_CONNECTED.

◆ uv_udp_get_send_queue_count()

UV_EXTERN size_t uv_udp_get_send_queue_count ( const uv_udp_t handle)

Definition at line 85 of file uv-data-getter-setters.c.

85  {
86  return handle->send_queue_count;
87 }

References handle.

◆ uv_udp_get_send_queue_size()

UV_EXTERN size_t uv_udp_get_send_queue_size ( const uv_udp_t handle)

Definition at line 81 of file uv-data-getter-setters.c.

81  {
82  return handle->send_queue_size;
83 }

References handle.

◆ uv_udp_getpeername()

UV_EXTERN int uv_udp_getpeername ( const uv_udp_t handle,
struct sockaddr name,
int namelen 
)

Definition at line 1276 of file udp.c.

1278  {
1279 
1280  return uv__getsockpeername((const uv_handle_t*) handle,
1281  getpeername,
1282  name,
1283  namelen);
1284 }

References handle, and uv__getsockpeername().

Referenced by uv__udp_is_connected().

◆ uv_udp_getsockname()

UV_EXTERN int uv_udp_getsockname ( const uv_udp_t handle,
struct sockaddr name,
int namelen 
)

Definition at line 1286 of file udp.c.

1288  {
1289 
1290  return uv__getsockpeername((const uv_handle_t*) handle,
1291  getsockname,
1292  name,
1293  namelen);
1294 }

References handle, and uv__getsockpeername().

Referenced by uv__udp_is_bound().

◆ uv_udp_init()

UV_EXTERN int uv_udp_init ( uv_loop_t loop,
uv_udp_t handle 
)

Definition at line 321 of file uv-common.c.

321  {
323 }
int uv_udp_init_ex(uv_loop_t *loop, uv_udp_t *handle, unsigned flags)
Definition: uv-common.c:296

References AF_UNSPEC, handle, loop, and uv_udp_init_ex().

Referenced by main().

◆ uv_udp_init_ex()

UV_EXTERN int uv_udp_init_ex ( uv_loop_t ,
uv_udp_t handle,
unsigned int  flags 
)

◆ uv_udp_open()

UV_EXTERN int uv_udp_open ( uv_udp_t handle,
uv_os_sock_t  sock 
)

Definition at line 991 of file udp.c.

991  {
992  int err;
993 
994  /* Check for already active socket. */
995  if (handle->io_watcher.fd != -1)
996  return UV_EBUSY;
997 
998  if (uv__fd_exists(handle->loop, sock))
999  return UV_EEXIST;
1000 
1001  err = uv__nonblock(sock, 1);
1002  if (err)
1003  return err;
1004 
1005  err = uv__set_reuse(sock);
1006  if (err)
1007  return err;
1008 
1009  handle->io_watcher.fd = sock;
1011  handle->flags |= UV_HANDLE_UDP_CONNECTED;
1012 
1013  return 0;
1014 }
static int uv__set_reuse(int fd)
Definition: udp.c:480
int uv__udp_is_connected(uv_udp_t *handle)
Definition: uv-common.c:393

References err, handle, int, SOL_SOCKET, uv__fd_exists(), uv__nonblock, uv__set_reuse(), uv__udp_is_bound(), uv__udp_is_connected(), UV_HANDLE_BOUND, UV_HANDLE_UDP_CONNECTED, uv_translate_sys_error(), and uv_udp_set_socket().

Referenced by uv_accept().

◆ uv_udp_recv_start()

UV_EXTERN int uv_udp_recv_start ( uv_udp_t handle,
uv_alloc_cb  alloc_cb,
uv_udp_recv_cb  recv_cb 
)

Definition at line 468 of file uv-common.c.

470  {
471  if (handle->type != UV_UDP || alloc_cb == NULL || recv_cb == NULL)
472  return UV_EINVAL;
473  else
474  return uv__udp_recv_start(handle, alloc_cb, recv_cb);
475 }
int uv__udp_recv_start(uv_udp_t *handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb)
Definition: udp.c:1297

References handle, NULL, and uv__udp_recv_start().

Referenced by main().

◆ uv_udp_recv_stop()

UV_EXTERN int uv_udp_recv_stop ( uv_udp_t handle)

Definition at line 478 of file uv-common.c.

478  {
479  if (handle->type != UV_UDP)
480  return UV_EINVAL;
481  else
482  return uv__udp_recv_stop(handle);
483 }
int uv__udp_recv_stop(uv_udp_t *handle)
Definition: udp.c:1322

References handle, and uv__udp_recv_stop().

Referenced by on_read(), uv_process_udp_recv_req(), and uv_udp_close().

◆ uv_udp_send()

UV_EXTERN int uv_udp_send ( uv_udp_send_t req,
uv_udp_t handle,
const uv_buf_t  bufs[],
unsigned int  nbufs,
const struct sockaddr addr,
uv_udp_send_cb  send_cb 
)

Definition at line 438 of file uv-common.c.

443  {
444  int addrlen;
445 
447  if (addrlen < 0)
448  return addrlen;
449 
450  return uv__udp_send(req, handle, bufs, nbufs, addr, addrlen, send_cb);
451 }
int uv__udp_send(uv_udp_send_t *req, uv_udp_t *handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr *addr, unsigned int addrlen, uv_udp_send_cb send_cb)
Definition: udp.c:650
int uv__udp_check_before_send(uv_udp_t *handle, const struct sockaddr *addr)
Definition: uv-common.c:407

References addr, addrlen, bufs, handle, req, uv__udp_check_before_send(), and uv__udp_send().

Referenced by main().

◆ uv_udp_set_broadcast()

UV_EXTERN int uv_udp_set_broadcast ( uv_udp_t handle,
int  on 
)

Definition at line 1128 of file udp.c.

1128  {
1129  if (setsockopt(handle->io_watcher.fd,
1130  SOL_SOCKET,
1131  SO_BROADCAST,
1132  &on,
1133  sizeof(on))) {
1134  return UV__ERR(errno);
1135  }
1136 
1137  return 0;
1138 }
#define SO_BROADCAST
Definition: sftypes.h:434

References handle, SO_BROADCAST, SOL_SOCKET, UV__ERR, uv_translate_sys_error(), and value.

Referenced by main().

◆ uv_udp_set_membership()

UV_EXTERN int uv_udp_set_membership ( uv_udp_t handle,
const char *  multicast_addr,
const char *  interface_addr,
uv_membership  membership 
)

Definition at line 1017 of file udp.c.

1020  {
1021  int err;
1022  struct sockaddr_in addr4;
1023  struct sockaddr_in6 addr6;
1024 
1025  if (uv_ip4_addr(multicast_addr, 0, &addr4) == 0) {
1027  if (err)
1028  return err;
1029  return uv__udp_set_membership4(handle, &addr4, interface_addr, membership);
1030  } else if (uv_ip6_addr(multicast_addr, 0, &addr6) == 0) {
1032  if (err)
1033  return err;
1034  return uv__udp_set_membership6(handle, &addr6, interface_addr, membership);
1035  } else {
1036  return UV_EINVAL;
1037  }
1038 }
static int uv__udp_set_membership4(uv_udp_t *handle, const struct sockaddr_in *multicast_addr, const char *interface_addr, uv_membership membership)
Definition: udp.c:760
static int uv__udp_maybe_deferred_bind(uv_udp_t *handle, int domain, unsigned int flags)
Definition: udp.c:569
static int uv__udp_set_membership6(uv_udp_t *handle, const struct sockaddr_in6 *multicast_addr, const char *interface_addr, uv_membership membership)
Definition: udp.c:807
UV_EXTERN int uv_ip4_addr(const char *ip, int port, struct sockaddr_in *addr)
Definition: uv-common.c:221
UV_EXTERN int uv_ip6_addr(const char *ip, int port, struct sockaddr_in6 *addr)
Definition: uv-common.c:232

References AF_INET, AF_INET6, err, handle, uv__udp_maybe_deferred_bind(), uv__udp_set_membership4(), uv__udp_set_membership6(), uv_ip4_addr(), uv_ip6_addr(), and UV_UDP_REUSEADDR.

◆ uv_udp_set_multicast_interface()

UV_EXTERN int uv_udp_set_multicast_interface ( uv_udp_t handle,
const char *  interface_addr 
)

Definition at line 1227 of file udp.c.

1227  {
1228  struct sockaddr_storage addr_st;
1229  struct sockaddr_in* addr4;
1230  struct sockaddr_in6* addr6;
1231 
1232  addr4 = (struct sockaddr_in*) &addr_st;
1233  addr6 = (struct sockaddr_in6*) &addr_st;
1234 
1235  if (!interface_addr) {
1236  memset(&addr_st, 0, sizeof addr_st);
1237  if (handle->flags & UV_HANDLE_IPV6) {
1238  addr_st.ss_family = AF_INET6;
1239  addr6->sin6_scope_id = 0;
1240  } else {
1241  addr_st.ss_family = AF_INET;
1242  addr4->sin_addr.s_addr = htonl(INADDR_ANY);
1243  }
1244  } else if (uv_ip4_addr(interface_addr, 0, addr4) == 0) {
1245  /* nothing, address was parsed */
1246  } else if (uv_ip6_addr(interface_addr, 0, addr6) == 0) {
1247  /* nothing, address was parsed */
1248  } else {
1249  return UV_EINVAL;
1250  }
1251 
1252  if (addr_st.ss_family == AF_INET) {
1253  if (setsockopt(handle->io_watcher.fd,
1254  IPPROTO_IP,
1255  IP_MULTICAST_IF,
1256  (void*) &addr4->sin_addr,
1257  sizeof(addr4->sin_addr)) == -1) {
1258  return UV__ERR(errno);
1259  }
1260  } else if (addr_st.ss_family == AF_INET6) {
1261  if (setsockopt(handle->io_watcher.fd,
1262  IPPROTO_IPV6,
1263  IPV6_MULTICAST_IF,
1264  &addr6->sin6_scope_id,
1265  sizeof(addr6->sin6_scope_id)) == -1) {
1266  return UV__ERR(errno);
1267  }
1268  } else {
1269  assert(0 && "unexpected address family");
1270  abort();
1271  }
1272 
1273  return 0;
1274 }
in_addr_t s_addr
Definition: sftypes.h:337
uint32_t sin6_scope_id
Definition: sftypes.h:376
struct in_addr sin_addr
Definition: sftypes.h:344
@ UV_HANDLE_IPV6
Definition: uv-common.h:102

References AF_INET, AF_INET6, assert(), handle, memset(), in_addr::s_addr, sockaddr_in6::sin6_scope_id, sockaddr_in::sin_addr, UV__ERR, UV_HANDLE_IPV6, uv_ip4_addr(), uv_ip6_addr(), and uv_translate_sys_error().

◆ uv_udp_set_multicast_loop()

UV_EXTERN int uv_udp_set_multicast_loop ( uv_udp_t handle,
int  on 
)

Definition at line 1203 of file udp.c.

1203  {
1204 /*
1205  * On Solaris and derivatives such as SmartOS, the length of socket options
1206  * is sizeof(int) for IPV6_MULTICAST_LOOP and sizeof(char) for
1207  * IP_MULTICAST_LOOP, so hardcode the size of the option in the IPv6 case,
1208  * and use the general uv__setsockopt_maybe_char call otherwise.
1209  */
1210 #if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
1211  defined(__MVS__) || defined(__QNX__)
1212  if (handle->flags & UV_HANDLE_IPV6)
1213  return uv__setsockopt(handle,
1214  IP_MULTICAST_LOOP,
1215  IPV6_MULTICAST_LOOP,
1216  &on,
1217  sizeof(on));
1218 #endif /* defined(__sun) || defined(_AIX) ||defined(__OpenBSD__) ||
1219  defined(__MVS__) || defined(__QNX__) */
1220 
1222  IP_MULTICAST_LOOP,
1223  IPV6_MULTICAST_LOOP,
1224  on);
1225 }
static int uv__setsockopt(uv_udp_t *handle, int option4, int option6, const void *val, socklen_t size)
Definition: udp.c:1084
static int uv__setsockopt_maybe_char(uv_udp_t *handle, int option4, int option6, int val)
Definition: udp.c:1109

References handle, uv__setsockopt(), uv__setsockopt_maybe_char(), and UV_HANDLE_IPV6.

◆ uv_udp_set_multicast_ttl()

UV_EXTERN int uv_udp_set_multicast_ttl ( uv_udp_t handle,
int  ttl 
)

Definition at line 1178 of file udp.c.

1178  {
1179 /*
1180  * On Solaris and derivatives such as SmartOS, the length of socket options
1181  * is sizeof(int) for IPV6_MULTICAST_HOPS and sizeof(char) for
1182  * IP_MULTICAST_TTL, so hardcode the size of the option in the IPv6 case,
1183  * and use the general uv__setsockopt_maybe_char call otherwise.
1184  */
1185 #if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
1186  defined(__MVS__) || defined(__QNX__)
1187  if (handle->flags & UV_HANDLE_IPV6)
1188  return uv__setsockopt(handle,
1189  IP_MULTICAST_TTL,
1190  IPV6_MULTICAST_HOPS,
1191  &ttl,
1192  sizeof(ttl));
1193 #endif /* defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
1194  defined(__MVS__) || defined(__QNX__) */
1195 
1197  IP_MULTICAST_TTL,
1198  IPV6_MULTICAST_HOPS,
1199  ttl);
1200 }

References handle, uv__setsockopt(), uv__setsockopt_maybe_char(), and UV_HANDLE_IPV6.

◆ uv_udp_set_source_membership()

UV_EXTERN int uv_udp_set_source_membership ( uv_udp_t handle,
const char *  multicast_addr,
const char *  interface_addr,
const char *  source_addr,
uv_membership  membership 
)

Definition at line 1041 of file udp.c.

1045  {
1046 #if !defined(__OpenBSD__) && \
1047  !defined(__NetBSD__) && \
1048  !defined(__ANDROID__) && \
1049  !defined(__DragonFly__) && \
1050  !defined(__QNX__)
1051  int err;
1052  union uv__sockaddr mcast_addr;
1053  union uv__sockaddr src_addr;
1054 
1055  err = uv_ip4_addr(multicast_addr, 0, &mcast_addr.in);
1056  if (err) {
1057  err = uv_ip6_addr(multicast_addr, 0, &mcast_addr.in6);
1058  if (err)
1059  return err;
1060  err = uv_ip6_addr(source_addr, 0, &src_addr.in6);
1061  if (err)
1062  return err;
1064  &mcast_addr.in6,
1065  interface_addr,
1066  &src_addr.in6,
1067  membership);
1068  }
1069 
1070  err = uv_ip4_addr(source_addr, 0, &src_addr.in);
1071  if (err)
1072  return err;
1074  &mcast_addr.in,
1075  interface_addr,
1076  &src_addr.in,
1077  membership);
1078 #else
1079  return UV_ENOSYS;
1080 #endif
1081 }
static int uv__udp_set_source_membership6(uv_udp_t *handle, const struct sockaddr_in6 *multicast_addr, const char *interface_addr, const struct sockaddr_in6 *source_addr, uv_membership membership)
Definition: udp.c:904
static int uv__udp_set_source_membership4(uv_udp_t *handle, const struct sockaddr_in *multicast_addr, const char *interface_addr, const struct sockaddr_in *source_addr, uv_membership membership)
Definition: udp.c:859

References err, handle, uv__sockaddr::in, uv__sockaddr::in6, uv__udp_set_source_membership4(), uv__udp_set_source_membership6(), uv_ip4_addr(), and uv_ip6_addr().

◆ uv_udp_set_ttl()

UV_EXTERN int uv_udp_set_ttl ( uv_udp_t handle,
int  ttl 
)

Definition at line 1141 of file udp.c.

1141  {
1142  if (ttl < 1 || ttl > 255)
1143  return UV_EINVAL;
1144 
1145 #if defined(__MVS__)
1146  if (!(handle->flags & UV_HANDLE_IPV6))
1147  return UV_ENOTSUP; /* zOS does not support setting ttl for IPv4 */
1148 #endif
1149 
1150 /*
1151  * On Solaris and derivatives such as SmartOS, the length of socket options
1152  * is sizeof(int) for IP_TTL and IPV6_UNICAST_HOPS,
1153  * so hardcode the size of these options on this platform,
1154  * and use the general uv__setsockopt_maybe_char call on other platforms.
1155  */
1156 #if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
1157  defined(__MVS__) || defined(__QNX__)
1158 
1159  return uv__setsockopt(handle,
1160  IP_TTL,
1161  IPV6_UNICAST_HOPS,
1162  &ttl,
1163  sizeof(ttl));
1164 
1165 #else /* !(defined(__sun) || defined(_AIX) || defined (__OpenBSD__) ||
1166  defined(__MVS__) || defined(__QNX__)) */
1167 
1169  IP_TTL,
1170  IPV6_UNICAST_HOPS,
1171  ttl);
1172 
1173 #endif /* defined(__sun) || defined(_AIX) || defined (__OpenBSD__) ||
1174  defined(__MVS__) || defined(__QNX__) */
1175 }

References handle, uv__setsockopt(), uv__setsockopt_maybe_char(), and UV_HANDLE_IPV6.

◆ uv_udp_try_send()

UV_EXTERN int uv_udp_try_send ( uv_udp_t handle,
const uv_buf_t  bufs[],
unsigned int  nbufs,
const struct sockaddr addr 
)

Definition at line 454 of file uv-common.c.

457  {
458  int addrlen;
459 
461  if (addrlen < 0)
462  return addrlen;
463 
464  return uv__udp_try_send(handle, bufs, nbufs, addr, addrlen);
465 }
int uv__udp_try_send(uv_udp_t *handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr *addr, unsigned int addrlen)
Definition: udp.c:716

References addr, addrlen, bufs, handle, uv__udp_check_before_send(), and uv__udp_try_send().

◆ uv_udp_using_recvmmsg()

UV_EXTERN int uv_udp_using_recvmmsg ( const uv_udp_t handle)

Definition at line 980 of file udp.c.

980  {
981 #if HAVE_MMSG
982  if (handle->flags & UV_HANDLE_UDP_RECVMMSG) {
983  uv_once(&once, uv__udp_mmsg_init);
984  return uv__recvmmsg_avail;
985  }
986 #endif
987  return 0;
988 }
static uv_once_t once
Definition: threadpool.c:32
@ UV_HANDLE_UDP_RECVMMSG
Definition: uv-common.h:115

References handle, once, UV_HANDLE_UDP_RECVMMSG, and uv_once().

Referenced by uv__udp_recvmsg().

◆ uv_unref()

UV_EXTERN void uv_unref ( uv_handle_t handle)

Definition at line 552 of file uv-common.c.

552  {
554 }

References handle, and uv__handle_unref.

Referenced by eof_timer_init(), and main().

◆ uv_update_time()

UV_EXTERN void uv_update_time ( uv_loop_t loop)

Definition at line 425 of file core.c.

425  {
426  uv__update_time(loop);
427 }

References assert(), loop, and uv__hrtime().

Referenced by uv__poll(), uv__poll_wine(), uv_loop_init(), and uv_run().

◆ uv_uptime()

UV_EXTERN int uv_uptime ( double *  uptime)

Definition at line 1017 of file aix.c.

1017  {
1018  struct utmp *utmp_buf;
1019  size_t entries = 0;
1020  time_t boot_time;
1021 
1022  boot_time = 0;
1023  utmpname(UTMP_FILE);
1024 
1025  setutent();
1026 
1027  while ((utmp_buf = getutent()) != NULL) {
1028  if (utmp_buf->ut_user[0] && utmp_buf->ut_type == USER_PROCESS)
1029  ++entries;
1030  if (utmp_buf->ut_type == BOOT_TIME)
1031  boot_time = utmp_buf->ut_time;
1032  }
1033 
1034  endutent();
1035 
1036  if (boot_time == 0)
1037  return UV_ENOSYS;
1038 
1039  *uptime = time(NULL) - boot_time;
1040  return 0;
1041 }
RzList * entries(RzBinFile *bf)
Definition: bin_ne.c:98
int time_t
Definition: sftypes.h:66

References ARRAY_SIZE, buffer_size, CLOCK_BOOTTIME, DWORD, EINVAL, entries(), i, info(), L, LONG, NULL, r, sp, sysinfo, time, timespec::tv_sec, UV__ERR, uv__free(), uv__malloc(), uv_translate_sys_error(), v, value, and which.

◆ uv_version()

UV_EXTERN unsigned int uv_version ( void  )

Definition at line 38 of file version.c.

38  {
39  return UV_VERSION_HEX;
40 }
#define UV_VERSION_HEX
Definition: version.h:39

References UV_VERSION_HEX.

◆ uv_version_string()

UV_EXTERN const char* uv_version_string ( void  )

Definition at line 43 of file version.c.

43  {
44  return UV_VERSION_STRING;
45 }
#define UV_VERSION_STRING
Definition: version.c:34

References UV_VERSION_STRING.

◆ uv_walk()

UV_EXTERN void uv_walk ( uv_loop_t loop,
uv_walk_cb  walk_cb,
void *  arg 
)

Definition at line 486 of file uv-common.c.

486  {
487  QUEUE queue;
488  QUEUE* q;
489  uv_handle_t* h;
490 
492  while (!QUEUE_EMPTY(&queue)) {
493  q = QUEUE_HEAD(&queue);
494  h = QUEUE_DATA(q, uv_handle_t, handle_queue);
495 
496  QUEUE_REMOVE(q);
498 
499  if (h->flags & UV_HANDLE_INTERNAL) continue;
500  walk_cb(h, arg);
501  }
502 }
#define QUEUE_HEAD(q)
Definition: queue.h:42
#define QUEUE_MOVE(h, n)
Definition: queue.h:72
uv_pipe_t queue
Definition: worker.c:9

References h, uv_loop_s::handle_queue, loop, queue, QUEUE_DATA, QUEUE_EMPTY, QUEUE_HEAD, QUEUE_INSERT_TAIL, QUEUE_MOVE, QUEUE_REMOVE, and UV_HANDLE_INTERNAL.

◆ uv_write()

UV_EXTERN int uv_write ( uv_write_t req,
uv_stream_t handle,
const uv_buf_t  bufs[],
unsigned int  nbufs,
uv_write_cb  cb 
)

Definition at line 1492 of file stream.c.

1496  {
1497  return uv_write2(req, handle, bufs, nbufs, NULL, cb);
1498 }
int uv_write2(uv_write_t *req, uv_stream_t *stream, const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t *send_handle, uv_write_cb cb)
Definition: stream.c:1393

References assert(), bufs, cb, err, handle, loop, NULL, req, uv__pipe_write(), UV_HANDLE_WRITABLE, uv_tcp_write(), uv_translate_sys_error(), uv_tty_write(), and uv_write2().

Referenced by echo_read(), main(), update(), uv_try_write(), uv_write2(), and write_data().

◆ uv_write2()

UV_EXTERN int uv_write2 ( uv_write_t req,
uv_stream_t handle,
const uv_buf_t  bufs[],
unsigned int  nbufs,
uv_stream_t send_handle,
uv_write_cb  cb 
)

Definition at line 1393 of file stream.c.

1398  {
1399  int empty_queue;
1400 
1401  assert(nbufs > 0);
1402  assert((stream->type == UV_TCP ||
1403  stream->type == UV_NAMED_PIPE ||
1404  stream->type == UV_TTY) &&
1405  "uv_write (unix) does not yet support other types of streams");
1406 
1407  if (uv__stream_fd(stream) < 0)
1408  return UV_EBADF;
1409 
1410  if (!(stream->flags & UV_HANDLE_WRITABLE))
1411  return UV_EPIPE;
1412 
1413  if (send_handle) {
1414  if (stream->type != UV_NAMED_PIPE || !((uv_pipe_t*)stream)->ipc)
1415  return UV_EINVAL;
1416 
1417  /* XXX We abuse uv_write2() to send over UDP handles to child processes.
1418  * Don't call uv__stream_fd() on those handles, it's a macro that on OS X
1419  * evaluates to a function that operates on a uv_stream_t with a couple of
1420  * OS X specific fields. On other Unices it does (handle)->io_watcher.fd,
1421  * which works but only by accident.
1422  */
1423  if (uv__handle_fd((uv_handle_t*) send_handle) < 0)
1424  return UV_EBADF;
1425 
1426 #if defined(__CYGWIN__) || defined(__MSYS__)
1427  /* Cygwin recvmsg always sets msg_controllen to zero, so we cannot send it.
1428  See https://github.com/mirror/newlib-cygwin/blob/86fc4bf0/winsup/cygwin/fhandler_socket.cc#L1736-L1743 */
1429  return UV_ENOSYS;
1430 #endif
1431  }
1432 
1433  /* It's legal for write_queue_size > 0 even when the write_queue is empty;
1434  * it means there are error-state requests in the write_completed_queue that
1435  * will touch up write_queue_size later, see also uv__write_req_finish().
1436  * We could check that write_queue is empty instead but that implies making
1437  * a write() syscall when we know that the handle is in error mode.
1438  */
1439  empty_queue = (stream->write_queue_size == 0);
1440 
1441  /* Initialize the req */
1442  uv__req_init(stream->loop, req, UV_WRITE);
1443  req->cb = cb;
1444  req->handle = stream;
1445  req->error = 0;
1446  req->send_handle = send_handle;
1447  QUEUE_INIT(&req->queue);
1448 
1449  req->bufs = req->bufsml;
1450  if (nbufs > ARRAY_SIZE(req->bufsml))
1451  req->bufs = uv__malloc(nbufs * sizeof(bufs[0]));
1452 
1453  if (req->bufs == NULL)
1454  return UV_ENOMEM;
1455 
1456  memcpy(req->bufs, bufs, nbufs * sizeof(bufs[0]));
1457  req->nbufs = nbufs;
1458  req->write_index = 0;
1459  stream->write_queue_size += uv__count_bufs(bufs, nbufs);
1460 
1461  /* Append the request to write_queue. */
1462  QUEUE_INSERT_TAIL(&stream->write_queue, &req->queue);
1463 
1464  /* If the queue was empty when this function began, we should attempt to
1465  * do the write immediately. Otherwise start the write_watcher and wait
1466  * for the fd to become writable.
1467  */
1468  if (stream->connect_req) {
1469  /* Still connecting, do nothing. */
1470  }
1471  else if (empty_queue) {
1472  uv__write(stream);
1473  }
1474  else {
1475  /*
1476  * blocking streams should never have anything in the queue.
1477  * if this assert fires then somehow the blocking stream isn't being
1478  * sufficiently flushed in uv__write.
1479  */
1481  uv__io_start(stream->loop, &stream->io_watcher, POLLOUT);
1483  }
1484 
1485  return 0;
1486 }
static int uv__handle_fd(uv_handle_t *handle)
Definition: stream.c:788
static void uv__write(uv_stream_t *stream)
Definition: stream.c:802

References ARRAY_SIZE, assert(), bufs, cb, err, handle, loop, memcpy(), NULL, QUEUE_INIT, QUEUE_INSERT_TAIL, req, uv__count_bufs(), uv__handle_fd(), uv__io_start(), uv__malloc(), uv__pipe_write(), uv__req_init, uv__stream_fd, uv__stream_osx_interrupt_select(), uv__write(), UV_HANDLE_BLOCKING_WRITES, UV_HANDLE_WRITABLE, uv_translate_sys_error(), and uv_write().

Referenced by on_new_connection(), and uv_write().