]> git.proxmox.com Git - rustc.git/blame - src/libuv/src/win/internal.h
Imported Upstream version 0.7
[rustc.git] / src / libuv / src / win / internal.h
CommitLineData
223e47cc
LB
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 UV_WIN_INTERNAL_H_
23#define UV_WIN_INTERNAL_H_
24
25#include "uv.h"
26#include "../uv-common.h"
27
28#include "tree.h"
29#include "winapi.h"
30#include "winsock.h"
31
32
33/*
34 * Handles
35 * (also see handle-inl.h)
36 */
37
38/* Used by all handles. */
39#define UV_HANDLE_CLOSED 0x00000002
40#define UV_HANDLE_ENDGAME_QUEUED 0x00000004
41#define UV_HANDLE_ACTIVE 0x00000010
42
43/* uv-common.h: #define UV__HANDLE_CLOSING 0x00000001 */
44/* uv-common.h: #define UV__HANDLE_ACTIVE 0x00000040 */
45/* uv-common.h: #define UV__HANDLE_REF 0x00000020 */
46/* uv-common.h: #define UV_HANDLE_INTERNAL 0x00000080 */
47
48/* Used by streams and UDP handles. */
49#define UV_HANDLE_READING 0x00000100
50#define UV_HANDLE_BOUND 0x00000200
51#define UV_HANDLE_BIND_ERROR 0x00000400
52#define UV_HANDLE_LISTENING 0x00000800
53#define UV_HANDLE_CONNECTION 0x00001000
54#define UV_HANDLE_CONNECTED 0x00002000
55#define UV_HANDLE_READABLE 0x00008000
56#define UV_HANDLE_WRITABLE 0x00010000
57#define UV_HANDLE_READ_PENDING 0x00020000
58#define UV_HANDLE_SYNC_BYPASS_IOCP 0x00040000
59#define UV_HANDLE_ZERO_READ 0x00080000
60#define UV_HANDLE_EMULATE_IOCP 0x00100000
61
62/* Only used by uv_tcp_t handles. */
63#define UV_HANDLE_IPV6 0x01000000
64#define UV_HANDLE_TCP_NODELAY 0x02000000
65#define UV_HANDLE_TCP_KEEPALIVE 0x04000000
66#define UV_HANDLE_TCP_SINGLE_ACCEPT 0x08000000
67#define UV_HANDLE_TCP_ACCEPT_STATE_CHANGING 0x10000000
68#define UV_HANDLE_TCP_SOCKET_CLOSED 0x20000000
69#define UV_HANDLE_SHARED_TCP_SOCKET 0x40000000
70
71/* Only used by uv_pipe_t handles. */
72#define UV_HANDLE_NON_OVERLAPPED_PIPE 0x01000000
73#define UV_HANDLE_PIPESERVER 0x02000000
74
75/* Only used by uv_tty_t handles. */
76#define UV_HANDLE_TTY_READABLE 0x01000000
77#define UV_HANDLE_TTY_RAW 0x02000000
78#define UV_HANDLE_TTY_SAVED_POSITION 0x04000000
79#define UV_HANDLE_TTY_SAVED_ATTRIBUTES 0x08000000
80
81/* Only used by uv_poll_t handles. */
82#define UV_HANDLE_POLL_SLOW 0x02000000
83
84
85/*
86 * Requests: see req-inl.h
87 */
88
89
90/*
91 * Streams: see stream-inl.h
92 */
93
94
95/*
96 * TCP
97 */
98int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb);
99int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client);
100int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb,
101 uv_read_cb read_cb);
102int uv_tcp_write(uv_loop_t* loop, uv_write_t* req, uv_tcp_t* handle,
103 uv_buf_t bufs[], int bufcnt, uv_write_cb cb);
104
105void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle, uv_req_t* req);
106void uv_process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle,
107 uv_write_t* req);
108void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle,
109 uv_req_t* req);
110void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle,
111 uv_connect_t* req);
112
113void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp);
114void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle);
115
116int uv_tcp_import(uv_tcp_t* tcp, WSAPROTOCOL_INFOW* socket_protocol_info,
117 int tcp_connection);
118
119int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid,
120 LPWSAPROTOCOL_INFOW protocol_info);
121
122
123/*
124 * UDP
125 */
126void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, uv_req_t* req);
127void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle,
128 uv_udp_send_t* req);
129
130void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle);
131void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle);
132
133
134/*
135 * Pipes
136 */
137uv_err_t uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access,
138 char* name, size_t nameSize);
139
140int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb);
141int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client);
142int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb,
143 uv_read_cb read_cb);
144int uv_pipe_read2_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb,
145 uv_read2_cb read_cb);
146int uv_pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle,
147 uv_buf_t bufs[], int bufcnt, uv_write_cb cb);
148int uv_pipe_write2(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle,
149 uv_buf_t bufs[], int bufcnt, uv_stream_t* send_handle, uv_write_cb cb);
150
151void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle,
152 uv_req_t* req);
153void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle,
154 uv_write_t* req);
155void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle,
156 uv_req_t* raw_req);
157void uv_process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle,
158 uv_connect_t* req);
159void uv_process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle,
160 uv_shutdown_t* req);
161
162void uv_pipe_close(uv_loop_t* loop, uv_pipe_t* handle);
163void uv_pipe_cleanup(uv_loop_t* loop, uv_pipe_t* handle);
164void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle);
165
166
167/*
168 * TTY
169 */
170void uv_console_init();
171
172int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb,
173 uv_read_cb read_cb);
174int uv_tty_read_stop(uv_tty_t* handle);
175int uv_tty_write(uv_loop_t* loop, uv_write_t* req, uv_tty_t* handle,
176 uv_buf_t bufs[], int bufcnt, uv_write_cb cb);
177void uv_tty_close(uv_tty_t* handle);
178
179void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle,
180 uv_req_t* req);
181void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle,
182 uv_write_t* req);
183/* TODO: remove me */
184void uv_process_tty_accept_req(uv_loop_t* loop, uv_tty_t* handle,
185 uv_req_t* raw_req);
186/* TODO: remove me */
187void uv_process_tty_connect_req(uv_loop_t* loop, uv_tty_t* handle,
188 uv_connect_t* req);
189
190void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle);
191
192
193/*
194 * Poll watchers
195 */
196void uv_process_poll_req(uv_loop_t* loop, uv_poll_t* handle,
197 uv_req_t* req);
198
199void uv_poll_close(uv_loop_t* loop, uv_poll_t* handle);
200void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle);
201
202
203/*
204 * Timers
205 */
206void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle);
207
208DWORD uv_get_poll_timeout(uv_loop_t* loop);
209void uv_process_timers(uv_loop_t* loop);
210
211
212/*
213 * Loop watchers
214 */
215void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle);
216
217void uv_prepare_invoke(uv_loop_t* loop);
218void uv_check_invoke(uv_loop_t* loop);
219void uv_idle_invoke(uv_loop_t* loop);
220
221void uv__once_init();
222
223
224/*
225 * Async watcher
226 */
227void uv_async_close(uv_loop_t* loop, uv_async_t* handle);
228void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle);
229
230void uv_process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle,
231 uv_req_t* req);
232
233
234/*
235 * Signal watcher
236 */
237void uv_signals_init();
238int uv__signal_dispatch(int signum);
239
240void uv_signal_close(uv_loop_t* loop, uv_signal_t* handle);
241void uv_signal_endgame(uv_loop_t* loop, uv_signal_t* handle);
242
243void uv_process_signal_req(uv_loop_t* loop, uv_signal_t* handle,
244 uv_req_t* req);
245
246
247/*
248 * Spawn
249 */
250void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle);
251void uv_process_close(uv_loop_t* loop, uv_process_t* handle);
252void uv_process_endgame(uv_loop_t* loop, uv_process_t* handle);
253
254
255/*
256 * Getaddrinfo
257 */
258void uv_process_getaddrinfo_req(uv_loop_t* loop, uv_getaddrinfo_t* req);
259
260
261/*
262 * FS
263 */
264void uv_fs_init();
265void uv_process_fs_req(uv_loop_t* loop, uv_fs_t* req);
266
267
268/*
269 * Threadpool
270 */
271void uv_process_work_req(uv_loop_t* loop, uv_work_t* req);
272
273
274/*
275 * FS Event
276 */
277void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
278 uv_fs_event_t* handle);
279void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle);
280void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle);
281
282
283/*
284 * Stat poller.
285 */
286void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle);
287
288
289/*
290 * Utilities.
291 */
292void uv__util_init();
293
294int uv_parent_pid();
295void uv_fatal_error(const int errorno, const char* syscall);
296uv_err_code uv_translate_sys_error(int sys_errno);
297
298
299/*
300 * Process stdio handles.
301 */
302uv_err_t uv__stdio_create(uv_loop_t* loop, uv_process_options_t* options,
303 BYTE** buffer_ptr);
304void uv__stdio_destroy(BYTE* buffer);
305void uv__stdio_noinherit(BYTE* buffer);
306int uv__stdio_verify(BYTE* buffer, WORD size);
307WORD uv__stdio_size(BYTE* buffer);
308HANDLE uv__stdio_handle(BYTE* buffer, int fd);
309
310
311/*
312 * Winapi and ntapi utility functions
313 */
314void uv_winapi_init();
315
316
317/*
318 * Winsock utility functions
319 */
320void uv_winsock_init();
321
322int uv_ntstatus_to_winsock_error(NTSTATUS status);
323
324BOOL uv_get_acceptex_function(SOCKET socket, LPFN_ACCEPTEX* target);
325BOOL uv_get_connectex_function(SOCKET socket, LPFN_CONNECTEX* target);
326
327int WSAAPI uv_wsarecv_workaround(SOCKET socket, WSABUF* buffers,
328 DWORD buffer_count, DWORD* bytes, DWORD* flags, WSAOVERLAPPED *overlapped,
329 LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
330int WSAAPI uv_wsarecvfrom_workaround(SOCKET socket, WSABUF* buffers,
331 DWORD buffer_count, DWORD* bytes, DWORD* flags, struct sockaddr* addr,
332 int* addr_len, WSAOVERLAPPED *overlapped,
333 LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
334
335int WSAAPI uv_msafd_poll(SOCKET socket, AFD_POLL_INFO* info,
336 OVERLAPPED* overlapped);
337
338/* Whether there are any non-IFS LSPs stacked on TCP */
339extern int uv_tcp_non_ifs_lsp_ipv4;
340extern int uv_tcp_non_ifs_lsp_ipv6;
341
342/* Ip address used to bind to any port at any interface */
343extern struct sockaddr_in uv_addr_ip4_any_;
344extern struct sockaddr_in6 uv_addr_ip6_any_;
345
346#endif /* UV_WIN_INTERNAL_H_ */