1
0

uv-win.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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. #ifndef _WIN32_WINNT
  22. # define _WIN32_WINNT 0x0502
  23. #endif
  24. #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
  25. typedef intptr_t ssize_t;
  26. # define _SSIZE_T_
  27. # define _SSIZE_T_DEFINED
  28. #endif
  29. #include <winsock2.h>
  30. #include <mswsock.h>
  31. #include <ws2tcpip.h>
  32. #include <windows.h>
  33. #include <process.h>
  34. #include <signal.h>
  35. #include <sys/stat.h>
  36. #if defined(_MSC_VER) && _MSC_VER < 1600
  37. # include "stdint-msvc2008.h"
  38. #else
  39. # include <stdint.h>
  40. #endif
  41. #include "tree.h"
  42. #define MAX_PIPENAME_LEN 256
  43. #ifndef S_IFLNK
  44. # define S_IFLNK 0xA000
  45. #endif
  46. /* Additional signals supported by uv_signal and or uv_kill. The CRT defines
  47. * the following signals already:
  48. *
  49. * #define SIGINT 2
  50. * #define SIGILL 4
  51. * #define SIGABRT_COMPAT 6
  52. * #define SIGFPE 8
  53. * #define SIGSEGV 11
  54. * #define SIGTERM 15
  55. * #define SIGBREAK 21
  56. * #define SIGABRT 22
  57. *
  58. * The additional signals have values that are common on other Unix
  59. * variants (Linux and Darwin)
  60. */
  61. #define SIGHUP 1
  62. #define SIGKILL 9
  63. #define SIGWINCH 28
  64. /* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */
  65. /* unix-like platforms. However MinGW doesn't define it, so we do. */
  66. #ifndef SIGABRT_COMPAT
  67. # define SIGABRT_COMPAT 6
  68. #endif
  69. /*
  70. * Guids and typedefs for winsock extension functions
  71. * Mingw32 doesn't have these :-(
  72. */
  73. #ifndef WSAID_ACCEPTEX
  74. # define WSAID_ACCEPTEX \
  75. {0xb5367df1, 0xcbac, 0x11cf, \
  76. {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
  77. # define WSAID_CONNECTEX \
  78. {0x25a207b9, 0xddf3, 0x4660, \
  79. {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}}
  80. # define WSAID_GETACCEPTEXSOCKADDRS \
  81. {0xb5367df2, 0xcbac, 0x11cf, \
  82. {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
  83. # define WSAID_DISCONNECTEX \
  84. {0x7fda2e11, 0x8630, 0x436f, \
  85. {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
  86. # define WSAID_TRANSMITFILE \
  87. {0xb5367df0, 0xcbac, 0x11cf, \
  88. {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
  89. typedef BOOL PASCAL (*LPFN_ACCEPTEX)
  90. (SOCKET sListenSocket,
  91. SOCKET sAcceptSocket,
  92. PVOID lpOutputBuffer,
  93. DWORD dwReceiveDataLength,
  94. DWORD dwLocalAddressLength,
  95. DWORD dwRemoteAddressLength,
  96. LPDWORD lpdwBytesReceived,
  97. LPOVERLAPPED lpOverlapped);
  98. typedef BOOL PASCAL (*LPFN_CONNECTEX)
  99. (SOCKET s,
  100. const struct sockaddr* name,
  101. int namelen,
  102. PVOID lpSendBuffer,
  103. DWORD dwSendDataLength,
  104. LPDWORD lpdwBytesSent,
  105. LPOVERLAPPED lpOverlapped);
  106. typedef void PASCAL (*LPFN_GETACCEPTEXSOCKADDRS)
  107. (PVOID lpOutputBuffer,
  108. DWORD dwReceiveDataLength,
  109. DWORD dwLocalAddressLength,
  110. DWORD dwRemoteAddressLength,
  111. LPSOCKADDR* LocalSockaddr,
  112. LPINT LocalSockaddrLength,
  113. LPSOCKADDR* RemoteSockaddr,
  114. LPINT RemoteSockaddrLength);
  115. typedef BOOL PASCAL (*LPFN_DISCONNECTEX)
  116. (SOCKET hSocket,
  117. LPOVERLAPPED lpOverlapped,
  118. DWORD dwFlags,
  119. DWORD reserved);
  120. typedef BOOL PASCAL (*LPFN_TRANSMITFILE)
  121. (SOCKET hSocket,
  122. HANDLE hFile,
  123. DWORD nNumberOfBytesToWrite,
  124. DWORD nNumberOfBytesPerSend,
  125. LPOVERLAPPED lpOverlapped,
  126. LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
  127. DWORD dwFlags);
  128. typedef PVOID RTL_SRWLOCK;
  129. typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
  130. #endif
  131. typedef int (WSAAPI* LPFN_WSARECV)
  132. (SOCKET socket,
  133. LPWSABUF buffers,
  134. DWORD buffer_count,
  135. LPDWORD bytes,
  136. LPDWORD flags,
  137. LPWSAOVERLAPPED overlapped,
  138. LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
  139. typedef int (WSAAPI* LPFN_WSARECVFROM)
  140. (SOCKET socket,
  141. LPWSABUF buffers,
  142. DWORD buffer_count,
  143. LPDWORD bytes,
  144. LPDWORD flags,
  145. struct sockaddr* addr,
  146. LPINT addr_len,
  147. LPWSAOVERLAPPED overlapped,
  148. LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
  149. #ifndef _NTDEF_
  150. typedef LONG NTSTATUS;
  151. typedef NTSTATUS *PNTSTATUS;
  152. #endif
  153. #ifndef RTL_CONDITION_VARIABLE_INIT
  154. typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE;
  155. #endif
  156. typedef struct _AFD_POLL_HANDLE_INFO {
  157. HANDLE Handle;
  158. ULONG Events;
  159. NTSTATUS Status;
  160. } AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO;
  161. typedef struct _AFD_POLL_INFO {
  162. LARGE_INTEGER Timeout;
  163. ULONG NumberOfHandles;
  164. ULONG Exclusive;
  165. AFD_POLL_HANDLE_INFO Handles[1];
  166. } AFD_POLL_INFO, *PAFD_POLL_INFO;
  167. #define UV_MSAFD_PROVIDER_COUNT 3
  168. /**
  169. * It should be possible to cast uv_buf_t[] to WSABUF[]
  170. * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
  171. */
  172. typedef struct uv_buf_t {
  173. ULONG len;
  174. char* base;
  175. } uv_buf_t;
  176. typedef int uv_file;
  177. typedef SOCKET uv_os_sock_t;
  178. typedef HANDLE uv_os_file_t;
  179. typedef HANDLE uv_thread_t;
  180. typedef HANDLE uv_sem_t;
  181. typedef CRITICAL_SECTION uv_mutex_t;
  182. /* This condition variable implementation is based on the SetEvent solution
  183. * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
  184. * We could not use the SignalObjectAndWait solution (section 3.4) because
  185. * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and
  186. * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs.
  187. */
  188. typedef union {
  189. CONDITION_VARIABLE cond_var;
  190. struct {
  191. unsigned int waiters_count;
  192. CRITICAL_SECTION waiters_count_lock;
  193. HANDLE signal_event;
  194. HANDLE broadcast_event;
  195. } fallback;
  196. } uv_cond_t;
  197. typedef union {
  198. /* srwlock_ has type SRWLOCK, but not all toolchains define this type in */
  199. /* windows.h. */
  200. SRWLOCK srwlock_;
  201. struct {
  202. uv_mutex_t read_mutex_;
  203. uv_mutex_t write_mutex_;
  204. unsigned int num_readers_;
  205. } fallback_;
  206. } uv_rwlock_t;
  207. typedef struct {
  208. unsigned int n;
  209. unsigned int count;
  210. uv_mutex_t mutex;
  211. uv_sem_t turnstile1;
  212. uv_sem_t turnstile2;
  213. } uv_barrier_t;
  214. typedef struct {
  215. DWORD tls_index;
  216. } uv_key_t;
  217. #define UV_ONCE_INIT { 0, NULL }
  218. typedef struct uv_once_s {
  219. unsigned char ran;
  220. HANDLE event;
  221. } uv_once_t;
  222. /* Platform-specific definitions for uv_spawn support. */
  223. typedef unsigned char uv_uid_t;
  224. typedef unsigned char uv_gid_t;
  225. /* Platform-specific definitions for uv_dlopen support. */
  226. #define UV_DYNAMIC FAR WINAPI
  227. typedef struct {
  228. HMODULE handle;
  229. char* errmsg;
  230. } uv_lib_t;
  231. RB_HEAD(uv_timer_tree_s, uv_timer_s);
  232. #define UV_LOOP_PRIVATE_FIELDS \
  233. /* The loop's I/O completion port */ \
  234. HANDLE iocp; \
  235. /* The current time according to the event loop. in msecs. */ \
  236. uint64_t time; \
  237. /* GetTickCount() result when the event loop time was last updated. */ \
  238. DWORD last_tick_count; \
  239. /* Tail of a single-linked circular queue of pending reqs. If the queue */ \
  240. /* is empty, tail_ is NULL. If there is only one item, */ \
  241. /* tail_->next_req == tail_ */ \
  242. uv_req_t* pending_reqs_tail; \
  243. /* Head of a single-linked list of closed handles */ \
  244. uv_handle_t* endgame_handles; \
  245. /* The head of the timers tree */ \
  246. struct uv_timer_tree_s timers; \
  247. /* Lists of active loop (prepare / check / idle) watchers */ \
  248. uv_prepare_t* prepare_handles; \
  249. uv_check_t* check_handles; \
  250. uv_idle_t* idle_handles; \
  251. /* This pointer will refer to the prepare/check/idle handle whose */ \
  252. /* callback is scheduled to be called next. This is needed to allow */ \
  253. /* safe removal from one of the lists above while that list being */ \
  254. /* iterated over. */ \
  255. uv_prepare_t* next_prepare_handle; \
  256. uv_check_t* next_check_handle; \
  257. uv_idle_t* next_idle_handle; \
  258. /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \
  259. SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \
  260. /* Counter to keep track of active tcp streams */ \
  261. unsigned int active_tcp_streams; \
  262. /* Counter to keep track of active udp streams */ \
  263. unsigned int active_udp_streams; \
  264. /* Counter to started timer */ \
  265. uint64_t timer_counter;
  266. #define UV_REQ_TYPE_PRIVATE \
  267. /* TODO: remove the req suffix */ \
  268. UV_ACCEPT, \
  269. UV_FS_EVENT_REQ, \
  270. UV_POLL_REQ, \
  271. UV_PROCESS_EXIT, \
  272. UV_READ, \
  273. UV_UDP_RECV, \
  274. UV_WAKEUP, \
  275. UV_SIGNAL_REQ, \
  276. UV_IOCP_REQ,
  277. #define UV_REQ_PRIVATE_FIELDS \
  278. union { \
  279. /* Used by I/O operations */ \
  280. struct { \
  281. OVERLAPPED overlapped; \
  282. size_t queued_bytes; \
  283. }; \
  284. }; \
  285. struct uv_req_s* next_req;
  286. #define UV_WRITE_PRIVATE_FIELDS \
  287. int ipc_header; \
  288. uv_buf_t write_buffer; \
  289. HANDLE event_handle; \
  290. HANDLE wait_handle;
  291. #define UV_CONNECT_PRIVATE_FIELDS \
  292. /* empty */
  293. #define UV_SHUTDOWN_PRIVATE_FIELDS \
  294. /* empty */
  295. #define UV_UDP_SEND_PRIVATE_FIELDS \
  296. /* empty */
  297. #define UV_PRIVATE_REQ_TYPES \
  298. typedef struct uv_pipe_accept_s { \
  299. UV_REQ_FIELDS \
  300. HANDLE pipeHandle; \
  301. struct uv_pipe_accept_s* next_pending; \
  302. } uv_pipe_accept_t; \
  303. \
  304. typedef struct uv_tcp_accept_s { \
  305. UV_REQ_FIELDS \
  306. SOCKET accept_socket; \
  307. char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \
  308. HANDLE event_handle; \
  309. HANDLE wait_handle; \
  310. struct uv_tcp_accept_s* next_pending; \
  311. } uv_tcp_accept_t; \
  312. \
  313. typedef struct uv_read_s { \
  314. UV_REQ_FIELDS \
  315. HANDLE event_handle; \
  316. HANDLE wait_handle; \
  317. } uv_read_t;
  318. #define uv_stream_connection_fields \
  319. unsigned int write_reqs_pending; \
  320. uv_shutdown_t* shutdown_req;
  321. #define uv_stream_server_fields \
  322. uv_connection_cb connection_cb;
  323. #define UV_STREAM_PRIVATE_FIELDS \
  324. unsigned int reqs_pending; \
  325. int activecnt; \
  326. uv_read_t read_req; \
  327. union { \
  328. struct { uv_stream_connection_fields }; \
  329. struct { uv_stream_server_fields }; \
  330. };
  331. #define uv_tcp_server_fields \
  332. uv_tcp_accept_t* accept_reqs; \
  333. unsigned int processed_accepts; \
  334. uv_tcp_accept_t* pending_accepts; \
  335. LPFN_ACCEPTEX func_acceptex;
  336. #define uv_tcp_connection_fields \
  337. uv_buf_t read_buffer; \
  338. LPFN_CONNECTEX func_connectex;
  339. #define UV_TCP_PRIVATE_FIELDS \
  340. SOCKET socket; \
  341. int bind_error; \
  342. union { \
  343. struct { uv_tcp_server_fields }; \
  344. struct { uv_tcp_connection_fields }; \
  345. };
  346. #define UV_UDP_PRIVATE_FIELDS \
  347. SOCKET socket; \
  348. unsigned int reqs_pending; \
  349. int activecnt; \
  350. uv_req_t recv_req; \
  351. uv_buf_t recv_buffer; \
  352. struct sockaddr_storage recv_from; \
  353. int recv_from_len; \
  354. uv_udp_recv_cb recv_cb; \
  355. uv_alloc_cb alloc_cb; \
  356. LPFN_WSARECV func_wsarecv; \
  357. LPFN_WSARECVFROM func_wsarecvfrom;
  358. #define uv_pipe_server_fields \
  359. int pending_instances; \
  360. uv_pipe_accept_t* accept_reqs; \
  361. uv_pipe_accept_t* pending_accepts;
  362. #define uv_pipe_connection_fields \
  363. uv_timer_t* eof_timer; \
  364. uv_write_t ipc_header_write_req; \
  365. int ipc_pid; \
  366. uint64_t remaining_ipc_rawdata_bytes; \
  367. unsigned char reserved[sizeof(void*)]; \
  368. struct { \
  369. WSAPROTOCOL_INFOW* socket_info; \
  370. int tcp_connection; \
  371. } pending_ipc_info; \
  372. uv_write_t* non_overlapped_writes_tail;
  373. #define UV_PIPE_PRIVATE_FIELDS \
  374. HANDLE handle; \
  375. WCHAR* name; \
  376. union { \
  377. struct { uv_pipe_server_fields }; \
  378. struct { uv_pipe_connection_fields }; \
  379. };
  380. #define UV_IOCP_PRIVATE_FIELDS \
  381. HANDLE handle; \
  382. OVERLAPPED ol; \
  383. uv_req_t req; \
  384. int activecnt; \
  385. /* TODO: put the parser states in an union - TTY handles are always */
  386. /* half-duplex so read-state can safely overlap write-state. */
  387. #define UV_TTY_PRIVATE_FIELDS \
  388. HANDLE handle; \
  389. union { \
  390. struct { \
  391. /* Used for readable TTY handles */ \
  392. HANDLE read_line_handle; \
  393. uv_buf_t read_line_buffer; \
  394. HANDLE read_raw_wait; \
  395. /* Fields used for translating win keystrokes into vt100 characters */ \
  396. char last_key[8]; \
  397. unsigned char last_key_offset; \
  398. unsigned char last_key_len; \
  399. WCHAR last_utf16_high_surrogate; \
  400. INPUT_RECORD last_input_record; \
  401. }; \
  402. struct { \
  403. /* Used for writable TTY handles */ \
  404. /* utf8-to-utf16 conversion state */ \
  405. unsigned int utf8_codepoint; \
  406. unsigned char utf8_bytes_left; \
  407. /* eol conversion state */ \
  408. unsigned char previous_eol; \
  409. /* ansi parser state */ \
  410. unsigned char ansi_parser_state; \
  411. unsigned char ansi_csi_argc; \
  412. unsigned short ansi_csi_argv[4]; \
  413. COORD saved_position; \
  414. WORD saved_attributes; \
  415. }; \
  416. };
  417. #define UV_POLL_PRIVATE_FIELDS \
  418. SOCKET socket; \
  419. /* Used in fast mode */ \
  420. SOCKET peer_socket; \
  421. AFD_POLL_INFO afd_poll_info_1; \
  422. AFD_POLL_INFO afd_poll_info_2; \
  423. /* Used in fast and slow mode. */ \
  424. uv_req_t poll_req_1; \
  425. uv_req_t poll_req_2; \
  426. unsigned char submitted_events_1; \
  427. unsigned char submitted_events_2; \
  428. unsigned char mask_events_1; \
  429. unsigned char mask_events_2; \
  430. unsigned char events;
  431. #define UV_TIMER_PRIVATE_FIELDS \
  432. RB_ENTRY(uv_timer_s) tree_entry; \
  433. uint64_t due; \
  434. uint64_t repeat; \
  435. uint64_t start_id; \
  436. uv_timer_cb timer_cb;
  437. #define UV_ASYNC_PRIVATE_FIELDS \
  438. struct uv_req_s async_req; \
  439. uv_async_cb async_cb; \
  440. /* char to avoid alignment issues */ \
  441. char volatile async_sent;
  442. #define UV_PREPARE_PRIVATE_FIELDS \
  443. uv_prepare_t* prepare_prev; \
  444. uv_prepare_t* prepare_next; \
  445. uv_prepare_cb prepare_cb;
  446. #define UV_CHECK_PRIVATE_FIELDS \
  447. uv_check_t* check_prev; \
  448. uv_check_t* check_next; \
  449. uv_check_cb check_cb;
  450. #define UV_IDLE_PRIVATE_FIELDS \
  451. uv_idle_t* idle_prev; \
  452. uv_idle_t* idle_next; \
  453. uv_idle_cb idle_cb;
  454. #define UV_HANDLE_PRIVATE_FIELDS \
  455. uv_handle_t* endgame_next; \
  456. unsigned int flags;
  457. #define UV_GETADDRINFO_PRIVATE_FIELDS \
  458. uv_getaddrinfo_cb getaddrinfo_cb; \
  459. void* alloc; \
  460. WCHAR* node; \
  461. WCHAR* service; \
  462. struct addrinfoW* hints; \
  463. struct addrinfoW* res; \
  464. int retcode;
  465. #define UV_PROCESS_PRIVATE_FIELDS \
  466. struct uv_process_exit_s { \
  467. UV_REQ_FIELDS \
  468. } exit_req; \
  469. BYTE* child_stdio_buffer; \
  470. int exit_signal; \
  471. HANDLE wait_handle; \
  472. HANDLE process_handle; \
  473. volatile char exit_cb_pending;
  474. #define UV_FS_PRIVATE_FIELDS \
  475. int flags; \
  476. DWORD sys_errno_; \
  477. union { \
  478. /* TODO: remove me in 0.9. */ \
  479. WCHAR* pathw; \
  480. int fd; \
  481. }; \
  482. union { \
  483. struct { \
  484. int mode; \
  485. WCHAR* new_pathw; \
  486. int file_flags; \
  487. int fd_out; \
  488. void* buf; \
  489. size_t length; \
  490. int64_t offset; \
  491. }; \
  492. struct { \
  493. double atime; \
  494. double mtime; \
  495. }; \
  496. };
  497. #define UV_WORK_PRIVATE_FIELDS \
  498. #define UV_FS_EVENT_PRIVATE_FIELDS \
  499. struct uv_fs_event_req_s { \
  500. UV_REQ_FIELDS \
  501. } req; \
  502. HANDLE dir_handle; \
  503. int req_pending; \
  504. uv_fs_event_cb cb; \
  505. WCHAR* filew; \
  506. WCHAR* short_filew; \
  507. WCHAR* dirw; \
  508. char* buffer;
  509. #define UV_SIGNAL_PRIVATE_FIELDS \
  510. RB_ENTRY(uv_signal_s) tree_entry; \
  511. struct uv_req_s signal_req; \
  512. unsigned long pending_signum;
  513. int uv_utf16_to_utf8(const WCHAR* utf16Buffer, size_t utf16Size,
  514. char* utf8Buffer, size_t utf8Size);
  515. int uv_utf8_to_utf16(const char* utf8Buffer, WCHAR* utf16Buffer,
  516. size_t utf16Size);
  517. #define UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS