1e66f31c5Sopenharmony_ci/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2e66f31c5Sopenharmony_ci *
3e66f31c5Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
4e66f31c5Sopenharmony_ci * of this software and associated documentation files (the "Software"), to
5e66f31c5Sopenharmony_ci * deal in the Software without restriction, including without limitation the
6e66f31c5Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7e66f31c5Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is
8e66f31c5Sopenharmony_ci * furnished to do so, subject to the following conditions:
9e66f31c5Sopenharmony_ci *
10e66f31c5Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
11e66f31c5Sopenharmony_ci * all copies or substantial portions of the Software.
12e66f31c5Sopenharmony_ci *
13e66f31c5Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14e66f31c5Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15e66f31c5Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16e66f31c5Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17e66f31c5Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18e66f31c5Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19e66f31c5Sopenharmony_ci * IN THE SOFTWARE.
20e66f31c5Sopenharmony_ci */
21e66f31c5Sopenharmony_ci
22e66f31c5Sopenharmony_ci#ifndef UV_UNIX_H
23e66f31c5Sopenharmony_ci#define UV_UNIX_H
24e66f31c5Sopenharmony_ci
25e66f31c5Sopenharmony_ci#include <sys/types.h>
26e66f31c5Sopenharmony_ci#include <sys/stat.h>
27e66f31c5Sopenharmony_ci#include <fcntl.h>
28e66f31c5Sopenharmony_ci#include <dirent.h>
29e66f31c5Sopenharmony_ci
30e66f31c5Sopenharmony_ci#include <sys/socket.h>
31e66f31c5Sopenharmony_ci#include <netinet/in.h>
32e66f31c5Sopenharmony_ci#include <netinet/tcp.h>
33e66f31c5Sopenharmony_ci#include <arpa/inet.h>
34e66f31c5Sopenharmony_ci#include <netdb.h>  /* MAXHOSTNAMELEN on Solaris */
35e66f31c5Sopenharmony_ci
36e66f31c5Sopenharmony_ci#include <termios.h>
37e66f31c5Sopenharmony_ci#include <pwd.h>
38e66f31c5Sopenharmony_ci
39e66f31c5Sopenharmony_ci#if !defined(__MVS__)
40e66f31c5Sopenharmony_ci#include <semaphore.h>
41e66f31c5Sopenharmony_ci#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
42e66f31c5Sopenharmony_ci#endif
43e66f31c5Sopenharmony_ci#include <pthread.h>
44e66f31c5Sopenharmony_ci#include <signal.h>
45e66f31c5Sopenharmony_ci
46e66f31c5Sopenharmony_ci#include "uv/threadpool.h"
47e66f31c5Sopenharmony_ci
48e66f31c5Sopenharmony_ci#if defined(__linux__)
49e66f31c5Sopenharmony_ci# include "uv/linux.h"
50e66f31c5Sopenharmony_ci#elif defined (__MVS__)
51e66f31c5Sopenharmony_ci# include "uv/os390.h"
52e66f31c5Sopenharmony_ci#elif defined(__PASE__)  /* __PASE__ and _AIX are both defined on IBM i */
53e66f31c5Sopenharmony_ci# include "uv/posix.h"  /* IBM i needs uv/posix.h, not uv/aix.h */
54e66f31c5Sopenharmony_ci#elif defined(_AIX)
55e66f31c5Sopenharmony_ci# include "uv/aix.h"
56e66f31c5Sopenharmony_ci#elif defined(__sun)
57e66f31c5Sopenharmony_ci# include "uv/sunos.h"
58e66f31c5Sopenharmony_ci#elif defined(__APPLE__)
59e66f31c5Sopenharmony_ci# include "uv/darwin.h"
60e66f31c5Sopenharmony_ci#elif defined(__DragonFly__)       || \
61e66f31c5Sopenharmony_ci      defined(__FreeBSD__)         || \
62e66f31c5Sopenharmony_ci      defined(__OpenBSD__)         || \
63e66f31c5Sopenharmony_ci      defined(__NetBSD__)
64e66f31c5Sopenharmony_ci# include "uv/bsd.h"
65e66f31c5Sopenharmony_ci#elif defined(__CYGWIN__) || \
66e66f31c5Sopenharmony_ci      defined(__MSYS__)   || \
67e66f31c5Sopenharmony_ci      defined(__HAIKU__)  || \
68e66f31c5Sopenharmony_ci      defined(__QNX__)    || \
69e66f31c5Sopenharmony_ci      defined(__GNU__)
70e66f31c5Sopenharmony_ci# include "uv/posix.h"
71e66f31c5Sopenharmony_ci#endif
72e66f31c5Sopenharmony_ci
73e66f31c5Sopenharmony_ci#ifndef NI_MAXHOST
74e66f31c5Sopenharmony_ci# define NI_MAXHOST 1025
75e66f31c5Sopenharmony_ci#endif
76e66f31c5Sopenharmony_ci
77e66f31c5Sopenharmony_ci#ifndef NI_MAXSERV
78e66f31c5Sopenharmony_ci# define NI_MAXSERV 32
79e66f31c5Sopenharmony_ci#endif
80e66f31c5Sopenharmony_ci
81e66f31c5Sopenharmony_ci#ifndef UV_IO_PRIVATE_PLATFORM_FIELDS
82e66f31c5Sopenharmony_ci# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */
83e66f31c5Sopenharmony_ci#endif
84e66f31c5Sopenharmony_ci
85e66f31c5Sopenharmony_cistruct uv__io_s;
86e66f31c5Sopenharmony_cistruct uv_loop_s;
87e66f31c5Sopenharmony_ci
88e66f31c5Sopenharmony_citypedef void (*uv__io_cb)(struct uv_loop_s* loop,
89e66f31c5Sopenharmony_ci                          struct uv__io_s* w,
90e66f31c5Sopenharmony_ci                          unsigned int events);
91e66f31c5Sopenharmony_citypedef struct uv__io_s uv__io_t;
92e66f31c5Sopenharmony_ci
93e66f31c5Sopenharmony_cistruct uv__io_s {
94e66f31c5Sopenharmony_ci  uv__io_cb cb;
95e66f31c5Sopenharmony_ci  struct uv__queue pending_queue;
96e66f31c5Sopenharmony_ci  struct uv__queue watcher_queue;
97e66f31c5Sopenharmony_ci  unsigned int pevents; /* Pending event mask i.e. mask at next tick. */
98e66f31c5Sopenharmony_ci  unsigned int events;  /* Current event mask. */
99e66f31c5Sopenharmony_ci  int fd;
100e66f31c5Sopenharmony_ci  UV_IO_PRIVATE_PLATFORM_FIELDS
101e66f31c5Sopenharmony_ci};
102e66f31c5Sopenharmony_ci
103e66f31c5Sopenharmony_ci#ifndef UV_PLATFORM_SEM_T
104e66f31c5Sopenharmony_ci# define UV_PLATFORM_SEM_T sem_t
105e66f31c5Sopenharmony_ci#endif
106e66f31c5Sopenharmony_ci
107e66f31c5Sopenharmony_ci#ifndef UV_PLATFORM_LOOP_FIELDS
108e66f31c5Sopenharmony_ci# define UV_PLATFORM_LOOP_FIELDS /* empty */
109e66f31c5Sopenharmony_ci#endif
110e66f31c5Sopenharmony_ci
111e66f31c5Sopenharmony_ci#ifndef UV_PLATFORM_FS_EVENT_FIELDS
112e66f31c5Sopenharmony_ci# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */
113e66f31c5Sopenharmony_ci#endif
114e66f31c5Sopenharmony_ci
115e66f31c5Sopenharmony_ci#ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS
116e66f31c5Sopenharmony_ci# define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */
117e66f31c5Sopenharmony_ci#endif
118e66f31c5Sopenharmony_ci
119e66f31c5Sopenharmony_ci/* Note: May be cast to struct iovec. See writev(2). */
120e66f31c5Sopenharmony_citypedef struct uv_buf_t {
121e66f31c5Sopenharmony_ci  char* base;
122e66f31c5Sopenharmony_ci  size_t len;
123e66f31c5Sopenharmony_ci} uv_buf_t;
124e66f31c5Sopenharmony_ci
125e66f31c5Sopenharmony_citypedef int uv_file;
126e66f31c5Sopenharmony_citypedef int uv_os_sock_t;
127e66f31c5Sopenharmony_citypedef int uv_os_fd_t;
128e66f31c5Sopenharmony_citypedef pid_t uv_pid_t;
129e66f31c5Sopenharmony_ci
130e66f31c5Sopenharmony_ci#define UV_ONCE_INIT PTHREAD_ONCE_INIT
131e66f31c5Sopenharmony_ci
132e66f31c5Sopenharmony_citypedef pthread_once_t uv_once_t;
133e66f31c5Sopenharmony_citypedef pthread_t uv_thread_t;
134e66f31c5Sopenharmony_citypedef pthread_mutex_t uv_mutex_t;
135e66f31c5Sopenharmony_citypedef pthread_rwlock_t uv_rwlock_t;
136e66f31c5Sopenharmony_citypedef UV_PLATFORM_SEM_T uv_sem_t;
137e66f31c5Sopenharmony_citypedef pthread_cond_t uv_cond_t;
138e66f31c5Sopenharmony_citypedef pthread_key_t uv_key_t;
139e66f31c5Sopenharmony_ci
140e66f31c5Sopenharmony_ci/* Note: guard clauses should match uv_barrier_init's in src/unix/thread.c. */
141e66f31c5Sopenharmony_ci#if defined(_AIX) || \
142e66f31c5Sopenharmony_ci    defined(__OpenBSD__) || \
143e66f31c5Sopenharmony_ci    !defined(PTHREAD_BARRIER_SERIAL_THREAD)
144e66f31c5Sopenharmony_ci/* TODO(bnoordhuis) Merge into uv_barrier_t in v2. */
145e66f31c5Sopenharmony_cistruct _uv_barrier {
146e66f31c5Sopenharmony_ci  uv_mutex_t mutex;
147e66f31c5Sopenharmony_ci  uv_cond_t cond;
148e66f31c5Sopenharmony_ci  unsigned threshold;
149e66f31c5Sopenharmony_ci  unsigned in;
150e66f31c5Sopenharmony_ci  unsigned out;
151e66f31c5Sopenharmony_ci};
152e66f31c5Sopenharmony_ci
153e66f31c5Sopenharmony_citypedef struct {
154e66f31c5Sopenharmony_ci  struct _uv_barrier* b;
155e66f31c5Sopenharmony_ci# if defined(PTHREAD_BARRIER_SERIAL_THREAD)
156e66f31c5Sopenharmony_ci  /* TODO(bnoordhuis) Remove padding in v2. */
157e66f31c5Sopenharmony_ci  char pad[sizeof(pthread_barrier_t) - sizeof(struct _uv_barrier*)];
158e66f31c5Sopenharmony_ci# endif
159e66f31c5Sopenharmony_ci} uv_barrier_t;
160e66f31c5Sopenharmony_ci#else
161e66f31c5Sopenharmony_citypedef pthread_barrier_t uv_barrier_t;
162e66f31c5Sopenharmony_ci#endif
163e66f31c5Sopenharmony_ci
164e66f31c5Sopenharmony_ci/* Platform-specific definitions for uv_spawn support. */
165e66f31c5Sopenharmony_citypedef gid_t uv_gid_t;
166e66f31c5Sopenharmony_citypedef uid_t uv_uid_t;
167e66f31c5Sopenharmony_ci
168e66f31c5Sopenharmony_citypedef struct dirent uv__dirent_t;
169e66f31c5Sopenharmony_ci
170e66f31c5Sopenharmony_ci#define UV_DIR_PRIVATE_FIELDS \
171e66f31c5Sopenharmony_ci  DIR* dir;
172e66f31c5Sopenharmony_ci
173e66f31c5Sopenharmony_ci#if defined(DT_UNKNOWN)
174e66f31c5Sopenharmony_ci# define HAVE_DIRENT_TYPES
175e66f31c5Sopenharmony_ci# if defined(DT_REG)
176e66f31c5Sopenharmony_ci#  define UV__DT_FILE DT_REG
177e66f31c5Sopenharmony_ci# else
178e66f31c5Sopenharmony_ci#  define UV__DT_FILE -1
179e66f31c5Sopenharmony_ci# endif
180e66f31c5Sopenharmony_ci# if defined(DT_DIR)
181e66f31c5Sopenharmony_ci#  define UV__DT_DIR DT_DIR
182e66f31c5Sopenharmony_ci# else
183e66f31c5Sopenharmony_ci#  define UV__DT_DIR -2
184e66f31c5Sopenharmony_ci# endif
185e66f31c5Sopenharmony_ci# if defined(DT_LNK)
186e66f31c5Sopenharmony_ci#  define UV__DT_LINK DT_LNK
187e66f31c5Sopenharmony_ci# else
188e66f31c5Sopenharmony_ci#  define UV__DT_LINK -3
189e66f31c5Sopenharmony_ci# endif
190e66f31c5Sopenharmony_ci# if defined(DT_FIFO)
191e66f31c5Sopenharmony_ci#  define UV__DT_FIFO DT_FIFO
192e66f31c5Sopenharmony_ci# else
193e66f31c5Sopenharmony_ci#  define UV__DT_FIFO -4
194e66f31c5Sopenharmony_ci# endif
195e66f31c5Sopenharmony_ci# if defined(DT_SOCK)
196e66f31c5Sopenharmony_ci#  define UV__DT_SOCKET DT_SOCK
197e66f31c5Sopenharmony_ci# else
198e66f31c5Sopenharmony_ci#  define UV__DT_SOCKET -5
199e66f31c5Sopenharmony_ci# endif
200e66f31c5Sopenharmony_ci# if defined(DT_CHR)
201e66f31c5Sopenharmony_ci#  define UV__DT_CHAR DT_CHR
202e66f31c5Sopenharmony_ci# else
203e66f31c5Sopenharmony_ci#  define UV__DT_CHAR -6
204e66f31c5Sopenharmony_ci# endif
205e66f31c5Sopenharmony_ci# if defined(DT_BLK)
206e66f31c5Sopenharmony_ci#  define UV__DT_BLOCK DT_BLK
207e66f31c5Sopenharmony_ci# else
208e66f31c5Sopenharmony_ci#  define UV__DT_BLOCK -7
209e66f31c5Sopenharmony_ci# endif
210e66f31c5Sopenharmony_ci#endif
211e66f31c5Sopenharmony_ci
212e66f31c5Sopenharmony_ci/* Platform-specific definitions for uv_dlopen support. */
213e66f31c5Sopenharmony_ci#define UV_DYNAMIC /* empty */
214e66f31c5Sopenharmony_ci
215e66f31c5Sopenharmony_citypedef struct {
216e66f31c5Sopenharmony_ci  void* handle;
217e66f31c5Sopenharmony_ci  char* errmsg;
218e66f31c5Sopenharmony_ci} uv_lib_t;
219e66f31c5Sopenharmony_ci
220e66f31c5Sopenharmony_ci#define UV_LOOP_PRIVATE_FIELDS                                                \
221e66f31c5Sopenharmony_ci  unsigned int magic;                                                         \
222e66f31c5Sopenharmony_ci  unsigned long flags;                                                        \
223e66f31c5Sopenharmony_ci  int backend_fd;                                                             \
224e66f31c5Sopenharmony_ci  struct uv__queue pending_queue;                                             \
225e66f31c5Sopenharmony_ci  struct uv__queue watcher_queue;                                             \
226e66f31c5Sopenharmony_ci  uv__io_t** watchers;                                                        \
227e66f31c5Sopenharmony_ci  unsigned int nwatchers;                                                     \
228e66f31c5Sopenharmony_ci  unsigned int nfds;                                                          \
229e66f31c5Sopenharmony_ci  struct uv__queue wq;                                                        \
230e66f31c5Sopenharmony_ci  uv_mutex_t wq_mutex;                                                        \
231e66f31c5Sopenharmony_ci  uv_async_t wq_async;                                                        \
232e66f31c5Sopenharmony_ci  uv_rwlock_t cloexec_lock;                                                   \
233e66f31c5Sopenharmony_ci  uv_handle_t* closing_handles;                                               \
234e66f31c5Sopenharmony_ci  struct uv__queue process_handles;                                           \
235e66f31c5Sopenharmony_ci  struct uv__queue prepare_handles;                                           \
236e66f31c5Sopenharmony_ci  struct uv__queue check_handles;                                             \
237e66f31c5Sopenharmony_ci  struct uv__queue idle_handles;                                              \
238e66f31c5Sopenharmony_ci  struct uv__queue async_handles;                                             \
239e66f31c5Sopenharmony_ci  void (*async_unused)(void);  /* TODO(bnoordhuis) Remove in libuv v2. */     \
240e66f31c5Sopenharmony_ci  uv__io_t async_io_watcher;                                                  \
241e66f31c5Sopenharmony_ci  int async_wfd;                                                              \
242e66f31c5Sopenharmony_ci  struct {                                                                    \
243e66f31c5Sopenharmony_ci    void* min;                                                                \
244e66f31c5Sopenharmony_ci    unsigned int nelts;                                                       \
245e66f31c5Sopenharmony_ci  } timer_heap;                                                               \
246e66f31c5Sopenharmony_ci  uint64_t timer_counter;                                                     \
247e66f31c5Sopenharmony_ci  uint64_t time;                                                              \
248e66f31c5Sopenharmony_ci  int signal_pipefd[2];                                                       \
249e66f31c5Sopenharmony_ci  uv__io_t signal_io_watcher;                                                 \
250e66f31c5Sopenharmony_ci  uv_signal_t child_watcher;                                                  \
251e66f31c5Sopenharmony_ci  int emfile_fd;                                                              \
252e66f31c5Sopenharmony_ci  UV_PLATFORM_LOOP_FIELDS                                                     \
253e66f31c5Sopenharmony_ci
254e66f31c5Sopenharmony_ci#define UV_REQ_TYPE_PRIVATE /* empty */
255e66f31c5Sopenharmony_ci
256e66f31c5Sopenharmony_ci#define UV_REQ_PRIVATE_FIELDS  /* empty */
257e66f31c5Sopenharmony_ci
258e66f31c5Sopenharmony_ci#define UV_PRIVATE_REQ_TYPES /* empty */
259e66f31c5Sopenharmony_ci
260e66f31c5Sopenharmony_ci#define UV_WRITE_PRIVATE_FIELDS                                               \
261e66f31c5Sopenharmony_ci  struct uv__queue queue;                                                     \
262e66f31c5Sopenharmony_ci  unsigned int write_index;                                                   \
263e66f31c5Sopenharmony_ci  uv_buf_t* bufs;                                                             \
264e66f31c5Sopenharmony_ci  unsigned int nbufs;                                                         \
265e66f31c5Sopenharmony_ci  int error;                                                                  \
266e66f31c5Sopenharmony_ci  uv_buf_t bufsml[4];                                                         \
267e66f31c5Sopenharmony_ci
268e66f31c5Sopenharmony_ci#define UV_CONNECT_PRIVATE_FIELDS                                             \
269e66f31c5Sopenharmony_ci  struct uv__queue queue;                                                     \
270e66f31c5Sopenharmony_ci
271e66f31c5Sopenharmony_ci#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */
272e66f31c5Sopenharmony_ci
273e66f31c5Sopenharmony_ci#define UV_UDP_SEND_PRIVATE_FIELDS                                            \
274e66f31c5Sopenharmony_ci  struct uv__queue queue;                                                     \
275e66f31c5Sopenharmony_ci  struct sockaddr_storage addr;                                               \
276e66f31c5Sopenharmony_ci  unsigned int nbufs;                                                         \
277e66f31c5Sopenharmony_ci  uv_buf_t* bufs;                                                             \
278e66f31c5Sopenharmony_ci  ssize_t status;                                                             \
279e66f31c5Sopenharmony_ci  uv_udp_send_cb send_cb;                                                     \
280e66f31c5Sopenharmony_ci  uv_buf_t bufsml[4];                                                         \
281e66f31c5Sopenharmony_ci
282e66f31c5Sopenharmony_ci#define UV_HANDLE_PRIVATE_FIELDS                                              \
283e66f31c5Sopenharmony_ci  uv_handle_t* next_closing;                                                  \
284e66f31c5Sopenharmony_ci  unsigned int flags;                                                         \
285e66f31c5Sopenharmony_ci
286e66f31c5Sopenharmony_ci#define UV_STREAM_PRIVATE_FIELDS                                              \
287e66f31c5Sopenharmony_ci  uv_connect_t *connect_req;                                                  \
288e66f31c5Sopenharmony_ci  uv_shutdown_t *shutdown_req;                                                \
289e66f31c5Sopenharmony_ci  uv__io_t io_watcher;                                                        \
290e66f31c5Sopenharmony_ci  struct uv__queue write_queue;                                               \
291e66f31c5Sopenharmony_ci  struct uv__queue write_completed_queue;                                     \
292e66f31c5Sopenharmony_ci  uv_connection_cb connection_cb;                                             \
293e66f31c5Sopenharmony_ci  int delayed_error;                                                          \
294e66f31c5Sopenharmony_ci  int accepted_fd;                                                            \
295e66f31c5Sopenharmony_ci  void* queued_fds;                                                           \
296e66f31c5Sopenharmony_ci  UV_STREAM_PRIVATE_PLATFORM_FIELDS                                           \
297e66f31c5Sopenharmony_ci
298e66f31c5Sopenharmony_ci#define UV_TCP_PRIVATE_FIELDS /* empty */
299e66f31c5Sopenharmony_ci
300e66f31c5Sopenharmony_ci#define UV_UDP_PRIVATE_FIELDS                                                 \
301e66f31c5Sopenharmony_ci  uv_alloc_cb alloc_cb;                                                       \
302e66f31c5Sopenharmony_ci  uv_udp_recv_cb recv_cb;                                                     \
303e66f31c5Sopenharmony_ci  uv__io_t io_watcher;                                                        \
304e66f31c5Sopenharmony_ci  struct uv__queue write_queue;                                               \
305e66f31c5Sopenharmony_ci  struct uv__queue write_completed_queue;                                     \
306e66f31c5Sopenharmony_ci
307e66f31c5Sopenharmony_ci#define UV_PIPE_PRIVATE_FIELDS                                                \
308e66f31c5Sopenharmony_ci  const char* pipe_fname; /* NULL or strdup'ed */
309e66f31c5Sopenharmony_ci
310e66f31c5Sopenharmony_ci#define UV_POLL_PRIVATE_FIELDS                                                \
311e66f31c5Sopenharmony_ci  uv__io_t io_watcher;
312e66f31c5Sopenharmony_ci
313e66f31c5Sopenharmony_ci#define UV_PREPARE_PRIVATE_FIELDS                                             \
314e66f31c5Sopenharmony_ci  uv_prepare_cb prepare_cb;                                                   \
315e66f31c5Sopenharmony_ci  struct uv__queue queue;                                                     \
316e66f31c5Sopenharmony_ci
317e66f31c5Sopenharmony_ci#define UV_CHECK_PRIVATE_FIELDS                                               \
318e66f31c5Sopenharmony_ci  uv_check_cb check_cb;                                                       \
319e66f31c5Sopenharmony_ci  struct uv__queue queue;                                                     \
320e66f31c5Sopenharmony_ci
321e66f31c5Sopenharmony_ci#define UV_IDLE_PRIVATE_FIELDS                                                \
322e66f31c5Sopenharmony_ci  uv_idle_cb idle_cb;                                                         \
323e66f31c5Sopenharmony_ci  struct uv__queue queue;                                                     \
324e66f31c5Sopenharmony_ci
325e66f31c5Sopenharmony_ci#define UV_ASYNC_PRIVATE_FIELDS                                               \
326e66f31c5Sopenharmony_ci  uv_async_cb async_cb;                                                       \
327e66f31c5Sopenharmony_ci  struct uv__queue queue;                                                     \
328e66f31c5Sopenharmony_ci  int pending;                                                                \
329e66f31c5Sopenharmony_ci
330e66f31c5Sopenharmony_ci#define UV_TIMER_PRIVATE_FIELDS                                               \
331e66f31c5Sopenharmony_ci  uv_timer_cb timer_cb;                                                       \
332e66f31c5Sopenharmony_ci  void* heap_node[3];                                                         \
333e66f31c5Sopenharmony_ci  uint64_t timeout;                                                           \
334e66f31c5Sopenharmony_ci  uint64_t repeat;                                                            \
335e66f31c5Sopenharmony_ci  uint64_t start_id;
336e66f31c5Sopenharmony_ci
337e66f31c5Sopenharmony_ci#define UV_GETADDRINFO_PRIVATE_FIELDS                                         \
338e66f31c5Sopenharmony_ci  struct uv__work work_req;                                                   \
339e66f31c5Sopenharmony_ci  uv_getaddrinfo_cb cb;                                                       \
340e66f31c5Sopenharmony_ci  struct addrinfo* hints;                                                     \
341e66f31c5Sopenharmony_ci  char* hostname;                                                             \
342e66f31c5Sopenharmony_ci  char* service;                                                              \
343e66f31c5Sopenharmony_ci  struct addrinfo* addrinfo;                                                  \
344e66f31c5Sopenharmony_ci  int retcode;
345e66f31c5Sopenharmony_ci
346e66f31c5Sopenharmony_ci#define UV_GETNAMEINFO_PRIVATE_FIELDS                                         \
347e66f31c5Sopenharmony_ci  struct uv__work work_req;                                                   \
348e66f31c5Sopenharmony_ci  uv_getnameinfo_cb getnameinfo_cb;                                           \
349e66f31c5Sopenharmony_ci  struct sockaddr_storage storage;                                            \
350e66f31c5Sopenharmony_ci  int flags;                                                                  \
351e66f31c5Sopenharmony_ci  char host[NI_MAXHOST];                                                      \
352e66f31c5Sopenharmony_ci  char service[NI_MAXSERV];                                                   \
353e66f31c5Sopenharmony_ci  int retcode;
354e66f31c5Sopenharmony_ci
355e66f31c5Sopenharmony_ci#define UV_PROCESS_PRIVATE_FIELDS                                             \
356e66f31c5Sopenharmony_ci  struct uv__queue queue;                                                     \
357e66f31c5Sopenharmony_ci  int status;                                                                 \
358e66f31c5Sopenharmony_ci
359e66f31c5Sopenharmony_ci#define UV_FS_PRIVATE_FIELDS                                                  \
360e66f31c5Sopenharmony_ci  const char *new_path;                                                       \
361e66f31c5Sopenharmony_ci  uv_file file;                                                               \
362e66f31c5Sopenharmony_ci  int flags;                                                                  \
363e66f31c5Sopenharmony_ci  mode_t mode;                                                                \
364e66f31c5Sopenharmony_ci  unsigned int nbufs;                                                         \
365e66f31c5Sopenharmony_ci  uv_buf_t* bufs;                                                             \
366e66f31c5Sopenharmony_ci  off_t off;                                                                  \
367e66f31c5Sopenharmony_ci  uv_uid_t uid;                                                               \
368e66f31c5Sopenharmony_ci  uv_gid_t gid;                                                               \
369e66f31c5Sopenharmony_ci  double atime;                                                               \
370e66f31c5Sopenharmony_ci  double mtime;                                                               \
371e66f31c5Sopenharmony_ci  struct uv__work work_req;                                                   \
372e66f31c5Sopenharmony_ci  uv_buf_t bufsml[4];                                                         \
373e66f31c5Sopenharmony_ci
374e66f31c5Sopenharmony_ci#define UV_WORK_PRIVATE_FIELDS                                                \
375e66f31c5Sopenharmony_ci  struct uv__work work_req;
376e66f31c5Sopenharmony_ci
377e66f31c5Sopenharmony_ci#define UV_TTY_PRIVATE_FIELDS                                                 \
378e66f31c5Sopenharmony_ci  struct termios orig_termios;                                                \
379e66f31c5Sopenharmony_ci  int mode;
380e66f31c5Sopenharmony_ci
381e66f31c5Sopenharmony_ci#define UV_SIGNAL_PRIVATE_FIELDS                                              \
382e66f31c5Sopenharmony_ci  /* RB_ENTRY(uv_signal_s) tree_entry; */                                     \
383e66f31c5Sopenharmony_ci  struct {                                                                    \
384e66f31c5Sopenharmony_ci    struct uv_signal_s* rbe_left;                                             \
385e66f31c5Sopenharmony_ci    struct uv_signal_s* rbe_right;                                            \
386e66f31c5Sopenharmony_ci    struct uv_signal_s* rbe_parent;                                           \
387e66f31c5Sopenharmony_ci    int rbe_color;                                                            \
388e66f31c5Sopenharmony_ci  } tree_entry;                                                               \
389e66f31c5Sopenharmony_ci  /* Use two counters here so we don have to fiddle with atomics. */          \
390e66f31c5Sopenharmony_ci  unsigned int caught_signals;                                                \
391e66f31c5Sopenharmony_ci  unsigned int dispatched_signals;
392e66f31c5Sopenharmony_ci
393e66f31c5Sopenharmony_ci#define UV_FS_EVENT_PRIVATE_FIELDS                                            \
394e66f31c5Sopenharmony_ci  uv_fs_event_cb cb;                                                          \
395e66f31c5Sopenharmony_ci  UV_PLATFORM_FS_EVENT_FIELDS                                                 \
396e66f31c5Sopenharmony_ci
397e66f31c5Sopenharmony_ci/* fs open() flags supported on this platform: */
398e66f31c5Sopenharmony_ci#if defined(O_APPEND)
399e66f31c5Sopenharmony_ci# define UV_FS_O_APPEND       O_APPEND
400e66f31c5Sopenharmony_ci#else
401e66f31c5Sopenharmony_ci# define UV_FS_O_APPEND       0
402e66f31c5Sopenharmony_ci#endif
403e66f31c5Sopenharmony_ci#if defined(O_CREAT)
404e66f31c5Sopenharmony_ci# define UV_FS_O_CREAT        O_CREAT
405e66f31c5Sopenharmony_ci#else
406e66f31c5Sopenharmony_ci# define UV_FS_O_CREAT        0
407e66f31c5Sopenharmony_ci#endif
408e66f31c5Sopenharmony_ci
409e66f31c5Sopenharmony_ci#if defined(__linux__) && defined(__arm__)
410e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECT       0x10000
411e66f31c5Sopenharmony_ci#elif defined(__linux__) && defined(__m68k__)
412e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECT       0x10000
413e66f31c5Sopenharmony_ci#elif defined(__linux__) && defined(__mips__)
414e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECT       0x08000
415e66f31c5Sopenharmony_ci#elif defined(__linux__) && defined(__powerpc__)
416e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECT       0x20000
417e66f31c5Sopenharmony_ci#elif defined(__linux__) && defined(__s390x__)
418e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECT       0x04000
419e66f31c5Sopenharmony_ci#elif defined(__linux__) && defined(__x86_64__)
420e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECT       0x04000
421e66f31c5Sopenharmony_ci#elif defined(__linux__) && defined(__loongarch__)
422e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECT       0x04000
423e66f31c5Sopenharmony_ci#elif defined(O_DIRECT)
424e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECT       O_DIRECT
425e66f31c5Sopenharmony_ci#else
426e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECT       0
427e66f31c5Sopenharmony_ci#endif
428e66f31c5Sopenharmony_ci
429e66f31c5Sopenharmony_ci#if defined(O_DIRECTORY)
430e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECTORY    O_DIRECTORY
431e66f31c5Sopenharmony_ci#else
432e66f31c5Sopenharmony_ci# define UV_FS_O_DIRECTORY    0
433e66f31c5Sopenharmony_ci#endif
434e66f31c5Sopenharmony_ci#if defined(O_DSYNC)
435e66f31c5Sopenharmony_ci# define UV_FS_O_DSYNC        O_DSYNC
436e66f31c5Sopenharmony_ci#else
437e66f31c5Sopenharmony_ci# define UV_FS_O_DSYNC        0
438e66f31c5Sopenharmony_ci#endif
439e66f31c5Sopenharmony_ci#if defined(O_EXCL)
440e66f31c5Sopenharmony_ci# define UV_FS_O_EXCL         O_EXCL
441e66f31c5Sopenharmony_ci#else
442e66f31c5Sopenharmony_ci# define UV_FS_O_EXCL         0
443e66f31c5Sopenharmony_ci#endif
444e66f31c5Sopenharmony_ci#if defined(O_EXLOCK)
445e66f31c5Sopenharmony_ci# define UV_FS_O_EXLOCK       O_EXLOCK
446e66f31c5Sopenharmony_ci#else
447e66f31c5Sopenharmony_ci# define UV_FS_O_EXLOCK       0
448e66f31c5Sopenharmony_ci#endif
449e66f31c5Sopenharmony_ci#if defined(O_NOATIME)
450e66f31c5Sopenharmony_ci# define UV_FS_O_NOATIME      O_NOATIME
451e66f31c5Sopenharmony_ci#else
452e66f31c5Sopenharmony_ci# define UV_FS_O_NOATIME      0
453e66f31c5Sopenharmony_ci#endif
454e66f31c5Sopenharmony_ci#if defined(O_NOCTTY)
455e66f31c5Sopenharmony_ci# define UV_FS_O_NOCTTY       O_NOCTTY
456e66f31c5Sopenharmony_ci#else
457e66f31c5Sopenharmony_ci# define UV_FS_O_NOCTTY       0
458e66f31c5Sopenharmony_ci#endif
459e66f31c5Sopenharmony_ci#if defined(O_NOFOLLOW)
460e66f31c5Sopenharmony_ci# define UV_FS_O_NOFOLLOW     O_NOFOLLOW
461e66f31c5Sopenharmony_ci#else
462e66f31c5Sopenharmony_ci# define UV_FS_O_NOFOLLOW     0
463e66f31c5Sopenharmony_ci#endif
464e66f31c5Sopenharmony_ci#if defined(O_NONBLOCK)
465e66f31c5Sopenharmony_ci# define UV_FS_O_NONBLOCK     O_NONBLOCK
466e66f31c5Sopenharmony_ci#else
467e66f31c5Sopenharmony_ci# define UV_FS_O_NONBLOCK     0
468e66f31c5Sopenharmony_ci#endif
469e66f31c5Sopenharmony_ci#if defined(O_RDONLY)
470e66f31c5Sopenharmony_ci# define UV_FS_O_RDONLY       O_RDONLY
471e66f31c5Sopenharmony_ci#else
472e66f31c5Sopenharmony_ci# define UV_FS_O_RDONLY       0
473e66f31c5Sopenharmony_ci#endif
474e66f31c5Sopenharmony_ci#if defined(O_RDWR)
475e66f31c5Sopenharmony_ci# define UV_FS_O_RDWR         O_RDWR
476e66f31c5Sopenharmony_ci#else
477e66f31c5Sopenharmony_ci# define UV_FS_O_RDWR         0
478e66f31c5Sopenharmony_ci#endif
479e66f31c5Sopenharmony_ci#if defined(O_SYMLINK)
480e66f31c5Sopenharmony_ci# define UV_FS_O_SYMLINK      O_SYMLINK
481e66f31c5Sopenharmony_ci#else
482e66f31c5Sopenharmony_ci# define UV_FS_O_SYMLINK      0
483e66f31c5Sopenharmony_ci#endif
484e66f31c5Sopenharmony_ci#if defined(O_SYNC)
485e66f31c5Sopenharmony_ci# define UV_FS_O_SYNC         O_SYNC
486e66f31c5Sopenharmony_ci#else
487e66f31c5Sopenharmony_ci# define UV_FS_O_SYNC         0
488e66f31c5Sopenharmony_ci#endif
489e66f31c5Sopenharmony_ci#if defined(O_TRUNC)
490e66f31c5Sopenharmony_ci# define UV_FS_O_TRUNC        O_TRUNC
491e66f31c5Sopenharmony_ci#else
492e66f31c5Sopenharmony_ci# define UV_FS_O_TRUNC        0
493e66f31c5Sopenharmony_ci#endif
494e66f31c5Sopenharmony_ci#if defined(O_WRONLY)
495e66f31c5Sopenharmony_ci# define UV_FS_O_WRONLY       O_WRONLY
496e66f31c5Sopenharmony_ci#else
497e66f31c5Sopenharmony_ci# define UV_FS_O_WRONLY       0
498e66f31c5Sopenharmony_ci#endif
499e66f31c5Sopenharmony_ci
500e66f31c5Sopenharmony_ci/* fs open() flags supported on other platforms: */
501e66f31c5Sopenharmony_ci#define UV_FS_O_FILEMAP       0
502e66f31c5Sopenharmony_ci#define UV_FS_O_RANDOM        0
503e66f31c5Sopenharmony_ci#define UV_FS_O_SHORT_LIVED   0
504e66f31c5Sopenharmony_ci#define UV_FS_O_SEQUENTIAL    0
505e66f31c5Sopenharmony_ci#define UV_FS_O_TEMPORARY     0
506e66f31c5Sopenharmony_ci
507e66f31c5Sopenharmony_ci#endif /* UV_UNIX_H */
508