uv.h 58 KB

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