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