17777dab0Sopenharmony_ci/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
27777dab0Sopenharmony_ci *
37777dab0Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
47777dab0Sopenharmony_ci * of this software and associated documentation files (the "Software"), to
57777dab0Sopenharmony_ci * deal in the Software without restriction, including without limitation the
67777dab0Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
77777dab0Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is
87777dab0Sopenharmony_ci * furnished to do so, subject to the following conditions:
97777dab0Sopenharmony_ci *
107777dab0Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
117777dab0Sopenharmony_ci * all copies or substantial portions of the Software.
127777dab0Sopenharmony_ci *
137777dab0Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
147777dab0Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
157777dab0Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
167777dab0Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
177777dab0Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
187777dab0Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
197777dab0Sopenharmony_ci * IN THE SOFTWARE.
207777dab0Sopenharmony_ci */
217777dab0Sopenharmony_ci
227777dab0Sopenharmony_ci#ifndef _WIN32_WINNT
237777dab0Sopenharmony_ci# define _WIN32_WINNT   0x0600
247777dab0Sopenharmony_ci#endif
257777dab0Sopenharmony_ci
267777dab0Sopenharmony_ci#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
277777dab0Sopenharmony_citypedef intptr_t ssize_t;
287777dab0Sopenharmony_ci# define SSIZE_MAX INTPTR_MAX
297777dab0Sopenharmony_ci# define _SSIZE_T_
307777dab0Sopenharmony_ci# define _SSIZE_T_DEFINED
317777dab0Sopenharmony_ci#endif
327777dab0Sopenharmony_ci
337777dab0Sopenharmony_ci#include <winsock2.h>
347777dab0Sopenharmony_ci
357777dab0Sopenharmony_ci#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
367777dab0Sopenharmony_citypedef struct pollfd {
377777dab0Sopenharmony_ci  SOCKET fd;
387777dab0Sopenharmony_ci  short  events;
397777dab0Sopenharmony_ci  short  revents;
407777dab0Sopenharmony_ci} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
417777dab0Sopenharmony_ci#endif
427777dab0Sopenharmony_ci
437777dab0Sopenharmony_ci#ifndef LOCALE_INVARIANT
447777dab0Sopenharmony_ci# define LOCALE_INVARIANT 0x007f
457777dab0Sopenharmony_ci#endif
467777dab0Sopenharmony_ci
477777dab0Sopenharmony_ci#include <mswsock.h>
487777dab0Sopenharmony_ci// Disable the typedef in mstcpip.h of MinGW.
497777dab0Sopenharmony_ci#define _TCP_INITIAL_RTO_PARAMETERS _TCP_INITIAL_RTO_PARAMETERS__AVOID
507777dab0Sopenharmony_ci#define TCP_INITIAL_RTO_PARAMETERS TCP_INITIAL_RTO_PARAMETERS__AVOID
517777dab0Sopenharmony_ci#define PTCP_INITIAL_RTO_PARAMETERS PTCP_INITIAL_RTO_PARAMETERS__AVOID
527777dab0Sopenharmony_ci#include <ws2tcpip.h>
537777dab0Sopenharmony_ci#undef _TCP_INITIAL_RTO_PARAMETERS
547777dab0Sopenharmony_ci#undef TCP_INITIAL_RTO_PARAMETERS
557777dab0Sopenharmony_ci#undef PTCP_INITIAL_RTO_PARAMETERS
567777dab0Sopenharmony_ci#include <windows.h>
577777dab0Sopenharmony_ci
587777dab0Sopenharmony_ci#include <process.h>
597777dab0Sopenharmony_ci#include <signal.h>
607777dab0Sopenharmony_ci#include <fcntl.h>
617777dab0Sopenharmony_ci#include <sys/stat.h>
627777dab0Sopenharmony_ci
637777dab0Sopenharmony_ci#if defined(_MSC_VER) && _MSC_VER < 1600
647777dab0Sopenharmony_ci# include "uv/stdint-msvc2008.h"
657777dab0Sopenharmony_ci#else
667777dab0Sopenharmony_ci# include <stdint.h>
677777dab0Sopenharmony_ci#endif
687777dab0Sopenharmony_ci
697777dab0Sopenharmony_ci#include "uv/tree.h"
707777dab0Sopenharmony_ci#include "uv/threadpool.h"
717777dab0Sopenharmony_ci
727777dab0Sopenharmony_ci#define MAX_PIPENAME_LEN 256
737777dab0Sopenharmony_ci
747777dab0Sopenharmony_ci#ifndef S_IFLNK
757777dab0Sopenharmony_ci# define S_IFLNK 0xA000
767777dab0Sopenharmony_ci#endif
777777dab0Sopenharmony_ci
787777dab0Sopenharmony_ci/* Additional signals supported by uv_signal and or uv_kill. The CRT defines
797777dab0Sopenharmony_ci * the following signals already:
807777dab0Sopenharmony_ci *
817777dab0Sopenharmony_ci *   #define SIGINT           2
827777dab0Sopenharmony_ci *   #define SIGILL           4
837777dab0Sopenharmony_ci *   #define SIGABRT_COMPAT   6
847777dab0Sopenharmony_ci *   #define SIGFPE           8
857777dab0Sopenharmony_ci *   #define SIGSEGV         11
867777dab0Sopenharmony_ci *   #define SIGTERM         15
877777dab0Sopenharmony_ci *   #define SIGBREAK        21
887777dab0Sopenharmony_ci *   #define SIGABRT         22
897777dab0Sopenharmony_ci *
907777dab0Sopenharmony_ci * The additional signals have values that are common on other Unix
917777dab0Sopenharmony_ci * variants (Linux and Darwin)
927777dab0Sopenharmony_ci */
937777dab0Sopenharmony_ci#define SIGHUP                1
947777dab0Sopenharmony_ci#define SIGKILL               9
957777dab0Sopenharmony_ci#define SIGWINCH             28
967777dab0Sopenharmony_ci
977777dab0Sopenharmony_ci/* Redefine NSIG to take SIGWINCH into consideration */
987777dab0Sopenharmony_ci#if defined(NSIG) && NSIG <= SIGWINCH
997777dab0Sopenharmony_ci# undef NSIG
1007777dab0Sopenharmony_ci#endif
1017777dab0Sopenharmony_ci#ifndef NSIG
1027777dab0Sopenharmony_ci# define NSIG SIGWINCH + 1
1037777dab0Sopenharmony_ci#endif
1047777dab0Sopenharmony_ci
1057777dab0Sopenharmony_ci/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many unix-like
1067777dab0Sopenharmony_ci * platforms. However MinGW doesn't define it, so we do. */
1077777dab0Sopenharmony_ci#ifndef SIGABRT_COMPAT
1087777dab0Sopenharmony_ci# define SIGABRT_COMPAT       6
1097777dab0Sopenharmony_ci#endif
1107777dab0Sopenharmony_ci
1117777dab0Sopenharmony_ci/*
1127777dab0Sopenharmony_ci * Guids and typedefs for winsock extension functions
1137777dab0Sopenharmony_ci * Mingw32 doesn't have these :-(
1147777dab0Sopenharmony_ci */
1157777dab0Sopenharmony_ci#ifndef WSAID_ACCEPTEX
1167777dab0Sopenharmony_ci# define WSAID_ACCEPTEX                                                       \
1177777dab0Sopenharmony_ci         {0xb5367df1, 0xcbac, 0x11cf,                                         \
1187777dab0Sopenharmony_ci         {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
1197777dab0Sopenharmony_ci
1207777dab0Sopenharmony_ci# define WSAID_CONNECTEX                                                      \
1217777dab0Sopenharmony_ci         {0x25a207b9, 0xddf3, 0x4660,                                         \
1227777dab0Sopenharmony_ci         {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}}
1237777dab0Sopenharmony_ci
1247777dab0Sopenharmony_ci# define WSAID_GETACCEPTEXSOCKADDRS                                           \
1257777dab0Sopenharmony_ci         {0xb5367df2, 0xcbac, 0x11cf,                                         \
1267777dab0Sopenharmony_ci         {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
1277777dab0Sopenharmony_ci
1287777dab0Sopenharmony_ci# define WSAID_DISCONNECTEX                                                   \
1297777dab0Sopenharmony_ci         {0x7fda2e11, 0x8630, 0x436f,                                         \
1307777dab0Sopenharmony_ci         {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
1317777dab0Sopenharmony_ci
1327777dab0Sopenharmony_ci# define WSAID_TRANSMITFILE                                                   \
1337777dab0Sopenharmony_ci         {0xb5367df0, 0xcbac, 0x11cf,                                         \
1347777dab0Sopenharmony_ci         {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
1357777dab0Sopenharmony_ci
1367777dab0Sopenharmony_ci  typedef BOOL (PASCAL *LPFN_ACCEPTEX)
1377777dab0Sopenharmony_ci                      (SOCKET sListenSocket,
1387777dab0Sopenharmony_ci                       SOCKET sAcceptSocket,
1397777dab0Sopenharmony_ci                       PVOID lpOutputBuffer,
1407777dab0Sopenharmony_ci                       DWORD dwReceiveDataLength,
1417777dab0Sopenharmony_ci                       DWORD dwLocalAddressLength,
1427777dab0Sopenharmony_ci                       DWORD dwRemoteAddressLength,
1437777dab0Sopenharmony_ci                       LPDWORD lpdwBytesReceived,
1447777dab0Sopenharmony_ci                       LPOVERLAPPED lpOverlapped);
1457777dab0Sopenharmony_ci
1467777dab0Sopenharmony_ci  typedef BOOL (PASCAL *LPFN_CONNECTEX)
1477777dab0Sopenharmony_ci                      (SOCKET s,
1487777dab0Sopenharmony_ci                       const struct sockaddr* name,
1497777dab0Sopenharmony_ci                       int namelen,
1507777dab0Sopenharmony_ci                       PVOID lpSendBuffer,
1517777dab0Sopenharmony_ci                       DWORD dwSendDataLength,
1527777dab0Sopenharmony_ci                       LPDWORD lpdwBytesSent,
1537777dab0Sopenharmony_ci                       LPOVERLAPPED lpOverlapped);
1547777dab0Sopenharmony_ci
1557777dab0Sopenharmony_ci  typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS)
1567777dab0Sopenharmony_ci                      (PVOID lpOutputBuffer,
1577777dab0Sopenharmony_ci                       DWORD dwReceiveDataLength,
1587777dab0Sopenharmony_ci                       DWORD dwLocalAddressLength,
1597777dab0Sopenharmony_ci                       DWORD dwRemoteAddressLength,
1607777dab0Sopenharmony_ci                       LPSOCKADDR* LocalSockaddr,
1617777dab0Sopenharmony_ci                       LPINT LocalSockaddrLength,
1627777dab0Sopenharmony_ci                       LPSOCKADDR* RemoteSockaddr,
1637777dab0Sopenharmony_ci                       LPINT RemoteSockaddrLength);
1647777dab0Sopenharmony_ci
1657777dab0Sopenharmony_ci  typedef BOOL (PASCAL *LPFN_DISCONNECTEX)
1667777dab0Sopenharmony_ci                      (SOCKET hSocket,
1677777dab0Sopenharmony_ci                       LPOVERLAPPED lpOverlapped,
1687777dab0Sopenharmony_ci                       DWORD dwFlags,
1697777dab0Sopenharmony_ci                       DWORD reserved);
1707777dab0Sopenharmony_ci
1717777dab0Sopenharmony_ci  typedef BOOL (PASCAL *LPFN_TRANSMITFILE)
1727777dab0Sopenharmony_ci                      (SOCKET hSocket,
1737777dab0Sopenharmony_ci                       HANDLE hFile,
1747777dab0Sopenharmony_ci                       DWORD nNumberOfBytesToWrite,
1757777dab0Sopenharmony_ci                       DWORD nNumberOfBytesPerSend,
1767777dab0Sopenharmony_ci                       LPOVERLAPPED lpOverlapped,
1777777dab0Sopenharmony_ci                       LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
1787777dab0Sopenharmony_ci                       DWORD dwFlags);
1797777dab0Sopenharmony_ci
1807777dab0Sopenharmony_ci  typedef PVOID RTL_SRWLOCK;
1817777dab0Sopenharmony_ci  typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
1827777dab0Sopenharmony_ci#endif
1837777dab0Sopenharmony_ci
1847777dab0Sopenharmony_citypedef int (WSAAPI* LPFN_WSARECV)
1857777dab0Sopenharmony_ci            (SOCKET socket,
1867777dab0Sopenharmony_ci             LPWSABUF buffers,
1877777dab0Sopenharmony_ci             DWORD buffer_count,
1887777dab0Sopenharmony_ci             LPDWORD bytes,
1897777dab0Sopenharmony_ci             LPDWORD flags,
1907777dab0Sopenharmony_ci             LPWSAOVERLAPPED overlapped,
1917777dab0Sopenharmony_ci             LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
1927777dab0Sopenharmony_ci
1937777dab0Sopenharmony_citypedef int (WSAAPI* LPFN_WSARECVFROM)
1947777dab0Sopenharmony_ci            (SOCKET socket,
1957777dab0Sopenharmony_ci             LPWSABUF buffers,
1967777dab0Sopenharmony_ci             DWORD buffer_count,
1977777dab0Sopenharmony_ci             LPDWORD bytes,
1987777dab0Sopenharmony_ci             LPDWORD flags,
1997777dab0Sopenharmony_ci             struct sockaddr* addr,
2007777dab0Sopenharmony_ci             LPINT addr_len,
2017777dab0Sopenharmony_ci             LPWSAOVERLAPPED overlapped,
2027777dab0Sopenharmony_ci             LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
2037777dab0Sopenharmony_ci
2047777dab0Sopenharmony_ci#ifndef _NTDEF_
2057777dab0Sopenharmony_ci  typedef LONG NTSTATUS;
2067777dab0Sopenharmony_ci  typedef NTSTATUS *PNTSTATUS;
2077777dab0Sopenharmony_ci#endif
2087777dab0Sopenharmony_ci
2097777dab0Sopenharmony_ci#ifndef RTL_CONDITION_VARIABLE_INIT
2107777dab0Sopenharmony_ci  typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE;
2117777dab0Sopenharmony_ci#endif
2127777dab0Sopenharmony_ci
2137777dab0Sopenharmony_citypedef struct _AFD_POLL_HANDLE_INFO {
2147777dab0Sopenharmony_ci  HANDLE Handle;
2157777dab0Sopenharmony_ci  ULONG Events;
2167777dab0Sopenharmony_ci  NTSTATUS Status;
2177777dab0Sopenharmony_ci} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO;
2187777dab0Sopenharmony_ci
2197777dab0Sopenharmony_citypedef struct _AFD_POLL_INFO {
2207777dab0Sopenharmony_ci  LARGE_INTEGER Timeout;
2217777dab0Sopenharmony_ci  ULONG NumberOfHandles;
2227777dab0Sopenharmony_ci  ULONG Exclusive;
2237777dab0Sopenharmony_ci  AFD_POLL_HANDLE_INFO Handles[1];
2247777dab0Sopenharmony_ci} AFD_POLL_INFO, *PAFD_POLL_INFO;
2257777dab0Sopenharmony_ci
2267777dab0Sopenharmony_ci#define UV_MSAFD_PROVIDER_COUNT 4
2277777dab0Sopenharmony_ci
2287777dab0Sopenharmony_ci
2297777dab0Sopenharmony_ci/**
2307777dab0Sopenharmony_ci * It should be possible to cast uv_buf_t[] to WSABUF[]
2317777dab0Sopenharmony_ci * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
2327777dab0Sopenharmony_ci */
2337777dab0Sopenharmony_citypedef struct uv_buf_t {
2347777dab0Sopenharmony_ci  ULONG len;
2357777dab0Sopenharmony_ci  char* base;
2367777dab0Sopenharmony_ci} uv_buf_t;
2377777dab0Sopenharmony_ci
2387777dab0Sopenharmony_citypedef int uv_file;
2397777dab0Sopenharmony_citypedef SOCKET uv_os_sock_t;
2407777dab0Sopenharmony_citypedef HANDLE uv_os_fd_t;
2417777dab0Sopenharmony_citypedef int uv_pid_t;
2427777dab0Sopenharmony_ci
2437777dab0Sopenharmony_citypedef HANDLE uv_thread_t;
2447777dab0Sopenharmony_ci
2457777dab0Sopenharmony_citypedef HANDLE uv_sem_t;
2467777dab0Sopenharmony_ci
2477777dab0Sopenharmony_citypedef CRITICAL_SECTION uv_mutex_t;
2487777dab0Sopenharmony_ci
2497777dab0Sopenharmony_ci/* This condition variable implementation is based on the SetEvent solution
2507777dab0Sopenharmony_ci * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
2517777dab0Sopenharmony_ci * We could not use the SignalObjectAndWait solution (section 3.4) because
2527777dab0Sopenharmony_ci * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and
2537777dab0Sopenharmony_ci * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs.
2547777dab0Sopenharmony_ci */
2557777dab0Sopenharmony_ci
2567777dab0Sopenharmony_citypedef union {
2577777dab0Sopenharmony_ci  CONDITION_VARIABLE cond_var;
2587777dab0Sopenharmony_ci  struct {
2597777dab0Sopenharmony_ci    unsigned int waiters_count;
2607777dab0Sopenharmony_ci    CRITICAL_SECTION waiters_count_lock;
2617777dab0Sopenharmony_ci    HANDLE signal_event;
2627777dab0Sopenharmony_ci    HANDLE broadcast_event;
2637777dab0Sopenharmony_ci  } unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */
2647777dab0Sopenharmony_ci} uv_cond_t;
2657777dab0Sopenharmony_ci
2667777dab0Sopenharmony_citypedef struct {
2677777dab0Sopenharmony_ci  SRWLOCK read_write_lock_;
2687777dab0Sopenharmony_ci  /* TODO: retained for ABI compatibility; remove me in v2.x */
2697777dab0Sopenharmony_ci#ifdef _WIN64
2707777dab0Sopenharmony_ci  unsigned char padding_[72];
2717777dab0Sopenharmony_ci#else
2727777dab0Sopenharmony_ci  unsigned char padding_[44];
2737777dab0Sopenharmony_ci#endif
2747777dab0Sopenharmony_ci} uv_rwlock_t;
2757777dab0Sopenharmony_ci
2767777dab0Sopenharmony_citypedef struct {
2777777dab0Sopenharmony_ci  unsigned int n;
2787777dab0Sopenharmony_ci  unsigned int count;
2797777dab0Sopenharmony_ci  uv_mutex_t mutex;
2807777dab0Sopenharmony_ci  uv_sem_t turnstile1;
2817777dab0Sopenharmony_ci  uv_sem_t turnstile2;
2827777dab0Sopenharmony_ci} uv_barrier_t;
2837777dab0Sopenharmony_ci
2847777dab0Sopenharmony_citypedef struct {
2857777dab0Sopenharmony_ci  DWORD tls_index;
2867777dab0Sopenharmony_ci} uv_key_t;
2877777dab0Sopenharmony_ci
2887777dab0Sopenharmony_ci#define UV_ONCE_INIT { 0, NULL }
2897777dab0Sopenharmony_ci
2907777dab0Sopenharmony_citypedef struct uv_once_s {
2917777dab0Sopenharmony_ci  unsigned char ran;
2927777dab0Sopenharmony_ci  HANDLE event;
2937777dab0Sopenharmony_ci} uv_once_t;
2947777dab0Sopenharmony_ci
2957777dab0Sopenharmony_ci/* Platform-specific definitions for uv_spawn support. */
2967777dab0Sopenharmony_citypedef unsigned char uv_uid_t;
2977777dab0Sopenharmony_citypedef unsigned char uv_gid_t;
2987777dab0Sopenharmony_ci
2997777dab0Sopenharmony_citypedef struct uv__dirent_s {
3007777dab0Sopenharmony_ci  int d_type;
3017777dab0Sopenharmony_ci  char d_name[1];
3027777dab0Sopenharmony_ci} uv__dirent_t;
3037777dab0Sopenharmony_ci
3047777dab0Sopenharmony_ci#define UV_DIR_PRIVATE_FIELDS \
3057777dab0Sopenharmony_ci  HANDLE dir_handle;          \
3067777dab0Sopenharmony_ci  WIN32_FIND_DATAW find_data; \
3077777dab0Sopenharmony_ci  BOOL need_find_call;
3087777dab0Sopenharmony_ci
3097777dab0Sopenharmony_ci#define HAVE_DIRENT_TYPES
3107777dab0Sopenharmony_ci#define UV__DT_DIR     UV_DIRENT_DIR
3117777dab0Sopenharmony_ci#define UV__DT_FILE    UV_DIRENT_FILE
3127777dab0Sopenharmony_ci#define UV__DT_LINK    UV_DIRENT_LINK
3137777dab0Sopenharmony_ci#define UV__DT_FIFO    UV_DIRENT_FIFO
3147777dab0Sopenharmony_ci#define UV__DT_SOCKET  UV_DIRENT_SOCKET
3157777dab0Sopenharmony_ci#define UV__DT_CHAR    UV_DIRENT_CHAR
3167777dab0Sopenharmony_ci#define UV__DT_BLOCK   UV_DIRENT_BLOCK
3177777dab0Sopenharmony_ci
3187777dab0Sopenharmony_ci/* Platform-specific definitions for uv_dlopen support. */
3197777dab0Sopenharmony_ci#define UV_DYNAMIC FAR WINAPI
3207777dab0Sopenharmony_citypedef struct {
3217777dab0Sopenharmony_ci  HMODULE handle;
3227777dab0Sopenharmony_ci  char* errmsg;
3237777dab0Sopenharmony_ci} uv_lib_t;
3247777dab0Sopenharmony_ci
3257777dab0Sopenharmony_ci#define UV_LOOP_PRIVATE_FIELDS                                                \
3267777dab0Sopenharmony_ci    /* The loop's I/O completion port */                                      \
3277777dab0Sopenharmony_ci  HANDLE iocp;                                                                \
3287777dab0Sopenharmony_ci  /* The current time according to the event loop. in msecs. */               \
3297777dab0Sopenharmony_ci  uint64_t time;                                                              \
3307777dab0Sopenharmony_ci  /* Tail of a single-linked circular queue of pending reqs. If the queue */  \
3317777dab0Sopenharmony_ci  /* is empty, tail_ is NULL. If there is only one item, */                   \
3327777dab0Sopenharmony_ci  /* tail_->next_req == tail_ */                                              \
3337777dab0Sopenharmony_ci  uv_req_t* pending_reqs_tail;                                                \
3347777dab0Sopenharmony_ci  /* Head of a single-linked list of closed handles */                        \
3357777dab0Sopenharmony_ci  uv_handle_t* endgame_handles;                                               \
3367777dab0Sopenharmony_ci  /* TODO(bnoordhuis) Stop heap-allocating |timer_heap| in libuv v2.x. */     \
3377777dab0Sopenharmony_ci  void* timer_heap;                                                           \
3387777dab0Sopenharmony_ci    /* Lists of active loop (prepare / check / idle) watchers */              \
3397777dab0Sopenharmony_ci  uv_prepare_t* prepare_handles;                                              \
3407777dab0Sopenharmony_ci  uv_check_t* check_handles;                                                  \
3417777dab0Sopenharmony_ci  uv_idle_t* idle_handles;                                                    \
3427777dab0Sopenharmony_ci  /* This pointer will refer to the prepare/check/idle handle whose */        \
3437777dab0Sopenharmony_ci  /* callback is scheduled to be called next. This is needed to allow */      \
3447777dab0Sopenharmony_ci  /* safe removal from one of the lists above while that list being */        \
3457777dab0Sopenharmony_ci  /* iterated over. */                                                        \
3467777dab0Sopenharmony_ci  uv_prepare_t* next_prepare_handle;                                          \
3477777dab0Sopenharmony_ci  uv_check_t* next_check_handle;                                              \
3487777dab0Sopenharmony_ci  uv_idle_t* next_idle_handle;                                                \
3497777dab0Sopenharmony_ci  /* This handle holds the peer sockets for the fast variant of uv_poll_t */  \
3507777dab0Sopenharmony_ci  SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT];                          \
3517777dab0Sopenharmony_ci  /* Counter to keep track of active tcp streams */                           \
3527777dab0Sopenharmony_ci  unsigned int active_tcp_streams;                                            \
3537777dab0Sopenharmony_ci  /* Counter to keep track of active udp streams */                           \
3547777dab0Sopenharmony_ci  unsigned int active_udp_streams;                                            \
3557777dab0Sopenharmony_ci  /* Counter to started timer */                                              \
3567777dab0Sopenharmony_ci  uint64_t timer_counter;                                                     \
3577777dab0Sopenharmony_ci  /* Threadpool */                                                            \
3587777dab0Sopenharmony_ci  void* wq[2];                                                                \
3597777dab0Sopenharmony_ci  uv_mutex_t wq_mutex;                                                        \
3607777dab0Sopenharmony_ci  uv_async_t wq_async;
3617777dab0Sopenharmony_ci
3627777dab0Sopenharmony_ci#define UV_REQ_TYPE_PRIVATE                                                   \
3637777dab0Sopenharmony_ci  /* TODO: remove the req suffix */                                           \
3647777dab0Sopenharmony_ci  UV_ACCEPT,                                                                  \
3657777dab0Sopenharmony_ci  UV_FS_EVENT_REQ,                                                            \
3667777dab0Sopenharmony_ci  UV_POLL_REQ,                                                                \
3677777dab0Sopenharmony_ci  UV_PROCESS_EXIT,                                                            \
3687777dab0Sopenharmony_ci  UV_READ,                                                                    \
3697777dab0Sopenharmony_ci  UV_UDP_RECV,                                                                \
3707777dab0Sopenharmony_ci  UV_WAKEUP,                                                                  \
3717777dab0Sopenharmony_ci  UV_SIGNAL_REQ,
3727777dab0Sopenharmony_ci
3737777dab0Sopenharmony_ci#define UV_REQ_PRIVATE_FIELDS                                                 \
3747777dab0Sopenharmony_ci  union {                                                                     \
3757777dab0Sopenharmony_ci    /* Used by I/O operations */                                              \
3767777dab0Sopenharmony_ci    struct {                                                                  \
3777777dab0Sopenharmony_ci      OVERLAPPED overlapped;                                                  \
3787777dab0Sopenharmony_ci      size_t queued_bytes;                                                    \
3797777dab0Sopenharmony_ci    } io;                                                                     \
3807777dab0Sopenharmony_ci  } u;                                                                        \
3817777dab0Sopenharmony_ci  struct uv_req_s* next_req;
3827777dab0Sopenharmony_ci
3837777dab0Sopenharmony_ci#define UV_WRITE_PRIVATE_FIELDS \
3847777dab0Sopenharmony_ci  int coalesced;                \
3857777dab0Sopenharmony_ci  uv_buf_t write_buffer;        \
3867777dab0Sopenharmony_ci  HANDLE event_handle;          \
3877777dab0Sopenharmony_ci  HANDLE wait_handle;
3887777dab0Sopenharmony_ci
3897777dab0Sopenharmony_ci#define UV_CONNECT_PRIVATE_FIELDS                                             \
3907777dab0Sopenharmony_ci  /* empty */
3917777dab0Sopenharmony_ci
3927777dab0Sopenharmony_ci#define UV_SHUTDOWN_PRIVATE_FIELDS                                            \
3937777dab0Sopenharmony_ci  /* empty */
3947777dab0Sopenharmony_ci
3957777dab0Sopenharmony_ci#define UV_UDP_SEND_PRIVATE_FIELDS                                            \
3967777dab0Sopenharmony_ci  /* empty */
3977777dab0Sopenharmony_ci
3987777dab0Sopenharmony_ci#define UV_PRIVATE_REQ_TYPES                                                  \
3997777dab0Sopenharmony_ci  typedef struct uv_pipe_accept_s {                                           \
4007777dab0Sopenharmony_ci    UV_REQ_FIELDS                                                             \
4017777dab0Sopenharmony_ci    HANDLE pipeHandle;                                                        \
4027777dab0Sopenharmony_ci    struct uv_pipe_accept_s* next_pending;                                    \
4037777dab0Sopenharmony_ci  } uv_pipe_accept_t;                                                         \
4047777dab0Sopenharmony_ci                                                                              \
4057777dab0Sopenharmony_ci  typedef struct uv_tcp_accept_s {                                            \
4067777dab0Sopenharmony_ci    UV_REQ_FIELDS                                                             \
4077777dab0Sopenharmony_ci    SOCKET accept_socket;                                                     \
4087777dab0Sopenharmony_ci    char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32];             \
4097777dab0Sopenharmony_ci    HANDLE event_handle;                                                      \
4107777dab0Sopenharmony_ci    HANDLE wait_handle;                                                       \
4117777dab0Sopenharmony_ci    struct uv_tcp_accept_s* next_pending;                                     \
4127777dab0Sopenharmony_ci  } uv_tcp_accept_t;                                                          \
4137777dab0Sopenharmony_ci                                                                              \
4147777dab0Sopenharmony_ci  typedef struct uv_read_s {                                                  \
4157777dab0Sopenharmony_ci    UV_REQ_FIELDS                                                             \
4167777dab0Sopenharmony_ci    HANDLE event_handle;                                                      \
4177777dab0Sopenharmony_ci    HANDLE wait_handle;                                                       \
4187777dab0Sopenharmony_ci  } uv_read_t;
4197777dab0Sopenharmony_ci
4207777dab0Sopenharmony_ci#define uv_stream_connection_fields                                           \
4217777dab0Sopenharmony_ci  unsigned int write_reqs_pending;                                            \
4227777dab0Sopenharmony_ci  uv_shutdown_t* shutdown_req;
4237777dab0Sopenharmony_ci
4247777dab0Sopenharmony_ci#define uv_stream_server_fields                                               \
4257777dab0Sopenharmony_ci  uv_connection_cb connection_cb;
4267777dab0Sopenharmony_ci
4277777dab0Sopenharmony_ci#define UV_STREAM_PRIVATE_FIELDS                                              \
4287777dab0Sopenharmony_ci  unsigned int reqs_pending;                                                  \
4297777dab0Sopenharmony_ci  int activecnt;                                                              \
4307777dab0Sopenharmony_ci  uv_read_t read_req;                                                         \
4317777dab0Sopenharmony_ci  union {                                                                     \
4327777dab0Sopenharmony_ci    struct { uv_stream_connection_fields } conn;                              \
4337777dab0Sopenharmony_ci    struct { uv_stream_server_fields     } serv;                              \
4347777dab0Sopenharmony_ci  } stream;
4357777dab0Sopenharmony_ci
4367777dab0Sopenharmony_ci#define uv_tcp_server_fields                                                  \
4377777dab0Sopenharmony_ci  uv_tcp_accept_t* accept_reqs;                                               \
4387777dab0Sopenharmony_ci  unsigned int processed_accepts;                                             \
4397777dab0Sopenharmony_ci  uv_tcp_accept_t* pending_accepts;                                           \
4407777dab0Sopenharmony_ci  LPFN_ACCEPTEX func_acceptex;
4417777dab0Sopenharmony_ci
4427777dab0Sopenharmony_ci#define uv_tcp_connection_fields                                              \
4437777dab0Sopenharmony_ci  uv_buf_t read_buffer;                                                       \
4447777dab0Sopenharmony_ci  LPFN_CONNECTEX func_connectex;
4457777dab0Sopenharmony_ci
4467777dab0Sopenharmony_ci#define UV_TCP_PRIVATE_FIELDS                                                 \
4477777dab0Sopenharmony_ci  SOCKET socket;                                                              \
4487777dab0Sopenharmony_ci  int delayed_error;                                                          \
4497777dab0Sopenharmony_ci  union {                                                                     \
4507777dab0Sopenharmony_ci    struct { uv_tcp_server_fields } serv;                                     \
4517777dab0Sopenharmony_ci    struct { uv_tcp_connection_fields } conn;                                 \
4527777dab0Sopenharmony_ci  } tcp;
4537777dab0Sopenharmony_ci
4547777dab0Sopenharmony_ci#define UV_UDP_PRIVATE_FIELDS                                                 \
4557777dab0Sopenharmony_ci  SOCKET socket;                                                              \
4567777dab0Sopenharmony_ci  unsigned int reqs_pending;                                                  \
4577777dab0Sopenharmony_ci  int activecnt;                                                              \
4587777dab0Sopenharmony_ci  uv_req_t recv_req;                                                          \
4597777dab0Sopenharmony_ci  uv_buf_t recv_buffer;                                                       \
4607777dab0Sopenharmony_ci  struct sockaddr_storage recv_from;                                          \
4617777dab0Sopenharmony_ci  int recv_from_len;                                                          \
4627777dab0Sopenharmony_ci  uv_udp_recv_cb recv_cb;                                                     \
4637777dab0Sopenharmony_ci  uv_alloc_cb alloc_cb;                                                       \
4647777dab0Sopenharmony_ci  LPFN_WSARECV func_wsarecv;                                                  \
4657777dab0Sopenharmony_ci  LPFN_WSARECVFROM func_wsarecvfrom;
4667777dab0Sopenharmony_ci
4677777dab0Sopenharmony_ci#define uv_pipe_server_fields                                                 \
4687777dab0Sopenharmony_ci  int pending_instances;                                                      \
4697777dab0Sopenharmony_ci  uv_pipe_accept_t* accept_reqs;                                              \
4707777dab0Sopenharmony_ci  uv_pipe_accept_t* pending_accepts;
4717777dab0Sopenharmony_ci
4727777dab0Sopenharmony_ci#define uv_pipe_connection_fields                                             \
4737777dab0Sopenharmony_ci  uv_timer_t* eof_timer;                                                      \
4747777dab0Sopenharmony_ci  uv_write_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \
4757777dab0Sopenharmony_ci  DWORD ipc_remote_pid;                                                       \
4767777dab0Sopenharmony_ci  union {                                                                     \
4777777dab0Sopenharmony_ci    uint32_t payload_remaining;                                               \
4787777dab0Sopenharmony_ci    uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \
4797777dab0Sopenharmony_ci  } ipc_data_frame;                                                           \
4807777dab0Sopenharmony_ci  void* ipc_xfer_queue[2];                                                    \
4817777dab0Sopenharmony_ci  int ipc_xfer_queue_length;                                                  \
4827777dab0Sopenharmony_ci  uv_write_t* non_overlapped_writes_tail;                                     \
4837777dab0Sopenharmony_ci  CRITICAL_SECTION readfile_thread_lock;                                      \
4847777dab0Sopenharmony_ci  volatile HANDLE readfile_thread_handle;
4857777dab0Sopenharmony_ci
4867777dab0Sopenharmony_ci#define UV_PIPE_PRIVATE_FIELDS                                                \
4877777dab0Sopenharmony_ci  HANDLE handle;                                                              \
4887777dab0Sopenharmony_ci  WCHAR* name;                                                                \
4897777dab0Sopenharmony_ci  union {                                                                     \
4907777dab0Sopenharmony_ci    struct { uv_pipe_server_fields } serv;                                    \
4917777dab0Sopenharmony_ci    struct { uv_pipe_connection_fields } conn;                                \
4927777dab0Sopenharmony_ci  } pipe;
4937777dab0Sopenharmony_ci
4947777dab0Sopenharmony_ci/* TODO: put the parser states in an union - TTY handles are always half-duplex
4957777dab0Sopenharmony_ci * so read-state can safely overlap write-state. */
4967777dab0Sopenharmony_ci#define UV_TTY_PRIVATE_FIELDS                                                 \
4977777dab0Sopenharmony_ci  HANDLE handle;                                                              \
4987777dab0Sopenharmony_ci  union {                                                                     \
4997777dab0Sopenharmony_ci    struct {                                                                  \
5007777dab0Sopenharmony_ci      /* Used for readable TTY handles */                                     \
5017777dab0Sopenharmony_ci      /* TODO: remove me in v2.x. */                                          \
5027777dab0Sopenharmony_ci      HANDLE unused_;                                                         \
5037777dab0Sopenharmony_ci      uv_buf_t read_line_buffer;                                              \
5047777dab0Sopenharmony_ci      HANDLE read_raw_wait;                                                   \
5057777dab0Sopenharmony_ci      /* Fields used for translating win keystrokes into vt100 characters */  \
5067777dab0Sopenharmony_ci      char last_key[8];                                                       \
5077777dab0Sopenharmony_ci      unsigned char last_key_offset;                                          \
5087777dab0Sopenharmony_ci      unsigned char last_key_len;                                             \
5097777dab0Sopenharmony_ci      WCHAR last_utf16_high_surrogate;                                        \
5107777dab0Sopenharmony_ci      INPUT_RECORD last_input_record;                                         \
5117777dab0Sopenharmony_ci    } rd;                                                                     \
5127777dab0Sopenharmony_ci    struct {                                                                  \
5137777dab0Sopenharmony_ci      /* Used for writable TTY handles */                                     \
5147777dab0Sopenharmony_ci      /* utf8-to-utf16 conversion state */                                    \
5157777dab0Sopenharmony_ci      unsigned int utf8_codepoint;                                            \
5167777dab0Sopenharmony_ci      unsigned char utf8_bytes_left;                                          \
5177777dab0Sopenharmony_ci      /* eol conversion state */                                              \
5187777dab0Sopenharmony_ci      unsigned char previous_eol;                                             \
5197777dab0Sopenharmony_ci      /* ansi parser state */                                                 \
5207777dab0Sopenharmony_ci      unsigned short ansi_parser_state;                                       \
5217777dab0Sopenharmony_ci      unsigned char ansi_csi_argc;                                            \
5227777dab0Sopenharmony_ci      unsigned short ansi_csi_argv[4];                                        \
5237777dab0Sopenharmony_ci      COORD saved_position;                                                   \
5247777dab0Sopenharmony_ci      WORD saved_attributes;                                                  \
5257777dab0Sopenharmony_ci    } wr;                                                                     \
5267777dab0Sopenharmony_ci  } tty;
5277777dab0Sopenharmony_ci
5287777dab0Sopenharmony_ci#define UV_POLL_PRIVATE_FIELDS                                                \
5297777dab0Sopenharmony_ci  SOCKET socket;                                                              \
5307777dab0Sopenharmony_ci  /* Used in fast mode */                                                     \
5317777dab0Sopenharmony_ci  SOCKET peer_socket;                                                         \
5327777dab0Sopenharmony_ci  AFD_POLL_INFO afd_poll_info_1;                                              \
5337777dab0Sopenharmony_ci  AFD_POLL_INFO afd_poll_info_2;                                              \
5347777dab0Sopenharmony_ci  /* Used in fast and slow mode. */                                           \
5357777dab0Sopenharmony_ci  uv_req_t poll_req_1;                                                        \
5367777dab0Sopenharmony_ci  uv_req_t poll_req_2;                                                        \
5377777dab0Sopenharmony_ci  unsigned char submitted_events_1;                                           \
5387777dab0Sopenharmony_ci  unsigned char submitted_events_2;                                           \
5397777dab0Sopenharmony_ci  unsigned char mask_events_1;                                                \
5407777dab0Sopenharmony_ci  unsigned char mask_events_2;                                                \
5417777dab0Sopenharmony_ci  unsigned char events;
5427777dab0Sopenharmony_ci
5437777dab0Sopenharmony_ci#define UV_TIMER_PRIVATE_FIELDS                                               \
5447777dab0Sopenharmony_ci  void* heap_node[3];                                                         \
5457777dab0Sopenharmony_ci  int unused;                                                                 \
5467777dab0Sopenharmony_ci  uint64_t timeout;                                                           \
5477777dab0Sopenharmony_ci  uint64_t repeat;                                                            \
5487777dab0Sopenharmony_ci  uint64_t start_id;                                                          \
5497777dab0Sopenharmony_ci  uv_timer_cb timer_cb;
5507777dab0Sopenharmony_ci
5517777dab0Sopenharmony_ci#define UV_ASYNC_PRIVATE_FIELDS                                               \
5527777dab0Sopenharmony_ci  struct uv_req_s async_req;                                                  \
5537777dab0Sopenharmony_ci  uv_async_cb async_cb;                                                       \
5547777dab0Sopenharmony_ci  /* char to avoid alignment issues */                                        \
5557777dab0Sopenharmony_ci  char volatile async_sent;
5567777dab0Sopenharmony_ci
5577777dab0Sopenharmony_ci#define UV_PREPARE_PRIVATE_FIELDS                                             \
5587777dab0Sopenharmony_ci  uv_prepare_t* prepare_prev;                                                 \
5597777dab0Sopenharmony_ci  uv_prepare_t* prepare_next;                                                 \
5607777dab0Sopenharmony_ci  uv_prepare_cb prepare_cb;
5617777dab0Sopenharmony_ci
5627777dab0Sopenharmony_ci#define UV_CHECK_PRIVATE_FIELDS                                               \
5637777dab0Sopenharmony_ci  uv_check_t* check_prev;                                                     \
5647777dab0Sopenharmony_ci  uv_check_t* check_next;                                                     \
5657777dab0Sopenharmony_ci  uv_check_cb check_cb;
5667777dab0Sopenharmony_ci
5677777dab0Sopenharmony_ci#define UV_IDLE_PRIVATE_FIELDS                                                \
5687777dab0Sopenharmony_ci  uv_idle_t* idle_prev;                                                       \
5697777dab0Sopenharmony_ci  uv_idle_t* idle_next;                                                       \
5707777dab0Sopenharmony_ci  uv_idle_cb idle_cb;
5717777dab0Sopenharmony_ci
5727777dab0Sopenharmony_ci#define UV_HANDLE_PRIVATE_FIELDS                                              \
5737777dab0Sopenharmony_ci  uv_handle_t* endgame_next;                                                  \
5747777dab0Sopenharmony_ci  unsigned int flags;
5757777dab0Sopenharmony_ci
5767777dab0Sopenharmony_ci#define UV_GETADDRINFO_PRIVATE_FIELDS                                         \
5777777dab0Sopenharmony_ci  struct uv__work work_req;                                                   \
5787777dab0Sopenharmony_ci  uv_getaddrinfo_cb getaddrinfo_cb;                                           \
5797777dab0Sopenharmony_ci  void* alloc;                                                                \
5807777dab0Sopenharmony_ci  WCHAR* node;                                                                \
5817777dab0Sopenharmony_ci  WCHAR* service;                                                             \
5827777dab0Sopenharmony_ci  /* The addrinfoW field is used to store a pointer to the hints, and    */   \
5837777dab0Sopenharmony_ci  /* later on to store the result of GetAddrInfoW. The final result will */   \
5847777dab0Sopenharmony_ci  /* be converted to struct addrinfo* and stored in the addrinfo field.  */   \
5857777dab0Sopenharmony_ci  struct addrinfoW* addrinfow;                                                \
5867777dab0Sopenharmony_ci  struct addrinfo* addrinfo;                                                  \
5877777dab0Sopenharmony_ci  int retcode;
5887777dab0Sopenharmony_ci
5897777dab0Sopenharmony_ci#define UV_GETNAMEINFO_PRIVATE_FIELDS                                         \
5907777dab0Sopenharmony_ci  struct uv__work work_req;                                                   \
5917777dab0Sopenharmony_ci  uv_getnameinfo_cb getnameinfo_cb;                                           \
5927777dab0Sopenharmony_ci  struct sockaddr_storage storage;                                            \
5937777dab0Sopenharmony_ci  int flags;                                                                  \
5947777dab0Sopenharmony_ci  char host[NI_MAXHOST];                                                      \
5957777dab0Sopenharmony_ci  char service[NI_MAXSERV];                                                   \
5967777dab0Sopenharmony_ci  int retcode;
5977777dab0Sopenharmony_ci
5987777dab0Sopenharmony_ci#define UV_PROCESS_PRIVATE_FIELDS                                             \
5997777dab0Sopenharmony_ci  struct uv_process_exit_s {                                                  \
6007777dab0Sopenharmony_ci    UV_REQ_FIELDS                                                             \
6017777dab0Sopenharmony_ci  } exit_req;                                                                 \
6027777dab0Sopenharmony_ci  BYTE* child_stdio_buffer;                                                   \
6037777dab0Sopenharmony_ci  int exit_signal;                                                            \
6047777dab0Sopenharmony_ci  HANDLE wait_handle;                                                         \
6057777dab0Sopenharmony_ci  HANDLE process_handle;                                                      \
6067777dab0Sopenharmony_ci  volatile char exit_cb_pending;
6077777dab0Sopenharmony_ci
6087777dab0Sopenharmony_ci#define UV_FS_PRIVATE_FIELDS                                                  \
6097777dab0Sopenharmony_ci  struct uv__work work_req;                                                   \
6107777dab0Sopenharmony_ci  int flags;                                                                  \
6117777dab0Sopenharmony_ci  DWORD sys_errno_;                                                           \
6127777dab0Sopenharmony_ci  union {                                                                     \
6137777dab0Sopenharmony_ci    /* TODO: remove me in 0.9. */                                             \
6147777dab0Sopenharmony_ci    WCHAR* pathw;                                                             \
6157777dab0Sopenharmony_ci    int fd;                                                                   \
6167777dab0Sopenharmony_ci  } file;                                                                     \
6177777dab0Sopenharmony_ci  union {                                                                     \
6187777dab0Sopenharmony_ci    struct {                                                                  \
6197777dab0Sopenharmony_ci      int mode;                                                               \
6207777dab0Sopenharmony_ci      WCHAR* new_pathw;                                                       \
6217777dab0Sopenharmony_ci      int file_flags;                                                         \
6227777dab0Sopenharmony_ci      int fd_out;                                                             \
6237777dab0Sopenharmony_ci      unsigned int nbufs;                                                     \
6247777dab0Sopenharmony_ci      uv_buf_t* bufs;                                                         \
6257777dab0Sopenharmony_ci      int64_t offset;                                                         \
6267777dab0Sopenharmony_ci      uv_buf_t bufsml[4];                                                     \
6277777dab0Sopenharmony_ci    } info;                                                                   \
6287777dab0Sopenharmony_ci    struct {                                                                  \
6297777dab0Sopenharmony_ci      double atime;                                                           \
6307777dab0Sopenharmony_ci      double mtime;                                                           \
6317777dab0Sopenharmony_ci    } time;                                                                   \
6327777dab0Sopenharmony_ci  } fs;
6337777dab0Sopenharmony_ci
6347777dab0Sopenharmony_ci#define UV_WORK_PRIVATE_FIELDS                                                \
6357777dab0Sopenharmony_ci  struct uv__work work_req;
6367777dab0Sopenharmony_ci
6377777dab0Sopenharmony_ci#define UV_FS_EVENT_PRIVATE_FIELDS                                            \
6387777dab0Sopenharmony_ci  struct uv_fs_event_req_s {                                                  \
6397777dab0Sopenharmony_ci    UV_REQ_FIELDS                                                             \
6407777dab0Sopenharmony_ci  } req;                                                                      \
6417777dab0Sopenharmony_ci  HANDLE dir_handle;                                                          \
6427777dab0Sopenharmony_ci  int req_pending;                                                            \
6437777dab0Sopenharmony_ci  uv_fs_event_cb cb;                                                          \
6447777dab0Sopenharmony_ci  WCHAR* filew;                                                               \
6457777dab0Sopenharmony_ci  WCHAR* short_filew;                                                         \
6467777dab0Sopenharmony_ci  WCHAR* dirw;                                                                \
6477777dab0Sopenharmony_ci  char* buffer;
6487777dab0Sopenharmony_ci
6497777dab0Sopenharmony_ci#define UV_SIGNAL_PRIVATE_FIELDS                                              \
6507777dab0Sopenharmony_ci  RB_ENTRY(uv_signal_s) tree_entry;                                           \
6517777dab0Sopenharmony_ci  struct uv_req_s signal_req;                                                 \
6527777dab0Sopenharmony_ci  unsigned long pending_signum;
6537777dab0Sopenharmony_ci
6547777dab0Sopenharmony_ci#ifndef F_OK
6557777dab0Sopenharmony_ci#define F_OK 0
6567777dab0Sopenharmony_ci#endif
6577777dab0Sopenharmony_ci#ifndef R_OK
6587777dab0Sopenharmony_ci#define R_OK 4
6597777dab0Sopenharmony_ci#endif
6607777dab0Sopenharmony_ci#ifndef W_OK
6617777dab0Sopenharmony_ci#define W_OK 2
6627777dab0Sopenharmony_ci#endif
6637777dab0Sopenharmony_ci#ifndef X_OK
6647777dab0Sopenharmony_ci#define X_OK 1
6657777dab0Sopenharmony_ci#endif
6667777dab0Sopenharmony_ci
6677777dab0Sopenharmony_ci/* fs open() flags supported on this platform: */
6687777dab0Sopenharmony_ci#define UV_FS_O_APPEND       _O_APPEND
6697777dab0Sopenharmony_ci#define UV_FS_O_CREAT        _O_CREAT
6707777dab0Sopenharmony_ci#define UV_FS_O_EXCL         _O_EXCL
6717777dab0Sopenharmony_ci#define UV_FS_O_FILEMAP      0x20000000
6727777dab0Sopenharmony_ci#define UV_FS_O_RANDOM       _O_RANDOM
6737777dab0Sopenharmony_ci#define UV_FS_O_RDONLY       _O_RDONLY
6747777dab0Sopenharmony_ci#define UV_FS_O_RDWR         _O_RDWR
6757777dab0Sopenharmony_ci#define UV_FS_O_SEQUENTIAL   _O_SEQUENTIAL
6767777dab0Sopenharmony_ci#define UV_FS_O_SHORT_LIVED  _O_SHORT_LIVED
6777777dab0Sopenharmony_ci#define UV_FS_O_TEMPORARY    _O_TEMPORARY
6787777dab0Sopenharmony_ci#define UV_FS_O_TRUNC        _O_TRUNC
6797777dab0Sopenharmony_ci#define UV_FS_O_WRONLY       _O_WRONLY
6807777dab0Sopenharmony_ci
6817777dab0Sopenharmony_ci/* fs open() flags supported on other platforms (or mapped on this platform): */
6827777dab0Sopenharmony_ci#define UV_FS_O_DIRECT       0x02000000 /* FILE_FLAG_NO_BUFFERING */
6837777dab0Sopenharmony_ci#define UV_FS_O_DIRECTORY    0
6847777dab0Sopenharmony_ci#define UV_FS_O_DSYNC        0x04000000 /* FILE_FLAG_WRITE_THROUGH */
6857777dab0Sopenharmony_ci#define UV_FS_O_EXLOCK       0x10000000 /* EXCLUSIVE SHARING MODE */
6867777dab0Sopenharmony_ci#define UV_FS_O_NOATIME      0
6877777dab0Sopenharmony_ci#define UV_FS_O_NOCTTY       0
6887777dab0Sopenharmony_ci#define UV_FS_O_NOFOLLOW     0
6897777dab0Sopenharmony_ci#define UV_FS_O_NONBLOCK     0
6907777dab0Sopenharmony_ci#define UV_FS_O_SYMLINK      0
6917777dab0Sopenharmony_ci#define UV_FS_O_SYNC         0x08000000 /* FILE_FLAG_WRITE_THROUGH */
692