1 /* Copyright Joyent, Inc. and other Node contributors. All rights reserved. 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a copy 4 * of this software and associated documentation files (the "Software"), to 5 * deal in the Software without restriction, including without limitation the 6 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 * sell copies of the Software, and to permit persons to whom the Software is 8 * furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 * IN THE SOFTWARE. 20 */ 21 22 #ifndef _WIN32_WINNT 23 # define _WIN32_WINNT 0x0600 24 #endif 25 26 #if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) 27 typedef intptr_t ssize_t; 28 # define SSIZE_MAX INTPTR_MAX 29 # define _SSIZE_T_ 30 # define _SSIZE_T_DEFINED 31 #endif 32 33 #include <winsock2.h> 34 35 #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) 36 typedef struct pollfd { 37 SOCKET fd; 38 short events; 39 short revents; 40 } WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; 41 #endif 42 43 #ifndef LOCALE_INVARIANT 44 # define LOCALE_INVARIANT 0x007f 45 #endif 46 47 #include <mswsock.h> 48 // Disable the typedef in mstcpip.h of MinGW. 49 #define _TCP_INITIAL_RTO_PARAMETERS _TCP_INITIAL_RTO_PARAMETERS__AVOID 50 #define TCP_INITIAL_RTO_PARAMETERS TCP_INITIAL_RTO_PARAMETERS__AVOID 51 #define PTCP_INITIAL_RTO_PARAMETERS PTCP_INITIAL_RTO_PARAMETERS__AVOID 52 #include <ws2tcpip.h> 53 #undef _TCP_INITIAL_RTO_PARAMETERS 54 #undef TCP_INITIAL_RTO_PARAMETERS 55 #undef PTCP_INITIAL_RTO_PARAMETERS 56 #include <windows.h> 57 58 #include <process.h> 59 #include <signal.h> 60 #include <fcntl.h> 61 #include <sys/stat.h> 62 63 #if defined(_MSC_VER) && _MSC_VER < 1600 64 # include "uv/stdint-msvc2008.h" 65 #else 66 # include <stdint.h> 67 #endif 68 69 #include "uv/tree.h" 70 #include "uv/threadpool.h" 71 72 #define MAX_PIPENAME_LEN 256 73 74 #ifndef S_IFLNK 75 # define S_IFLNK 0xA000 76 #endif 77 78 /* Additional signals supported by uv_signal and or uv_kill. The CRT defines 79 * the following signals already: 80 * 81 * #define SIGINT 2 82 * #define SIGILL 4 83 * #define SIGABRT_COMPAT 6 84 * #define SIGFPE 8 85 * #define SIGSEGV 11 86 * #define SIGTERM 15 87 * #define SIGBREAK 21 88 * #define SIGABRT 22 89 * 90 * The additional signals have values that are common on other Unix 91 * variants (Linux and Darwin) 92 */ 93 #define SIGHUP 1 94 #define SIGKILL 9 95 #define SIGWINCH 28 96 97 /* Redefine NSIG to take SIGWINCH into consideration */ 98 #if defined(NSIG) && NSIG <= SIGWINCH 99 # undef NSIG 100 #endif 101 #ifndef NSIG 102 # define NSIG SIGWINCH + 1 103 #endif 104 105 /* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many unix-like 106 * platforms. However MinGW doesn't define it, so we do. */ 107 #ifndef SIGABRT_COMPAT 108 # define SIGABRT_COMPAT 6 109 #endif 110 111 /* 112 * Guids and typedefs for winsock extension functions 113 * Mingw32 doesn't have these :-( 114 */ 115 #ifndef WSAID_ACCEPTEX 116 # define WSAID_ACCEPTEX \ 117 {0xb5367df1, 0xcbac, 0x11cf, \ 118 {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} 119 120 # define WSAID_CONNECTEX \ 121 {0x25a207b9, 0xddf3, 0x4660, \ 122 {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} 123 124 # define WSAID_GETACCEPTEXSOCKADDRS \ 125 {0xb5367df2, 0xcbac, 0x11cf, \ 126 {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} 127 128 # define WSAID_DISCONNECTEX \ 129 {0x7fda2e11, 0x8630, 0x436f, \ 130 {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}} 131 132 # define WSAID_TRANSMITFILE \ 133 {0xb5367df0, 0xcbac, 0x11cf, \ 134 {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} 135 136 typedef BOOL (PASCAL *LPFN_ACCEPTEX) 137 (SOCKET sListenSocket, 138 SOCKET sAcceptSocket, 139 PVOID lpOutputBuffer, 140 DWORD dwReceiveDataLength, 141 DWORD dwLocalAddressLength, 142 DWORD dwRemoteAddressLength, 143 LPDWORD lpdwBytesReceived, 144 LPOVERLAPPED lpOverlapped); 145 146 typedef BOOL (PASCAL *LPFN_CONNECTEX) 147 (SOCKET s, 148 const struct sockaddr* name, 149 int namelen, 150 PVOID lpSendBuffer, 151 DWORD dwSendDataLength, 152 LPDWORD lpdwBytesSent, 153 LPOVERLAPPED lpOverlapped); 154 155 typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS) 156 (PVOID lpOutputBuffer, 157 DWORD dwReceiveDataLength, 158 DWORD dwLocalAddressLength, 159 DWORD dwRemoteAddressLength, 160 LPSOCKADDR* LocalSockaddr, 161 LPINT LocalSockaddrLength, 162 LPSOCKADDR* RemoteSockaddr, 163 LPINT RemoteSockaddrLength); 164 165 typedef BOOL (PASCAL *LPFN_DISCONNECTEX) 166 (SOCKET hSocket, 167 LPOVERLAPPED lpOverlapped, 168 DWORD dwFlags, 169 DWORD reserved); 170 171 typedef BOOL (PASCAL *LPFN_TRANSMITFILE) 172 (SOCKET hSocket, 173 HANDLE hFile, 174 DWORD nNumberOfBytesToWrite, 175 DWORD nNumberOfBytesPerSend, 176 LPOVERLAPPED lpOverlapped, 177 LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, 178 DWORD dwFlags); 179 180 typedef PVOID RTL_SRWLOCK; 181 typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK; 182 #endif 183 184 typedef int (WSAAPI* LPFN_WSARECV) 185 (SOCKET socket, 186 LPWSABUF buffers, 187 DWORD buffer_count, 188 LPDWORD bytes, 189 LPDWORD flags, 190 LPWSAOVERLAPPED overlapped, 191 LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); 192 193 typedef int (WSAAPI* LPFN_WSARECVFROM) 194 (SOCKET socket, 195 LPWSABUF buffers, 196 DWORD buffer_count, 197 LPDWORD bytes, 198 LPDWORD flags, 199 struct sockaddr* addr, 200 LPINT addr_len, 201 LPWSAOVERLAPPED overlapped, 202 LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); 203 204 #ifndef _NTDEF_ 205 typedef LONG NTSTATUS; 206 typedef NTSTATUS *PNTSTATUS; 207 #endif 208 209 #ifndef RTL_CONDITION_VARIABLE_INIT 210 typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; 211 #endif 212 213 typedef struct _AFD_POLL_HANDLE_INFO { 214 HANDLE Handle; 215 ULONG Events; 216 NTSTATUS Status; 217 } AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO; 218 219 typedef struct _AFD_POLL_INFO { 220 LARGE_INTEGER Timeout; 221 ULONG NumberOfHandles; 222 ULONG Exclusive; 223 AFD_POLL_HANDLE_INFO Handles[1]; 224 } AFD_POLL_INFO, *PAFD_POLL_INFO; 225 226 #define UV_MSAFD_PROVIDER_COUNT 4 227 228 229 /** 230 * It should be possible to cast uv_buf_t[] to WSABUF[] 231 * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx 232 */ 233 typedef struct uv_buf_t { 234 ULONG len; 235 char* base; 236 } uv_buf_t; 237 238 typedef int uv_file; 239 typedef SOCKET uv_os_sock_t; 240 typedef HANDLE uv_os_fd_t; 241 typedef int uv_pid_t; 242 243 typedef HANDLE uv_thread_t; 244 245 typedef HANDLE uv_sem_t; 246 247 typedef CRITICAL_SECTION uv_mutex_t; 248 249 /* This condition variable implementation is based on the SetEvent solution 250 * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html 251 * We could not use the SignalObjectAndWait solution (section 3.4) because 252 * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and 253 * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. 254 */ 255 256 typedef union { 257 CONDITION_VARIABLE cond_var; 258 struct { 259 unsigned int waiters_count; 260 CRITICAL_SECTION waiters_count_lock; 261 HANDLE signal_event; 262 HANDLE broadcast_event; 263 } unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */ 264 } uv_cond_t; 265 266 typedef struct { 267 SRWLOCK read_write_lock_; 268 /* TODO: retained for ABI compatibility; remove me in v2.x */ 269 #ifdef _WIN64 270 unsigned char padding_[72]; 271 #else 272 unsigned char padding_[44]; 273 #endif 274 } uv_rwlock_t; 275 276 typedef struct { 277 unsigned int n; 278 unsigned int count; 279 uv_mutex_t mutex; 280 uv_sem_t turnstile1; 281 uv_sem_t turnstile2; 282 } uv_barrier_t; 283 284 typedef struct { 285 DWORD tls_index; 286 } uv_key_t; 287 288 #define UV_ONCE_INIT { 0, NULL } 289 290 typedef struct uv_once_s { 291 unsigned char ran; 292 HANDLE event; 293 } uv_once_t; 294 295 /* Platform-specific definitions for uv_spawn support. */ 296 typedef unsigned char uv_uid_t; 297 typedef unsigned char uv_gid_t; 298 299 typedef struct uv__dirent_s { 300 int d_type; 301 char d_name[1]; 302 } uv__dirent_t; 303 304 #define UV_DIR_PRIVATE_FIELDS \ 305 HANDLE dir_handle; \ 306 WIN32_FIND_DATAW find_data; \ 307 BOOL need_find_call; 308 309 #define HAVE_DIRENT_TYPES 310 #define UV__DT_DIR UV_DIRENT_DIR 311 #define UV__DT_FILE UV_DIRENT_FILE 312 #define UV__DT_LINK UV_DIRENT_LINK 313 #define UV__DT_FIFO UV_DIRENT_FIFO 314 #define UV__DT_SOCKET UV_DIRENT_SOCKET 315 #define UV__DT_CHAR UV_DIRENT_CHAR 316 #define UV__DT_BLOCK UV_DIRENT_BLOCK 317 318 /* Platform-specific definitions for uv_dlopen support. */ 319 #define UV_DYNAMIC FAR WINAPI 320 typedef struct { 321 HMODULE handle; 322 char* errmsg; 323 } uv_lib_t; 324 325 #define UV_LOOP_PRIVATE_FIELDS \ 326 /* The loop's I/O completion port */ \ 327 HANDLE iocp; \ 328 /* The current time according to the event loop. in msecs. */ \ 329 uint64_t time; \ 330 /* Tail of a single-linked circular queue of pending reqs. If the queue */ \ 331 /* is empty, tail_ is NULL. If there is only one item, */ \ 332 /* tail_->next_req == tail_ */ \ 333 uv_req_t* pending_reqs_tail; \ 334 /* Head of a single-linked list of closed handles */ \ 335 uv_handle_t* endgame_handles; \ 336 /* TODO(bnoordhuis) Stop heap-allocating |timer_heap| in libuv v2.x. */ \ 337 void* timer_heap; \ 338 /* Lists of active loop (prepare / check / idle) watchers */ \ 339 uv_prepare_t* prepare_handles; \ 340 uv_check_t* check_handles; \ 341 uv_idle_t* idle_handles; \ 342 /* This pointer will refer to the prepare/check/idle handle whose */ \ 343 /* callback is scheduled to be called next. This is needed to allow */ \ 344 /* safe removal from one of the lists above while that list being */ \ 345 /* iterated over. */ \ 346 uv_prepare_t* next_prepare_handle; \ 347 uv_check_t* next_check_handle; \ 348 uv_idle_t* next_idle_handle; \ 349 /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \ 350 SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \ 351 /* Counter to keep track of active tcp streams */ \ 352 unsigned int active_tcp_streams; \ 353 /* Counter to keep track of active udp streams */ \ 354 unsigned int active_udp_streams; \ 355 /* Counter to started timer */ \ 356 uint64_t timer_counter; \ 357 /* Threadpool */ \ 358 void* wq[2]; \ 359 uv_mutex_t wq_mutex; \ 360 uv_async_t wq_async; 361 362 #define UV_REQ_TYPE_PRIVATE \ 363 /* TODO: remove the req suffix */ \ 364 UV_ACCEPT, \ 365 UV_FS_EVENT_REQ, \ 366 UV_POLL_REQ, \ 367 UV_PROCESS_EXIT, \ 368 UV_READ, \ 369 UV_UDP_RECV, \ 370 UV_WAKEUP, \ 371 UV_SIGNAL_REQ, 372 373 #define UV_REQ_PRIVATE_FIELDS \ 374 union { \ 375 /* Used by I/O operations */ \ 376 struct { \ 377 OVERLAPPED overlapped; \ 378 size_t queued_bytes; \ 379 } io; \ 380 } u; \ 381 struct uv_req_s* next_req; 382 383 #define UV_WRITE_PRIVATE_FIELDS \ 384 int coalesced; \ 385 uv_buf_t write_buffer; \ 386 HANDLE event_handle; \ 387 HANDLE wait_handle; 388 389 #define UV_CONNECT_PRIVATE_FIELDS \ 390 /* empty */ 391 392 #define UV_SHUTDOWN_PRIVATE_FIELDS \ 393 /* empty */ 394 395 #define UV_UDP_SEND_PRIVATE_FIELDS \ 396 /* empty */ 397 398 #define UV_PRIVATE_REQ_TYPES \ 399 typedef struct uv_pipe_accept_s { \ 400 UV_REQ_FIELDS \ 401 HANDLE pipeHandle; \ 402 struct uv_pipe_accept_s* next_pending; \ 403 } uv_pipe_accept_t; \ 404 \ 405 typedef struct uv_tcp_accept_s { \ 406 UV_REQ_FIELDS \ 407 SOCKET accept_socket; \ 408 char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \ 409 HANDLE event_handle; \ 410 HANDLE wait_handle; \ 411 struct uv_tcp_accept_s* next_pending; \ 412 } uv_tcp_accept_t; \ 413 \ 414 typedef struct uv_read_s { \ 415 UV_REQ_FIELDS \ 416 HANDLE event_handle; \ 417 HANDLE wait_handle; \ 418 } uv_read_t; 419 420 #define uv_stream_connection_fields \ 421 unsigned int write_reqs_pending; \ 422 uv_shutdown_t* shutdown_req; 423 424 #define uv_stream_server_fields \ 425 uv_connection_cb connection_cb; 426 427 #define UV_STREAM_PRIVATE_FIELDS \ 428 unsigned int reqs_pending; \ 429 int activecnt; \ 430 uv_read_t read_req; \ 431 union { \ 432 struct { uv_stream_connection_fields } conn; \ 433 struct { uv_stream_server_fields } serv; \ 434 } stream; 435 436 #define uv_tcp_server_fields \ 437 uv_tcp_accept_t* accept_reqs; \ 438 unsigned int processed_accepts; \ 439 uv_tcp_accept_t* pending_accepts; \ 440 LPFN_ACCEPTEX func_acceptex; 441 442 #define uv_tcp_connection_fields \ 443 uv_buf_t read_buffer; \ 444 LPFN_CONNECTEX func_connectex; 445 446 #define UV_TCP_PRIVATE_FIELDS \ 447 SOCKET socket; \ 448 int delayed_error; \ 449 union { \ 450 struct { uv_tcp_server_fields } serv; \ 451 struct { uv_tcp_connection_fields } conn; \ 452 } tcp; 453 454 #define UV_UDP_PRIVATE_FIELDS \ 455 SOCKET socket; \ 456 unsigned int reqs_pending; \ 457 int activecnt; \ 458 uv_req_t recv_req; \ 459 uv_buf_t recv_buffer; \ 460 struct sockaddr_storage recv_from; \ 461 int recv_from_len; \ 462 uv_udp_recv_cb recv_cb; \ 463 uv_alloc_cb alloc_cb; \ 464 LPFN_WSARECV func_wsarecv; \ 465 LPFN_WSARECVFROM func_wsarecvfrom; 466 467 #define uv_pipe_server_fields \ 468 int pending_instances; \ 469 uv_pipe_accept_t* accept_reqs; \ 470 uv_pipe_accept_t* pending_accepts; 471 472 #define uv_pipe_connection_fields \ 473 uv_timer_t* eof_timer; \ 474 uv_write_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ 475 DWORD ipc_remote_pid; \ 476 union { \ 477 uint32_t payload_remaining; \ 478 uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \ 479 } ipc_data_frame; \ 480 void* ipc_xfer_queue[2]; \ 481 int ipc_xfer_queue_length; \ 482 uv_write_t* non_overlapped_writes_tail; \ 483 CRITICAL_SECTION readfile_thread_lock; \ 484 volatile HANDLE readfile_thread_handle; 485 486 #define UV_PIPE_PRIVATE_FIELDS \ 487 HANDLE handle; \ 488 WCHAR* name; \ 489 union { \ 490 struct { uv_pipe_server_fields } serv; \ 491 struct { uv_pipe_connection_fields } conn; \ 492 } pipe; 493 494 /* TODO: put the parser states in an union - TTY handles are always half-duplex 495 * so read-state can safely overlap write-state. */ 496 #define UV_TTY_PRIVATE_FIELDS \ 497 HANDLE handle; \ 498 union { \ 499 struct { \ 500 /* Used for readable TTY handles */ \ 501 /* TODO: remove me in v2.x. */ \ 502 HANDLE unused_; \ 503 uv_buf_t read_line_buffer; \ 504 HANDLE read_raw_wait; \ 505 /* Fields used for translating win keystrokes into vt100 characters */ \ 506 char last_key[8]; \ 507 unsigned char last_key_offset; \ 508 unsigned char last_key_len; \ 509 WCHAR last_utf16_high_surrogate; \ 510 INPUT_RECORD last_input_record; \ 511 } rd; \ 512 struct { \ 513 /* Used for writable TTY handles */ \ 514 /* utf8-to-utf16 conversion state */ \ 515 unsigned int utf8_codepoint; \ 516 unsigned char utf8_bytes_left; \ 517 /* eol conversion state */ \ 518 unsigned char previous_eol; \ 519 /* ansi parser state */ \ 520 unsigned short ansi_parser_state; \ 521 unsigned char ansi_csi_argc; \ 522 unsigned short ansi_csi_argv[4]; \ 523 COORD saved_position; \ 524 WORD saved_attributes; \ 525 } wr; \ 526 } tty; 527 528 #define UV_POLL_PRIVATE_FIELDS \ 529 SOCKET socket; \ 530 /* Used in fast mode */ \ 531 SOCKET peer_socket; \ 532 AFD_POLL_INFO afd_poll_info_1; \ 533 AFD_POLL_INFO afd_poll_info_2; \ 534 /* Used in fast and slow mode. */ \ 535 uv_req_t poll_req_1; \ 536 uv_req_t poll_req_2; \ 537 unsigned char submitted_events_1; \ 538 unsigned char submitted_events_2; \ 539 unsigned char mask_events_1; \ 540 unsigned char mask_events_2; \ 541 unsigned char events; 542 543 #define UV_TIMER_PRIVATE_FIELDS \ 544 void* heap_node[3]; \ 545 int unused; \ 546 uint64_t timeout; \ 547 uint64_t repeat; \ 548 uint64_t start_id; \ 549 uv_timer_cb timer_cb; 550 551 #define UV_ASYNC_PRIVATE_FIELDS \ 552 struct uv_req_s async_req; \ 553 uv_async_cb async_cb; \ 554 /* char to avoid alignment issues */ \ 555 char volatile async_sent; 556 557 #define UV_PREPARE_PRIVATE_FIELDS \ 558 uv_prepare_t* prepare_prev; \ 559 uv_prepare_t* prepare_next; \ 560 uv_prepare_cb prepare_cb; 561 562 #define UV_CHECK_PRIVATE_FIELDS \ 563 uv_check_t* check_prev; \ 564 uv_check_t* check_next; \ 565 uv_check_cb check_cb; 566 567 #define UV_IDLE_PRIVATE_FIELDS \ 568 uv_idle_t* idle_prev; \ 569 uv_idle_t* idle_next; \ 570 uv_idle_cb idle_cb; 571 572 #define UV_HANDLE_PRIVATE_FIELDS \ 573 uv_handle_t* endgame_next; \ 574 unsigned int flags; 575 576 #define UV_GETADDRINFO_PRIVATE_FIELDS \ 577 struct uv__work work_req; \ 578 uv_getaddrinfo_cb getaddrinfo_cb; \ 579 void* alloc; \ 580 WCHAR* node; \ 581 WCHAR* service; \ 582 /* The addrinfoW field is used to store a pointer to the hints, and */ \ 583 /* later on to store the result of GetAddrInfoW. The final result will */ \ 584 /* be converted to struct addrinfo* and stored in the addrinfo field. */ \ 585 struct addrinfoW* addrinfow; \ 586 struct addrinfo* addrinfo; \ 587 int retcode; 588 589 #define UV_GETNAMEINFO_PRIVATE_FIELDS \ 590 struct uv__work work_req; \ 591 uv_getnameinfo_cb getnameinfo_cb; \ 592 struct sockaddr_storage storage; \ 593 int flags; \ 594 char host[NI_MAXHOST]; \ 595 char service[NI_MAXSERV]; \ 596 int retcode; 597 598 #define UV_PROCESS_PRIVATE_FIELDS \ 599 struct uv_process_exit_s { \ 600 UV_REQ_FIELDS \ 601 } exit_req; \ 602 BYTE* child_stdio_buffer; \ 603 int exit_signal; \ 604 HANDLE wait_handle; \ 605 HANDLE process_handle; \ 606 volatile char exit_cb_pending; 607 608 #define UV_FS_PRIVATE_FIELDS \ 609 struct uv__work work_req; \ 610 int flags; \ 611 DWORD sys_errno_; \ 612 union { \ 613 /* TODO: remove me in 0.9. */ \ 614 WCHAR* pathw; \ 615 int fd; \ 616 } file; \ 617 union { \ 618 struct { \ 619 int mode; \ 620 WCHAR* new_pathw; \ 621 int file_flags; \ 622 int fd_out; \ 623 unsigned int nbufs; \ 624 uv_buf_t* bufs; \ 625 int64_t offset; \ 626 uv_buf_t bufsml[4]; \ 627 } info; \ 628 struct { \ 629 double atime; \ 630 double mtime; \ 631 } time; \ 632 } fs; 633 634 #define UV_WORK_PRIVATE_FIELDS \ 635 struct uv__work work_req; 636 637 #define UV_FS_EVENT_PRIVATE_FIELDS \ 638 struct uv_fs_event_req_s { \ 639 UV_REQ_FIELDS \ 640 } req; \ 641 HANDLE dir_handle; \ 642 int req_pending; \ 643 uv_fs_event_cb cb; \ 644 WCHAR* filew; \ 645 WCHAR* short_filew; \ 646 WCHAR* dirw; \ 647 char* buffer; 648 649 #define UV_SIGNAL_PRIVATE_FIELDS \ 650 RB_ENTRY(uv_signal_s) tree_entry; \ 651 struct uv_req_s signal_req; \ 652 unsigned long pending_signum; 653 654 #ifndef F_OK 655 #define F_OK 0 656 #endif 657 #ifndef R_OK 658 #define R_OK 4 659 #endif 660 #ifndef W_OK 661 #define W_OK 2 662 #endif 663 #ifndef X_OK 664 #define X_OK 1 665 #endif 666 667 /* fs open() flags supported on this platform: */ 668 #define UV_FS_O_APPEND _O_APPEND 669 #define UV_FS_O_CREAT _O_CREAT 670 #define UV_FS_O_EXCL _O_EXCL 671 #define UV_FS_O_FILEMAP 0x20000000 672 #define UV_FS_O_RANDOM _O_RANDOM 673 #define UV_FS_O_RDONLY _O_RDONLY 674 #define UV_FS_O_RDWR _O_RDWR 675 #define UV_FS_O_SEQUENTIAL _O_SEQUENTIAL 676 #define UV_FS_O_SHORT_LIVED _O_SHORT_LIVED 677 #define UV_FS_O_TEMPORARY _O_TEMPORARY 678 #define UV_FS_O_TRUNC _O_TRUNC 679 #define UV_FS_O_WRONLY _O_WRONLY 680 681 /* fs open() flags supported on other platforms (or mapped on this platform): */ 682 #define UV_FS_O_DIRECT 0x02000000 /* FILE_FLAG_NO_BUFFERING */ 683 #define UV_FS_O_DIRECTORY 0 684 #define UV_FS_O_DSYNC 0x04000000 /* FILE_FLAG_WRITE_THROUGH */ 685 #define UV_FS_O_EXLOCK 0x10000000 /* EXCLUSIVE SHARING MODE */ 686 #define UV_FS_O_NOATIME 0 687 #define UV_FS_O_NOCTTY 0 688 #define UV_FS_O_NOFOLLOW 0 689 #define UV_FS_O_NONBLOCK 0 690 #define UV_FS_O_SYMLINK 0 691 #define UV_FS_O_SYNC 0x08000000 /* FILE_FLAG_WRITE_THROUGH */ 692