Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-07 08:43:57

0001 /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
0002  *
0003  * Permission is hereby granted, free of charge, to any person obtaining a copy
0004  * of this software and associated documentation files (the "Software"), to
0005  * deal in the Software without restriction, including without limitation the
0006  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
0007  * sell copies of the Software, and to permit persons to whom the Software is
0008  * furnished to do so, subject to the following conditions:
0009  *
0010  * The above copyright notice and this permission notice shall be included in
0011  * all copies or substantial portions of the Software.
0012  *
0013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0014  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0015  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0016  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0017  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0018  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
0019  * IN THE SOFTWARE.
0020  */
0021 
0022 /* See https://github.com/libuv/libuv#documentation for documentation. */
0023 
0024 #ifndef UV_H
0025 #define UV_H
0026 #ifdef __cplusplus
0027 extern "C" {
0028 #endif
0029 
0030 #if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED)
0031 #error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both."
0032 #endif
0033 
0034 #ifndef UV_EXTERN
0035 #ifdef _WIN32
0036   /* Windows - set up dll import/export decorators. */
0037 # if defined(BUILDING_UV_SHARED)
0038     /* Building shared library. */
0039 #   define UV_EXTERN __declspec(dllexport)
0040 # elif defined(USING_UV_SHARED)
0041     /* Using shared library. */
0042 #   define UV_EXTERN __declspec(dllimport)
0043 # else
0044     /* Building static library. */
0045 #   define UV_EXTERN /* nothing */
0046 # endif
0047 #elif __GNUC__ >= 4
0048 # define UV_EXTERN __attribute__((visibility("default")))
0049 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) /* Sun Studio >= 8 */
0050 # define UV_EXTERN __global
0051 #else
0052 # define UV_EXTERN /* nothing */
0053 #endif
0054 #endif /* UV_EXTERN */
0055 
0056 #include "uv/errno.h"
0057 #include "uv/version.h"
0058 #include <stddef.h>
0059 #include <stdio.h>
0060 #include <stdint.h>
0061 #include <math.h>
0062 
0063 /* Internal type, do not use. */
0064 struct uv__queue {
0065   struct uv__queue* next;
0066   struct uv__queue* prev;
0067 };
0068 
0069 #if defined(_WIN32)
0070 # include "uv/win.h"
0071 #else
0072 # include "uv/unix.h"
0073 #endif
0074 
0075 /* Expand this list if necessary. */
0076 #define UV_ERRNO_MAP(XX)                                                      \
0077   XX(E2BIG, "argument list too long")                                         \
0078   XX(EACCES, "permission denied")                                             \
0079   XX(EADDRINUSE, "address already in use")                                    \
0080   XX(EADDRNOTAVAIL, "address not available")                                  \
0081   XX(EAFNOSUPPORT, "address family not supported")                            \
0082   XX(EAGAIN, "resource temporarily unavailable")                              \
0083   XX(EAI_ADDRFAMILY, "address family not supported")                          \
0084   XX(EAI_AGAIN, "temporary failure")                                          \
0085   XX(EAI_BADFLAGS, "bad ai_flags value")                                      \
0086   XX(EAI_BADHINTS, "invalid value for hints")                                 \
0087   XX(EAI_CANCELED, "request canceled")                                        \
0088   XX(EAI_FAIL, "permanent failure")                                           \
0089   XX(EAI_FAMILY, "ai_family not supported")                                   \
0090   XX(EAI_MEMORY, "out of memory")                                             \
0091   XX(EAI_NODATA, "no address")                                                \
0092   XX(EAI_NONAME, "unknown node or service")                                   \
0093   XX(EAI_OVERFLOW, "argument buffer overflow")                                \
0094   XX(EAI_PROTOCOL, "resolved protocol is unknown")                            \
0095   XX(EAI_SERVICE, "service not available for socket type")                    \
0096   XX(EAI_SOCKTYPE, "socket type not supported")                               \
0097   XX(EALREADY, "connection already in progress")                              \
0098   XX(EBADF, "bad file descriptor")                                            \
0099   XX(EBUSY, "resource busy or locked")                                        \
0100   XX(ECANCELED, "operation canceled")                                         \
0101   XX(ECHARSET, "invalid Unicode character")                                   \
0102   XX(ECONNABORTED, "software caused connection abort")                        \
0103   XX(ECONNREFUSED, "connection refused")                                      \
0104   XX(ECONNRESET, "connection reset by peer")                                  \
0105   XX(EDESTADDRREQ, "destination address required")                            \
0106   XX(EEXIST, "file already exists")                                           \
0107   XX(EFAULT, "bad address in system call argument")                           \
0108   XX(EFBIG, "file too large")                                                 \
0109   XX(EHOSTUNREACH, "host is unreachable")                                     \
0110   XX(EINTR, "interrupted system call")                                        \
0111   XX(EINVAL, "invalid argument")                                              \
0112   XX(EIO, "i/o error")                                                        \
0113   XX(EISCONN, "socket is already connected")                                  \
0114   XX(EISDIR, "illegal operation on a directory")                              \
0115   XX(ELOOP, "too many symbolic links encountered")                            \
0116   XX(EMFILE, "too many open files")                                           \
0117   XX(EMSGSIZE, "message too long")                                            \
0118   XX(ENAMETOOLONG, "name too long")                                           \
0119   XX(ENETDOWN, "network is down")                                             \
0120   XX(ENETUNREACH, "network is unreachable")                                   \
0121   XX(ENFILE, "file table overflow")                                           \
0122   XX(ENOBUFS, "no buffer space available")                                    \
0123   XX(ENODEV, "no such device")                                                \
0124   XX(ENOENT, "no such file or directory")                                     \
0125   XX(ENOMEM, "not enough memory")                                             \
0126   XX(ENONET, "machine is not on the network")                                 \
0127   XX(ENOPROTOOPT, "protocol not available")                                   \
0128   XX(ENOSPC, "no space left on device")                                       \
0129   XX(ENOSYS, "function not implemented")                                      \
0130   XX(ENOTCONN, "socket is not connected")                                     \
0131   XX(ENOTDIR, "not a directory")                                              \
0132   XX(ENOTEMPTY, "directory not empty")                                        \
0133   XX(ENOTSOCK, "socket operation on non-socket")                              \
0134   XX(ENOTSUP, "operation not supported on socket")                            \
0135   XX(EOVERFLOW, "value too large for defined data type")                      \
0136   XX(EPERM, "operation not permitted")                                        \
0137   XX(EPIPE, "broken pipe")                                                    \
0138   XX(EPROTO, "protocol error")                                                \
0139   XX(EPROTONOSUPPORT, "protocol not supported")                               \
0140   XX(EPROTOTYPE, "protocol wrong type for socket")                            \
0141   XX(ERANGE, "result too large")                                              \
0142   XX(EROFS, "read-only file system")                                          \
0143   XX(ESHUTDOWN, "cannot send after transport endpoint shutdown")              \
0144   XX(ESPIPE, "invalid seek")                                                  \
0145   XX(ESRCH, "no such process")                                                \
0146   XX(ETIMEDOUT, "connection timed out")                                       \
0147   XX(ETXTBSY, "text file is busy")                                            \
0148   XX(EXDEV, "cross-device link not permitted")                                \
0149   XX(UNKNOWN, "unknown error")                                                \
0150   XX(EOF, "end of file")                                                      \
0151   XX(ENXIO, "no such device or address")                                      \
0152   XX(EMLINK, "too many links")                                                \
0153   XX(EHOSTDOWN, "host is down")                                               \
0154   XX(EREMOTEIO, "remote I/O error")                                           \
0155   XX(ENOTTY, "inappropriate ioctl for device")                                \
0156   XX(EFTYPE, "inappropriate file type or format")                             \
0157   XX(EILSEQ, "illegal byte sequence")                                         \
0158   XX(ESOCKTNOSUPPORT, "socket type not supported")                            \
0159   XX(ENODATA, "no data available")                                            \
0160   XX(EUNATCH, "protocol driver not attached")                                 \
0161   XX(ENOEXEC, "exec format error")                                            \
0162 
0163 #define UV_HANDLE_TYPE_MAP(XX)                                                \
0164   XX(ASYNC, async)                                                            \
0165   XX(CHECK, check)                                                            \
0166   XX(FS_EVENT, fs_event)                                                      \
0167   XX(FS_POLL, fs_poll)                                                        \
0168   XX(HANDLE, handle)                                                          \
0169   XX(IDLE, idle)                                                              \
0170   XX(NAMED_PIPE, pipe)                                                        \
0171   XX(POLL, poll)                                                              \
0172   XX(PREPARE, prepare)                                                        \
0173   XX(PROCESS, process)                                                        \
0174   XX(STREAM, stream)                                                          \
0175   XX(TCP, tcp)                                                                \
0176   XX(TIMER, timer)                                                            \
0177   XX(TTY, tty)                                                                \
0178   XX(UDP, udp)                                                                \
0179   XX(SIGNAL, signal)                                                          \
0180 
0181 #define UV_REQ_TYPE_MAP(XX)                                                   \
0182   XX(REQ, req)                                                                \
0183   XX(CONNECT, connect)                                                        \
0184   XX(WRITE, write)                                                            \
0185   XX(SHUTDOWN, shutdown)                                                      \
0186   XX(UDP_SEND, udp_send)                                                      \
0187   XX(FS, fs)                                                                  \
0188   XX(WORK, work)                                                              \
0189   XX(GETADDRINFO, getaddrinfo)                                                \
0190   XX(GETNAMEINFO, getnameinfo)                                                \
0191   XX(RANDOM, random)                                                          \
0192 
0193 typedef enum {
0194 #define XX(code, _) UV_ ## code = UV__ ## code,
0195   UV_ERRNO_MAP(XX)
0196 #undef XX
0197   UV_ERRNO_MAX = UV__EOF - 1
0198 } uv_errno_t;
0199 
0200 typedef enum {
0201   UV_UNKNOWN_HANDLE = 0,
0202 #define XX(uc, lc) UV_##uc,
0203   UV_HANDLE_TYPE_MAP(XX)
0204 #undef XX
0205   UV_FILE,
0206   UV_HANDLE_TYPE_MAX
0207 } uv_handle_type;
0208 
0209 typedef enum {
0210   UV_UNKNOWN_REQ = 0,
0211 #define XX(uc, lc) UV_##uc,
0212   UV_REQ_TYPE_MAP(XX)
0213 #undef XX
0214   UV_REQ_TYPE_PRIVATE
0215   UV_REQ_TYPE_MAX
0216 } uv_req_type;
0217 
0218 
0219 /* Handle types. */
0220 typedef struct uv_loop_s uv_loop_t;
0221 typedef struct uv_handle_s uv_handle_t;
0222 typedef struct uv_dir_s uv_dir_t;
0223 typedef struct uv_stream_s uv_stream_t;
0224 typedef struct uv_tcp_s uv_tcp_t;
0225 typedef struct uv_udp_s uv_udp_t;
0226 typedef struct uv_pipe_s uv_pipe_t;
0227 typedef struct uv_tty_s uv_tty_t;
0228 typedef struct uv_poll_s uv_poll_t;
0229 typedef struct uv_timer_s uv_timer_t;
0230 typedef struct uv_prepare_s uv_prepare_t;
0231 typedef struct uv_check_s uv_check_t;
0232 typedef struct uv_idle_s uv_idle_t;
0233 typedef struct uv_async_s uv_async_t;
0234 typedef struct uv_process_s uv_process_t;
0235 typedef struct uv_fs_event_s uv_fs_event_t;
0236 typedef struct uv_fs_poll_s uv_fs_poll_t;
0237 typedef struct uv_signal_s uv_signal_t;
0238 
0239 /* Request types. */
0240 typedef struct uv_req_s uv_req_t;
0241 typedef struct uv_getaddrinfo_s uv_getaddrinfo_t;
0242 typedef struct uv_getnameinfo_s uv_getnameinfo_t;
0243 typedef struct uv_shutdown_s uv_shutdown_t;
0244 typedef struct uv_write_s uv_write_t;
0245 typedef struct uv_connect_s uv_connect_t;
0246 typedef struct uv_udp_send_s uv_udp_send_t;
0247 typedef struct uv_fs_s uv_fs_t;
0248 typedef struct uv_work_s uv_work_t;
0249 typedef struct uv_random_s uv_random_t;
0250 
0251 /* None of the above. */
0252 typedef struct uv_env_item_s uv_env_item_t;
0253 typedef struct uv_cpu_info_s uv_cpu_info_t;
0254 typedef struct uv_interface_address_s uv_interface_address_t;
0255 typedef struct uv_dirent_s uv_dirent_t;
0256 typedef struct uv_passwd_s uv_passwd_t;
0257 typedef struct uv_group_s uv_group_t;
0258 typedef struct uv_utsname_s uv_utsname_t;
0259 typedef struct uv_statfs_s uv_statfs_t;
0260 
0261 typedef struct uv_metrics_s uv_metrics_t;
0262 
0263 typedef enum {
0264   UV_LOOP_BLOCK_SIGNAL = 0,
0265   UV_METRICS_IDLE_TIME,
0266   UV_LOOP_USE_IO_URING_SQPOLL
0267 #define UV_LOOP_USE_IO_URING_SQPOLL UV_LOOP_USE_IO_URING_SQPOLL
0268 } uv_loop_option;
0269 
0270 typedef enum {
0271   UV_RUN_DEFAULT = 0,
0272   UV_RUN_ONCE,
0273   UV_RUN_NOWAIT
0274 } uv_run_mode;
0275 
0276 
0277 UV_EXTERN unsigned int uv_version(void);
0278 UV_EXTERN const char* uv_version_string(void);
0279 
0280 typedef void* (*uv_malloc_func)(size_t size);
0281 typedef void* (*uv_realloc_func)(void* ptr, size_t size);
0282 typedef void* (*uv_calloc_func)(size_t count, size_t size);
0283 typedef void (*uv_free_func)(void* ptr);
0284 
0285 UV_EXTERN void uv_library_shutdown(void);
0286 
0287 UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func,
0288                                    uv_realloc_func realloc_func,
0289                                    uv_calloc_func calloc_func,
0290                                    uv_free_func free_func);
0291 
0292 UV_EXTERN uv_loop_t* uv_default_loop(void);
0293 UV_EXTERN int uv_loop_init(uv_loop_t* loop);
0294 UV_EXTERN int uv_loop_close(uv_loop_t* loop);
0295 /*
0296  * NOTE:
0297  *  This function is DEPRECATED, users should
0298  *  allocate the loop manually and use uv_loop_init instead.
0299  */
0300 UV_EXTERN uv_loop_t* uv_loop_new(void);
0301 /*
0302  * NOTE:
0303  *  This function is DEPRECATED. Users should use
0304  *  uv_loop_close and free the memory manually instead.
0305  */
0306 UV_EXTERN void uv_loop_delete(uv_loop_t*);
0307 UV_EXTERN size_t uv_loop_size(void);
0308 UV_EXTERN int uv_loop_alive(const uv_loop_t* loop);
0309 UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...);
0310 UV_EXTERN int uv_loop_fork(uv_loop_t* loop);
0311 
0312 UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode);
0313 UV_EXTERN void uv_stop(uv_loop_t*);
0314 
0315 UV_EXTERN void uv_ref(uv_handle_t*);
0316 UV_EXTERN void uv_unref(uv_handle_t*);
0317 UV_EXTERN int uv_has_ref(const uv_handle_t*);
0318 
0319 UV_EXTERN void uv_update_time(uv_loop_t*);
0320 UV_EXTERN uint64_t uv_now(const uv_loop_t*);
0321 
0322 UV_EXTERN int uv_backend_fd(const uv_loop_t*);
0323 UV_EXTERN int uv_backend_timeout(const uv_loop_t*);
0324 
0325 typedef void (*uv_alloc_cb)(uv_handle_t* handle,
0326                             size_t suggested_size,
0327                             uv_buf_t* buf);
0328 typedef void (*uv_read_cb)(uv_stream_t* stream,
0329                            ssize_t nread,
0330                            const uv_buf_t* buf);
0331 typedef void (*uv_write_cb)(uv_write_t* req, int status);
0332 typedef void (*uv_connect_cb)(uv_connect_t* req, int status);
0333 typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status);
0334 typedef void (*uv_connection_cb)(uv_stream_t* server, int status);
0335 typedef void (*uv_close_cb)(uv_handle_t* handle);
0336 typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events);
0337 typedef void (*uv_timer_cb)(uv_timer_t* handle);
0338 typedef void (*uv_async_cb)(uv_async_t* handle);
0339 typedef void (*uv_prepare_cb)(uv_prepare_t* handle);
0340 typedef void (*uv_check_cb)(uv_check_t* handle);
0341 typedef void (*uv_idle_cb)(uv_idle_t* handle);
0342 typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal);
0343 typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg);
0344 typedef void (*uv_fs_cb)(uv_fs_t* req);
0345 typedef void (*uv_work_cb)(uv_work_t* req);
0346 typedef void (*uv_after_work_cb)(uv_work_t* req, int status);
0347 typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req,
0348                                   int status,
0349                                   struct addrinfo* res);
0350 typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req,
0351                                   int status,
0352                                   const char* hostname,
0353                                   const char* service);
0354 typedef void (*uv_random_cb)(uv_random_t* req,
0355                              int status,
0356                              void* buf,
0357                              size_t buflen);
0358 
0359 typedef enum {
0360   UV_CLOCK_MONOTONIC,
0361   UV_CLOCK_REALTIME
0362 } uv_clock_id;
0363 
0364 /* XXX(bnoordhuis) not 2038-proof, https://github.com/libuv/libuv/issues/3864 */
0365 typedef struct {
0366   long tv_sec;
0367   long tv_nsec;
0368 } uv_timespec_t;
0369 
0370 typedef struct {
0371   int64_t tv_sec;
0372   int32_t tv_nsec;
0373 } uv_timespec64_t;
0374 
0375 /* XXX(bnoordhuis) not 2038-proof, https://github.com/libuv/libuv/issues/3864 */
0376 typedef struct {
0377   long tv_sec;
0378   long tv_usec;
0379 } uv_timeval_t;
0380 
0381 typedef struct {
0382   int64_t tv_sec;
0383   int32_t tv_usec;
0384 } uv_timeval64_t;
0385 
0386 typedef struct {
0387   uint64_t st_dev;
0388   uint64_t st_mode;
0389   uint64_t st_nlink;
0390   uint64_t st_uid;
0391   uint64_t st_gid;
0392   uint64_t st_rdev;
0393   uint64_t st_ino;
0394   uint64_t st_size;
0395   uint64_t st_blksize;
0396   uint64_t st_blocks;
0397   uint64_t st_flags;
0398   uint64_t st_gen;
0399   uv_timespec_t st_atim;
0400   uv_timespec_t st_mtim;
0401   uv_timespec_t st_ctim;
0402   uv_timespec_t st_birthtim;
0403 } uv_stat_t;
0404 
0405 
0406 typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle,
0407                                const char* filename,
0408                                int events,
0409                                int status);
0410 
0411 typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle,
0412                               int status,
0413                               const uv_stat_t* prev,
0414                               const uv_stat_t* curr);
0415 
0416 typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum);
0417 
0418 
0419 typedef enum {
0420   UV_LEAVE_GROUP = 0,
0421   UV_JOIN_GROUP
0422 } uv_membership;
0423 
0424 
0425 UV_EXTERN int uv_translate_sys_error(int sys_errno);
0426 
0427 UV_EXTERN const char* uv_strerror(int err);
0428 UV_EXTERN char* uv_strerror_r(int err, char* buf, size_t buflen);
0429 
0430 UV_EXTERN const char* uv_err_name(int err);
0431 UV_EXTERN char* uv_err_name_r(int err, char* buf, size_t buflen);
0432 
0433 
0434 #define UV_REQ_FIELDS                                                         \
0435   /* public */                                                                \
0436   void* data;                                                                 \
0437   /* read-only */                                                             \
0438   uv_req_type type;                                                           \
0439   /* private */                                                               \
0440   void* reserved[6];                                                          \
0441   UV_REQ_PRIVATE_FIELDS                                                       \
0442 
0443 /* Abstract base class of all requests. */
0444 struct uv_req_s {
0445   UV_REQ_FIELDS
0446 };
0447 
0448 
0449 /* Platform-specific request types. */
0450 UV_PRIVATE_REQ_TYPES
0451 
0452 
0453 UV_EXTERN int uv_shutdown(uv_shutdown_t* req,
0454                           uv_stream_t* handle,
0455                           uv_shutdown_cb cb);
0456 
0457 struct uv_shutdown_s {
0458   UV_REQ_FIELDS
0459   uv_stream_t* handle;
0460   uv_shutdown_cb cb;
0461   UV_SHUTDOWN_PRIVATE_FIELDS
0462 };
0463 
0464 
0465 #define UV_HANDLE_FIELDS                                                      \
0466   /* public */                                                                \
0467   void* data;                                                                 \
0468   /* read-only */                                                             \
0469   uv_loop_t* loop;                                                            \
0470   uv_handle_type type;                                                        \
0471   /* private */                                                               \
0472   uv_close_cb close_cb;                                                       \
0473   struct uv__queue handle_queue;                                              \
0474   union {                                                                     \
0475     int fd;                                                                   \
0476     void* reserved[4];                                                        \
0477   } u;                                                                        \
0478   UV_HANDLE_PRIVATE_FIELDS                                                    \
0479 
0480 /* The abstract base class of all handles. */
0481 struct uv_handle_s {
0482   UV_HANDLE_FIELDS
0483 };
0484 
0485 UV_EXTERN size_t uv_handle_size(uv_handle_type type);
0486 UV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle);
0487 UV_EXTERN const char* uv_handle_type_name(uv_handle_type type);
0488 UV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle);
0489 UV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle);
0490 UV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data);
0491 
0492 UV_EXTERN size_t uv_req_size(uv_req_type type);
0493 UV_EXTERN void* uv_req_get_data(const uv_req_t* req);
0494 UV_EXTERN void uv_req_set_data(uv_req_t* req, void* data);
0495 UV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req);
0496 UV_EXTERN const char* uv_req_type_name(uv_req_type type);
0497 
0498 UV_EXTERN int uv_is_active(const uv_handle_t* handle);
0499 
0500 UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg);
0501 
0502 /* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */
0503 UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream);
0504 UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream);
0505 
0506 UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb);
0507 
0508 UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value);
0509 UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value);
0510 
0511 UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd);
0512 
0513 UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len);
0514 
0515 UV_EXTERN int uv_pipe(uv_file fds[2], int read_flags, int write_flags);
0516 UV_EXTERN int uv_socketpair(int type,
0517                             int protocol,
0518                             uv_os_sock_t socket_vector[2],
0519                             int flags0,
0520                             int flags1);
0521 
0522 #define UV_STREAM_FIELDS                                                      \
0523   /* number of bytes queued for writing */                                    \
0524   size_t write_queue_size;                                                    \
0525   uv_alloc_cb alloc_cb;                                                       \
0526   uv_read_cb read_cb;                                                         \
0527   /* private */                                                               \
0528   UV_STREAM_PRIVATE_FIELDS
0529 
0530 /*
0531  * uv_stream_t is a subclass of uv_handle_t.
0532  *
0533  * uv_stream is an abstract class.
0534  *
0535  * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t.
0536  */
0537 struct uv_stream_s {
0538   UV_HANDLE_FIELDS
0539   UV_STREAM_FIELDS
0540 };
0541 
0542 UV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream);
0543 
0544 UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb);
0545 UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client);
0546 
0547 UV_EXTERN int uv_read_start(uv_stream_t*,
0548                             uv_alloc_cb alloc_cb,
0549                             uv_read_cb read_cb);
0550 UV_EXTERN int uv_read_stop(uv_stream_t*);
0551 
0552 UV_EXTERN int uv_write(uv_write_t* req,
0553                        uv_stream_t* handle,
0554                        const uv_buf_t bufs[],
0555                        unsigned int nbufs,
0556                        uv_write_cb cb);
0557 UV_EXTERN int uv_write2(uv_write_t* req,
0558                         uv_stream_t* handle,
0559                         const uv_buf_t bufs[],
0560                         unsigned int nbufs,
0561                         uv_stream_t* send_handle,
0562                         uv_write_cb cb);
0563 UV_EXTERN int uv_try_write(uv_stream_t* handle,
0564                            const uv_buf_t bufs[],
0565                            unsigned int nbufs);
0566 UV_EXTERN int uv_try_write2(uv_stream_t* handle,
0567                             const uv_buf_t bufs[],
0568                             unsigned int nbufs,
0569                             uv_stream_t* send_handle);
0570 
0571 /* uv_write_t is a subclass of uv_req_t. */
0572 struct uv_write_s {
0573   UV_REQ_FIELDS
0574   uv_write_cb cb;
0575   uv_stream_t* send_handle; /* TODO: make private and unix-only in v2.x. */
0576   uv_stream_t* handle;
0577   UV_WRITE_PRIVATE_FIELDS
0578 };
0579 
0580 
0581 UV_EXTERN int uv_is_readable(const uv_stream_t* handle);
0582 UV_EXTERN int uv_is_writable(const uv_stream_t* handle);
0583 
0584 UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking);
0585 
0586 UV_EXTERN int uv_is_closing(const uv_handle_t* handle);
0587 
0588 
0589 /*
0590  * uv_tcp_t is a subclass of uv_stream_t.
0591  *
0592  * Represents a TCP stream or TCP server.
0593  */
0594 struct uv_tcp_s {
0595   UV_HANDLE_FIELDS
0596   UV_STREAM_FIELDS
0597   UV_TCP_PRIVATE_FIELDS
0598 };
0599 
0600 UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle);
0601 UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags);
0602 UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock);
0603 UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable);
0604 UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle,
0605                                int enable,
0606                                unsigned int delay);
0607 UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable);
0608 
0609 enum uv_tcp_flags {
0610   /* Used with uv_tcp_bind, when an IPv6 address is used. */
0611   UV_TCP_IPV6ONLY = 1,
0612 
0613   /* Enable SO_REUSEPORT socket option when binding the handle.
0614    * This allows completely duplicate bindings by multiple processes
0615    * or threads if they all set SO_REUSEPORT before binding the port.
0616    * Incoming connections are distributed across the participating
0617    * listener sockets.
0618    *
0619    * This flag is available only on Linux 3.9+, DragonFlyBSD 3.6+,
0620    * FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ for now.
0621    */
0622   UV_TCP_REUSEPORT = 2,
0623 };
0624 
0625 UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle,
0626                           const struct sockaddr* addr,
0627                           unsigned int flags);
0628 UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle,
0629                                  struct sockaddr* name,
0630                                  int* namelen);
0631 UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle,
0632                                  struct sockaddr* name,
0633                                  int* namelen);
0634 UV_EXTERN int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb);
0635 UV_EXTERN int uv_tcp_connect(uv_connect_t* req,
0636                              uv_tcp_t* handle,
0637                              const struct sockaddr* addr,
0638                              uv_connect_cb cb);
0639 
0640 /* uv_connect_t is a subclass of uv_req_t. */
0641 struct uv_connect_s {
0642   UV_REQ_FIELDS
0643   uv_connect_cb cb;
0644   uv_stream_t* handle;
0645   UV_CONNECT_PRIVATE_FIELDS
0646 };
0647 
0648 
0649 /*
0650  * UDP support.
0651  */
0652 
0653 enum uv_udp_flags {
0654   /* Disables dual stack mode. */
0655   UV_UDP_IPV6ONLY = 1,
0656   /*
0657    * Indicates message was truncated because read buffer was too small. The
0658    * remainder was discarded by the OS. Used in uv_udp_recv_cb.
0659    */
0660   UV_UDP_PARTIAL = 2,
0661   /*
0662    * Indicates if SO_REUSEADDR will be set when binding the handle.
0663    * This sets the SO_REUSEPORT socket flag on the BSDs (except for
0664    * DragonFlyBSD), OS X, and other platforms where SO_REUSEPORTs don't
0665    * have the capability of load balancing, as the opposite of what
0666    * UV_UDP_REUSEPORT would do. On other Unix platforms, it sets the
0667    * SO_REUSEADDR flag. What that means is that multiple threads or
0668    * processes can bind to the same address without error (provided
0669    * they all set the flag) but only the last one to bind will receive
0670    * any traffic, in effect "stealing" the port from the previous listener.
0671    */
0672   UV_UDP_REUSEADDR = 4,
0673   /*
0674    * Indicates that the message was received by recvmmsg, so the buffer provided
0675    * must not be freed by the recv_cb callback.
0676    */
0677   UV_UDP_MMSG_CHUNK = 8,
0678   /*
0679    * Indicates that the buffer provided has been fully utilized by recvmmsg and
0680    * that it should now be freed by the recv_cb callback. When this flag is set
0681    * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL.
0682    */
0683   UV_UDP_MMSG_FREE = 16,
0684   /*
0685    * Indicates if IP_RECVERR/IPV6_RECVERR will be set when binding the handle.
0686    * This sets IP_RECVERR for IPv4 and IPV6_RECVERR for IPv6 UDP sockets on
0687    * Linux. This stops the Linux kernel from suppressing some ICMP error
0688    * messages and enables full ICMP error reporting for faster failover.
0689    * This flag is no-op on platforms other than Linux.
0690    */
0691   UV_UDP_LINUX_RECVERR = 32,
0692   /*
0693    * Indicates if SO_REUSEPORT will be set when binding the handle.
0694    * This sets the SO_REUSEPORT socket option on supported platforms.
0695    * Unlike UV_UDP_REUSEADDR, this flag will make multiple threads or
0696    * processes that are binding to the same address and port "share"
0697    * the port, which means incoming datagrams are distributed across
0698    * the receiving sockets among threads or processes.
0699    *
0700    * This flag is available only on Linux 3.9+, DragonFlyBSD 3.6+,
0701    * FreeBSD 12.0+, Solaris 11.4, and AIX 7.2.5+ for now.
0702    */
0703   UV_UDP_REUSEPORT = 64,
0704   /*
0705    * Indicates that recvmmsg should be used, if available.
0706    */
0707   UV_UDP_RECVMMSG = 256
0708 };
0709 
0710 typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status);
0711 typedef void (*uv_udp_recv_cb)(uv_udp_t* handle,
0712                                ssize_t nread,
0713                                const uv_buf_t* buf,
0714                                const struct sockaddr* addr,
0715                                unsigned flags);
0716 
0717 /* uv_udp_t is a subclass of uv_handle_t. */
0718 struct uv_udp_s {
0719   UV_HANDLE_FIELDS
0720   /* read-only */
0721   /*
0722    * Number of bytes queued for sending. This field strictly shows how much
0723    * information is currently queued.
0724    */
0725   size_t send_queue_size;
0726   /*
0727    * Number of send requests currently in the queue awaiting to be processed.
0728    */
0729   size_t send_queue_count;
0730   UV_UDP_PRIVATE_FIELDS
0731 };
0732 
0733 /* uv_udp_send_t is a subclass of uv_req_t. */
0734 struct uv_udp_send_s {
0735   UV_REQ_FIELDS
0736   uv_udp_t* handle;
0737   uv_udp_send_cb cb;
0738   UV_UDP_SEND_PRIVATE_FIELDS
0739 };
0740 
0741 UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle);
0742 UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags);
0743 UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock);
0744 UV_EXTERN int uv_udp_bind(uv_udp_t* handle,
0745                           const struct sockaddr* addr,
0746                           unsigned int flags);
0747 UV_EXTERN int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr);
0748 
0749 UV_EXTERN int uv_udp_getpeername(const uv_udp_t* handle,
0750                                  struct sockaddr* name,
0751                                  int* namelen);
0752 UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle,
0753                                  struct sockaddr* name,
0754                                  int* namelen);
0755 UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
0756                                     const char* multicast_addr,
0757                                     const char* interface_addr,
0758                                     uv_membership membership);
0759 UV_EXTERN int uv_udp_set_source_membership(uv_udp_t* handle,
0760                                            const char* multicast_addr,
0761                                            const char* interface_addr,
0762                                            const char* source_addr,
0763                                            uv_membership membership);
0764 UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on);
0765 UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
0766 UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle,
0767                                              const char* interface_addr);
0768 UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on);
0769 UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl);
0770 UV_EXTERN int uv_udp_send(uv_udp_send_t* req,
0771                           uv_udp_t* handle,
0772                           const uv_buf_t bufs[],
0773                           unsigned int nbufs,
0774                           const struct sockaddr* addr,
0775                           uv_udp_send_cb send_cb);
0776 UV_EXTERN int uv_udp_try_send(uv_udp_t* handle,
0777                               const uv_buf_t bufs[],
0778                               unsigned int nbufs,
0779                               const struct sockaddr* addr);
0780 UV_EXTERN int uv_udp_try_send2(uv_udp_t* handle,
0781                                unsigned int count,
0782                                uv_buf_t* bufs[/*count*/],
0783                                unsigned int nbufs[/*count*/],
0784                                struct sockaddr* addrs[/*count*/],
0785                                unsigned int flags);
0786 UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle,
0787                                 uv_alloc_cb alloc_cb,
0788                                 uv_udp_recv_cb recv_cb);
0789 UV_EXTERN int uv_udp_using_recvmmsg(const uv_udp_t* handle);
0790 UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle);
0791 UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle);
0792 UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle);
0793 
0794 
0795 /*
0796  * uv_tty_t is a subclass of uv_stream_t.
0797  *
0798  * Representing a stream for the console.
0799  */
0800 struct uv_tty_s {
0801   UV_HANDLE_FIELDS
0802   UV_STREAM_FIELDS
0803   UV_TTY_PRIVATE_FIELDS
0804 };
0805 
0806 typedef enum {
0807   /* Initial/normal terminal mode */
0808   UV_TTY_MODE_NORMAL,
0809   /*
0810    * Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled).
0811    * May become equivalent to UV_TTY_MODE_RAW_VT in future libuv versions.
0812    */
0813   UV_TTY_MODE_RAW,
0814   /* Binary-safe I/O mode for IPC (Unix-only) */
0815   UV_TTY_MODE_IO,
0816   /* Raw input mode. On Windows ENABLE_VIRTUAL_TERMINAL_INPUT is also set. */
0817   UV_TTY_MODE_RAW_VT
0818 } uv_tty_mode_t;
0819 
0820 typedef enum {
0821   /*
0822    * The console supports handling of virtual terminal sequences
0823    * (Windows10 new console, ConEmu)
0824    */
0825   UV_TTY_SUPPORTED,
0826   /* The console cannot process the virtual terminal sequence.  (Legacy
0827    * console)
0828    */
0829   UV_TTY_UNSUPPORTED
0830 } uv_tty_vtermstate_t;
0831 
0832 
0833 UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable);
0834 UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode);
0835 UV_EXTERN int uv_tty_reset_mode(void);
0836 UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
0837 UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state);
0838 UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state);
0839 
0840 #ifdef __cplusplus
0841 extern "C++" {
0842 
0843 inline int uv_tty_set_mode(uv_tty_t* handle, int mode) {
0844   return uv_tty_set_mode(handle, static_cast<uv_tty_mode_t>(mode));
0845 }
0846 
0847 }
0848 #endif
0849 
0850 UV_EXTERN uv_handle_type uv_guess_handle(uv_file file);
0851 
0852 enum {
0853   UV_PIPE_NO_TRUNCATE = 1u << 0
0854 };
0855 
0856 /*
0857  * uv_pipe_t is a subclass of uv_stream_t.
0858  *
0859  * Representing a pipe stream or pipe server. On Windows this is a Named
0860  * Pipe. On Unix this is a Unix domain socket.
0861  */
0862 struct uv_pipe_s {
0863   UV_HANDLE_FIELDS
0864   UV_STREAM_FIELDS
0865   int ipc; /* non-zero if this pipe is used for passing handles */
0866   UV_PIPE_PRIVATE_FIELDS
0867 };
0868 
0869 UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
0870 UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file);
0871 UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);
0872 UV_EXTERN int uv_pipe_bind2(uv_pipe_t* handle,
0873                             const char* name,
0874                             size_t namelen,
0875                             unsigned int flags);
0876 UV_EXTERN void uv_pipe_connect(uv_connect_t* req,
0877                                uv_pipe_t* handle,
0878                                const char* name,
0879                                uv_connect_cb cb);
0880 UV_EXTERN int uv_pipe_connect2(uv_connect_t* req,
0881                                uv_pipe_t* handle,
0882                                const char* name,
0883                                size_t namelen,
0884                                unsigned int flags,
0885                                uv_connect_cb cb);
0886 UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle,
0887                                   char* buffer,
0888                                   size_t* size);
0889 UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle,
0890                                   char* buffer,
0891                                   size_t* size);
0892 UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count);
0893 UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle);
0894 UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle);
0895 UV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags);
0896 
0897 
0898 struct uv_poll_s {
0899   UV_HANDLE_FIELDS
0900   uv_poll_cb poll_cb;
0901   UV_POLL_PRIVATE_FIELDS
0902 };
0903 
0904 enum uv_poll_event {
0905   UV_READABLE = 1,
0906   UV_WRITABLE = 2,
0907   UV_DISCONNECT = 4,
0908   UV_PRIORITIZED = 8
0909 };
0910 
0911 UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd);
0912 UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop,
0913                                   uv_poll_t* handle,
0914                                   uv_os_sock_t socket);
0915 UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb);
0916 UV_EXTERN int uv_poll_stop(uv_poll_t* handle);
0917 
0918 
0919 struct uv_prepare_s {
0920   UV_HANDLE_FIELDS
0921   UV_PREPARE_PRIVATE_FIELDS
0922 };
0923 
0924 UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare);
0925 UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb);
0926 UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare);
0927 
0928 
0929 struct uv_check_s {
0930   UV_HANDLE_FIELDS
0931   UV_CHECK_PRIVATE_FIELDS
0932 };
0933 
0934 UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check);
0935 UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb);
0936 UV_EXTERN int uv_check_stop(uv_check_t* check);
0937 
0938 
0939 struct uv_idle_s {
0940   UV_HANDLE_FIELDS
0941   UV_IDLE_PRIVATE_FIELDS
0942 };
0943 
0944 UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle);
0945 UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb);
0946 UV_EXTERN int uv_idle_stop(uv_idle_t* idle);
0947 
0948 
0949 struct uv_async_s {
0950   UV_HANDLE_FIELDS
0951   UV_ASYNC_PRIVATE_FIELDS
0952 };
0953 
0954 UV_EXTERN int uv_async_init(uv_loop_t*,
0955                             uv_async_t* async,
0956                             uv_async_cb async_cb);
0957 UV_EXTERN int uv_async_send(uv_async_t* async);
0958 
0959 
0960 /*
0961  * uv_timer_t is a subclass of uv_handle_t.
0962  *
0963  * Used to get woken up at a specified time in the future.
0964  */
0965 struct uv_timer_s {
0966   UV_HANDLE_FIELDS
0967   UV_TIMER_PRIVATE_FIELDS
0968 };
0969 
0970 UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle);
0971 UV_EXTERN int uv_timer_start(uv_timer_t* handle,
0972                              uv_timer_cb cb,
0973                              uint64_t timeout,
0974                              uint64_t repeat);
0975 UV_EXTERN int uv_timer_stop(uv_timer_t* handle);
0976 UV_EXTERN int uv_timer_again(uv_timer_t* handle);
0977 UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat);
0978 UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle);
0979 UV_EXTERN uint64_t uv_timer_get_due_in(const uv_timer_t* handle);
0980 
0981 
0982 /*
0983  * uv_getaddrinfo_t is a subclass of uv_req_t.
0984  *
0985  * Request object for uv_getaddrinfo.
0986  */
0987 struct uv_getaddrinfo_s {
0988   UV_REQ_FIELDS
0989   /* read-only */
0990   uv_loop_t* loop;
0991   /* struct addrinfo* addrinfo is marked as private, but it really isn't. */
0992   UV_GETADDRINFO_PRIVATE_FIELDS
0993 };
0994 
0995 
0996 UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop,
0997                              uv_getaddrinfo_t* req,
0998                              uv_getaddrinfo_cb getaddrinfo_cb,
0999                              const char* node,
1000                              const char* service,
1001                              const struct addrinfo* hints);
1002 UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai);
1003 
1004 
1005 /*
1006 * uv_getnameinfo_t is a subclass of uv_req_t.
1007 *
1008 * Request object for uv_getnameinfo.
1009 */
1010 struct uv_getnameinfo_s {
1011   UV_REQ_FIELDS
1012   /* read-only */
1013   uv_loop_t* loop;
1014   /* host and service are marked as private, but they really aren't. */
1015   UV_GETNAMEINFO_PRIVATE_FIELDS
1016 };
1017 
1018 UV_EXTERN int uv_getnameinfo(uv_loop_t* loop,
1019                              uv_getnameinfo_t* req,
1020                              uv_getnameinfo_cb getnameinfo_cb,
1021                              const struct sockaddr* addr,
1022                              int flags);
1023 
1024 
1025 /* uv_spawn() options. */
1026 typedef enum {
1027   UV_IGNORE         = 0x00,
1028   UV_CREATE_PIPE    = 0x01,
1029   UV_INHERIT_FD     = 0x02,
1030   UV_INHERIT_STREAM = 0x04,
1031 
1032   /*
1033    * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE
1034    * determine the direction of flow, from the child process' perspective. Both
1035    * flags may be specified to create a duplex data stream.
1036    */
1037   UV_READABLE_PIPE  = 0x10,
1038   UV_WRITABLE_PIPE  = 0x20,
1039 
1040   /*
1041    * When UV_CREATE_PIPE is specified, specifying UV_NONBLOCK_PIPE opens the
1042    * handle in non-blocking mode in the child. This may cause loss of data,
1043    * if the child is not designed to handle to encounter this mode,
1044    * but can also be significantly more efficient.
1045    */
1046   UV_NONBLOCK_PIPE  = 0x40,
1047   UV_OVERLAPPED_PIPE = 0x40 /* old name, for compatibility */
1048 } uv_stdio_flags;
1049 
1050 typedef struct uv_stdio_container_s {
1051   uv_stdio_flags flags;
1052 
1053   union {
1054     uv_stream_t* stream;
1055     int fd;
1056   } data;
1057 } uv_stdio_container_t;
1058 
1059 typedef struct uv_process_options_s {
1060   uv_exit_cb exit_cb; /* Called after the process exits. */
1061   const char* file;   /* Path to program to execute. */
1062   /*
1063    * Command line arguments. args[0] should be the path to the program. On
1064    * Windows this uses CreateProcess which concatenates the arguments into a
1065    * string this can cause some strange errors. See the note at
1066    * windows_verbatim_arguments.
1067    */
1068   char** args;
1069   /*
1070    * This will be set as the environ variable in the subprocess. If this is
1071    * NULL then the parents environ will be used.
1072    */
1073   char** env;
1074   /*
1075    * If non-null this represents a directory the subprocess should execute
1076    * in. Stands for current working directory.
1077    */
1078   const char* cwd;
1079   /*
1080    * Various flags that control how uv_spawn() behaves. See the definition of
1081    * `enum uv_process_flags` below.
1082    */
1083   unsigned int flags;
1084   /*
1085    * The `stdio` field points to an array of uv_stdio_container_t structs that
1086    * describe the file descriptors that will be made available to the child
1087    * process. The convention is that stdio[0] points to stdin, fd 1 is used for
1088    * stdout, and fd 2 is stderr.
1089    *
1090    * Note that on windows file descriptors greater than 2 are available to the
1091    * child process only if the child processes uses the MSVCRT runtime.
1092    */
1093   int stdio_count;
1094   uv_stdio_container_t* stdio;
1095   /*
1096    * Libuv can change the child process' user/group id. This happens only when
1097    * the appropriate bits are set in the flags fields. This is not supported on
1098    * windows; uv_spawn() will fail and set the error to UV_ENOTSUP.
1099    */
1100   uv_uid_t uid;
1101   uv_gid_t gid;
1102 } uv_process_options_t;
1103 
1104 /*
1105  * These are the flags that can be used for the uv_process_options.flags field.
1106  */
1107 enum uv_process_flags {
1108   /*
1109    * Set the child process' user id. The user id is supplied in the `uid` field
1110    * of the options struct. This does not work on windows; setting this flag
1111    * will cause uv_spawn() to fail.
1112    */
1113   UV_PROCESS_SETUID = (1 << 0),
1114   /*
1115    * Set the child process' group id. The user id is supplied in the `gid`
1116    * field of the options struct. This does not work on windows; setting this
1117    * flag will cause uv_spawn() to fail.
1118    */
1119   UV_PROCESS_SETGID = (1 << 1),
1120   /*
1121    * Do not wrap any arguments in quotes, or perform any other escaping, when
1122    * converting the argument list into a command line string. This option is
1123    * only meaningful on Windows systems. On Unix it is silently ignored.
1124    */
1125   UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2),
1126   /*
1127    * Spawn the child process in a detached state - this will make it a process
1128    * group leader, and will effectively enable the child to keep running after
1129    * the parent exits.  Note that the child process will still keep the
1130    * parent's event loop alive unless the parent process calls uv_unref() on
1131    * the child's process handle.
1132    */
1133   UV_PROCESS_DETACHED = (1 << 3),
1134   /*
1135    * Hide the subprocess window that would normally be created. This option is
1136    * only meaningful on Windows systems. On Unix it is silently ignored.
1137    */
1138   UV_PROCESS_WINDOWS_HIDE = (1 << 4),
1139   /*
1140    * Hide the subprocess console window that would normally be created. This
1141    * option is only meaningful on Windows systems. On Unix it is silently
1142    * ignored.
1143    */
1144   UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5),
1145   /*
1146    * Hide the subprocess GUI window that would normally be created. This
1147    * option is only meaningful on Windows systems. On Unix it is silently
1148    * ignored.
1149    */
1150   UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6),
1151   /*
1152    * On Windows, if the path to the program to execute, specified in
1153    * uv_process_options_t's file field, has a directory component,
1154    * search for the exact file name before trying variants with
1155    * extensions like '.exe' or '.cmd'.
1156    */
1157   UV_PROCESS_WINDOWS_FILE_PATH_EXACT_NAME = (1 << 7)
1158 };
1159 
1160 /*
1161  * uv_process_t is a subclass of uv_handle_t.
1162  */
1163 struct uv_process_s {
1164   UV_HANDLE_FIELDS
1165   uv_exit_cb exit_cb;
1166   int pid;
1167   UV_PROCESS_PRIVATE_FIELDS
1168 };
1169 
1170 UV_EXTERN int uv_spawn(uv_loop_t* loop,
1171                        uv_process_t* handle,
1172                        const uv_process_options_t* options);
1173 UV_EXTERN int uv_process_kill(uv_process_t*, int signum);
1174 UV_EXTERN int uv_kill(int pid, int signum);
1175 UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*);
1176 
1177 
1178 /*
1179  * uv_work_t is a subclass of uv_req_t.
1180  */
1181 struct uv_work_s {
1182   UV_REQ_FIELDS
1183   uv_loop_t* loop;
1184   uv_work_cb work_cb;
1185   uv_after_work_cb after_work_cb;
1186   UV_WORK_PRIVATE_FIELDS
1187 };
1188 
1189 UV_EXTERN int uv_queue_work(uv_loop_t* loop,
1190                             uv_work_t* req,
1191                             uv_work_cb work_cb,
1192                             uv_after_work_cb after_work_cb);
1193 
1194 UV_EXTERN int uv_cancel(uv_req_t* req);
1195 
1196 
1197 struct uv_cpu_times_s {
1198   uint64_t user; /* milliseconds */
1199   uint64_t nice; /* milliseconds */
1200   uint64_t sys; /* milliseconds */
1201   uint64_t idle; /* milliseconds */
1202   uint64_t irq; /* milliseconds */
1203 };
1204 
1205 struct uv_cpu_info_s {
1206   char* model;
1207   int speed;
1208   struct uv_cpu_times_s cpu_times;
1209 };
1210 
1211 struct uv_interface_address_s {
1212   char* name;
1213   char phys_addr[6];
1214   int is_internal;
1215   union {
1216     struct sockaddr_in address4;
1217     struct sockaddr_in6 address6;
1218   } address;
1219   union {
1220     struct sockaddr_in netmask4;
1221     struct sockaddr_in6 netmask6;
1222   } netmask;
1223 };
1224 
1225 struct uv_passwd_s {
1226   char* username;
1227   unsigned long uid;
1228   unsigned long gid;
1229   char* shell;
1230   char* homedir;
1231 };
1232 
1233 struct uv_group_s {
1234   char* groupname;
1235   unsigned long gid;
1236   char** members;
1237 };
1238 
1239 struct uv_utsname_s {
1240   char sysname[256];
1241   char release[256];
1242   char version[256];
1243   char machine[256];
1244   /* This struct does not contain the nodename and domainname fields present in
1245      the utsname type. domainname is a GNU extension. Both fields are referred
1246      to as meaningless in the docs. */
1247 };
1248 
1249 struct uv_statfs_s {
1250   uint64_t f_type;
1251   uint64_t f_bsize;
1252   uint64_t f_blocks;
1253   uint64_t f_bfree;
1254   uint64_t f_bavail;
1255   uint64_t f_files;
1256   uint64_t f_ffree;
1257   uint64_t f_spare[4];
1258 };
1259 
1260 typedef enum {
1261   UV_DIRENT_UNKNOWN,
1262   UV_DIRENT_FILE,
1263   UV_DIRENT_DIR,
1264   UV_DIRENT_LINK,
1265   UV_DIRENT_FIFO,
1266   UV_DIRENT_SOCKET,
1267   UV_DIRENT_CHAR,
1268   UV_DIRENT_BLOCK
1269 } uv_dirent_type_t;
1270 
1271 struct uv_dirent_s {
1272   const char* name;
1273   uv_dirent_type_t type;
1274 };
1275 
1276 UV_EXTERN char** uv_setup_args(int argc, char** argv);
1277 UV_EXTERN int uv_get_process_title(char* buffer, size_t size);
1278 UV_EXTERN int uv_set_process_title(const char* title);
1279 UV_EXTERN int uv_resident_set_memory(size_t* rss);
1280 UV_EXTERN int uv_uptime(double* uptime);
1281 UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd);
1282 UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd);
1283 
1284 typedef struct {
1285    uv_timeval_t ru_utime; /* user CPU time used */
1286    uv_timeval_t ru_stime; /* system CPU time used */
1287    uint64_t ru_maxrss;    /* maximum resident set size */
1288    uint64_t ru_ixrss;     /* integral shared memory size */
1289    uint64_t ru_idrss;     /* integral unshared data size */
1290    uint64_t ru_isrss;     /* integral unshared stack size */
1291    uint64_t ru_minflt;    /* page reclaims (soft page faults) */
1292    uint64_t ru_majflt;    /* page faults (hard page faults) */
1293    uint64_t ru_nswap;     /* swaps */
1294    uint64_t ru_inblock;   /* block input operations */
1295    uint64_t ru_oublock;   /* block output operations */
1296    uint64_t ru_msgsnd;    /* IPC messages sent */
1297    uint64_t ru_msgrcv;    /* IPC messages received */
1298    uint64_t ru_nsignals;  /* signals received */
1299    uint64_t ru_nvcsw;     /* voluntary context switches */
1300    uint64_t ru_nivcsw;    /* involuntary context switches */
1301 } uv_rusage_t;
1302 
1303 UV_EXTERN int uv_getrusage(uv_rusage_t* rusage);
1304 UV_EXTERN int uv_getrusage_thread(uv_rusage_t* rusage);
1305 
1306 UV_EXTERN int uv_os_homedir(char* buffer, size_t* size);
1307 UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size);
1308 UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd);
1309 UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd);
1310 UV_EXTERN int uv_os_get_passwd2(uv_passwd_t* pwd, uv_uid_t uid);
1311 UV_EXTERN int uv_os_get_group(uv_group_t* grp, uv_uid_t gid);
1312 UV_EXTERN void uv_os_free_group(uv_group_t* grp);
1313 UV_EXTERN uv_pid_t uv_os_getpid(void);
1314 UV_EXTERN uv_pid_t uv_os_getppid(void);
1315 
1316 #if defined(__PASE__)
1317 /* On IBM i PASE, the highest process priority is -10 */
1318 # define UV_PRIORITY_LOW 39          /* RUNPTY(99) */
1319 # define UV_PRIORITY_BELOW_NORMAL 15 /* RUNPTY(50) */
1320 # define UV_PRIORITY_NORMAL 0        /* RUNPTY(20) */
1321 # define UV_PRIORITY_ABOVE_NORMAL -4 /* RUNTY(12) */
1322 # define UV_PRIORITY_HIGH -7         /* RUNPTY(6) */
1323 # define UV_PRIORITY_HIGHEST -10     /* RUNPTY(1) */
1324 #else
1325 # define UV_PRIORITY_LOW 19
1326 # define UV_PRIORITY_BELOW_NORMAL 10
1327 # define UV_PRIORITY_NORMAL 0
1328 # define UV_PRIORITY_ABOVE_NORMAL -7
1329 # define UV_PRIORITY_HIGH -14
1330 # define UV_PRIORITY_HIGHEST -20
1331 #endif
1332 
1333 UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority);
1334 UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority);
1335 
1336 enum {
1337   UV_THREAD_PRIORITY_HIGHEST = 2,
1338   UV_THREAD_PRIORITY_ABOVE_NORMAL = 1,
1339   UV_THREAD_PRIORITY_NORMAL = 0,
1340   UV_THREAD_PRIORITY_BELOW_NORMAL = -1,
1341   UV_THREAD_PRIORITY_LOWEST = -2,
1342 };
1343 
1344 UV_EXTERN int uv_thread_getpriority(uv_thread_t tid, int* priority);
1345 UV_EXTERN int uv_thread_setpriority(uv_thread_t tid, int priority);
1346 
1347 UV_EXTERN unsigned int uv_available_parallelism(void);
1348 UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count);
1349 UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count);
1350 UV_EXTERN int uv_cpumask_size(void);
1351 
1352 UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses,
1353                                      int* count);
1354 UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses,
1355                                            int count);
1356 
1357 struct uv_env_item_s {
1358   char* name;
1359   char* value;
1360 };
1361 
1362 UV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count);
1363 UV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count);
1364 UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size);
1365 UV_EXTERN int uv_os_setenv(const char* name, const char* value);
1366 UV_EXTERN int uv_os_unsetenv(const char* name);
1367 
1368 #ifdef MAXHOSTNAMELEN
1369 # define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
1370 #else
1371   /*
1372     Fallback for the maximum hostname size, including the null terminator. The
1373     Windows gethostname() documentation states that 256 bytes will always be
1374     large enough to hold the null-terminated hostname.
1375   */
1376 # define UV_MAXHOSTNAMESIZE 256
1377 #endif
1378 
1379 UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size);
1380 
1381 UV_EXTERN int uv_os_uname(uv_utsname_t* buffer);
1382 
1383 struct uv_metrics_s {
1384   uint64_t loop_count;
1385   uint64_t events;
1386   uint64_t events_waiting;
1387   /* private */
1388   uint64_t* reserved[13];
1389 };
1390 
1391 UV_EXTERN int uv_metrics_info(uv_loop_t* loop, uv_metrics_t* metrics);
1392 UV_EXTERN uint64_t uv_metrics_idle_time(uv_loop_t* loop);
1393 
1394 typedef enum {
1395   UV_FS_UNKNOWN = -1,
1396   UV_FS_CUSTOM,
1397   UV_FS_OPEN,
1398   UV_FS_CLOSE,
1399   UV_FS_READ,
1400   UV_FS_WRITE,
1401   UV_FS_SENDFILE,
1402   UV_FS_STAT,
1403   UV_FS_LSTAT,
1404   UV_FS_FSTAT,
1405   UV_FS_FTRUNCATE,
1406   UV_FS_UTIME,
1407   UV_FS_FUTIME,
1408   UV_FS_ACCESS,
1409   UV_FS_CHMOD,
1410   UV_FS_FCHMOD,
1411   UV_FS_FSYNC,
1412   UV_FS_FDATASYNC,
1413   UV_FS_UNLINK,
1414   UV_FS_RMDIR,
1415   UV_FS_MKDIR,
1416   UV_FS_MKDTEMP,
1417   UV_FS_RENAME,
1418   UV_FS_SCANDIR,
1419   UV_FS_LINK,
1420   UV_FS_SYMLINK,
1421   UV_FS_READLINK,
1422   UV_FS_CHOWN,
1423   UV_FS_FCHOWN,
1424   UV_FS_REALPATH,
1425   UV_FS_COPYFILE,
1426   UV_FS_LCHOWN,
1427   UV_FS_OPENDIR,
1428   UV_FS_READDIR,
1429   UV_FS_CLOSEDIR,
1430   UV_FS_STATFS,
1431   UV_FS_MKSTEMP,
1432   UV_FS_LUTIME
1433 } uv_fs_type;
1434 
1435 struct uv_dir_s {
1436   uv_dirent_t* dirents;
1437   size_t nentries;
1438   void* reserved[4];
1439   UV_DIR_PRIVATE_FIELDS
1440 };
1441 
1442 /* uv_fs_t is a subclass of uv_req_t. */
1443 struct uv_fs_s {
1444   UV_REQ_FIELDS
1445   uv_fs_type fs_type;
1446   uv_loop_t* loop;
1447   uv_fs_cb cb;
1448   ssize_t result;
1449   void* ptr;
1450   const char* path;
1451   uv_stat_t statbuf;  /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */
1452   UV_FS_PRIVATE_FIELDS
1453 };
1454 
1455 UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*);
1456 UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*);
1457 UV_EXTERN int uv_fs_get_system_error(const uv_fs_t*);
1458 UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*);
1459 UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*);
1460 UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*);
1461 
1462 UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req);
1463 UV_EXTERN int uv_fs_close(uv_loop_t* loop,
1464                           uv_fs_t* req,
1465                           uv_file file,
1466                           uv_fs_cb cb);
1467 UV_EXTERN int uv_fs_open(uv_loop_t* loop,
1468                          uv_fs_t* req,
1469                          const char* path,
1470                          int flags,
1471                          int mode,
1472                          uv_fs_cb cb);
1473 UV_EXTERN int uv_fs_read(uv_loop_t* loop,
1474                          uv_fs_t* req,
1475                          uv_file file,
1476                          const uv_buf_t bufs[],
1477                          unsigned int nbufs,
1478                          int64_t offset,
1479                          uv_fs_cb cb);
1480 UV_EXTERN int uv_fs_unlink(uv_loop_t* loop,
1481                            uv_fs_t* req,
1482                            const char* path,
1483                            uv_fs_cb cb);
1484 UV_EXTERN int uv_fs_write(uv_loop_t* loop,
1485                           uv_fs_t* req,
1486                           uv_file file,
1487                           const uv_buf_t bufs[],
1488                           unsigned int nbufs,
1489                           int64_t offset,
1490                           uv_fs_cb cb);
1491 /*
1492  * This flag can be used with uv_fs_copyfile() to return an error if the
1493  * destination already exists.
1494  */
1495 #define UV_FS_COPYFILE_EXCL   0x0001
1496 
1497 /*
1498  * This flag can be used with uv_fs_copyfile() to attempt to create a reflink.
1499  * If copy-on-write is not supported, a fallback copy mechanism is used.
1500  */
1501 #define UV_FS_COPYFILE_FICLONE 0x0002
1502 
1503 /*
1504  * This flag can be used with uv_fs_copyfile() to attempt to create a reflink.
1505  * If copy-on-write is not supported, an error is returned.
1506  */
1507 #define UV_FS_COPYFILE_FICLONE_FORCE 0x0004
1508 
1509 UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop,
1510                              uv_fs_t* req,
1511                              const char* path,
1512                              const char* new_path,
1513                              int flags,
1514                              uv_fs_cb cb);
1515 UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop,
1516                           uv_fs_t* req,
1517                           const char* path,
1518                           int mode,
1519                           uv_fs_cb cb);
1520 UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop,
1521                             uv_fs_t* req,
1522                             const char* tpl,
1523                             uv_fs_cb cb);
1524 UV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop,
1525                             uv_fs_t* req,
1526                             const char* tpl,
1527                             uv_fs_cb cb);
1528 UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop,
1529                           uv_fs_t* req,
1530                           const char* path,
1531                           uv_fs_cb cb);
1532 UV_EXTERN int uv_fs_scandir(uv_loop_t* loop,
1533                             uv_fs_t* req,
1534                             const char* path,
1535                             int flags,
1536                             uv_fs_cb cb);
1537 UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req,
1538                                  uv_dirent_t* ent);
1539 UV_EXTERN int uv_fs_opendir(uv_loop_t* loop,
1540                             uv_fs_t* req,
1541                             const char* path,
1542                             uv_fs_cb cb);
1543 UV_EXTERN int uv_fs_readdir(uv_loop_t* loop,
1544                             uv_fs_t* req,
1545                             uv_dir_t* dir,
1546                             uv_fs_cb cb);
1547 UV_EXTERN int uv_fs_closedir(uv_loop_t* loop,
1548                              uv_fs_t* req,
1549                              uv_dir_t* dir,
1550                              uv_fs_cb cb);
1551 UV_EXTERN int uv_fs_stat(uv_loop_t* loop,
1552                          uv_fs_t* req,
1553                          const char* path,
1554                          uv_fs_cb cb);
1555 UV_EXTERN int uv_fs_fstat(uv_loop_t* loop,
1556                           uv_fs_t* req,
1557                           uv_file file,
1558                           uv_fs_cb cb);
1559 UV_EXTERN int uv_fs_rename(uv_loop_t* loop,
1560                            uv_fs_t* req,
1561                            const char* path,
1562                            const char* new_path,
1563                            uv_fs_cb cb);
1564 UV_EXTERN int uv_fs_fsync(uv_loop_t* loop,
1565                           uv_fs_t* req,
1566                           uv_file file,
1567                           uv_fs_cb cb);
1568 UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop,
1569                               uv_fs_t* req,
1570                               uv_file file,
1571                               uv_fs_cb cb);
1572 UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop,
1573                               uv_fs_t* req,
1574                               uv_file file,
1575                               int64_t offset,
1576                               uv_fs_cb cb);
1577 UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop,
1578                              uv_fs_t* req,
1579                              uv_file out_fd,
1580                              uv_file in_fd,
1581                              int64_t in_offset,
1582                              size_t length,
1583                              uv_fs_cb cb);
1584 UV_EXTERN int uv_fs_access(uv_loop_t* loop,
1585                            uv_fs_t* req,
1586                            const char* path,
1587                            int mode,
1588                            uv_fs_cb cb);
1589 UV_EXTERN int uv_fs_chmod(uv_loop_t* loop,
1590                           uv_fs_t* req,
1591                           const char* path,
1592                           int mode,
1593                           uv_fs_cb cb);
1594 #define UV_FS_UTIME_NOW  (INFINITY)
1595 #define UV_FS_UTIME_OMIT (NAN)
1596 UV_EXTERN int uv_fs_utime(uv_loop_t* loop,
1597                           uv_fs_t* req,
1598                           const char* path,
1599                           double atime,
1600                           double mtime,
1601                           uv_fs_cb cb);
1602 UV_EXTERN int uv_fs_futime(uv_loop_t* loop,
1603                            uv_fs_t* req,
1604                            uv_file file,
1605                            double atime,
1606                            double mtime,
1607                            uv_fs_cb cb);
1608 UV_EXTERN int uv_fs_lutime(uv_loop_t* loop,
1609                            uv_fs_t* req,
1610                            const char* path,
1611                            double atime,
1612                            double mtime,
1613                            uv_fs_cb cb);
1614 UV_EXTERN int uv_fs_lstat(uv_loop_t* loop,
1615                           uv_fs_t* req,
1616                           const char* path,
1617                           uv_fs_cb cb);
1618 UV_EXTERN int uv_fs_link(uv_loop_t* loop,
1619                          uv_fs_t* req,
1620                          const char* path,
1621                          const char* new_path,
1622                          uv_fs_cb cb);
1623 
1624 /*
1625  * This flag can be used with uv_fs_symlink() on Windows to specify whether
1626  * path argument points to a directory.
1627  */
1628 #define UV_FS_SYMLINK_DIR          0x0001
1629 
1630 /*
1631  * This flag can be used with uv_fs_symlink() on Windows to specify whether
1632  * the symlink is to be created using junction points.
1633  */
1634 #define UV_FS_SYMLINK_JUNCTION     0x0002
1635 
1636 UV_EXTERN int uv_fs_symlink(uv_loop_t* loop,
1637                             uv_fs_t* req,
1638                             const char* path,
1639                             const char* new_path,
1640                             int flags,
1641                             uv_fs_cb cb);
1642 UV_EXTERN int uv_fs_readlink(uv_loop_t* loop,
1643                              uv_fs_t* req,
1644                              const char* path,
1645                              uv_fs_cb cb);
1646 UV_EXTERN int uv_fs_realpath(uv_loop_t* loop,
1647                              uv_fs_t* req,
1648                              const char* path,
1649                              uv_fs_cb cb);
1650 UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop,
1651                            uv_fs_t* req,
1652                            uv_file file,
1653                            int mode,
1654                            uv_fs_cb cb);
1655 UV_EXTERN int uv_fs_chown(uv_loop_t* loop,
1656                           uv_fs_t* req,
1657                           const char* path,
1658                           uv_uid_t uid,
1659                           uv_gid_t gid,
1660                           uv_fs_cb cb);
1661 UV_EXTERN int uv_fs_fchown(uv_loop_t* loop,
1662                            uv_fs_t* req,
1663                            uv_file file,
1664                            uv_uid_t uid,
1665                            uv_gid_t gid,
1666                            uv_fs_cb cb);
1667 UV_EXTERN int uv_fs_lchown(uv_loop_t* loop,
1668                            uv_fs_t* req,
1669                            const char* path,
1670                            uv_uid_t uid,
1671                            uv_gid_t gid,
1672                            uv_fs_cb cb);
1673 UV_EXTERN int uv_fs_statfs(uv_loop_t* loop,
1674                            uv_fs_t* req,
1675                            const char* path,
1676                            uv_fs_cb cb);
1677 
1678 
1679 enum uv_fs_event {
1680   UV_RENAME = 1,
1681   UV_CHANGE = 2
1682 };
1683 
1684 
1685 struct uv_fs_event_s {
1686   UV_HANDLE_FIELDS
1687   /* private */
1688   char* path;
1689   UV_FS_EVENT_PRIVATE_FIELDS
1690 };
1691 
1692 
1693 /*
1694  * uv_fs_stat() based polling file watcher.
1695  */
1696 struct uv_fs_poll_s {
1697   UV_HANDLE_FIELDS
1698   /* Private, don't touch. */
1699   void* poll_ctx;
1700 };
1701 
1702 UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle);
1703 UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle,
1704                                uv_fs_poll_cb poll_cb,
1705                                const char* path,
1706                                unsigned int interval);
1707 UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle);
1708 UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle,
1709                                  char* buffer,
1710                                  size_t* size);
1711 
1712 
1713 struct uv_signal_s {
1714   UV_HANDLE_FIELDS
1715   uv_signal_cb signal_cb;
1716   int signum;
1717   UV_SIGNAL_PRIVATE_FIELDS
1718 };
1719 
1720 UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle);
1721 UV_EXTERN int uv_signal_start(uv_signal_t* handle,
1722                               uv_signal_cb signal_cb,
1723                               int signum);
1724 UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle,
1725                                       uv_signal_cb signal_cb,
1726                                       int signum);
1727 UV_EXTERN int uv_signal_stop(uv_signal_t* handle);
1728 
1729 UV_EXTERN void uv_loadavg(double avg[3]);
1730 
1731 
1732 /*
1733  * Flags to be passed to uv_fs_event_start().
1734  */
1735 enum uv_fs_event_flags {
1736   /*
1737    * By default, if the fs event watcher is given a directory name, we will
1738    * watch for all events in that directory. This flags overrides this behavior
1739    * and makes fs_event report only changes to the directory entry itself. This
1740    * flag does not affect individual files watched.
1741    * This flag is currently not implemented yet on any backend.
1742    */
1743   UV_FS_EVENT_WATCH_ENTRY = 1,
1744 
1745   /*
1746    * By default uv_fs_event will try to use a kernel interface such as inotify
1747    * or kqueue to detect events. This may not work on remote filesystems such
1748    * as NFS mounts. This flag makes fs_event fall back to calling stat() on a
1749    * regular interval.
1750    * This flag is currently not implemented yet on any backend.
1751    */
1752   UV_FS_EVENT_STAT = 2,
1753 
1754   /*
1755    * By default, event watcher, when watching directory, is not registering
1756    * (is ignoring) changes in it's subdirectories.
1757    * This flag will override this behaviour on platforms that support it.
1758    */
1759   UV_FS_EVENT_RECURSIVE = 4
1760 };
1761 
1762 
1763 UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle);
1764 UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle,
1765                                 uv_fs_event_cb cb,
1766                                 const char* path,
1767                                 unsigned int flags);
1768 UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle);
1769 UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle,
1770                                   char* buffer,
1771                                   size_t* size);
1772 
1773 UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr);
1774 UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr);
1775 
1776 UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size);
1777 UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size);
1778 UV_EXTERN int uv_ip_name(const struct sockaddr* src, char* dst, size_t size);
1779 
1780 UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size);
1781 UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst);
1782 
1783 
1784 struct uv_random_s {
1785   UV_REQ_FIELDS
1786   /* read-only */
1787   uv_loop_t* loop;
1788   /* private */
1789   int status;
1790   void* buf;
1791   size_t buflen;
1792   uv_random_cb cb;
1793   struct uv__work work_req;
1794 };
1795 
1796 UV_EXTERN int uv_random(uv_loop_t* loop,
1797                         uv_random_t* req,
1798                         void *buf,
1799                         size_t buflen,
1800                         unsigned flags,  /* For future extension; must be 0. */
1801                         uv_random_cb cb);
1802 
1803 #if defined(IF_NAMESIZE)
1804 # define UV_IF_NAMESIZE (IF_NAMESIZE + 1)
1805 #elif defined(IFNAMSIZ)
1806 # define UV_IF_NAMESIZE (IFNAMSIZ + 1)
1807 #else
1808 # define UV_IF_NAMESIZE (16 + 1)
1809 #endif
1810 
1811 UV_EXTERN int uv_if_indextoname(unsigned int ifindex,
1812                                 char* buffer,
1813                                 size_t* size);
1814 UV_EXTERN int uv_if_indextoiid(unsigned int ifindex,
1815                                char* buffer,
1816                                size_t* size);
1817 
1818 UV_EXTERN int uv_exepath(char* buffer, size_t* size);
1819 
1820 UV_EXTERN int uv_cwd(char* buffer, size_t* size);
1821 
1822 UV_EXTERN int uv_chdir(const char* dir);
1823 
1824 UV_EXTERN uint64_t uv_get_free_memory(void);
1825 UV_EXTERN uint64_t uv_get_total_memory(void);
1826 UV_EXTERN uint64_t uv_get_constrained_memory(void);
1827 UV_EXTERN uint64_t uv_get_available_memory(void);
1828 
1829 UV_EXTERN int uv_clock_gettime(uv_clock_id clock_id, uv_timespec64_t* ts);
1830 UV_EXTERN uint64_t uv_hrtime(void);
1831 UV_EXTERN void uv_sleep(unsigned int msec);
1832 
1833 UV_EXTERN void uv_disable_stdio_inheritance(void);
1834 
1835 UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib);
1836 UV_EXTERN void uv_dlclose(uv_lib_t* lib);
1837 UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr);
1838 UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib);
1839 
1840 UV_EXTERN int uv_mutex_init(uv_mutex_t* handle);
1841 UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle);
1842 UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle);
1843 UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle);
1844 UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle);
1845 UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle);
1846 
1847 UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock);
1848 UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock);
1849 UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock);
1850 UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock);
1851 UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock);
1852 UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock);
1853 UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock);
1854 UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock);
1855 
1856 UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value);
1857 UV_EXTERN void uv_sem_destroy(uv_sem_t* sem);
1858 UV_EXTERN void uv_sem_post(uv_sem_t* sem);
1859 UV_EXTERN void uv_sem_wait(uv_sem_t* sem);
1860 UV_EXTERN int uv_sem_trywait(uv_sem_t* sem);
1861 
1862 UV_EXTERN int uv_cond_init(uv_cond_t* cond);
1863 UV_EXTERN void uv_cond_destroy(uv_cond_t* cond);
1864 UV_EXTERN void uv_cond_signal(uv_cond_t* cond);
1865 UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond);
1866 
1867 UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count);
1868 UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier);
1869 UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier);
1870 
1871 UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex);
1872 UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond,
1873                                 uv_mutex_t* mutex,
1874                                 uint64_t timeout);
1875 
1876 UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void));
1877 
1878 UV_EXTERN int uv_key_create(uv_key_t* key);
1879 UV_EXTERN void uv_key_delete(uv_key_t* key);
1880 UV_EXTERN void* uv_key_get(uv_key_t* key);
1881 UV_EXTERN void uv_key_set(uv_key_t* key, void* value);
1882 
1883 UV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv);
1884 
1885 typedef void (*uv_thread_cb)(void* arg);
1886 
1887 UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);
1888 UV_EXTERN int uv_thread_detach(uv_thread_t* tid);
1889 
1890 typedef enum {
1891   UV_THREAD_NO_FLAGS = 0x00,
1892   UV_THREAD_HAS_STACK_SIZE = 0x01
1893 } uv_thread_create_flags;
1894 
1895 struct uv_thread_options_s {
1896   unsigned int flags;
1897   size_t stack_size;
1898   /* More fields may be added at any time. */
1899 };
1900 
1901 typedef struct uv_thread_options_s uv_thread_options_t;
1902 
1903 UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid,
1904                                   const uv_thread_options_t* params,
1905                                   uv_thread_cb entry,
1906                                   void* arg);
1907 UV_EXTERN int uv_thread_setaffinity(uv_thread_t* tid,
1908                                     char* cpumask,
1909                                     char* oldmask,
1910                                     size_t mask_size);
1911 UV_EXTERN int uv_thread_getaffinity(uv_thread_t* tid,
1912                                     char* cpumask,
1913                                     size_t mask_size);
1914 UV_EXTERN int uv_thread_getcpu(void);
1915 UV_EXTERN uv_thread_t uv_thread_self(void);
1916 UV_EXTERN int uv_thread_join(uv_thread_t *tid);
1917 UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2);
1918 UV_EXTERN int uv_thread_setname(const char* name);
1919 UV_EXTERN int uv_thread_getname(uv_thread_t* tid, char* name, size_t size);
1920 
1921 
1922 /* The presence of these unions force similar struct layout. */
1923 #define XX(_, name) uv_ ## name ## _t name;
1924 union uv_any_handle {
1925   UV_HANDLE_TYPE_MAP(XX)
1926 };
1927 
1928 union uv_any_req {
1929   UV_REQ_TYPE_MAP(XX)
1930 };
1931 #undef XX
1932 
1933 
1934 struct uv_loop_s {
1935   /* User data - use this for whatever. */
1936   void* data;
1937   /* Loop reference counting. */
1938   unsigned int active_handles;
1939   struct uv__queue handle_queue;
1940   union {
1941     void* unused;
1942     unsigned int count;
1943   } active_reqs;
1944   /* Internal storage for future extensions. */
1945   void* internal_fields;
1946   /* Internal flag to signal loop stop. */
1947   unsigned int stop_flag;
1948   UV_LOOP_PRIVATE_FIELDS
1949 };
1950 
1951 UV_EXTERN void* uv_loop_get_data(const uv_loop_t*);
1952 UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data);
1953 
1954 /* Unicode utilities needed for dealing with Windows. */
1955 UV_EXTERN size_t uv_utf16_length_as_wtf8(const uint16_t* utf16,
1956                                          ssize_t utf16_len);
1957 UV_EXTERN int uv_utf16_to_wtf8(const uint16_t* utf16,
1958                                ssize_t utf16_len,
1959                                char** wtf8_ptr,
1960                                size_t* wtf8_len_ptr);
1961 UV_EXTERN ssize_t uv_wtf8_length_as_utf16(const char* wtf8);
1962 UV_EXTERN void uv_wtf8_to_utf16(const char* wtf8,
1963                                 uint16_t* utf16,
1964                                 size_t utf16_len);
1965 
1966 /* Don't export the private CPP symbols. */
1967 #undef UV_HANDLE_TYPE_PRIVATE
1968 #undef UV_REQ_TYPE_PRIVATE
1969 #undef UV_REQ_PRIVATE_FIELDS
1970 #undef UV_STREAM_PRIVATE_FIELDS
1971 #undef UV_TCP_PRIVATE_FIELDS
1972 #undef UV_PREPARE_PRIVATE_FIELDS
1973 #undef UV_CHECK_PRIVATE_FIELDS
1974 #undef UV_IDLE_PRIVATE_FIELDS
1975 #undef UV_ASYNC_PRIVATE_FIELDS
1976 #undef UV_TIMER_PRIVATE_FIELDS
1977 #undef UV_GETADDRINFO_PRIVATE_FIELDS
1978 #undef UV_GETNAMEINFO_PRIVATE_FIELDS
1979 #undef UV_FS_REQ_PRIVATE_FIELDS
1980 #undef UV_WORK_PRIVATE_FIELDS
1981 #undef UV_FS_EVENT_PRIVATE_FIELDS
1982 #undef UV_SIGNAL_PRIVATE_FIELDS
1983 #undef UV_LOOP_PRIVATE_FIELDS
1984 #undef UV_LOOP_PRIVATE_PLATFORM_FIELDS
1985 #undef UV__ERR
1986 
1987 #ifdef __cplusplus
1988 }
1989 #endif
1990 #endif /* UV_H */