about summary refs log tree commit diff
path: root/src/rt/libuv/include
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-10-22 17:37:18 -0700
committerBrian Anderson <banderson@mozilla.com>2011-10-22 17:37:18 -0700
commitbdbeb75bfb868c98d528cdf131c8102c58be195b (patch)
tree1fce689b0606fb8423999990a01f2dc8158d4dc1 /src/rt/libuv/include
parent81a44ccacfc9da31dab6434db54ef023e9950ac2 (diff)
downloadrust-bdbeb75bfb868c98d528cdf131c8102c58be195b.tar.gz
rust-bdbeb75bfb868c98d528cdf131c8102c58be195b.zip
Upgrade libuv to 179f475b2ad64729feb0422f06ce133cb364482a
Diffstat (limited to 'src/rt/libuv/include')
-rw-r--r--src/rt/libuv/include/ares.h13
-rw-r--r--src/rt/libuv/include/ares_version.h4
-rw-r--r--src/rt/libuv/include/uv-private/ev.h1
-rw-r--r--src/rt/libuv/include/uv-private/uv-linux.h29
-rw-r--r--src/rt/libuv/include/uv-private/uv-unix.h47
-rw-r--r--src/rt/libuv/include/uv-private/uv-win.h170
-rw-r--r--src/rt/libuv/include/uv.h278
7 files changed, 378 insertions, 164 deletions
diff --git a/src/rt/libuv/include/ares.h b/src/rt/libuv/include/ares.h
index 905a29eea6f..53ac861b2ce 100644
--- a/src/rt/libuv/include/ares.h
+++ b/src/rt/libuv/include/ares.h
@@ -1,6 +1,6 @@
 
 /* Copyright 1998, 2009 by the Massachusetts Institute of Technology.
- * Copyright (C) 2007-2010 by Daniel Stenberg
+ * Copyright (C) 2007-2011 by Daniel Stenberg
  *
  * Permission to use, copy, modify, and distribute this
  * software and its documentation for any purpose and without
@@ -96,10 +96,19 @@ typedef int ares_socklen_t;
 #  include <netinet/in.h>
 #  include <sys/socket.h>
 #  include <tcp.h>
+#elif defined(_WIN32_WCE)
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  include <windows.h>
+#  include <winsock.h>
 #elif defined(WIN32)
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  include <windows.h>
 #  include <winsock2.h>
 #  include <ws2tcpip.h>
-#  include <windows.h>
 #else
 #  include <sys/socket.h>
 #  include <netinet/in.h>
diff --git a/src/rt/libuv/include/ares_version.h b/src/rt/libuv/include/ares_version.h
index 8baa897cda2..efd0156dd10 100644
--- a/src/rt/libuv/include/ares_version.h
+++ b/src/rt/libuv/include/ares_version.h
@@ -7,11 +7,11 @@
 
 #define ARES_VERSION_MAJOR 1
 #define ARES_VERSION_MINOR 7
-#define ARES_VERSION_PATCH 4
+#define ARES_VERSION_PATCH 5
 #define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
                        (ARES_VERSION_MINOR<<8)|\
                        (ARES_VERSION_PATCH))
-#define ARES_VERSION_STR "1.7.4"
+#define ARES_VERSION_STR "1.7.5-DEV"
 
 #if (ARES_VERSION >= 0x010700)
 #  define CARES_HAVE_ARES_LIBRARY_INIT 1
diff --git a/src/rt/libuv/include/uv-private/ev.h b/src/rt/libuv/include/uv-private/ev.h
index 1db1e266493..5d2d7a1e37e 100644
--- a/src/rt/libuv/include/uv-private/ev.h
+++ b/src/rt/libuv/include/uv-private/ev.h
@@ -207,6 +207,7 @@ enum {
   EV_NONE     =       0x00, /* no events */
   EV_READ     =       0x01, /* ev_io detected read will not block */
   EV_WRITE    =       0x02, /* ev_io detected write will not block */
+  EV_LIBUV_KQUEUE_HACK = 0x40,
   EV__IOFDSET =       0x80, /* internal use only */
   EV_IO       =    EV_READ, /* alias for type-detection */
   EV_TIMER    = 0x00000100, /* timer timed out */
diff --git a/src/rt/libuv/include/uv-private/uv-linux.h b/src/rt/libuv/include/uv-private/uv-linux.h
deleted file mode 100644
index 7f7b05932d9..00000000000
--- a/src/rt/libuv/include/uv-private/uv-linux.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* 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 UV_LINUX_H
-#define UV_LINUX_H
-
-#define UV_FS_EVENT_PRIVATE_FIELDS \
-  ev_io read_watcher; \
-  uv_fs_event_cb cb; \
-
-#endif /* UV_LINUX_H */
diff --git a/src/rt/libuv/include/uv-private/uv-unix.h b/src/rt/libuv/include/uv-private/uv-unix.h
index 5fa132872dc..0db14e9c7f0 100644
--- a/src/rt/libuv/include/uv-private/uv-unix.h
+++ b/src/rt/libuv/include/uv-private/uv-unix.h
@@ -27,16 +27,13 @@
 #include "ev.h"
 #include "eio.h"
 
-#if defined(__linux__)
-#include "uv-private/uv-linux.h"
-#endif
-
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <netdb.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
-
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <termios.h>
 
 /* Note: May be cast to struct iovec. See writev(2). */
 typedef struct {
@@ -46,11 +43,6 @@ typedef struct {
 
 typedef int uv_file;
 
-/* Stub. Remove it once all platforms support the file watcher API. */
-#ifndef UV_FS_EVENT_PRIVATE_FIELDS
-#define UV_FS_EVENT_PRIVATE_FIELDS /* empty */
-#endif
-
 #define UV_LOOP_PRIVATE_FIELDS \
   ares_channel channel; \
   /* \
@@ -99,8 +91,6 @@ typedef int uv_file;
 
 
 #define UV_STREAM_PRIVATE_FIELDS \
-  uv_read_cb read_cb; \
-  uv_alloc_cb alloc_cb; \
   uv_connect_t *connect_req; \
   uv_shutdown_t *shutdown_req; \
   ev_io read_watcher; \
@@ -109,7 +99,8 @@ typedef int uv_file;
   ngx_queue_t write_completed_queue; \
   int delayed_error; \
   uv_connection_cb connection_cb; \
-  int accepted_fd;
+  int accepted_fd; \
+  int blocking;
 
 
 /* UV_TCP */
@@ -183,6 +174,32 @@ typedef int uv_file;
 #define UV_WORK_PRIVATE_FIELDS \
   eio_req* eio;
 
-#define UV_TTY_PRIVATE_FIELDS /* empty */
+#define UV_TTY_PRIVATE_FIELDS \
+  struct termios orig_termios; \
+  int mode;
+
+/* UV_FS_EVENT_PRIVATE_FIELDS */
+#if defined(__linux__)
+
+#define UV_FS_EVENT_PRIVATE_FIELDS \
+  ev_io read_watcher; \
+  uv_fs_event_cb cb; \
+
+#elif (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) \
+  || defined(__FreeBSD__) \
+  || defined(__OpenBSD__) \
+  || defined(__NetBSD__)
+
+#define UV_FS_EVENT_PRIVATE_FIELDS \
+  ev_io event_watcher; \
+  uv_fs_event_cb cb; \
+  int fflags; \
+
+#else
+
+/* Stub for platforms where the file watcher isn't implemented yet. */
+#define UV_FS_EVENT_PRIVATE_FIELDS
+
+#endif
 
 #endif /* UV_UNIX_H */
diff --git a/src/rt/libuv/include/uv-private/uv-win.h b/src/rt/libuv/include/uv-private/uv-win.h
index f203d672891..ed132d3ad4f 100644
--- a/src/rt/libuv/include/uv-private/uv-win.h
+++ b/src/rt/libuv/include/uv-private/uv-win.h
@@ -34,6 +34,98 @@
 
 #define MAX_PIPENAME_LEN 256
 
+/*
+ * Guids and typedefs for winsock extension functions
+ * Mingw32 doesn't have these :-(
+ */
+#ifndef WSAID_ACCEPTEX
+# define WSAID_ACCEPTEX                                        \
+         {0xb5367df1, 0xcbac, 0x11cf,                          \
+         {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
+
+# define WSAID_CONNECTEX                                       \
+         {0x25a207b9, 0xddf3, 0x4660,                          \
+         {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}}
+
+# define WSAID_GETACCEPTEXSOCKADDRS                            \
+         {0xb5367df2, 0xcbac, 0x11cf,                          \
+         {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
+
+# define WSAID_DISCONNECTEX                                    \
+         {0x7fda2e11, 0x8630, 0x436f,                          \
+         {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
+
+# define WSAID_TRANSMITFILE                                    \
+         {0xb5367df0, 0xcbac, 0x11cf,                          \
+         {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
+
+  typedef BOOL PASCAL (*LPFN_ACCEPTEX)
+                      (SOCKET sListenSocket,
+                       SOCKET sAcceptSocket,
+                       PVOID lpOutputBuffer,
+                       DWORD dwReceiveDataLength,
+                       DWORD dwLocalAddressLength,
+                       DWORD dwRemoteAddressLength,
+                       LPDWORD lpdwBytesReceived,
+                       LPOVERLAPPED lpOverlapped);
+
+  typedef BOOL PASCAL (*LPFN_CONNECTEX)
+                      (SOCKET s,
+                       const struct sockaddr* name,
+                       int namelen,
+                       PVOID lpSendBuffer,
+                       DWORD dwSendDataLength,
+                       LPDWORD lpdwBytesSent,
+                       LPOVERLAPPED lpOverlapped);
+
+  typedef void PASCAL (*LPFN_GETACCEPTEXSOCKADDRS)
+                      (PVOID lpOutputBuffer,
+                       DWORD dwReceiveDataLength,
+                       DWORD dwLocalAddressLength,
+                       DWORD dwRemoteAddressLength,
+                       LPSOCKADDR* LocalSockaddr,
+                       LPINT LocalSockaddrLength,
+                       LPSOCKADDR* RemoteSockaddr,
+                       LPINT RemoteSockaddrLength);
+
+  typedef BOOL PASCAL (*LPFN_DISCONNECTEX)
+                      (SOCKET hSocket,
+                       LPOVERLAPPED lpOverlapped,
+                       DWORD dwFlags,
+                       DWORD reserved);
+
+  typedef BOOL PASCAL (*LPFN_TRANSMITFILE)
+                      (SOCKET hSocket,
+                       HANDLE hFile,
+                       DWORD nNumberOfBytesToWrite,
+                       DWORD nNumberOfBytesPerSend,
+                       LPOVERLAPPED lpOverlapped,
+                       LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
+                       DWORD dwFlags);
+#endif
+
+typedef int (WSAAPI* LPFN_WSARECV)
+            (SOCKET socket,
+             LPWSABUF buffers,
+             DWORD buffer_count,
+             LPDWORD bytes,
+             LPDWORD flags,
+             LPWSAOVERLAPPED overlapped,
+             LPWSAOVERLAPPED_COMPLETION_ROUTINE
+             completion_routine);
+
+typedef int (WSAAPI* LPFN_WSARECVFROM)
+            (SOCKET socket,
+             LPWSABUF buffers,
+             DWORD buffer_count,
+             LPDWORD bytes,
+             LPDWORD flags,
+             struct sockaddr* addr,
+             LPINT addr_len,
+             LPWSAOVERLAPPED overlapped,
+             LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
+
+
 /**
  * It should be possible to cast uv_buf_t[] to WSABUF[]
  * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
@@ -75,9 +167,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
   uv_idle_t* next_idle_handle;                                                \
   ares_channel ares_chan;                                                     \
   int ares_active_sockets;                                                    \
-  uv_timer_t ares_polling_timer;                                              \
-  /* Last error code */                                                       \
-  uv_err_t last_error;
+  uv_timer_t ares_polling_timer;
 
 #define UV_REQ_TYPE_PRIVATE               \
   /* TODO: remove the req suffix */       \
@@ -100,7 +190,10 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
   struct uv_req_s* next_req;
 
 #define UV_WRITE_PRIVATE_FIELDS           \
-  /* empty */
+  int ipc_header;                         \
+  uv_buf_t write_buffer;                  \
+  HANDLE event_handle;                    \
+  HANDLE wait_handle;
 
 #define UV_CONNECT_PRIVATE_FIELDS         \
   /* empty */
@@ -117,12 +210,21 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
     HANDLE pipeHandle;                    \
     struct uv_pipe_accept_s* next_pending; \
   } uv_pipe_accept_t;                     \
+                                          \
   typedef struct uv_tcp_accept_s {        \
     UV_REQ_FIELDS                         \
     SOCKET accept_socket;                 \
     char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \
+    HANDLE event_handle;                  \
+    HANDLE wait_handle;                   \
     struct uv_tcp_accept_s* next_pending; \
-  } uv_tcp_accept_t;
+  } uv_tcp_accept_t;                      \
+                                          \
+  typedef struct uv_read_s {              \
+    UV_REQ_FIELDS                         \
+    HANDLE event_handle;                  \
+    HANDLE wait_handle;                   \
+  } uv_read_t;
 
 #define uv_stream_connection_fields       \
   unsigned int write_reqs_pending;        \
@@ -133,9 +235,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
 
 #define UV_STREAM_PRIVATE_FIELDS          \
   unsigned int reqs_pending;              \
-  uv_alloc_cb alloc_cb;                   \
-  uv_read_cb read_cb;                     \
-  uv_req_t read_req;                      \
+  uv_read_t read_req;                     \
   union {                                 \
     struct { uv_stream_connection_fields };  \
     struct { uv_stream_server_fields     };  \
@@ -143,14 +243,16 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
 
 #define uv_tcp_server_fields              \
   uv_tcp_accept_t* accept_reqs;           \
-  uv_tcp_accept_t* pending_accepts;
+  uv_tcp_accept_t* pending_accepts;       \
+  LPFN_ACCEPTEX func_acceptex;
 
 #define uv_tcp_connection_fields          \
-  uv_buf_t read_buffer;
+  uv_buf_t read_buffer;                   \
+  LPFN_CONNECTEX func_connectex;
 
 #define UV_TCP_PRIVATE_FIELDS             \
   SOCKET socket;                          \
-  uv_err_t bind_error;                    \
+  int bind_error;                         \
   union {                                 \
     struct { uv_tcp_server_fields };      \
     struct { uv_tcp_connection_fields };  \
@@ -164,14 +266,21 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
   struct sockaddr_storage recv_from;      \
   int recv_from_len;                      \
   uv_udp_recv_cb recv_cb;                 \
-  uv_alloc_cb alloc_cb;
+  uv_alloc_cb alloc_cb;                   \
+  LPFN_WSARECV func_wsarecv;              \
+  LPFN_WSARECVFROM func_wsarecvfrom;
 
 #define uv_pipe_server_fields             \
-    uv_pipe_accept_t accept_reqs[4];      \
-    uv_pipe_accept_t* pending_accepts;
+  uv_pipe_accept_t accept_reqs[4];        \
+  uv_pipe_accept_t* pending_accepts;
 
 #define uv_pipe_connection_fields         \
-  uv_timer_t* eof_timer;
+  uv_timer_t* eof_timer;                  \
+  uv_write_t ipc_header_write_req;        \
+  int ipc_pid;                            \
+  uint64_t remaining_ipc_rawdata_bytes;   \
+  WSAPROTOCOL_INFOW* pending_socket_info; \
+  uv_write_t* non_overlapped_writes_tail;
 
 #define UV_PIPE_PRIVATE_FIELDS            \
   HANDLE handle;                          \
@@ -181,6 +290,33 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
     struct { uv_pipe_connection_fields }; \
   };
 
+/* TODO: put the parser states in an union - TTY handles are always */
+/* half-duplex so read-state can safely overlap write-state. */
+#define UV_TTY_PRIVATE_FIELDS             \
+  HANDLE handle;                          \
+  HANDLE read_line_handle;                \
+  uv_buf_t read_line_buffer;              \
+  HANDLE read_raw_wait;                   \
+  DWORD original_console_mode;            \
+  /* Fields used for translating win */   \
+  /* keystrokes into vt100 characters */  \
+  char last_key[8];                       \
+  unsigned char last_key_offset;          \
+  unsigned char last_key_len;             \
+  INPUT_RECORD last_input_record;         \
+  WCHAR last_utf16_high_surrogate;        \
+  /* utf8-to-utf16 conversion state */    \
+  unsigned char utf8_bytes_left;          \
+  unsigned int utf8_codepoint;            \
+  /* eol conversion state */              \
+  unsigned char previous_eol;             \
+  /* ansi parser state */                 \
+  unsigned char ansi_parser_state;        \
+  unsigned char ansi_csi_argc;            \
+  unsigned short ansi_csi_argv[4];        \
+  COORD saved_position;                   \
+  WORD saved_attributes;
+
 #define UV_TIMER_PRIVATE_FIELDS           \
   RB_ENTRY(uv_timer_s) tree_entry;        \
   int64_t due;                            \
@@ -244,6 +380,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
   HANDLE close_handle;
 
 #define UV_FS_PRIVATE_FIELDS              \
+  wchar_t* pathw;                         \
   int flags;                              \
   int last_error;                         \
   struct _stati64 stat;                   \
@@ -270,11 +407,10 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
   int req_pending;                        \
   uv_fs_event_cb cb;                      \
   wchar_t* filew;                         \
+  wchar_t* short_filew;                   \
   int is_path_dir;                        \
   char* buffer;
 
-#define UV_TTY_PRIVATE_FIELDS /* empty */
-
 int uv_utf16_to_utf8(const wchar_t* utf16Buffer, size_t utf16Size,
     char* utf8Buffer, size_t utf8Size);
 int uv_utf8_to_utf16(const char* utf8Buffer, wchar_t* utf16Buffer,
diff --git a/src/rt/libuv/include/uv.h b/src/rt/libuv/include/uv.h
index b8bdc093022..7bee299185a 100644
--- a/src/rt/libuv/include/uv.h
+++ b/src/rt/libuv/include/uv.h
@@ -41,6 +41,98 @@ extern "C" {
 typedef intptr_t ssize_t;
 #endif
 
+#if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)
+# include "uv-private/uv-unix.h"
+#else
+# include "uv-private/uv-win.h"
+#endif
+
+/* Expand this list if necessary. */
+typedef enum {
+  UV_UNKNOWN = -1,
+  UV_OK = 0,
+  UV_EOF,
+  UV_EACCESS,
+  UV_EAGAIN,
+  UV_EADDRINUSE,
+  UV_EADDRNOTAVAIL,
+  UV_EAFNOSUPPORT,
+  UV_EALREADY,
+  UV_EBADF,
+  UV_EBUSY,
+  UV_ECONNABORTED,
+  UV_ECONNREFUSED,
+  UV_ECONNRESET,
+  UV_EDESTADDRREQ,
+  UV_EFAULT,
+  UV_EHOSTUNREACH,
+  UV_EINTR,
+  UV_EINVAL,
+  UV_EISCONN,
+  UV_EMFILE,
+  UV_EMSGSIZE,
+  UV_ENETDOWN,
+  UV_ENETUNREACH,
+  UV_ENFILE,
+  UV_ENOBUFS,
+  UV_ENOMEM,
+  UV_ENOTDIR,
+  UV_ENONET,
+  UV_ENOPROTOOPT,
+  UV_ENOTCONN,
+  UV_ENOTSOCK,
+  UV_ENOTSUP,
+  UV_ENOENT,
+  UV_ENOSYS,
+  UV_EPIPE,
+  UV_EPROTO,
+  UV_EPROTONOSUPPORT,
+  UV_EPROTOTYPE,
+  UV_ETIMEDOUT,
+  UV_ECHARSET,
+  UV_EAIFAMNOSUPPORT,
+  UV_EAINONAME,
+  UV_EAISERVICE,
+  UV_EAISOCKTYPE,
+  UV_ESHUTDOWN,
+  UV_EEXIST
+} uv_err_code;
+
+typedef enum {
+  UV_UNKNOWN_HANDLE = 0,
+  UV_TCP,
+  UV_UDP,
+  UV_NAMED_PIPE,
+  UV_TTY,
+  UV_FILE,
+  UV_TIMER,
+  UV_PREPARE,
+  UV_CHECK,
+  UV_IDLE,
+  UV_ASYNC,
+  UV_ARES_TASK,
+  UV_ARES_EVENT,
+  UV_PROCESS,
+  UV_FS_EVENT
+} uv_handle_type;
+
+typedef enum {
+  UV_UNKNOWN_REQ = 0,
+  UV_CONNECT,
+  UV_ACCEPT,
+  UV_READ,
+  UV_WRITE,
+  UV_SHUTDOWN,
+  UV_WAKEUP,
+  UV_UDP_SEND,
+  UV_FS,
+  UV_WORK,
+  UV_GETADDRINFO,
+  UV_REQ_TYPE_PRIVATE
+} uv_req_type;
+
+
+
 typedef struct uv_loop_s uv_loop_t;
 typedef struct uv_ares_task_s uv_ares_task_t;
 typedef struct uv_err_s uv_err_t;
@@ -69,12 +161,6 @@ typedef struct uv_fs_s uv_fs_t;
 typedef struct uv_fs_event_s uv_fs_event_t;
 typedef struct uv_work_s uv_work_t;
 
-#if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)
-# include "uv-private/uv-unix.h"
-#else
-# include "uv-private/uv-win.h"
-#endif
-
 
 /*
  * This function must be called before any other functions in libuv.
@@ -121,6 +207,13 @@ int64_t uv_now(uv_loop_t*);
  */
 typedef uv_buf_t (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size);
 typedef void (*uv_read_cb)(uv_stream_t* stream, ssize_t nread, uv_buf_t buf);
+/*
+ * Just like the uv_read_cb except that if the pending parameter is true
+ * then you can use uv_accept() to pull the new handle into the process.
+ * If no handle is pending then pending will be UV_UNKNOWN_HANDLE.
+ */
+typedef void (*uv_read2_cb)(uv_pipe_t* pipe, ssize_t nread, uv_buf_t buf,
+    uv_handle_type pending);
 typedef void (*uv_write_cb)(uv_write_t* req, int status);
 typedef void (*uv_connect_cb)(uv_connect_t* req, int status);
 typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status);
@@ -148,88 +241,10 @@ typedef void (*uv_after_work_cb)(uv_work_t* req);
 typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename,
     int events, int status);
 
-
-/* Expand this list if necessary. */
-typedef enum {
-  UV_UNKNOWN = -1,
-  UV_OK = 0,
-  UV_EOF,
-  UV_EACCESS,
-  UV_EAGAIN,
-  UV_EADDRINUSE,
-  UV_EADDRNOTAVAIL,
-  UV_EAFNOSUPPORT,
-  UV_EALREADY,
-  UV_EBADF,
-  UV_EBUSY,
-  UV_ECONNABORTED,
-  UV_ECONNREFUSED,
-  UV_ECONNRESET,
-  UV_EDESTADDRREQ,
-  UV_EFAULT,
-  UV_EHOSTUNREACH,
-  UV_EINTR,
-  UV_EINVAL,
-  UV_EISCONN,
-  UV_EMFILE,
-  UV_EMSGSIZE,
-  UV_ENETDOWN,
-  UV_ENETUNREACH,
-  UV_ENFILE,
-  UV_ENOBUFS,
-  UV_ENOMEM,
-  UV_ENONET,
-  UV_ENOPROTOOPT,
-  UV_ENOTCONN,
-  UV_ENOTSOCK,
-  UV_ENOTSUP,
-  UV_ENOENT,
-  UV_EPIPE,
-  UV_EPROTO,
-  UV_EPROTONOSUPPORT,
-  UV_EPROTOTYPE,
-  UV_ETIMEDOUT,
-  UV_ECHARSET,
-  UV_EAIFAMNOSUPPORT,
-  UV_EAINONAME,
-  UV_EAISERVICE,
-  UV_EAISOCKTYPE,
-  UV_ESHUTDOWN,
-  UV_EEXIST
-} uv_err_code;
-
 typedef enum {
-  UV_UNKNOWN_HANDLE = 0,
-  UV_TCP,
-  UV_UDP,
-  UV_NAMED_PIPE,
-  UV_TTY,
-  UV_FILE,
-  UV_TIMER,
-  UV_PREPARE,
-  UV_CHECK,
-  UV_IDLE,
-  UV_ASYNC,
-  UV_ARES_TASK,
-  UV_ARES_EVENT,
-  UV_PROCESS,
-  UV_FS_EVENT
-} uv_handle_type;
-
-typedef enum {
-  UV_UNKNOWN_REQ = 0,
-  UV_CONNECT,
-  UV_ACCEPT,
-  UV_READ,
-  UV_WRITE,
-  UV_SHUTDOWN,
-  UV_WAKEUP,
-  UV_UDP_SEND,
-  UV_FS,
-  UV_WORK,
-  UV_GETADDRINFO,
-  UV_REQ_TYPE_PRIVATE
-} uv_req_type;
+  UV_LEAVE_GROUP = 0,
+  UV_JOIN_GROUP
+} uv_membership;
 
 
 struct uv_err_s {
@@ -330,6 +345,9 @@ uv_buf_t uv_buf_init(char* base, size_t len);
 #define UV_STREAM_FIELDS \
   /* number of bytes queued for writing */ \
   size_t write_queue_size; \
+  uv_alloc_cb alloc_cb; \
+  uv_read_cb read_cb; \
+  uv_read2_cb read2_cb; \
   /* private */ \
   UV_STREAM_PRIVATE_FIELDS
 
@@ -338,8 +356,8 @@ uv_buf_t uv_buf_init(char* base, size_t len);
  *
  * uv_stream is an abstract class.
  *
- * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t, uv_tty_t
- * and soon uv_file_t.
+ * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t, uv_tty_t, and
+ * soon uv_file_t.
  */
 struct uv_stream_s {
   UV_HANDLE_FIELDS
@@ -375,13 +393,12 @@ int uv_read_start(uv_stream_t*, uv_alloc_cb alloc_cb, uv_read_cb read_cb);
 
 int uv_read_stop(uv_stream_t*);
 
-typedef enum {
-  UV_STDIN = 0,
-  UV_STDOUT,
-  UV_STDERR
-} uv_std_type;
+/*
+ * Extended read methods for receiving handles over a pipe. The pipe must be
+ * initialized with ipc == 1.
+ */
+int uv_read2_start(uv_stream_t*, uv_alloc_cb alloc_cb, uv_read2_cb read_cb);
 
-uv_stream_t* uv_std_handle(uv_loop_t*, uv_std_type type);
 
 /*
  * Write data to stream. Buffers are written in order. Example:
@@ -404,10 +421,14 @@ uv_stream_t* uv_std_handle(uv_loop_t*, uv_std_type type);
 int uv_write(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[], int bufcnt,
     uv_write_cb cb);
 
+int uv_write2(uv_write_t* req, uv_stream_t* handle, uv_buf_t bufs[], int bufcnt,
+    uv_stream_t* send_handle, uv_write_cb cb);
+
 /* uv_write_t is a subclass of uv_req_t */
 struct uv_write_s {
   UV_REQ_FIELDS
   uv_write_cb cb;
+  uv_stream_t* send_handle;
   uv_stream_t* handle;
   UV_WRITE_PRIVATE_FIELDS
 };
@@ -427,6 +448,15 @@ struct uv_tcp_s {
 
 int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle);
 
+/* Enable/disable Nagle's algorithm. */
+int uv_tcp_nodelay(uv_tcp_t* handle, int enable);
+
+/* Enable/disable TCP keep-alive.
+ *
+ * `ms` is the initial delay in seconds, ignored when `enable` is zero.
+ */
+int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay);
+
 int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in);
 int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6);
 int uv_tcp_getsockname(uv_tcp_t* handle, struct sockaddr* name, int* namelen);
@@ -537,6 +567,21 @@ int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr, unsigned flags);
 int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name, int* namelen);
 
 /*
+ * Set membership for a multicast address
+ *
+ * Arguments:
+ *  handle              UDP handle. Should have been initialized with `uv_udp_init`.
+ *  multicast_addr      multicast address to set membership for
+ *  interface_addr      interface address
+ *  membership          Should be UV_JOIN_GROUP or UV_LEAVE_GROUP
+ *
+ * Returns:
+ *  0 on success, -1 on error.
+ */
+int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr,
+  const char* interface_addr, uv_membership membership);
+
+/*
  * Send data. If the socket has not previously been bound with `uv_udp_bind`
  * or `uv_udp_bind6`, it is bound to 0.0.0.0 (the "all interfaces" address)
  * and a random port number.
@@ -574,7 +619,7 @@ int uv_udp_send6(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
     int bufcnt, struct sockaddr_in6 addr, uv_udp_send_cb send_cb);
 
 /*
- * Send data. If the socket has not previously been bound with `uv_udp_bind`
+ * Receive data. If the socket has not previously been bound with `uv_udp_bind`
  * or `uv_udp_bind6`, it is bound to 0.0.0.0 (the "all interfaces" address)
  * and a random port number.
  *
@@ -612,7 +657,18 @@ struct uv_tty_s {
   UV_TTY_PRIVATE_FIELDS
 };
 
-int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd);
+/*
+ * Initialize a new TTY stream with the given file descriptor. Usually the
+ * file descriptor will be
+ *   0 = stdin
+ *   1 = stdout
+ *   2 = stderr
+ * The last argument, readable, specifies if you plan on calling
+ * uv_read_start with this stream. stdin is readable, stdout is not.
+ *
+ * TTY streams which are not readable have blocking writes.
+ */
+int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable);
 
 /*
  * Set mode. 0 for normal, 1 for raw.
@@ -620,6 +676,12 @@ int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd);
 int uv_tty_set_mode(uv_tty_t*, int mode);
 
 /*
+ * To be called when the program exits. Resets TTY settings to default
+ * values for the next process to take over.
+ */
+void uv_tty_reset_mode();
+
+/*
  * Gets the current Window size. On success zero is returned.
  */
 int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
@@ -642,9 +704,14 @@ struct uv_pipe_s {
   UV_HANDLE_FIELDS
   UV_STREAM_FIELDS
   UV_PIPE_PRIVATE_FIELDS
+  int ipc; /* non-zero if this pipe is used for passing handles */
 };
 
-int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle);
+/*
+ * Initialize a pipe. The last argument is a boolean to indicate if
+ * this pipe will be used for handle passing between processes.
+ */
+int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
 
 /*
  * Opens an existing file descriptor or HANDLE as a pipe.
@@ -807,6 +874,8 @@ struct uv_getaddrinfo_s {
  *
  * uv_freeaddrinfo() must be called after completion to free the addrinfo
  * structure.
+ *
+ * On error NXDOMAIN the status code will be non-zero and UV_ENOENT returned.
  */
  int uv_getaddrinfo(uv_loop_t*,
                     uv_getaddrinfo_t* handle,
@@ -1003,7 +1072,7 @@ int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb);
 int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
     const char* new_path, uv_fs_cb cb);
 
-/* 
+/*
  * This flag can be used with uv_fs_symlink on Windows
  * to specify whether path argument points to a directory.
  */
@@ -1039,6 +1108,13 @@ struct uv_fs_event_s {
 
 
 /*
+ * Gets load avg
+ * See: http://en.wikipedia.org/wiki/Load_(computing)
+ * (Returns [0,0,0] for windows and cygwin)
+ */
+void uv_loadavg(double avg[3]);
+
+/*
 * If filename is a directory then we will watch for all events in that
 * directory. If filename is a file - we will only get events from that
 * file. Subdirectories are not watched.
@@ -1059,6 +1135,10 @@ int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size);
 /* Gets the executable path */
 int uv_exepath(char* buffer, size_t* size);
 
+/* Gets memory info in bytes */
+uint64_t uv_get_free_memory(void);
+uint64_t uv_get_total_memory(void);
+
 /*
  * Returns the current high-resolution real time. This is expressed in
  * nanoseconds. It is relative to an arbitrary time in the past. It is not