1 /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to
5 * deal in the Software without restriction, including without limitation the
6 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 * sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 * IN THE SOFTWARE.
20 */
21
22 /* See https://github.com/libuv/libuv#documentation for documentation. */
23
24 #ifndef UV_H
25 #define UV_H
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED)
31 #error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both."
32 #endif
33
34 #ifdef _WIN32
35 /* Windows - set up dll import/export decorators. */
36 # if defined(BUILDING_UV_SHARED)
37 /* Building shared library. */
38 # define UV_EXTERN __declspec(dllexport)
39 # elif defined(USING_UV_SHARED)
40 /* Using shared library. */
41 # define UV_EXTERN __declspec(dllimport)
42 # else
43 /* Building static library. */
44 # define UV_EXTERN /* nothing */
45 # endif
46 #elif __GNUC__ >= 4
47 # define UV_EXTERN __attribute__((visibility("default")))
48 #else
49 # define UV_EXTERN /* nothing */
50 #endif
51
52 #include "uv/errno.h"
53 #include "uv/version.h"
54 #include <stddef.h>
55 #include <stdio.h>
56
57 #if defined(_MSC_VER) && _MSC_VER < 1600
58 # include "uv/stdint-msvc2008.h"
59 #else
60 # include <stdint.h>
61 #endif
62
63 #if defined(_WIN32)
64 # include "uv/win.h"
65 #else
66 # include "uv/unix.h"
67 #endif
68
69 /* Expand this list if necessary. */
70 #define UV_ERRNO_MAP(XX) \
71 XX(E2BIG, "argument list too long") \
72 XX(EACCES, "permission denied") \
73 XX(EADDRINUSE, "address already in use") \
74 XX(EADDRNOTAVAIL, "address not available") \
75 XX(EAFNOSUPPORT, "address family not supported") \
76 XX(EAGAIN, "resource temporarily unavailable") \
77 XX(EAI_ADDRFAMILY, "address family not supported") \
78 XX(EAI_AGAIN, "temporary failure") \
79 XX(EAI_BADFLAGS, "bad ai_flags value") \
80 XX(EAI_BADHINTS, "invalid value for hints") \
81 XX(EAI_CANCELED, "request canceled") \
82 XX(EAI_FAIL, "permanent failure") \
83 XX(EAI_FAMILY, "ai_family not supported") \
84 XX(EAI_MEMORY, "out of memory") \
85 XX(EAI_NODATA, "no address") \
86 XX(EAI_NONAME, "unknown node or service") \
87 XX(EAI_OVERFLOW, "argument buffer overflow") \
88 XX(EAI_PROTOCOL, "resolved protocol is unknown") \
89 XX(EAI_SERVICE, "service not available for socket type") \
90 XX(EAI_SOCKTYPE, "socket type not supported") \
91 XX(EALREADY, "connection already in progress") \
92 XX(EBADF, "bad file descriptor") \
93 XX(EBUSY, "resource busy or locked") \
94 XX(ECANCELED, "operation canceled") \
95 XX(ECHARSET, "invalid Unicode character") \
96 XX(ECONNABORTED, "software caused connection abort") \
97 XX(ECONNREFUSED, "connection refused") \
98 XX(ECONNRESET, "connection reset by peer") \
99 XX(EDESTADDRREQ, "destination address required") \
100 XX(EEXIST, "file already exists") \
101 XX(EFAULT, "bad address in system call argument") \
102 XX(EFBIG, "file too large") \
103 XX(EHOSTUNREACH, "host is unreachable") \
104 XX(EINTR, "interrupted system call") \
105 XX(EINVAL, "invalid argument") \
106 XX(EIO, "i/o error") \
107 XX(EISCONN, "socket is already connected") \
108 XX(EISDIR, "illegal operation on a directory") \
109 XX(ELOOP, "too many symbolic links encountered") \
110 XX(EMFILE, "too many open files") \
111 XX(EMSGSIZE, "message too long") \
112 XX(ENAMETOOLONG, "name too long") \
113 XX(ENETDOWN, "network is down") \
114 XX(ENETUNREACH, "network is unreachable") \
115 XX(ENFILE, "file table overflow") \
116 XX(ENOBUFS, "no buffer space available") \
117 XX(ENODEV, "no such device") \
118 XX(ENOENT, "no such file or directory") \
119 XX(ENOMEM, "not enough memory") \
120 XX(ENONET, "machine is not on the network") \
121 XX(ENOPROTOOPT, "protocol not available") \
122 XX(ENOSPC, "no space left on device") \
123 XX(ENOSYS, "function not implemented") \
124 XX(ENOTCONN, "socket is not connected") \
125 XX(ENOTDIR, "not a directory") \
126 XX(ENOTEMPTY, "directory not empty") \
127 XX(ENOTSOCK, "socket operation on non-socket") \
128 XX(ENOTSUP, "operation not supported on socket") \
129 XX(EPERM, "operation not permitted") \
130 XX(EPIPE, "broken pipe") \
131 XX(EPROTO, "protocol error") \
132 XX(EPROTONOSUPPORT, "protocol not supported") \
133 XX(EPROTOTYPE, "protocol wrong type for socket") \
134 XX(ERANGE, "result too large") \
135 XX(EROFS, "read-only file system") \
136 XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \
137 XX(ESPIPE, "invalid seek") \
138 XX(ESRCH, "no such process") \
139 XX(ETIMEDOUT, "connection timed out") \
140 XX(ETXTBSY, "text file is busy") \
141 XX(EXDEV, "cross-device link not permitted") \
142 XX(UNKNOWN, "unknown error") \
143 XX(EOF, "end of file") \
144 XX(ENXIO, "no such device or address") \
145 XX(EMLINK, "too many links") \
146 XX(EHOSTDOWN, "host is down") \
147 XX(EREMOTEIO, "remote I/O error") \
148 XX(ENOTTY, "inappropriate ioctl for device") \
149 XX(EFTYPE, "inappropriate file type or format") \
150 XX(EILSEQ, "illegal byte sequence") \
151
152 #define UV_HANDLE_TYPE_MAP(XX) \
153 XX(ASYNC, async) \
154 XX(CHECK, check) \
155 XX(FS_EVENT, fs_event) \
156 XX(FS_POLL, fs_poll) \
157 XX(HANDLE, handle) \
158 XX(IDLE, idle) \
159 XX(NAMED_PIPE, pipe) \
160 XX(POLL, poll) \
161 XX(PREPARE, prepare) \
162 XX(PROCESS, process) \
163 XX(STREAM, stream) \
164 XX(TCP, tcp) \
165 XX(TIMER, timer) \
166 XX(TTY, tty) \
167 XX(UDP, udp) \
168 XX(SIGNAL, signal) \
169
170 #define UV_REQ_TYPE_MAP(XX) \
171 XX(REQ, req) \
172 XX(CONNECT, connect) \
173 XX(WRITE, write) \
174 XX(SHUTDOWN, shutdown) \
175 XX(UDP_SEND, udp_send) \
176 XX(FS, fs) \
177 XX(WORK, work) \
178 XX(GETADDRINFO, getaddrinfo) \
179 XX(GETNAMEINFO, getnameinfo) \
180 XX(RANDOM, random) \
181
182 typedef enum {
183 #define XX(code, _) UV_ ## code = UV__ ## code,
184 UV_ERRNO_MAP(XX)
185 #undef XX
186 UV_ERRNO_MAX = UV__EOF - 1
187 } uv_errno_t;
188
189 typedef enum {
190 UV_UNKNOWN_HANDLE = 0,
191 #define XX(uc, lc) UV_##uc,
192 UV_HANDLE_TYPE_MAP(XX)
193 #undef XX
194 UV_FILE,
195 UV_HANDLE_TYPE_MAX
196 } uv_handle_type;
197
198 typedef enum {
199 UV_UNKNOWN_REQ = 0,
200 #define XX(uc, lc) UV_##uc,
201 UV_REQ_TYPE_MAP(XX)
202 #undef XX
203 UV_REQ_TYPE_PRIVATE
204 UV_REQ_TYPE_MAX
205 } uv_req_type;
206
207
208 /* Handle types. */
209 typedef struct uv_loop_s uv_loop_t;
210 typedef struct uv_handle_s uv_handle_t;
211 typedef struct uv_dir_s uv_dir_t;
212 typedef struct uv_stream_s uv_stream_t;
213 typedef struct uv_tcp_s uv_tcp_t;
214 typedef struct uv_udp_s uv_udp_t;
215 typedef struct uv_pipe_s uv_pipe_t;
216 typedef struct uv_tty_s uv_tty_t;
217 typedef struct uv_poll_s uv_poll_t;
218 typedef struct uv_timer_s uv_timer_t;
219 typedef struct uv_prepare_s uv_prepare_t;
220 typedef struct uv_check_s uv_check_t;
221 typedef struct uv_idle_s uv_idle_t;
222 typedef struct uv_async_s uv_async_t;
223 typedef struct uv_process_s uv_process_t;
224 typedef struct uv_fs_event_s uv_fs_event_t;
225 typedef struct uv_fs_poll_s uv_fs_poll_t;
226 typedef struct uv_signal_s uv_signal_t;
227
228 /* Request types. */
229 typedef struct uv_req_s uv_req_t;
230 typedef struct uv_getaddrinfo_s uv_getaddrinfo_t;
231 typedef struct uv_getnameinfo_s uv_getnameinfo_t;
232 typedef struct uv_shutdown_s uv_shutdown_t;
233 typedef struct uv_write_s uv_write_t;
234 typedef struct uv_connect_s uv_connect_t;
235 typedef struct uv_udp_send_s uv_udp_send_t;
236 typedef struct uv_fs_s uv_fs_t;
237 typedef struct uv_work_s uv_work_t;
238 typedef struct uv_random_s uv_random_t;
239
240 /* None of the above. */
241 typedef struct uv_env_item_s uv_env_item_t;
242 typedef struct uv_cpu_info_s uv_cpu_info_t;
243 typedef struct uv_interface_address_s uv_interface_address_t;
244 typedef struct uv_dirent_s uv_dirent_t;
245 typedef struct uv_passwd_s uv_passwd_t;
246 typedef struct uv_utsname_s uv_utsname_t;
247 typedef struct uv_statfs_s uv_statfs_t;
248
249 typedef enum {
250 UV_LOOP_BLOCK_SIGNAL
251 } uv_loop_option;
252
253 typedef enum {
254 UV_RUN_DEFAULT = 0,
255 UV_RUN_ONCE,
256 UV_RUN_NOWAIT
257 } uv_run_mode;
258
259
260 UV_EXTERN unsigned int uv_version(void);
261 UV_EXTERN const char* uv_version_string(void);
262
263 typedef void* (*uv_malloc_func)(size_t size);
264 typedef void* (*uv_realloc_func)(void* ptr, size_t size);
265 typedef void* (*uv_calloc_func)(size_t count, size_t size);
266 typedef void (*uv_free_func)(void* ptr);
267
268 UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func,
269 uv_realloc_func realloc_func,
270 uv_calloc_func calloc_func,
271 uv_free_func free_func);
272
273 UV_EXTERN uv_loop_t* uv_default_loop(void);
274 UV_EXTERN int uv_loop_init(uv_loop_t* loop);
275 UV_EXTERN int uv_loop_close(uv_loop_t* loop);
276 /*
277 * NOTE:
278 * This function is DEPRECATED (to be removed after 0.12), users should
279 * allocate the loop manually and use uv_loop_init instead.
280 */
281 UV_EXTERN uv_loop_t* uv_loop_new(void);
282 /*
283 * NOTE:
284 * This function is DEPRECATED (to be removed after 0.12). Users should use
285 * uv_loop_close and free the memory manually instead.
286 */
287 UV_EXTERN void uv_loop_delete(uv_loop_t*);
288 UV_EXTERN size_t uv_loop_size(void);
289 UV_EXTERN int uv_loop_alive(const uv_loop_t* loop);
290 UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...);
291 UV_EXTERN int uv_loop_fork(uv_loop_t* loop);
292
293 UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode);
294 UV_EXTERN void uv_stop(uv_loop_t*);
295
296 UV_EXTERN void uv_ref(uv_handle_t*);
297 UV_EXTERN void uv_unref(uv_handle_t*);
298 UV_EXTERN int uv_has_ref(const uv_handle_t*);
299
300 UV_EXTERN void uv_update_time(uv_loop_t*);
301 UV_EXTERN uint64_t uv_now(const uv_loop_t*);
302
303 UV_EXTERN int uv_backend_fd(const uv_loop_t*);
304 UV_EXTERN int uv_backend_timeout(const uv_loop_t*);
305
306 typedef void (*uv_alloc_cb)(uv_handle_t* handle,
307 size_t suggested_size,
308 uv_buf_t* buf);
309 typedef void (*uv_read_cb)(uv_stream_t* stream,
310 ssize_t nread,
311 const uv_buf_t* buf);
312 typedef void (*uv_write_cb)(uv_write_t* req, int status);
313 typedef void (*uv_connect_cb)(uv_connect_t* req, int status);
314 typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status);
315 typedef void (*uv_connection_cb)(uv_stream_t* server, int status);
316 typedef void (*uv_close_cb)(uv_handle_t* handle);
317 typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events);
318 typedef void (*uv_timer_cb)(uv_timer_t* handle);
319 typedef void (*uv_async_cb)(uv_async_t* handle);
320 typedef void (*uv_prepare_cb)(uv_prepare_t* handle);
321 typedef void (*uv_check_cb)(uv_check_t* handle);
322 typedef void (*uv_idle_cb)(uv_idle_t* handle);
323 typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal);
324 typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg);
325 typedef void (*uv_fs_cb)(uv_fs_t* req);
326 typedef void (*uv_work_cb)(uv_work_t* req);
327 typedef void (*uv_after_work_cb)(uv_work_t* req, int status);
328 typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req,
329 int status,
330 struct addrinfo* res);
331 typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req,
332 int status,
333 const char* hostname,
334 const char* service);
335 typedef void (*uv_random_cb)(uv_random_t* req,
336 int status,
337 void* buf,
338 size_t buflen);
339
340 typedef struct {
341 long tv_sec;
342 long tv_nsec;
343 } uv_timespec_t;
344
345
346 typedef struct {
347 uint64_t st_dev;
348 uint64_t st_mode;
349 uint64_t st_nlink;
350 uint64_t st_uid;
351 uint64_t st_gid;
352 uint64_t st_rdev;
353 uint64_t st_ino;
354 uint64_t st_size;
355 uint64_t st_blksize;
356 uint64_t st_blocks;
357 uint64_t st_flags;
358 uint64_t st_gen;
359 uv_timespec_t st_atim;
360 uv_timespec_t st_mtim;
361 uv_timespec_t st_ctim;
362 uv_timespec_t st_birthtim;
363 } uv_stat_t;
364
365
366 typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle,
367 const char* filename,
368 int events,
369 int status);
370
371 typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle,
372 int status,
373 const uv_stat_t* prev,
374 const uv_stat_t* curr);
375
376 typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum);
377
378
379 typedef enum {
380 UV_LEAVE_GROUP = 0,
381 UV_JOIN_GROUP
382 } uv_membership;
383
384
385 UV_EXTERN int uv_translate_sys_error(int sys_errno);
386
387 UV_EXTERN const char* uv_strerror(int err);
388 UV_EXTERN char* uv_strerror_r(int err, char* buf, size_t buflen);
389
390 UV_EXTERN const char* uv_err_name(int err);
391 UV_EXTERN char* uv_err_name_r(int err, char* buf, size_t buflen);
392
393
394 #define UV_REQ_FIELDS \
395 /* public */ \
396 void* data; \
397 /* read-only */ \
398 uv_req_type type; \
399 /* private */ \
400 void* reserved[6]; \
401 UV_REQ_PRIVATE_FIELDS \
402
403 /* Abstract base class of all requests. */
404 struct uv_req_s {
405 UV_REQ_FIELDS
406 };
407
408
409 /* Platform-specific request types. */
410 UV_PRIVATE_REQ_TYPES
411
412
413 UV_EXTERN int uv_shutdown(uv_shutdown_t* req,
414 uv_stream_t* handle,
415 uv_shutdown_cb cb);
416
417 struct uv_shutdown_s {
418 UV_REQ_FIELDS
419 uv_stream_t* handle;
420 uv_shutdown_cb cb;
421 UV_SHUTDOWN_PRIVATE_FIELDS
422 };
423
424
425 #define UV_HANDLE_FIELDS \
426 /* public */ \
427 void* data; \
428 /* read-only */ \
429 uv_loop_t* loop; \
430 uv_handle_type type; \
431 /* private */ \
432 uv_close_cb close_cb; \
433 void* handle_queue[2]; \
434 union { \
435 int fd; \
436 void* reserved[4]; \
437 } u; \
438 UV_HANDLE_PRIVATE_FIELDS \
439
440 /* The abstract base class of all handles. */
441 struct uv_handle_s {
442 UV_HANDLE_FIELDS
443 };
444
445 UV_EXTERN size_t uv_handle_size(uv_handle_type type);
446 UV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle);
447 UV_EXTERN const char* uv_handle_type_name(uv_handle_type type);
448 UV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle);
449 UV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle);
450 UV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data);
451
452 UV_EXTERN size_t uv_req_size(uv_req_type type);
453 UV_EXTERN void* uv_req_get_data(const uv_req_t* req);
454 UV_EXTERN void uv_req_set_data(uv_req_t* req, void* data);
455 UV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req);
456 UV_EXTERN const char* uv_req_type_name(uv_req_type type);
457
458 UV_EXTERN int uv_is_active(const uv_handle_t* handle);
459
460 UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg);
461
462 /* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */
463 UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream);
464 UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream);
465
466 UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb);
467
468 UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value);
469 UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value);
470
471 UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd);
472
473 UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len);
474
475
476 #define UV_STREAM_FIELDS \
477 /* number of bytes queued for writing */ \
478 size_t write_queue_size; \
479 uv_alloc_cb alloc_cb; \
480 uv_read_cb read_cb; \
481 /* private */ \
482 UV_STREAM_PRIVATE_FIELDS
483
484 /*
485 * uv_stream_t is a subclass of uv_handle_t.
486 *
487 * uv_stream is an abstract class.
488 *
489 * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t.
490 */
491 struct uv_stream_s {
492 UV_HANDLE_FIELDS
493 UV_STREAM_FIELDS
494 };
495
496 UV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream);
497
498 UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb);
499 UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client);
500
501 UV_EXTERN int uv_read_start(uv_stream_t*,
502 uv_alloc_cb alloc_cb,
503 uv_read_cb read_cb);
504 UV_EXTERN int uv_read_stop(uv_stream_t*);
505
506 UV_EXTERN int uv_write(uv_write_t* req,
507 uv_stream_t* handle,
508 const uv_buf_t bufs[],
509 unsigned int nbufs,
510 uv_write_cb cb);
511 UV_EXTERN int uv_write2(uv_write_t* req,
512 uv_stream_t* handle,
513 const uv_buf_t bufs[],
514 unsigned int nbufs,
515 uv_stream_t* send_handle,
516 uv_write_cb cb);
517 UV_EXTERN int uv_try_write(uv_stream_t* handle,
518 const uv_buf_t bufs[],
519 unsigned int nbufs);
520
521 /* uv_write_t is a subclass of uv_req_t. */
522 struct uv_write_s {
523 UV_REQ_FIELDS
524 uv_write_cb cb;
525 uv_stream_t* send_handle; /* TODO: make private and unix-only in v2.x. */
526 uv_stream_t* handle;
527 UV_WRITE_PRIVATE_FIELDS
528 };
529
530
531 UV_EXTERN int uv_is_readable(const uv_stream_t* handle);
532 UV_EXTERN int uv_is_writable(const uv_stream_t* handle);
533
534 UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking);
535
536 UV_EXTERN int uv_is_closing(const uv_handle_t* handle);
537
538
539 /*
540 * uv_tcp_t is a subclass of uv_stream_t.
541 *
542 * Represents a TCP stream or TCP server.
543 */
544 struct uv_tcp_s {
545 UV_HANDLE_FIELDS
546 UV_STREAM_FIELDS
547 UV_TCP_PRIVATE_FIELDS
548 };
549
550 UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle);
551 UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags);
552 UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock);
553 UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable);
554 UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle,
555 int enable,
556 unsigned int delay);
557 UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable);
558
559 enum uv_tcp_flags {
560 /* Used with uv_tcp_bind, when an IPv6 address is used. */
561 UV_TCP_IPV6ONLY = 1
562 };
563
564 UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle,
565 const struct sockaddr* addr,
566 unsigned int flags);
567 UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle,
568 struct sockaddr* name,
569 int* namelen);
570 UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle,
571 struct sockaddr* name,
572 int* namelen);
573 UV_EXTERN int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb);
574 UV_EXTERN int uv_tcp_connect(uv_connect_t* req,
575 uv_tcp_t* handle,
576 const struct sockaddr* addr,
577 uv_connect_cb cb);
578
579 /* uv_connect_t is a subclass of uv_req_t. */
580 struct uv_connect_s {
581 UV_REQ_FIELDS
582 uv_connect_cb cb;
583 uv_stream_t* handle;
584 UV_CONNECT_PRIVATE_FIELDS
585 };
586
587
588 /*
589 * UDP support.
590 */
591
592 enum uv_udp_flags {
593 /* Disables dual stack mode. */
594 UV_UDP_IPV6ONLY = 1,
595 /*
596 * Indicates message was truncated because read buffer was too small. The
597 * remainder was discarded by the OS. Used in uv_udp_recv_cb.
598 */
599 UV_UDP_PARTIAL = 2,
600 /*
601 * Indicates if SO_REUSEADDR will be set when binding the handle.
602 * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other
603 * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that
604 * multiple threads or processes can bind to the same address without error
605 * (provided they all set the flag) but only the last one to bind will receive
606 * any traffic, in effect "stealing" the port from the previous listener.
607 */
608 UV_UDP_REUSEADDR = 4,
609 /*
610 * Indicates that the message was received by recvmmsg and that it's not at
611 * the beginning of the buffer allocated by alloc_cb - so the buffer provided
612 * must not be freed by the recv_cb callback.
613 */
614 UV_UDP_MMSG_CHUNK = 8
615 };
616
617 typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status);
618 typedef void (*uv_udp_recv_cb)(uv_udp_t* handle,
619 ssize_t nread,
620 const uv_buf_t* buf,
621 const struct sockaddr* addr,
622 unsigned flags);
623
624 /* uv_udp_t is a subclass of uv_handle_t. */
625 struct uv_udp_s {
626 UV_HANDLE_FIELDS
627 /* read-only */
628 /*
629 * Number of bytes queued for sending. This field strictly shows how much
630 * information is currently queued.
631 */
632 size_t send_queue_size;
633 /*
634 * Number of send requests currently in the queue awaiting to be processed.
635 */
636 size_t send_queue_count;
637 UV_UDP_PRIVATE_FIELDS
638 };
639
640 /* uv_udp_send_t is a subclass of uv_req_t. */
641 struct uv_udp_send_s {
642 UV_REQ_FIELDS
643 uv_udp_t* handle;
644 uv_udp_send_cb cb;
645 UV_UDP_SEND_PRIVATE_FIELDS
646 };
647
648 UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle);
649 UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags);
650 UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock);
651 UV_EXTERN int uv_udp_bind(uv_udp_t* handle,
652 const struct sockaddr* addr,
653 unsigned int flags);
654 UV_EXTERN int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr);
655
656 UV_EXTERN int uv_udp_getpeername(const uv_udp_t* handle,
657 struct sockaddr* name,
658 int* namelen);
659 UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle,
660 struct sockaddr* name,
661 int* namelen);
662 UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
663 const char* multicast_addr,
664 const char* interface_addr,
665 uv_membership membership);
666 UV_EXTERN int uv_udp_set_source_membership(uv_udp_t* handle,
667 const char* multicast_addr,
668 const char* interface_addr,
669 const char* source_addr,
670 uv_membership membership);
671 UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on);
672 UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
673 UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle,
674 const char* interface_addr);
675 UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on);
676 UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl);
677 UV_EXTERN int uv_udp_send(uv_udp_send_t* req,
678 uv_udp_t* handle,
679 const uv_buf_t bufs[],
680 unsigned int nbufs,
681 const struct sockaddr* addr,
682 uv_udp_send_cb send_cb);
683 UV_EXTERN int uv_udp_try_send(uv_udp_t* handle,
684 const uv_buf_t bufs[],
685 unsigned int nbufs,
686 const struct sockaddr* addr);
687 UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle,
688 uv_alloc_cb alloc_cb,
689 uv_udp_recv_cb recv_cb);
690 UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle);
691 UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle);
692 UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle);
693
694
695 /*
696 * uv_tty_t is a subclass of uv_stream_t.
697 *
698 * Representing a stream for the console.
699 */
700 struct uv_tty_s {
701 UV_HANDLE_FIELDS
702 UV_STREAM_FIELDS
703 UV_TTY_PRIVATE_FIELDS
704 };
705
706 typedef enum {
707 /* Initial/normal terminal mode */
708 UV_TTY_MODE_NORMAL,
709 /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */
710 UV_TTY_MODE_RAW,
711 /* Binary-safe I/O mode for IPC (Unix-only) */
712 UV_TTY_MODE_IO
713 } uv_tty_mode_t;
714
715 typedef enum {
716 /*
717 * The console supports handling of virtual terminal sequences
718 * (Windows10 new console, ConEmu)
719 */
720 UV_TTY_SUPPORTED,
721 /* The console cannot process the virtual terminal sequence. (Legacy
722 * console)
723 */
724 UV_TTY_UNSUPPORTED
725 } uv_tty_vtermstate_t;
726
727
728 UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable);
729 UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode);
730 UV_EXTERN int uv_tty_reset_mode(void);
731 UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
732 UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state);
733 UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state);
734
735 #ifdef __cplusplus
736 extern "C++" {
737
uv_tty_set_mode(uv_tty_t * handle,int mode)738 inline int uv_tty_set_mode(uv_tty_t* handle, int mode) {
739 return uv_tty_set_mode(handle, static_cast<uv_tty_mode_t>(mode));
740 }
741
742 }
743 #endif
744
745 UV_EXTERN uv_handle_type uv_guess_handle(uv_file file);
746
747 /*
748 * uv_pipe_t is a subclass of uv_stream_t.
749 *
750 * Representing a pipe stream or pipe server. On Windows this is a Named
751 * Pipe. On Unix this is a Unix domain socket.
752 */
753 struct uv_pipe_s {
754 UV_HANDLE_FIELDS
755 UV_STREAM_FIELDS
756 int ipc; /* non-zero if this pipe is used for passing handles */
757 UV_PIPE_PRIVATE_FIELDS
758 };
759
760 UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
761 UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file);
762 UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);
763 UV_EXTERN void uv_pipe_connect(uv_connect_t* req,
764 uv_pipe_t* handle,
765 const char* name,
766 uv_connect_cb cb);
767 UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle,
768 char* buffer,
769 size_t* size);
770 UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle,
771 char* buffer,
772 size_t* size);
773 UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count);
774 UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle);
775 UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle);
776 UV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags);
777
778
779 struct uv_poll_s {
780 UV_HANDLE_FIELDS
781 uv_poll_cb poll_cb;
782 UV_POLL_PRIVATE_FIELDS
783 };
784
785 enum uv_poll_event {
786 UV_READABLE = 1,
787 UV_WRITABLE = 2,
788 UV_DISCONNECT = 4,
789 UV_PRIORITIZED = 8
790 };
791
792 UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd);
793 UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop,
794 uv_poll_t* handle,
795 uv_os_sock_t socket);
796 UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb);
797 UV_EXTERN int uv_poll_stop(uv_poll_t* handle);
798
799
800 struct uv_prepare_s {
801 UV_HANDLE_FIELDS
802 UV_PREPARE_PRIVATE_FIELDS
803 };
804
805 UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare);
806 UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb);
807 UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare);
808
809
810 struct uv_check_s {
811 UV_HANDLE_FIELDS
812 UV_CHECK_PRIVATE_FIELDS
813 };
814
815 UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check);
816 UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb);
817 UV_EXTERN int uv_check_stop(uv_check_t* check);
818
819
820 struct uv_idle_s {
821 UV_HANDLE_FIELDS
822 UV_IDLE_PRIVATE_FIELDS
823 };
824
825 UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle);
826 UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb);
827 UV_EXTERN int uv_idle_stop(uv_idle_t* idle);
828
829
830 struct uv_async_s {
831 UV_HANDLE_FIELDS
832 UV_ASYNC_PRIVATE_FIELDS
833 };
834
835 UV_EXTERN int uv_async_init(uv_loop_t*,
836 uv_async_t* async,
837 uv_async_cb async_cb);
838 UV_EXTERN int uv_async_send(uv_async_t* async);
839
840
841 /*
842 * uv_timer_t is a subclass of uv_handle_t.
843 *
844 * Used to get woken up at a specified time in the future.
845 */
846 struct uv_timer_s {
847 UV_HANDLE_FIELDS
848 UV_TIMER_PRIVATE_FIELDS
849 };
850
851 UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle);
852 UV_EXTERN int uv_timer_start(uv_timer_t* handle,
853 uv_timer_cb cb,
854 uint64_t timeout,
855 uint64_t repeat);
856 UV_EXTERN int uv_timer_stop(uv_timer_t* handle);
857 UV_EXTERN int uv_timer_again(uv_timer_t* handle);
858 UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat);
859 UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle);
860
861
862 /*
863 * uv_getaddrinfo_t is a subclass of uv_req_t.
864 *
865 * Request object for uv_getaddrinfo.
866 */
867 struct uv_getaddrinfo_s {
868 UV_REQ_FIELDS
869 /* read-only */
870 uv_loop_t* loop;
871 /* struct addrinfo* addrinfo is marked as private, but it really isn't. */
872 UV_GETADDRINFO_PRIVATE_FIELDS
873 };
874
875
876 UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop,
877 uv_getaddrinfo_t* req,
878 uv_getaddrinfo_cb getaddrinfo_cb,
879 const char* node,
880 const char* service,
881 const struct addrinfo* hints);
882 UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai);
883
884
885 /*
886 * uv_getnameinfo_t is a subclass of uv_req_t.
887 *
888 * Request object for uv_getnameinfo.
889 */
890 struct uv_getnameinfo_s {
891 UV_REQ_FIELDS
892 /* read-only */
893 uv_loop_t* loop;
894 /* host and service are marked as private, but they really aren't. */
895 UV_GETNAMEINFO_PRIVATE_FIELDS
896 };
897
898 UV_EXTERN int uv_getnameinfo(uv_loop_t* loop,
899 uv_getnameinfo_t* req,
900 uv_getnameinfo_cb getnameinfo_cb,
901 const struct sockaddr* addr,
902 int flags);
903
904
905 /* uv_spawn() options. */
906 typedef enum {
907 UV_IGNORE = 0x00,
908 UV_CREATE_PIPE = 0x01,
909 UV_INHERIT_FD = 0x02,
910 UV_INHERIT_STREAM = 0x04,
911
912 /*
913 * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE
914 * determine the direction of flow, from the child process' perspective. Both
915 * flags may be specified to create a duplex data stream.
916 */
917 UV_READABLE_PIPE = 0x10,
918 UV_WRITABLE_PIPE = 0x20,
919
920 /*
921 * Open the child pipe handle in overlapped mode on Windows.
922 * On Unix it is silently ignored.
923 */
924 UV_OVERLAPPED_PIPE = 0x40
925 } uv_stdio_flags;
926
927 typedef struct uv_stdio_container_s {
928 uv_stdio_flags flags;
929
930 union {
931 uv_stream_t* stream;
932 int fd;
933 } data;
934 } uv_stdio_container_t;
935
936 typedef struct uv_process_options_s {
937 uv_exit_cb exit_cb; /* Called after the process exits. */
938 const char* file; /* Path to program to execute. */
939 /*
940 * Command line arguments. args[0] should be the path to the program. On
941 * Windows this uses CreateProcess which concatenates the arguments into a
942 * string this can cause some strange errors. See the note at
943 * windows_verbatim_arguments.
944 */
945 char** args;
946 /*
947 * This will be set as the environ variable in the subprocess. If this is
948 * NULL then the parents environ will be used.
949 */
950 char** env;
951 /*
952 * If non-null this represents a directory the subprocess should execute
953 * in. Stands for current working directory.
954 */
955 const char* cwd;
956 /*
957 * Various flags that control how uv_spawn() behaves. See the definition of
958 * `enum uv_process_flags` below.
959 */
960 unsigned int flags;
961 /*
962 * The `stdio` field points to an array of uv_stdio_container_t structs that
963 * describe the file descriptors that will be made available to the child
964 * process. The convention is that stdio[0] points to stdin, fd 1 is used for
965 * stdout, and fd 2 is stderr.
966 *
967 * Note that on windows file descriptors greater than 2 are available to the
968 * child process only if the child processes uses the MSVCRT runtime.
969 */
970 int stdio_count;
971 uv_stdio_container_t* stdio;
972 /*
973 * Libuv can change the child process' user/group id. This happens only when
974 * the appropriate bits are set in the flags fields. This is not supported on
975 * windows; uv_spawn() will fail and set the error to UV_ENOTSUP.
976 */
977 uv_uid_t uid;
978 uv_gid_t gid;
979 } uv_process_options_t;
980
981 /*
982 * These are the flags that can be used for the uv_process_options.flags field.
983 */
984 enum uv_process_flags {
985 /*
986 * Set the child process' user id. The user id is supplied in the `uid` field
987 * of the options struct. This does not work on windows; setting this flag
988 * will cause uv_spawn() to fail.
989 */
990 UV_PROCESS_SETUID = (1 << 0),
991 /*
992 * Set the child process' group id. The user id is supplied in the `gid`
993 * field of the options struct. This does not work on windows; setting this
994 * flag will cause uv_spawn() to fail.
995 */
996 UV_PROCESS_SETGID = (1 << 1),
997 /*
998 * Do not wrap any arguments in quotes, or perform any other escaping, when
999 * converting the argument list into a command line string. This option is
1000 * only meaningful on Windows systems. On Unix it is silently ignored.
1001 */
1002 UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2),
1003 /*
1004 * Spawn the child process in a detached state - this will make it a process
1005 * group leader, and will effectively enable the child to keep running after
1006 * the parent exits. Note that the child process will still keep the
1007 * parent's event loop alive unless the parent process calls uv_unref() on
1008 * the child's process handle.
1009 */
1010 UV_PROCESS_DETACHED = (1 << 3),
1011 /*
1012 * Hide the subprocess window that would normally be created. This option is
1013 * only meaningful on Windows systems. On Unix it is silently ignored.
1014 */
1015 UV_PROCESS_WINDOWS_HIDE = (1 << 4),
1016 /*
1017 * Hide the subprocess console window that would normally be created. This
1018 * option is only meaningful on Windows systems. On Unix it is silently
1019 * ignored.
1020 */
1021 UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5),
1022 /*
1023 * Hide the subprocess GUI window that would normally be created. This
1024 * option is only meaningful on Windows systems. On Unix it is silently
1025 * ignored.
1026 */
1027 UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6)
1028 };
1029
1030 /*
1031 * uv_process_t is a subclass of uv_handle_t.
1032 */
1033 struct uv_process_s {
1034 UV_HANDLE_FIELDS
1035 uv_exit_cb exit_cb;
1036 int pid;
1037 UV_PROCESS_PRIVATE_FIELDS
1038 };
1039
1040 UV_EXTERN int uv_spawn(uv_loop_t* loop,
1041 uv_process_t* handle,
1042 const uv_process_options_t* options);
1043 UV_EXTERN int uv_process_kill(uv_process_t*, int signum);
1044 UV_EXTERN int uv_kill(int pid, int signum);
1045 UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*);
1046
1047
1048 /*
1049 * uv_work_t is a subclass of uv_req_t.
1050 */
1051 struct uv_work_s {
1052 UV_REQ_FIELDS
1053 uv_loop_t* loop;
1054 uv_work_cb work_cb;
1055 uv_after_work_cb after_work_cb;
1056 UV_WORK_PRIVATE_FIELDS
1057 };
1058
1059 UV_EXTERN int uv_queue_work(uv_loop_t* loop,
1060 uv_work_t* req,
1061 uv_work_cb work_cb,
1062 uv_after_work_cb after_work_cb);
1063
1064 UV_EXTERN int uv_cancel(uv_req_t* req);
1065
1066
1067 struct uv_cpu_times_s {
1068 uint64_t user;
1069 uint64_t nice;
1070 uint64_t sys;
1071 uint64_t idle;
1072 uint64_t irq;
1073 };
1074
1075 struct uv_cpu_info_s {
1076 char* model;
1077 int speed;
1078 struct uv_cpu_times_s cpu_times;
1079 };
1080
1081 struct uv_interface_address_s {
1082 char* name;
1083 char phys_addr[6];
1084 int is_internal;
1085 union {
1086 struct sockaddr_in address4;
1087 struct sockaddr_in6 address6;
1088 } address;
1089 union {
1090 struct sockaddr_in netmask4;
1091 struct sockaddr_in6 netmask6;
1092 } netmask;
1093 };
1094
1095 struct uv_passwd_s {
1096 char* username;
1097 long uid;
1098 long gid;
1099 char* shell;
1100 char* homedir;
1101 };
1102
1103 struct uv_utsname_s {
1104 char sysname[256];
1105 char release[256];
1106 char version[256];
1107 char machine[256];
1108 /* This struct does not contain the nodename and domainname fields present in
1109 the utsname type. domainname is a GNU extension. Both fields are referred
1110 to as meaningless in the docs. */
1111 };
1112
1113 struct uv_statfs_s {
1114 uint64_t f_type;
1115 uint64_t f_bsize;
1116 uint64_t f_blocks;
1117 uint64_t f_bfree;
1118 uint64_t f_bavail;
1119 uint64_t f_files;
1120 uint64_t f_ffree;
1121 uint64_t f_spare[4];
1122 };
1123
1124 typedef enum {
1125 UV_DIRENT_UNKNOWN,
1126 UV_DIRENT_FILE,
1127 UV_DIRENT_DIR,
1128 UV_DIRENT_LINK,
1129 UV_DIRENT_FIFO,
1130 UV_DIRENT_SOCKET,
1131 UV_DIRENT_CHAR,
1132 UV_DIRENT_BLOCK
1133 } uv_dirent_type_t;
1134
1135 struct uv_dirent_s {
1136 const char* name;
1137 uv_dirent_type_t type;
1138 };
1139
1140 UV_EXTERN char** uv_setup_args(int argc, char** argv);
1141 UV_EXTERN int uv_get_process_title(char* buffer, size_t size);
1142 UV_EXTERN int uv_set_process_title(const char* title);
1143 UV_EXTERN int uv_resident_set_memory(size_t* rss);
1144 UV_EXTERN int uv_uptime(double* uptime);
1145 UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd);
1146 UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd);
1147
1148 typedef struct {
1149 long tv_sec;
1150 long tv_usec;
1151 } uv_timeval_t;
1152
1153 typedef struct {
1154 int64_t tv_sec;
1155 int32_t tv_usec;
1156 } uv_timeval64_t;
1157
1158 typedef struct {
1159 uv_timeval_t ru_utime; /* user CPU time used */
1160 uv_timeval_t ru_stime; /* system CPU time used */
1161 uint64_t ru_maxrss; /* maximum resident set size */
1162 uint64_t ru_ixrss; /* integral shared memory size */
1163 uint64_t ru_idrss; /* integral unshared data size */
1164 uint64_t ru_isrss; /* integral unshared stack size */
1165 uint64_t ru_minflt; /* page reclaims (soft page faults) */
1166 uint64_t ru_majflt; /* page faults (hard page faults) */
1167 uint64_t ru_nswap; /* swaps */
1168 uint64_t ru_inblock; /* block input operations */
1169 uint64_t ru_oublock; /* block output operations */
1170 uint64_t ru_msgsnd; /* IPC messages sent */
1171 uint64_t ru_msgrcv; /* IPC messages received */
1172 uint64_t ru_nsignals; /* signals received */
1173 uint64_t ru_nvcsw; /* voluntary context switches */
1174 uint64_t ru_nivcsw; /* involuntary context switches */
1175 } uv_rusage_t;
1176
1177 UV_EXTERN int uv_getrusage(uv_rusage_t* rusage);
1178
1179 UV_EXTERN int uv_os_homedir(char* buffer, size_t* size);
1180 UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size);
1181 UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd);
1182 UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd);
1183 UV_EXTERN uv_pid_t uv_os_getpid(void);
1184 UV_EXTERN uv_pid_t uv_os_getppid(void);
1185
1186 #define UV_PRIORITY_LOW 19
1187 #define UV_PRIORITY_BELOW_NORMAL 10
1188 #define UV_PRIORITY_NORMAL 0
1189 #define UV_PRIORITY_ABOVE_NORMAL -7
1190 #define UV_PRIORITY_HIGH -14
1191 #define UV_PRIORITY_HIGHEST -20
1192
1193 UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority);
1194 UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority);
1195
1196 UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count);
1197 UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count);
1198
1199 UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses,
1200 int* count);
1201 UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses,
1202 int count);
1203
1204 struct uv_env_item_s {
1205 char* name;
1206 char* value;
1207 };
1208
1209 UV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count);
1210 UV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count);
1211 UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size);
1212 UV_EXTERN int uv_os_setenv(const char* name, const char* value);
1213 UV_EXTERN int uv_os_unsetenv(const char* name);
1214
1215 #ifdef MAXHOSTNAMELEN
1216 # define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
1217 #else
1218 /*
1219 Fallback for the maximum hostname size, including the null terminator. The
1220 Windows gethostname() documentation states that 256 bytes will always be
1221 large enough to hold the null-terminated hostname.
1222 */
1223 # define UV_MAXHOSTNAMESIZE 256
1224 #endif
1225
1226 UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size);
1227
1228 UV_EXTERN int uv_os_uname(uv_utsname_t* buffer);
1229
1230
1231 typedef enum {
1232 UV_FS_UNKNOWN = -1,
1233 UV_FS_CUSTOM,
1234 UV_FS_OPEN,
1235 UV_FS_CLOSE,
1236 UV_FS_READ,
1237 UV_FS_WRITE,
1238 UV_FS_SENDFILE,
1239 UV_FS_STAT,
1240 UV_FS_LSTAT,
1241 UV_FS_FSTAT,
1242 UV_FS_FTRUNCATE,
1243 UV_FS_UTIME,
1244 UV_FS_FUTIME,
1245 UV_FS_ACCESS,
1246 UV_FS_CHMOD,
1247 UV_FS_FCHMOD,
1248 UV_FS_FSYNC,
1249 UV_FS_FDATASYNC,
1250 UV_FS_UNLINK,
1251 UV_FS_RMDIR,
1252 UV_FS_MKDIR,
1253 UV_FS_MKDTEMP,
1254 UV_FS_RENAME,
1255 UV_FS_SCANDIR,
1256 UV_FS_LINK,
1257 UV_FS_SYMLINK,
1258 UV_FS_READLINK,
1259 UV_FS_CHOWN,
1260 UV_FS_FCHOWN,
1261 UV_FS_REALPATH,
1262 UV_FS_COPYFILE,
1263 UV_FS_LCHOWN,
1264 UV_FS_OPENDIR,
1265 UV_FS_READDIR,
1266 UV_FS_CLOSEDIR,
1267 UV_FS_STATFS,
1268 UV_FS_MKSTEMP
1269 } uv_fs_type;
1270
1271 struct uv_dir_s {
1272 uv_dirent_t* dirents;
1273 size_t nentries;
1274 void* reserved[4];
1275 UV_DIR_PRIVATE_FIELDS
1276 };
1277
1278 /* uv_fs_t is a subclass of uv_req_t. */
1279 struct uv_fs_s {
1280 UV_REQ_FIELDS
1281 uv_fs_type fs_type;
1282 uv_loop_t* loop;
1283 uv_fs_cb cb;
1284 ssize_t result;
1285 void* ptr;
1286 const char* path;
1287 uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */
1288 UV_FS_PRIVATE_FIELDS
1289 };
1290
1291 UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*);
1292 UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*);
1293 UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*);
1294 UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*);
1295 UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*);
1296
1297 UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req);
1298 UV_EXTERN int uv_fs_close(uv_loop_t* loop,
1299 uv_fs_t* req,
1300 uv_file file,
1301 uv_fs_cb cb);
1302 UV_EXTERN int uv_fs_open(uv_loop_t* loop,
1303 uv_fs_t* req,
1304 const char* path,
1305 int flags,
1306 int mode,
1307 uv_fs_cb cb);
1308 UV_EXTERN int uv_fs_read(uv_loop_t* loop,
1309 uv_fs_t* req,
1310 uv_file file,
1311 const uv_buf_t bufs[],
1312 unsigned int nbufs,
1313 int64_t offset,
1314 uv_fs_cb cb);
1315 UV_EXTERN int uv_fs_unlink(uv_loop_t* loop,
1316 uv_fs_t* req,
1317 const char* path,
1318 uv_fs_cb cb);
1319 UV_EXTERN int uv_fs_write(uv_loop_t* loop,
1320 uv_fs_t* req,
1321 uv_file file,
1322 const uv_buf_t bufs[],
1323 unsigned int nbufs,
1324 int64_t offset,
1325 uv_fs_cb cb);
1326 /*
1327 * This flag can be used with uv_fs_copyfile() to return an error if the
1328 * destination already exists.
1329 */
1330 #define UV_FS_COPYFILE_EXCL 0x0001
1331
1332 /*
1333 * This flag can be used with uv_fs_copyfile() to attempt to create a reflink.
1334 * If copy-on-write is not supported, a fallback copy mechanism is used.
1335 */
1336 #define UV_FS_COPYFILE_FICLONE 0x0002
1337
1338 /*
1339 * This flag can be used with uv_fs_copyfile() to attempt to create a reflink.
1340 * If copy-on-write is not supported, an error is returned.
1341 */
1342 #define UV_FS_COPYFILE_FICLONE_FORCE 0x0004
1343
1344 UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop,
1345 uv_fs_t* req,
1346 const char* path,
1347 const char* new_path,
1348 int flags,
1349 uv_fs_cb cb);
1350 UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop,
1351 uv_fs_t* req,
1352 const char* path,
1353 int mode,
1354 uv_fs_cb cb);
1355 UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop,
1356 uv_fs_t* req,
1357 const char* tpl,
1358 uv_fs_cb cb);
1359 UV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop,
1360 uv_fs_t* req,
1361 const char* tpl,
1362 uv_fs_cb cb);
1363 UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop,
1364 uv_fs_t* req,
1365 const char* path,
1366 uv_fs_cb cb);
1367 UV_EXTERN int uv_fs_scandir(uv_loop_t* loop,
1368 uv_fs_t* req,
1369 const char* path,
1370 int flags,
1371 uv_fs_cb cb);
1372 UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req,
1373 uv_dirent_t* ent);
1374 UV_EXTERN int uv_fs_opendir(uv_loop_t* loop,
1375 uv_fs_t* req,
1376 const char* path,
1377 uv_fs_cb cb);
1378 UV_EXTERN int uv_fs_readdir(uv_loop_t* loop,
1379 uv_fs_t* req,
1380 uv_dir_t* dir,
1381 uv_fs_cb cb);
1382 UV_EXTERN int uv_fs_closedir(uv_loop_t* loop,
1383 uv_fs_t* req,
1384 uv_dir_t* dir,
1385 uv_fs_cb cb);
1386 UV_EXTERN int uv_fs_stat(uv_loop_t* loop,
1387 uv_fs_t* req,
1388 const char* path,
1389 uv_fs_cb cb);
1390 UV_EXTERN int uv_fs_fstat(uv_loop_t* loop,
1391 uv_fs_t* req,
1392 uv_file file,
1393 uv_fs_cb cb);
1394 UV_EXTERN int uv_fs_rename(uv_loop_t* loop,
1395 uv_fs_t* req,
1396 const char* path,
1397 const char* new_path,
1398 uv_fs_cb cb);
1399 UV_EXTERN int uv_fs_fsync(uv_loop_t* loop,
1400 uv_fs_t* req,
1401 uv_file file,
1402 uv_fs_cb cb);
1403 UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop,
1404 uv_fs_t* req,
1405 uv_file file,
1406 uv_fs_cb cb);
1407 UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop,
1408 uv_fs_t* req,
1409 uv_file file,
1410 int64_t offset,
1411 uv_fs_cb cb);
1412 UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop,
1413 uv_fs_t* req,
1414 uv_file out_fd,
1415 uv_file in_fd,
1416 int64_t in_offset,
1417 size_t length,
1418 uv_fs_cb cb);
1419 UV_EXTERN int uv_fs_access(uv_loop_t* loop,
1420 uv_fs_t* req,
1421 const char* path,
1422 int mode,
1423 uv_fs_cb cb);
1424 UV_EXTERN int uv_fs_chmod(uv_loop_t* loop,
1425 uv_fs_t* req,
1426 const char* path,
1427 int mode,
1428 uv_fs_cb cb);
1429 UV_EXTERN int uv_fs_utime(uv_loop_t* loop,
1430 uv_fs_t* req,
1431 const char* path,
1432 double atime,
1433 double mtime,
1434 uv_fs_cb cb);
1435 UV_EXTERN int uv_fs_futime(uv_loop_t* loop,
1436 uv_fs_t* req,
1437 uv_file file,
1438 double atime,
1439 double mtime,
1440 uv_fs_cb cb);
1441 UV_EXTERN int uv_fs_lstat(uv_loop_t* loop,
1442 uv_fs_t* req,
1443 const char* path,
1444 uv_fs_cb cb);
1445 UV_EXTERN int uv_fs_link(uv_loop_t* loop,
1446 uv_fs_t* req,
1447 const char* path,
1448 const char* new_path,
1449 uv_fs_cb cb);
1450
1451 /*
1452 * This flag can be used with uv_fs_symlink() on Windows to specify whether
1453 * path argument points to a directory.
1454 */
1455 #define UV_FS_SYMLINK_DIR 0x0001
1456
1457 /*
1458 * This flag can be used with uv_fs_symlink() on Windows to specify whether
1459 * the symlink is to be created using junction points.
1460 */
1461 #define UV_FS_SYMLINK_JUNCTION 0x0002
1462
1463 UV_EXTERN int uv_fs_symlink(uv_loop_t* loop,
1464 uv_fs_t* req,
1465 const char* path,
1466 const char* new_path,
1467 int flags,
1468 uv_fs_cb cb);
1469 UV_EXTERN int uv_fs_readlink(uv_loop_t* loop,
1470 uv_fs_t* req,
1471 const char* path,
1472 uv_fs_cb cb);
1473 UV_EXTERN int uv_fs_realpath(uv_loop_t* loop,
1474 uv_fs_t* req,
1475 const char* path,
1476 uv_fs_cb cb);
1477 UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop,
1478 uv_fs_t* req,
1479 uv_file file,
1480 int mode,
1481 uv_fs_cb cb);
1482 UV_EXTERN int uv_fs_chown(uv_loop_t* loop,
1483 uv_fs_t* req,
1484 const char* path,
1485 uv_uid_t uid,
1486 uv_gid_t gid,
1487 uv_fs_cb cb);
1488 UV_EXTERN int uv_fs_fchown(uv_loop_t* loop,
1489 uv_fs_t* req,
1490 uv_file file,
1491 uv_uid_t uid,
1492 uv_gid_t gid,
1493 uv_fs_cb cb);
1494 UV_EXTERN int uv_fs_lchown(uv_loop_t* loop,
1495 uv_fs_t* req,
1496 const char* path,
1497 uv_uid_t uid,
1498 uv_gid_t gid,
1499 uv_fs_cb cb);
1500 UV_EXTERN int uv_fs_statfs(uv_loop_t* loop,
1501 uv_fs_t* req,
1502 const char* path,
1503 uv_fs_cb cb);
1504
1505
1506 enum uv_fs_event {
1507 UV_RENAME = 1,
1508 UV_CHANGE = 2
1509 };
1510
1511
1512 struct uv_fs_event_s {
1513 UV_HANDLE_FIELDS
1514 /* private */
1515 char* path;
1516 UV_FS_EVENT_PRIVATE_FIELDS
1517 };
1518
1519
1520 /*
1521 * uv_fs_stat() based polling file watcher.
1522 */
1523 struct uv_fs_poll_s {
1524 UV_HANDLE_FIELDS
1525 /* Private, don't touch. */
1526 void* poll_ctx;
1527 };
1528
1529 UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle);
1530 UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle,
1531 uv_fs_poll_cb poll_cb,
1532 const char* path,
1533 unsigned int interval);
1534 UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle);
1535 UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle,
1536 char* buffer,
1537 size_t* size);
1538
1539
1540 struct uv_signal_s {
1541 UV_HANDLE_FIELDS
1542 uv_signal_cb signal_cb;
1543 int signum;
1544 UV_SIGNAL_PRIVATE_FIELDS
1545 };
1546
1547 UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle);
1548 UV_EXTERN int uv_signal_start(uv_signal_t* handle,
1549 uv_signal_cb signal_cb,
1550 int signum);
1551 UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle,
1552 uv_signal_cb signal_cb,
1553 int signum);
1554 UV_EXTERN int uv_signal_stop(uv_signal_t* handle);
1555
1556 UV_EXTERN void uv_loadavg(double avg[3]);
1557
1558
1559 /*
1560 * Flags to be passed to uv_fs_event_start().
1561 */
1562 enum uv_fs_event_flags {
1563 /*
1564 * By default, if the fs event watcher is given a directory name, we will
1565 * watch for all events in that directory. This flags overrides this behavior
1566 * and makes fs_event report only changes to the directory entry itself. This
1567 * flag does not affect individual files watched.
1568 * This flag is currently not implemented yet on any backend.
1569 */
1570 UV_FS_EVENT_WATCH_ENTRY = 1,
1571
1572 /*
1573 * By default uv_fs_event will try to use a kernel interface such as inotify
1574 * or kqueue to detect events. This may not work on remote filesystems such
1575 * as NFS mounts. This flag makes fs_event fall back to calling stat() on a
1576 * regular interval.
1577 * This flag is currently not implemented yet on any backend.
1578 */
1579 UV_FS_EVENT_STAT = 2,
1580
1581 /*
1582 * By default, event watcher, when watching directory, is not registering
1583 * (is ignoring) changes in it's subdirectories.
1584 * This flag will override this behaviour on platforms that support it.
1585 */
1586 UV_FS_EVENT_RECURSIVE = 4
1587 };
1588
1589
1590 UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle);
1591 UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle,
1592 uv_fs_event_cb cb,
1593 const char* path,
1594 unsigned int flags);
1595 UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle);
1596 UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle,
1597 char* buffer,
1598 size_t* size);
1599
1600 UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr);
1601 UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr);
1602
1603 UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size);
1604 UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size);
1605
1606 UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size);
1607 UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst);
1608
1609
1610 struct uv_random_s {
1611 UV_REQ_FIELDS
1612 /* read-only */
1613 uv_loop_t* loop;
1614 /* private */
1615 int status;
1616 void* buf;
1617 size_t buflen;
1618 uv_random_cb cb;
1619 struct uv__work work_req;
1620 };
1621
1622 UV_EXTERN int uv_random(uv_loop_t* loop,
1623 uv_random_t* req,
1624 void *buf,
1625 size_t buflen,
1626 unsigned flags, /* For future extension; must be 0. */
1627 uv_random_cb cb);
1628
1629 #if defined(IF_NAMESIZE)
1630 # define UV_IF_NAMESIZE (IF_NAMESIZE + 1)
1631 #elif defined(IFNAMSIZ)
1632 # define UV_IF_NAMESIZE (IFNAMSIZ + 1)
1633 #else
1634 # define UV_IF_NAMESIZE (16 + 1)
1635 #endif
1636
1637 UV_EXTERN int uv_if_indextoname(unsigned int ifindex,
1638 char* buffer,
1639 size_t* size);
1640 UV_EXTERN int uv_if_indextoiid(unsigned int ifindex,
1641 char* buffer,
1642 size_t* size);
1643
1644 UV_EXTERN int uv_exepath(char* buffer, size_t* size);
1645
1646 UV_EXTERN int uv_cwd(char* buffer, size_t* size);
1647
1648 UV_EXTERN int uv_chdir(const char* dir);
1649
1650 UV_EXTERN uint64_t uv_get_free_memory(void);
1651 UV_EXTERN uint64_t uv_get_total_memory(void);
1652 UV_EXTERN uint64_t uv_get_constrained_memory(void);
1653
1654 UV_EXTERN uint64_t uv_hrtime(void);
1655 UV_EXTERN void uv_sleep(unsigned int msec);
1656
1657 UV_EXTERN void uv_disable_stdio_inheritance(void);
1658
1659 UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib);
1660 UV_EXTERN void uv_dlclose(uv_lib_t* lib);
1661 UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr);
1662 UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib);
1663
1664 UV_EXTERN int uv_mutex_init(uv_mutex_t* handle);
1665 UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle);
1666 UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle);
1667 UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle);
1668 UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle);
1669 UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle);
1670
1671 UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock);
1672 UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock);
1673 UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock);
1674 UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock);
1675 UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock);
1676 UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock);
1677 UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock);
1678 UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock);
1679
1680 UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value);
1681 UV_EXTERN void uv_sem_destroy(uv_sem_t* sem);
1682 UV_EXTERN void uv_sem_post(uv_sem_t* sem);
1683 UV_EXTERN void uv_sem_wait(uv_sem_t* sem);
1684 UV_EXTERN int uv_sem_trywait(uv_sem_t* sem);
1685
1686 UV_EXTERN int uv_cond_init(uv_cond_t* cond);
1687 UV_EXTERN void uv_cond_destroy(uv_cond_t* cond);
1688 UV_EXTERN void uv_cond_signal(uv_cond_t* cond);
1689 UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond);
1690
1691 UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count);
1692 UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier);
1693 UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier);
1694
1695 UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex);
1696 UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond,
1697 uv_mutex_t* mutex,
1698 uint64_t timeout);
1699
1700 UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void));
1701
1702 UV_EXTERN int uv_key_create(uv_key_t* key);
1703 UV_EXTERN void uv_key_delete(uv_key_t* key);
1704 UV_EXTERN void* uv_key_get(uv_key_t* key);
1705 UV_EXTERN void uv_key_set(uv_key_t* key, void* value);
1706
1707 UV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv);
1708
1709 typedef void (*uv_thread_cb)(void* arg);
1710
1711 UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);
1712
1713 typedef enum {
1714 UV_THREAD_NO_FLAGS = 0x00,
1715 UV_THREAD_HAS_STACK_SIZE = 0x01
1716 } uv_thread_create_flags;
1717
1718 struct uv_thread_options_s {
1719 unsigned int flags;
1720 size_t stack_size;
1721 /* More fields may be added at any time. */
1722 };
1723
1724 typedef struct uv_thread_options_s uv_thread_options_t;
1725
1726 UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid,
1727 const uv_thread_options_t* params,
1728 uv_thread_cb entry,
1729 void* arg);
1730 UV_EXTERN uv_thread_t uv_thread_self(void);
1731 UV_EXTERN int uv_thread_join(uv_thread_t *tid);
1732 UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2);
1733
1734 /* The presence of these unions force similar struct layout. */
1735 #define XX(_, name) uv_ ## name ## _t name;
1736 union uv_any_handle {
1737 UV_HANDLE_TYPE_MAP(XX)
1738 };
1739
1740 union uv_any_req {
1741 UV_REQ_TYPE_MAP(XX)
1742 };
1743 #undef XX
1744
1745
1746 struct uv_loop_s {
1747 /* User data - use this for whatever. */
1748 void* data;
1749 /* Loop reference counting. */
1750 unsigned int active_handles;
1751 void* handle_queue[2];
1752 union {
1753 void* unused[2];
1754 unsigned int count;
1755 } active_reqs;
1756 /* Internal flag to signal loop stop. */
1757 unsigned int stop_flag;
1758 UV_LOOP_PRIVATE_FIELDS
1759 };
1760
1761 UV_EXTERN void* uv_loop_get_data(const uv_loop_t*);
1762 UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data);
1763
1764 /* Don't export the private CPP symbols. */
1765 #undef UV_HANDLE_TYPE_PRIVATE
1766 #undef UV_REQ_TYPE_PRIVATE
1767 #undef UV_REQ_PRIVATE_FIELDS
1768 #undef UV_STREAM_PRIVATE_FIELDS
1769 #undef UV_TCP_PRIVATE_FIELDS
1770 #undef UV_PREPARE_PRIVATE_FIELDS
1771 #undef UV_CHECK_PRIVATE_FIELDS
1772 #undef UV_IDLE_PRIVATE_FIELDS
1773 #undef UV_ASYNC_PRIVATE_FIELDS
1774 #undef UV_TIMER_PRIVATE_FIELDS
1775 #undef UV_GETADDRINFO_PRIVATE_FIELDS
1776 #undef UV_GETNAMEINFO_PRIVATE_FIELDS
1777 #undef UV_FS_REQ_PRIVATE_FIELDS
1778 #undef UV_WORK_PRIVATE_FIELDS
1779 #undef UV_FS_EVENT_PRIVATE_FIELDS
1780 #undef UV_SIGNAL_PRIVATE_FIELDS
1781 #undef UV_LOOP_PRIVATE_FIELDS
1782 #undef UV_LOOP_PRIVATE_PLATFORM_FIELDS
1783 #undef UV__ERR
1784
1785 #ifdef __cplusplus
1786 }
1787 #endif
1788 #endif /* UV_H */
1789