2011-05-13 10:16:40 +08:00
|
|
|
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _WIN32_WINNT
|
|
|
|
# define _WIN32_WINNT 0x0501
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <mswsock.h>
|
|
|
|
#include <ws2tcpip.h>
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include "tree.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-05-20 08:50:13 +08:00
|
|
|
* It should be possible to cast uv_buf[] to WSABUF[]
|
2011-05-13 10:16:40 +08:00
|
|
|
* see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
|
|
|
|
*/
|
2011-05-20 08:50:13 +08:00
|
|
|
typedef struct uv_buf {
|
2011-05-13 10:16:40 +08:00
|
|
|
ULONG len;
|
|
|
|
char* base;
|
2011-05-20 08:50:13 +08:00
|
|
|
} uv_buf;
|
2011-05-13 10:16:40 +08:00
|
|
|
|
2011-05-20 08:50:13 +08:00
|
|
|
#define uv_req_private_fields \
|
2011-05-13 10:16:40 +08:00
|
|
|
union { \
|
|
|
|
/* Used by I/O operations */ \
|
|
|
|
struct { \
|
|
|
|
OVERLAPPED overlapped; \
|
|
|
|
size_t queued_bytes; \
|
|
|
|
}; \
|
2011-05-20 08:50:13 +08:00
|
|
|
/* Used by timers */ \
|
|
|
|
struct { \
|
|
|
|
RB_ENTRY(uv_req_s) tree_entry; \
|
|
|
|
int64_t due; \
|
|
|
|
}; \
|
2011-05-13 10:16:40 +08:00
|
|
|
}; \
|
|
|
|
int flags;
|
|
|
|
|
2011-05-20 08:50:13 +08:00
|
|
|
#define uv_tcp_connection_fields \
|
2011-05-13 10:16:40 +08:00
|
|
|
void* read_cb; \
|
2011-05-20 08:50:13 +08:00
|
|
|
struct uv_req_s read_req; \
|
2011-05-13 10:16:40 +08:00
|
|
|
unsigned int write_reqs_pending; \
|
|
|
|
uv_req_t* shutdown_req;
|
|
|
|
|
2011-05-20 08:50:13 +08:00
|
|
|
#define uv_tcp_server_fields \
|
2011-05-13 10:16:40 +08:00
|
|
|
void *accept_cb; \
|
|
|
|
SOCKET accept_socket; \
|
2011-05-20 08:50:13 +08:00
|
|
|
struct uv_req_s accept_req; \
|
2011-05-13 10:16:40 +08:00
|
|
|
char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32];
|
|
|
|
|
2011-05-20 08:50:13 +08:00
|
|
|
#define uv_tcp_fields \
|
2011-05-13 10:16:40 +08:00
|
|
|
unsigned int reqs_pending; \
|
|
|
|
union { \
|
|
|
|
SOCKET socket; \
|
|
|
|
HANDLE handle; \
|
|
|
|
}; \
|
|
|
|
union { \
|
2011-05-20 08:50:13 +08:00
|
|
|
struct { uv_tcp_connection_fields }; \
|
|
|
|
struct { uv_tcp_server_fields }; \
|
2011-05-13 10:16:40 +08:00
|
|
|
};
|
|
|
|
|
2011-05-20 08:50:13 +08:00
|
|
|
#define uv_loop_fields \
|
|
|
|
uv_handle_t* loop_prev; \
|
|
|
|
uv_handle_t* loop_next; \
|
2011-05-13 10:16:40 +08:00
|
|
|
void* loop_cb;
|
|
|
|
|
2011-05-20 08:50:13 +08:00
|
|
|
#define uv_async_fields \
|
|
|
|
struct uv_req_s async_req; \
|
2011-05-13 10:16:40 +08:00
|
|
|
/* char to avoid alignment issues */ \
|
|
|
|
char volatile async_sent;
|
|
|
|
|
2011-05-20 08:50:13 +08:00
|
|
|
#define uv_handle_private_fields \
|
|
|
|
uv_handle_t* endgame_next; \
|
2011-05-13 10:16:40 +08:00
|
|
|
unsigned int flags; \
|
2011-05-20 08:50:13 +08:00
|
|
|
uv_err_t error; \
|
2011-05-13 10:16:40 +08:00
|
|
|
union { \
|
2011-05-20 08:50:13 +08:00
|
|
|
struct { uv_tcp_fields }; \
|
|
|
|
struct { uv_loop_fields }; \
|
|
|
|
struct { uv_async_fields }; \
|
2011-05-13 10:16:40 +08:00
|
|
|
};
|