libuv/uv-win.h

127 lines
4.4 KiB
C
Raw Normal View History

/* 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.
*/
2011-04-18 17:25:03 +00:00
#ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
#endif
#include <stdint.h>
2011-03-30 03:03:56 +00:00
#include <winsock2.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#include <windows.h>
#include "tree.h"
2011-03-23 12:56:06 +00:00
/**
2011-05-13 14:15:02 +00:00
* It should be possible to cast uv_buf_t[] to WSABUF[]
2011-03-30 03:03:56 +00:00
* see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
2011-03-23 12:56:06 +00:00
*/
2011-05-13 14:15:02 +00:00
typedef struct uv_buf_t {
2011-03-30 03:03:56 +00:00
ULONG len;
char* base;
2011-05-13 14:15:02 +00:00
} uv_buf_t;
2011-03-28 08:55:29 +00:00
#define UV_REQ_PRIVATE_FIELDS \
2011-04-14 20:34:13 +00:00
union { \
/* Used by I/O operations */ \
struct { \
OVERLAPPED overlapped; \
size_t queued_bytes; \
}; \
2011-04-14 20:34:13 +00:00
}; \
int flags; \
uv_err_t error; \
struct uv_req_s* next_req;
2011-03-30 03:03:56 +00:00
2011-05-16 19:38:20 +00:00
#define uv_tcp_connection_fields \
uv_alloc_cb alloc_cb; \
uv_read_cb read_cb; \
2011-05-16 19:38:20 +00:00
struct uv_req_s read_req; \
unsigned int write_reqs_pending; \
2011-05-12 02:56:33 +00:00
uv_req_t* shutdown_req;
2011-05-16 19:38:20 +00:00
#define uv_tcp_server_fields \
uv_connection_cb connection_cb; \
SOCKET accept_socket; \
2011-05-16 19:38:20 +00:00
struct uv_req_s accept_req; \
char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32];
2011-06-07 16:09:25 +00:00
#define UV_TCP_PRIVATE_FIELDS \
unsigned int reqs_pending; \
2011-04-14 20:34:13 +00:00
union { \
SOCKET socket; \
HANDLE handle; \
}; \
2011-05-03 03:21:15 +00:00
union { \
2011-05-16 19:38:20 +00:00
struct { uv_tcp_connection_fields }; \
struct { uv_tcp_server_fields }; \
};
#define UV_TIMER_PRIVATE_FIELDS \
RB_ENTRY(uv_timer_s) tree_entry; \
2011-05-17 00:24:58 +00:00
int64_t due; \
int64_t repeat; \
2011-06-17 16:39:18 +00:00
uv_timer_cb timer_cb;
#define UV_ASYNC_PRIVATE_FIELDS \
2011-05-16 19:38:20 +00:00
struct uv_req_s async_req; \
2011-05-09 02:25:34 +00:00
/* char to avoid alignment issues */ \
char volatile async_sent;
2011-06-17 16:39:18 +00:00
#define UV_PREPARE_PRIVATE_FIELDS \
uv_prepare_t* prepare_prev; \
uv_prepare_t* prepare_next; \
uv_prepare_cb prepare_cb;
2011-06-17 16:39:18 +00:00
#define UV_CHECK_PRIVATE_FIELDS \
uv_check_t* check_prev; \
uv_check_t* check_next; \
uv_check_cb check_cb;
#define UV_IDLE_PRIVATE_FIELDS \
uv_idle_t* idle_prev; \
uv_idle_t* idle_next; \
uv_idle_cb idle_cb;
#define UV_HANDLE_PRIVATE_FIELDS \
2011-05-16 19:38:20 +00:00
uv_handle_t* endgame_next; \
2011-04-14 20:34:13 +00:00
unsigned int flags; \
2011-06-17 16:39:18 +00:00
uv_err_t error;
2011-06-20 16:41:57 +00:00
#define UV_ARES_ACTION_PRIVATE_FIELDS \
struct uv_req_s ares_req; \
SOCKET sock; \
int read; \
int write;
#define UV_ARES_TASK_PRIVATE_FIELDS \
uv_ares_task_t* ares_prev; \
uv_ares_task_t* ares_next; \
struct uv_req_s ares_req; \
SOCKET sock; \
HANDLE h_wait; \
WSAEVENT h_event; \
HANDLE h_close_event;
int uv_utf16_to_utf8(wchar_t* utf16Buffer, size_t utf16Size, char* utf8Buffer, size_t utf8Size);