uv-win.h 30 KB

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