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