[Cmake-commits] CMake branch, master, updated. v3.8.1-1315-gbc341a9

Kitware Robot kwrobot at kitware.com
Sun May 28 09:05:07 EDT 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  bc341a9d5e3863dd80393144eae88f27883db764 (commit)
       via  478ce1c7b4e46d7a370844921c2138e61d61c4a4 (commit)
       via  1ebb421bfc8eb21a4e5e56e501a62d000a9f59db (commit)
       via  362435f02a52008a90a1c19862f09b01f1b5bd7f (commit)
      from  e6c7c420b1b5bf03902e34e15f5eb796e05c8a04 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc341a9d5e3863dd80393144eae88f27883db764
commit bc341a9d5e3863dd80393144eae88f27883db764
Merge: e6c7c42 478ce1c
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Sun May 28 13:03:39 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Sun May 28 09:03:46 2017 -0400

    Merge topic 'update-libuv'
    
    478ce1c7 libuv: Update build within CMake
    1ebb421b Merge branch 'upstream-libuv' into update-libuv
    362435f0 libuv 2017-05-25 (dc596109)
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !896


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=478ce1c7b4e46d7a370844921c2138e61d61c4a4
commit 478ce1c7b4e46d7a370844921c2138e61d61c4a4
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri May 26 13:48:48 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri May 26 13:48:48 2017 -0400

    libuv: Update build within CMake
    
    Update our CMake build rules to account for upstream changes.

diff --git a/Utilities/cmlibuv/CMakeLists.txt b/Utilities/cmlibuv/CMakeLists.txt
index 618f79d..3252e3d 100644
--- a/Utilities/cmlibuv/CMakeLists.txt
+++ b/Utilities/cmlibuv/CMakeLists.txt
@@ -164,7 +164,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
     src/unix/linux-inotify.c
     src/unix/linux-syscalls.c
     src/unix/linux-syscalls.h
+    src/unix/procfs-exepath.c
     src/unix/proctitle.c
+    src/unix/sysinfo-loadavg.c
+    src/unix/sysinfo-memory.c
     )
 endif()
 
@@ -249,6 +252,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
       )
   endif()
   list(APPEND uv_sources
+    src/unix/no-proctitle.c
     src/unix/sunos.c
     )
 endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1ebb421bfc8eb21a4e5e56e501a62d000a9f59db
commit 1ebb421bfc8eb21a4e5e56e501a62d000a9f59db
Merge: bc407ba 362435f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri May 26 13:33:41 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri May 26 13:33:41 2017 -0400

    Merge branch 'upstream-libuv' into update-libuv
    
    * upstream-libuv:
      libuv 2017-05-25 (dc596109)

diff --cc Utilities/cmlibuv/include/uv-posix.h
index 0000000,9a96634..9a96634
mode 000000,100644..100644
--- a/Utilities/cmlibuv/include/uv-posix.h
+++ b/Utilities/cmlibuv/include/uv-posix.h
diff --cc Utilities/cmlibuv/include/uv.h
index ce04875,0000000..38f5676
mode 100644,000000..100644
--- a/Utilities/cmlibuv/include/uv.h
+++ b/Utilities/cmlibuv/include/uv.h
@@@ -1,1509 -1,0 +1,1511 @@@
 +/* 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.
 + */
 +
 +/* See https://github.com/libuv/libuv#documentation for documentation. */
 +
 +#ifndef UV_H
 +#define UV_H
 +
 +/* Include KWSys Large File Support configuration. */
 +#include <cmsys/Configure.h>
 +
 +#ifdef __cplusplus
 +extern "C" {
 +#endif
 +
 +#ifdef _WIN32
 +  /* Windows - set up dll import/export decorators. */
 +# if defined(BUILDING_UV_SHARED)
 +    /* Building shared library. */
 +#   define UV_EXTERN __declspec(dllexport)
 +# elif defined(USING_UV_SHARED)
 +    /* Using shared library. */
 +#   define UV_EXTERN __declspec(dllimport)
 +# else
 +    /* Building static library. */
 +#   define UV_EXTERN /* nothing */
 +# endif
 +#elif __GNUC__ >= 4
 +# define UV_EXTERN __attribute__((visibility("default")))
 +#else
 +# define UV_EXTERN /* nothing */
 +#endif
 +
 +#include "uv-errno.h"
 +#include "uv-version.h"
 +#include <stddef.h>
 +#include <stdio.h>
 +
 +#if defined(_MSC_VER) && _MSC_VER < 1600
 +# include "stdint-msvc2008.h"
 +#else
 +# include <stdint.h>
 +#endif
 +
 +#if defined(_WIN32)
 +# include "uv-win.h"
 +#else
 +# include "uv-unix.h"
 +#endif
 +
 +/* Expand this list if necessary. */
 +#define UV_ERRNO_MAP(XX)                                                      \
 +  XX(E2BIG, "argument list too long")                                         \
 +  XX(EACCES, "permission denied")                                             \
 +  XX(EADDRINUSE, "address already in use")                                    \
 +  XX(EADDRNOTAVAIL, "address not available")                                  \
 +  XX(EAFNOSUPPORT, "address family not supported")                            \
 +  XX(EAGAIN, "resource temporarily unavailable")                              \
 +  XX(EAI_ADDRFAMILY, "address family not supported")                          \
 +  XX(EAI_AGAIN, "temporary failure")                                          \
 +  XX(EAI_BADFLAGS, "bad ai_flags value")                                      \
 +  XX(EAI_BADHINTS, "invalid value for hints")                                 \
 +  XX(EAI_CANCELED, "request canceled")                                        \
 +  XX(EAI_FAIL, "permanent failure")                                           \
 +  XX(EAI_FAMILY, "ai_family not supported")                                   \
 +  XX(EAI_MEMORY, "out of memory")                                             \
 +  XX(EAI_NODATA, "no address")                                                \
 +  XX(EAI_NONAME, "unknown node or service")                                   \
 +  XX(EAI_OVERFLOW, "argument buffer overflow")                                \
 +  XX(EAI_PROTOCOL, "resolved protocol is unknown")                            \
 +  XX(EAI_SERVICE, "service not available for socket type")                    \
 +  XX(EAI_SOCKTYPE, "socket type not supported")                               \
 +  XX(EALREADY, "connection already in progress")                              \
 +  XX(EBADF, "bad file descriptor")                                            \
 +  XX(EBUSY, "resource busy or locked")                                        \
 +  XX(ECANCELED, "operation canceled")                                         \
 +  XX(ECHARSET, "invalid Unicode character")                                   \
 +  XX(ECONNABORTED, "software caused connection abort")                        \
 +  XX(ECONNREFUSED, "connection refused")                                      \
 +  XX(ECONNRESET, "connection reset by peer")                                  \
 +  XX(EDESTADDRREQ, "destination address required")                            \
 +  XX(EEXIST, "file already exists")                                           \
 +  XX(EFAULT, "bad address in system call argument")                           \
 +  XX(EFBIG, "file too large")                                                 \
 +  XX(EHOSTUNREACH, "host is unreachable")                                     \
 +  XX(EINTR, "interrupted system call")                                        \
 +  XX(EINVAL, "invalid argument")                                              \
 +  XX(EIO, "i/o error")                                                        \
 +  XX(EISCONN, "socket is already connected")                                  \
 +  XX(EISDIR, "illegal operation on a directory")                              \
 +  XX(ELOOP, "too many symbolic links encountered")                            \
 +  XX(EMFILE, "too many open files")                                           \
 +  XX(EMSGSIZE, "message too long")                                            \
 +  XX(ENAMETOOLONG, "name too long")                                           \
 +  XX(ENETDOWN, "network is down")                                             \
 +  XX(ENETUNREACH, "network is unreachable")                                   \
 +  XX(ENFILE, "file table overflow")                                           \
 +  XX(ENOBUFS, "no buffer space available")                                    \
 +  XX(ENODEV, "no such device")                                                \
 +  XX(ENOENT, "no such file or directory")                                     \
 +  XX(ENOMEM, "not enough memory")                                             \
 +  XX(ENONET, "machine is not on the network")                                 \
 +  XX(ENOPROTOOPT, "protocol not available")                                   \
 +  XX(ENOSPC, "no space left on device")                                       \
 +  XX(ENOSYS, "function not implemented")                                      \
 +  XX(ENOTCONN, "socket is not connected")                                     \
 +  XX(ENOTDIR, "not a directory")                                              \
 +  XX(ENOTEMPTY, "directory not empty")                                        \
 +  XX(ENOTSOCK, "socket operation on non-socket")                              \
 +  XX(ENOTSUP, "operation not supported on socket")                            \
 +  XX(EPERM, "operation not permitted")                                        \
 +  XX(EPIPE, "broken pipe")                                                    \
 +  XX(EPROTO, "protocol error")                                                \
 +  XX(EPROTONOSUPPORT, "protocol not supported")                               \
 +  XX(EPROTOTYPE, "protocol wrong type for socket")                            \
 +  XX(ERANGE, "result too large")                                              \
 +  XX(EROFS, "read-only file system")                                          \
 +  XX(ESHUTDOWN, "cannot send after transport endpoint shutdown")              \
 +  XX(ESPIPE, "invalid seek")                                                  \
 +  XX(ESRCH, "no such process")                                                \
 +  XX(ETIMEDOUT, "connection timed out")                                       \
 +  XX(ETXTBSY, "text file is busy")                                            \
 +  XX(EXDEV, "cross-device link not permitted")                                \
 +  XX(UNKNOWN, "unknown error")                                                \
 +  XX(EOF, "end of file")                                                      \
 +  XX(ENXIO, "no such device or address")                                      \
 +  XX(EMLINK, "too many links")                                                \
 +  XX(EHOSTDOWN, "host is down")                                               \
 +
 +#define UV_HANDLE_TYPE_MAP(XX)                                                \
 +  XX(ASYNC, async)                                                            \
 +  XX(CHECK, check)                                                            \
 +  XX(FS_EVENT, fs_event)                                                      \
 +  XX(FS_POLL, fs_poll)                                                        \
 +  XX(HANDLE, handle)                                                          \
 +  XX(IDLE, idle)                                                              \
 +  XX(NAMED_PIPE, pipe)                                                        \
 +  XX(POLL, poll)                                                              \
 +  XX(PREPARE, prepare)                                                        \
 +  XX(PROCESS, process)                                                        \
 +  XX(STREAM, stream)                                                          \
 +  XX(TCP, tcp)                                                                \
 +  XX(TIMER, timer)                                                            \
 +  XX(TTY, tty)                                                                \
 +  XX(UDP, udp)                                                                \
 +  XX(SIGNAL, signal)                                                          \
 +
 +#define UV_REQ_TYPE_MAP(XX)                                                   \
 +  XX(REQ, req)                                                                \
 +  XX(CONNECT, connect)                                                        \
 +  XX(WRITE, write)                                                            \
 +  XX(SHUTDOWN, shutdown)                                                      \
 +  XX(UDP_SEND, udp_send)                                                      \
 +  XX(FS, fs)                                                                  \
 +  XX(WORK, work)                                                              \
 +  XX(GETADDRINFO, getaddrinfo)                                                \
 +  XX(GETNAMEINFO, getnameinfo)                                                \
 +
 +typedef enum {
 +#define XX(code, _) UV_ ## code = UV__ ## code,
 +  UV_ERRNO_MAP(XX)
 +#undef XX
 +  UV_ERRNO_MAX = UV__EOF - 1
 +} uv_errno_t;
 +
 +typedef enum {
 +  UV_UNKNOWN_HANDLE = 0,
 +#define XX(uc, lc) UV_##uc,
 +  UV_HANDLE_TYPE_MAP(XX)
 +#undef XX
 +  UV_FILE,
 +  UV_HANDLE_TYPE_MAX
 +} uv_handle_type;
 +
 +typedef enum {
 +  UV_UNKNOWN_REQ = 0,
 +#define XX(uc, lc) UV_##uc,
 +  UV_REQ_TYPE_MAP(XX)
 +#undef XX
 +  UV_REQ_TYPE_PRIVATE
 +  UV_REQ_TYPE_MAX
 +} uv_req_type;
 +
 +
 +/* Handle types. */
 +typedef struct uv_loop_s uv_loop_t;
 +typedef struct uv_handle_s uv_handle_t;
 +typedef struct uv_stream_s uv_stream_t;
 +typedef struct uv_tcp_s uv_tcp_t;
 +typedef struct uv_udp_s uv_udp_t;
 +typedef struct uv_pipe_s uv_pipe_t;
 +typedef struct uv_tty_s uv_tty_t;
 +typedef struct uv_poll_s uv_poll_t;
 +typedef struct uv_timer_s uv_timer_t;
 +typedef struct uv_prepare_s uv_prepare_t;
 +typedef struct uv_check_s uv_check_t;
 +typedef struct uv_idle_s uv_idle_t;
 +typedef struct uv_async_s uv_async_t;
 +typedef struct uv_process_s uv_process_t;
 +typedef struct uv_fs_event_s uv_fs_event_t;
 +typedef struct uv_fs_poll_s uv_fs_poll_t;
 +typedef struct uv_signal_s uv_signal_t;
 +
 +/* Request types. */
 +typedef struct uv_req_s uv_req_t;
 +typedef struct uv_getaddrinfo_s uv_getaddrinfo_t;
 +typedef struct uv_getnameinfo_s uv_getnameinfo_t;
 +typedef struct uv_shutdown_s uv_shutdown_t;
 +typedef struct uv_write_s uv_write_t;
 +typedef struct uv_connect_s uv_connect_t;
 +typedef struct uv_udp_send_s uv_udp_send_t;
 +typedef struct uv_fs_s uv_fs_t;
 +typedef struct uv_work_s uv_work_t;
 +
 +/* None of the above. */
 +typedef struct uv_cpu_info_s uv_cpu_info_t;
 +typedef struct uv_interface_address_s uv_interface_address_t;
 +typedef struct uv_dirent_s uv_dirent_t;
 +typedef struct uv_passwd_s uv_passwd_t;
 +
 +typedef enum {
 +  UV_LOOP_BLOCK_SIGNAL
 +} uv_loop_option;
 +
 +typedef enum {
 +  UV_RUN_DEFAULT = 0,
 +  UV_RUN_ONCE,
 +  UV_RUN_NOWAIT
 +} uv_run_mode;
 +
 +
 +UV_EXTERN unsigned int uv_version(void);
 +UV_EXTERN const char* uv_version_string(void);
 +
 +typedef void* (*uv_malloc_func)(size_t size);
 +typedef void* (*uv_realloc_func)(void* ptr, size_t size);
 +typedef void* (*uv_calloc_func)(size_t count, size_t size);
 +typedef void (*uv_free_func)(void* ptr);
 +
 +UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func,
 +                                   uv_realloc_func realloc_func,
 +                                   uv_calloc_func calloc_func,
 +                                   uv_free_func free_func);
 +
 +UV_EXTERN uv_loop_t* uv_default_loop(void);
 +UV_EXTERN int uv_loop_init(uv_loop_t* loop);
 +UV_EXTERN int uv_loop_close(uv_loop_t* loop);
 +/*
 + * NOTE:
 + *  This function is DEPRECATED (to be removed after 0.12), users should
 + *  allocate the loop manually and use uv_loop_init instead.
 + */
 +UV_EXTERN uv_loop_t* uv_loop_new(void);
 +/*
 + * NOTE:
 + *  This function is DEPRECATED (to be removed after 0.12). Users should use
 + *  uv_loop_close and free the memory manually instead.
 + */
 +UV_EXTERN void uv_loop_delete(uv_loop_t*);
 +UV_EXTERN size_t uv_loop_size(void);
 +UV_EXTERN int uv_loop_alive(const uv_loop_t* loop);
 +UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...);
 +UV_EXTERN int uv_loop_fork(uv_loop_t* loop);
 +
 +UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode);
 +UV_EXTERN void uv_stop(uv_loop_t*);
 +
 +UV_EXTERN void uv_ref(uv_handle_t*);
 +UV_EXTERN void uv_unref(uv_handle_t*);
 +UV_EXTERN int uv_has_ref(const uv_handle_t*);
 +
 +UV_EXTERN void uv_update_time(uv_loop_t*);
 +UV_EXTERN uint64_t uv_now(const uv_loop_t*);
 +
 +UV_EXTERN int uv_backend_fd(const uv_loop_t*);
 +UV_EXTERN int uv_backend_timeout(const uv_loop_t*);
 +
 +typedef void (*uv_alloc_cb)(uv_handle_t* handle,
 +                            size_t suggested_size,
 +                            uv_buf_t* buf);
 +typedef void (*uv_read_cb)(uv_stream_t* stream,
 +                           ssize_t nread,
 +                           const uv_buf_t* buf);
 +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);
 +typedef void (*uv_connection_cb)(uv_stream_t* server, int status);
 +typedef void (*uv_close_cb)(uv_handle_t* handle);
 +typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events);
 +typedef void (*uv_timer_cb)(uv_timer_t* handle);
 +typedef void (*uv_async_cb)(uv_async_t* handle);
 +typedef void (*uv_prepare_cb)(uv_prepare_t* handle);
 +typedef void (*uv_check_cb)(uv_check_t* handle);
 +typedef void (*uv_idle_cb)(uv_idle_t* handle);
 +typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal);
 +typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg);
 +typedef void (*uv_fs_cb)(uv_fs_t* req);
 +typedef void (*uv_work_cb)(uv_work_t* req);
 +typedef void (*uv_after_work_cb)(uv_work_t* req, int status);
 +typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req,
 +                                  int status,
 +                                  struct addrinfo* res);
 +typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req,
 +                                  int status,
 +                                  const char* hostname,
 +                                  const char* service);
 +
 +typedef struct {
 +  long tv_sec;
 +  long tv_nsec;
 +} uv_timespec_t;
 +
 +
 +typedef struct {
 +  uint64_t st_dev;
 +  uint64_t st_mode;
 +  uint64_t st_nlink;
 +  uint64_t st_uid;
 +  uint64_t st_gid;
 +  uint64_t st_rdev;
 +  uint64_t st_ino;
 +  uint64_t st_size;
 +  uint64_t st_blksize;
 +  uint64_t st_blocks;
 +  uint64_t st_flags;
 +  uint64_t st_gen;
 +  uv_timespec_t st_atim;
 +  uv_timespec_t st_mtim;
 +  uv_timespec_t st_ctim;
 +  uv_timespec_t st_birthtim;
 +} uv_stat_t;
 +
 +
 +typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle,
 +                               const char* filename,
 +                               int events,
 +                               int status);
 +
 +typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle,
 +                              int status,
 +                              const uv_stat_t* prev,
 +                              const uv_stat_t* curr);
 +
 +typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum);
 +
 +
 +typedef enum {
 +  UV_LEAVE_GROUP = 0,
 +  UV_JOIN_GROUP
 +} uv_membership;
 +
 +
 +UV_EXTERN int uv_translate_sys_error(int sys_errno);
 +
 +UV_EXTERN const char* uv_strerror(int err);
 +UV_EXTERN const char* uv_err_name(int err);
 +
 +
 +#define UV_REQ_FIELDS                                                         \
 +  /* public */                                                                \
 +  void* data;                                                                 \
 +  /* read-only */                                                             \
 +  uv_req_type type;                                                           \
 +  /* private */                                                               \
 +  void* active_queue[2];                                                      \
 +  void* reserved[4];                                                          \
 +  UV_REQ_PRIVATE_FIELDS                                                       \
 +
 +/* Abstract base class of all requests. */
 +struct uv_req_s {
 +  UV_REQ_FIELDS
 +};
 +
 +
 +/* Platform-specific request types. */
 +UV_PRIVATE_REQ_TYPES
 +
 +
 +UV_EXTERN int uv_shutdown(uv_shutdown_t* req,
 +                          uv_stream_t* handle,
 +                          uv_shutdown_cb cb);
 +
 +struct uv_shutdown_s {
 +  UV_REQ_FIELDS
 +  uv_stream_t* handle;
 +  uv_shutdown_cb cb;
 +  UV_SHUTDOWN_PRIVATE_FIELDS
 +};
 +
 +
 +#define UV_HANDLE_FIELDS                                                      \
 +  /* public */                                                                \
 +  void* data;                                                                 \
 +  /* read-only */                                                             \
 +  uv_loop_t* loop;                                                            \
 +  uv_handle_type type;                                                        \
 +  /* private */                                                               \
 +  uv_close_cb close_cb;                                                       \
 +  void* handle_queue[2];                                                      \
 +  union {                                                                     \
 +    int fd;                                                                   \
 +    void* reserved[4];                                                        \
 +  } u;                                                                        \
 +  UV_HANDLE_PRIVATE_FIELDS                                                    \
 +
 +/* The abstract base class of all handles. */
 +struct uv_handle_s {
 +  UV_HANDLE_FIELDS
 +};
 +
 +UV_EXTERN size_t uv_handle_size(uv_handle_type type);
 +UV_EXTERN size_t uv_req_size(uv_req_type type);
 +
 +UV_EXTERN int uv_is_active(const uv_handle_t* handle);
 +
 +UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg);
 +
 +/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */
 +UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream);
 +UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream);
 +
 +UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb);
 +
 +UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value);
 +UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value);
 +
 +UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd);
 +
 +UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int 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;                                                         \
 +  /* private */                                                               \
 +  UV_STREAM_PRIVATE_FIELDS
 +
 +/*
 + * uv_stream_t is a subclass of uv_handle_t.
 + *
 + * uv_stream is an abstract class.
 + *
 + * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t.
 + */
 +struct uv_stream_s {
 +  UV_HANDLE_FIELDS
 +  UV_STREAM_FIELDS
 +};
 +
 +UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb);
 +UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client);
 +
 +UV_EXTERN int uv_read_start(uv_stream_t*,
 +                            uv_alloc_cb alloc_cb,
 +                            uv_read_cb read_cb);
 +UV_EXTERN int uv_read_stop(uv_stream_t*);
 +
 +UV_EXTERN int uv_write(uv_write_t* req,
 +                       uv_stream_t* handle,
 +                       const uv_buf_t bufs[],
 +                       unsigned int nbufs,
 +                       uv_write_cb cb);
 +UV_EXTERN int uv_write2(uv_write_t* req,
 +                        uv_stream_t* handle,
 +                        const uv_buf_t bufs[],
 +                        unsigned int nbufs,
 +                        uv_stream_t* send_handle,
 +                        uv_write_cb cb);
 +UV_EXTERN int uv_try_write(uv_stream_t* handle,
 +                           const uv_buf_t bufs[],
 +                           unsigned int nbufs);
 +
 +/* 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
 +};
 +
 +
 +UV_EXTERN int uv_is_readable(const uv_stream_t* handle);
 +UV_EXTERN int uv_is_writable(const uv_stream_t* handle);
 +
 +UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking);
 +
 +UV_EXTERN int uv_is_closing(const uv_handle_t* handle);
 +
 +
 +/*
 + * uv_tcp_t is a subclass of uv_stream_t.
 + *
 + * Represents a TCP stream or TCP server.
 + */
 +struct uv_tcp_s {
 +  UV_HANDLE_FIELDS
 +  UV_STREAM_FIELDS
 +  UV_TCP_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle);
 +UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags);
 +UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock);
 +UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable);
 +UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle,
 +                               int enable,
 +                               unsigned int delay);
 +UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable);
 +
 +enum uv_tcp_flags {
 +  /* Used with uv_tcp_bind, when an IPv6 address is used. */
 +  UV_TCP_IPV6ONLY = 1
 +};
 +
 +UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle,
 +                          const struct sockaddr* addr,
 +                          unsigned int flags);
 +UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle,
 +                                 struct sockaddr* name,
 +                                 int* namelen);
 +UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle,
 +                                 struct sockaddr* name,
 +                                 int* namelen);
 +UV_EXTERN int uv_tcp_connect(uv_connect_t* req,
 +                             uv_tcp_t* handle,
 +                             const struct sockaddr* addr,
 +                             uv_connect_cb cb);
 +
 +/* uv_connect_t is a subclass of uv_req_t. */
 +struct uv_connect_s {
 +  UV_REQ_FIELDS
 +  uv_connect_cb cb;
 +  uv_stream_t* handle;
 +  UV_CONNECT_PRIVATE_FIELDS
 +};
 +
 +
 +/*
 + * UDP support.
 + */
 +
 +enum uv_udp_flags {
 +  /* Disables dual stack mode. */
 +  UV_UDP_IPV6ONLY = 1,
 +  /*
 +   * Indicates message was truncated because read buffer was too small. The
 +   * remainder was discarded by the OS. Used in uv_udp_recv_cb.
 +   */
 +  UV_UDP_PARTIAL = 2,
 +  /*
 +   * Indicates if SO_REUSEADDR will be set when binding the handle.
 +   * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other
 +   * Unix platforms, it sets the SO_REUSEADDR flag.  What that means is that
 +   * multiple threads or processes can bind to the same address without error
 +   * (provided they all set the flag) but only the last one to bind will receive
 +   * any traffic, in effect "stealing" the port from the previous listener.
 +   */
 +  UV_UDP_REUSEADDR = 4
 +};
 +
 +typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status);
 +typedef void (*uv_udp_recv_cb)(uv_udp_t* handle,
 +                               ssize_t nread,
 +                               const uv_buf_t* buf,
 +                               const struct sockaddr* addr,
 +                               unsigned flags);
 +
 +/* uv_udp_t is a subclass of uv_handle_t. */
 +struct uv_udp_s {
 +  UV_HANDLE_FIELDS
 +  /* read-only */
 +  /*
 +   * Number of bytes queued for sending. This field strictly shows how much
 +   * information is currently queued.
 +   */
 +  size_t send_queue_size;
 +  /*
 +   * Number of send requests currently in the queue awaiting to be processed.
 +   */
 +  size_t send_queue_count;
 +  UV_UDP_PRIVATE_FIELDS
 +};
 +
 +/* uv_udp_send_t is a subclass of uv_req_t. */
 +struct uv_udp_send_s {
 +  UV_REQ_FIELDS
 +  uv_udp_t* handle;
 +  uv_udp_send_cb cb;
 +  UV_UDP_SEND_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle);
 +UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags);
 +UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock);
 +UV_EXTERN int uv_udp_bind(uv_udp_t* handle,
 +                          const struct sockaddr* addr,
 +                          unsigned int flags);
 +
 +UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle,
 +                                 struct sockaddr* name,
 +                                 int* namelen);
 +UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
 +                                    const char* multicast_addr,
 +                                    const char* interface_addr,
 +                                    uv_membership membership);
 +UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on);
 +UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
 +UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle,
 +                                             const char* interface_addr);
 +UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on);
 +UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl);
 +UV_EXTERN int uv_udp_send(uv_udp_send_t* req,
 +                          uv_udp_t* handle,
 +                          const uv_buf_t bufs[],
 +                          unsigned int nbufs,
 +                          const struct sockaddr* addr,
 +                          uv_udp_send_cb send_cb);
 +UV_EXTERN int uv_udp_try_send(uv_udp_t* handle,
 +                              const uv_buf_t bufs[],
 +                              unsigned int nbufs,
 +                              const struct sockaddr* addr);
 +UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle,
 +                                uv_alloc_cb alloc_cb,
 +                                uv_udp_recv_cb recv_cb);
 +UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle);
 +
 +
 +/*
 + * uv_tty_t is a subclass of uv_stream_t.
 + *
 + * Representing a stream for the console.
 + */
 +struct uv_tty_s {
 +  UV_HANDLE_FIELDS
 +  UV_STREAM_FIELDS
 +  UV_TTY_PRIVATE_FIELDS
 +};
 +
 +typedef enum {
 +  /* Initial/normal terminal mode */
 +  UV_TTY_MODE_NORMAL,
 +  /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */
 +  UV_TTY_MODE_RAW,
 +  /* Binary-safe I/O mode for IPC (Unix-only) */
 +  UV_TTY_MODE_IO
 +} uv_tty_mode_t;
 +
 +UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable);
 +UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode);
 +UV_EXTERN int uv_tty_reset_mode(void);
 +UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
 +
 +#ifdef __cplusplus
 +extern "C++" {
 +
 +inline int uv_tty_set_mode(uv_tty_t* handle, int mode) {
 +  return uv_tty_set_mode(handle, static_cast<uv_tty_mode_t>(mode));
 +}
 +
 +}
 +#endif
 +
 +UV_EXTERN uv_handle_type uv_guess_handle(uv_file file);
 +
 +/*
 + * uv_pipe_t is a subclass of uv_stream_t.
 + *
 + * Representing a pipe stream or pipe server. On Windows this is a Named
 + * Pipe. On Unix this is a Unix domain socket.
 + */
 +struct uv_pipe_s {
 +  UV_HANDLE_FIELDS
 +  UV_STREAM_FIELDS
 +  int ipc; /* non-zero if this pipe is used for passing handles */
 +  UV_PIPE_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc);
 +UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file);
 +UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name);
 +UV_EXTERN void uv_pipe_connect(uv_connect_t* req,
 +                               uv_pipe_t* handle,
 +                               const char* name,
 +                               uv_connect_cb cb);
 +UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle,
 +                                  char* buffer,
 +                                  size_t* size);
 +UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle,
 +                                  char* buffer,
 +                                  size_t* size);
 +UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count);
 +UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle);
 +UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle);
 +
 +
 +struct uv_poll_s {
 +  UV_HANDLE_FIELDS
 +  uv_poll_cb poll_cb;
 +  UV_POLL_PRIVATE_FIELDS
 +};
 +
 +enum uv_poll_event {
 +  UV_READABLE = 1,
 +  UV_WRITABLE = 2,
 +  UV_DISCONNECT = 4
 +};
 +
 +UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd);
 +UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop,
 +                                  uv_poll_t* handle,
 +                                  uv_os_sock_t socket);
 +UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb);
 +UV_EXTERN int uv_poll_stop(uv_poll_t* handle);
 +
 +
 +struct uv_prepare_s {
 +  UV_HANDLE_FIELDS
 +  UV_PREPARE_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare);
 +UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb);
 +UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare);
 +
 +
 +struct uv_check_s {
 +  UV_HANDLE_FIELDS
 +  UV_CHECK_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check);
 +UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb);
 +UV_EXTERN int uv_check_stop(uv_check_t* check);
 +
 +
 +struct uv_idle_s {
 +  UV_HANDLE_FIELDS
 +  UV_IDLE_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle);
 +UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb);
 +UV_EXTERN int uv_idle_stop(uv_idle_t* idle);
 +
 +
 +struct uv_async_s {
 +  UV_HANDLE_FIELDS
 +  UV_ASYNC_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_async_init(uv_loop_t*,
 +                            uv_async_t* async,
 +                            uv_async_cb async_cb);
 +UV_EXTERN int uv_async_send(uv_async_t* async);
 +
 +
 +/*
 + * uv_timer_t is a subclass of uv_handle_t.
 + *
 + * Used to get woken up at a specified time in the future.
 + */
 +struct uv_timer_s {
 +  UV_HANDLE_FIELDS
 +  UV_TIMER_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle);
 +UV_EXTERN int uv_timer_start(uv_timer_t* handle,
 +                             uv_timer_cb cb,
 +                             uint64_t timeout,
 +                             uint64_t repeat);
 +UV_EXTERN int uv_timer_stop(uv_timer_t* handle);
 +UV_EXTERN int uv_timer_again(uv_timer_t* handle);
 +UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat);
 +UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle);
 +
 +
 +/*
 + * uv_getaddrinfo_t is a subclass of uv_req_t.
 + *
 + * Request object for uv_getaddrinfo.
 + */
 +struct uv_getaddrinfo_s {
 +  UV_REQ_FIELDS
 +  /* read-only */
 +  uv_loop_t* loop;
 +  /* struct addrinfo* addrinfo is marked as private, but it really isn't. */
 +  UV_GETADDRINFO_PRIVATE_FIELDS
 +};
 +
 +
 +UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop,
 +                             uv_getaddrinfo_t* req,
 +                             uv_getaddrinfo_cb getaddrinfo_cb,
 +                             const char* node,
 +                             const char* service,
 +                             const struct addrinfo* hints);
 +UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai);
 +
 +
 +/*
 +* uv_getnameinfo_t is a subclass of uv_req_t.
 +*
 +* Request object for uv_getnameinfo.
 +*/
 +struct uv_getnameinfo_s {
 +  UV_REQ_FIELDS
 +  /* read-only */
 +  uv_loop_t* loop;
 +  /* host and service are marked as private, but they really aren't. */
 +  UV_GETNAMEINFO_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_getnameinfo(uv_loop_t* loop,
 +                             uv_getnameinfo_t* req,
 +                             uv_getnameinfo_cb getnameinfo_cb,
 +                             const struct sockaddr* addr,
 +                             int flags);
 +
 +
 +/* uv_spawn() options. */
 +typedef enum {
 +  UV_IGNORE         = 0x00,
 +  UV_CREATE_PIPE    = 0x01,
 +  UV_INHERIT_FD     = 0x02,
 +  UV_INHERIT_STREAM = 0x04,
 +
 +  /*
 +   * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE
 +   * determine the direction of flow, from the child process' perspective. Both
 +   * flags may be specified to create a duplex data stream.
 +   */
 +  UV_READABLE_PIPE  = 0x10,
 +  UV_WRITABLE_PIPE  = 0x20
 +} uv_stdio_flags;
 +
 +typedef struct uv_stdio_container_s {
 +  uv_stdio_flags flags;
 +
 +  union {
 +    uv_stream_t* stream;
 +    int fd;
 +  } data;
 +} uv_stdio_container_t;
 +
 +typedef struct uv_process_options_s {
 +  uv_exit_cb exit_cb; /* Called after the process exits. */
 +  const char* file;   /* Path to program to execute. */
 +  /*
 +   * Command line arguments. args[0] should be the path to the program. On
 +   * Windows this uses CreateProcess which concatenates the arguments into a
 +   * string this can cause some strange errors. See the note at
 +   * windows_verbatim_arguments.
 +   */
 +  char** args;
 +  /*
 +   * This will be set as the environ variable in the subprocess. If this is
 +   * NULL then the parents environ will be used.
 +   */
 +  char** env;
 +  /*
 +   * If non-null this represents a directory the subprocess should execute
 +   * in. Stands for current working directory.
 +   */
 +  const char* cwd;
 +  /*
 +   * Various flags that control how uv_spawn() behaves. See the definition of
 +   * `enum uv_process_flags` below.
 +   */
 +  unsigned int flags;
 +  /*
 +   * The `stdio` field points to an array of uv_stdio_container_t structs that
 +   * describe the file descriptors that will be made available to the child
 +   * process. The convention is that stdio[0] points to stdin, fd 1 is used for
 +   * stdout, and fd 2 is stderr.
 +   *
 +   * Note that on windows file descriptors greater than 2 are available to the
 +   * child process only if the child processes uses the MSVCRT runtime.
 +   */
 +  int stdio_count;
 +  uv_stdio_container_t* stdio;
 +  /*
 +   * Libuv can change the child process' user/group id. This happens only when
 +   * the appropriate bits are set in the flags fields. This is not supported on
 +   * windows; uv_spawn() will fail and set the error to UV_ENOTSUP.
 +   */
 +  uv_uid_t uid;
 +  uv_gid_t gid;
 +} uv_process_options_t;
 +
 +/*
 + * These are the flags that can be used for the uv_process_options.flags field.
 + */
 +enum uv_process_flags {
 +  /*
 +   * Set the child process' user id. The user id is supplied in the `uid` field
 +   * of the options struct. This does not work on windows; setting this flag
 +   * will cause uv_spawn() to fail.
 +   */
 +  UV_PROCESS_SETUID = (1 << 0),
 +  /*
 +   * Set the child process' group id. The user id is supplied in the `gid`
 +   * field of the options struct. This does not work on windows; setting this
 +   * flag will cause uv_spawn() to fail.
 +   */
 +  UV_PROCESS_SETGID = (1 << 1),
 +  /*
 +   * Do not wrap any arguments in quotes, or perform any other escaping, when
 +   * converting the argument list into a command line string. This option is
 +   * only meaningful on Windows systems. On Unix it is silently ignored.
 +   */
 +  UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2),
 +  /*
 +   * Spawn the child process in a detached state - this will make it a process
 +   * group leader, and will effectively enable the child to keep running after
 +   * the parent exits.  Note that the child process will still keep the
 +   * parent's event loop alive unless the parent process calls uv_unref() on
 +   * the child's process handle.
 +   */
 +  UV_PROCESS_DETACHED = (1 << 3),
 +  /*
 +   * Hide the subprocess console window that would normally be created. This
 +   * option is only meaningful on Windows systems. On Unix it is silently
 +   * ignored.
 +   */
 +  UV_PROCESS_WINDOWS_HIDE = (1 << 4)
 +};
 +
 +/*
 + * uv_process_t is a subclass of uv_handle_t.
 + */
 +struct uv_process_s {
 +  UV_HANDLE_FIELDS
 +  uv_exit_cb exit_cb;
 +  int pid;
 +  UV_PROCESS_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_spawn(uv_loop_t* loop,
 +                       uv_process_t* handle,
 +                       const uv_process_options_t* options);
 +UV_EXTERN int uv_process_kill(uv_process_t*, int signum);
 +UV_EXTERN int uv_kill(int pid, int signum);
 +
 +
 +/*
 + * uv_work_t is a subclass of uv_req_t.
 + */
 +struct uv_work_s {
 +  UV_REQ_FIELDS
 +  uv_loop_t* loop;
 +  uv_work_cb work_cb;
 +  uv_after_work_cb after_work_cb;
 +  UV_WORK_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_queue_work(uv_loop_t* loop,
 +                            uv_work_t* req,
 +                            uv_work_cb work_cb,
 +                            uv_after_work_cb after_work_cb);
 +
 +UV_EXTERN int uv_cancel(uv_req_t* req);
 +
 +
 +struct uv_cpu_info_s {
 +  char* model;
 +  int speed;
 +  struct uv_cpu_times_s {
 +    uint64_t user;
 +    uint64_t nice;
 +    uint64_t sys;
 +    uint64_t idle;
 +    uint64_t irq;
 +  } cpu_times;
 +};
 +
 +struct uv_interface_address_s {
 +  char* name;
 +  char phys_addr[6];
 +  int is_internal;
 +  union {
 +    struct sockaddr_in address4;
 +    struct sockaddr_in6 address6;
 +  } address;
 +  union {
 +    struct sockaddr_in netmask4;
 +    struct sockaddr_in6 netmask6;
 +  } netmask;
 +};
 +
 +struct uv_passwd_s {
 +  char* username;
 +  long uid;
 +  long gid;
 +  char* shell;
 +  char* homedir;
 +};
 +
 +typedef enum {
 +  UV_DIRENT_UNKNOWN,
 +  UV_DIRENT_FILE,
 +  UV_DIRENT_DIR,
 +  UV_DIRENT_LINK,
 +  UV_DIRENT_FIFO,
 +  UV_DIRENT_SOCKET,
 +  UV_DIRENT_CHAR,
 +  UV_DIRENT_BLOCK
 +} uv_dirent_type_t;
 +
 +struct uv_dirent_s {
 +  const char* name;
 +  uv_dirent_type_t type;
 +};
 +
 +UV_EXTERN char** uv_setup_args(int argc, char** argv);
 +UV_EXTERN int uv_get_process_title(char* buffer, size_t size);
 +UV_EXTERN int uv_set_process_title(const char* title);
 +UV_EXTERN int uv_resident_set_memory(size_t* rss);
 +UV_EXTERN int uv_uptime(double* uptime);
 +
 +typedef struct {
 +  long tv_sec;
 +  long tv_usec;
 +} uv_timeval_t;
 +
 +typedef struct {
 +   uv_timeval_t ru_utime; /* user CPU time used */
 +   uv_timeval_t ru_stime; /* system CPU time used */
 +   uint64_t ru_maxrss;    /* maximum resident set size */
 +   uint64_t ru_ixrss;     /* integral shared memory size */
 +   uint64_t ru_idrss;     /* integral unshared data size */
 +   uint64_t ru_isrss;     /* integral unshared stack size */
 +   uint64_t ru_minflt;    /* page reclaims (soft page faults) */
 +   uint64_t ru_majflt;    /* page faults (hard page faults) */
 +   uint64_t ru_nswap;     /* swaps */
 +   uint64_t ru_inblock;   /* block input operations */
 +   uint64_t ru_oublock;   /* block output operations */
 +   uint64_t ru_msgsnd;    /* IPC messages sent */
 +   uint64_t ru_msgrcv;    /* IPC messages received */
 +   uint64_t ru_nsignals;  /* signals received */
 +   uint64_t ru_nvcsw;     /* voluntary context switches */
 +   uint64_t ru_nivcsw;    /* involuntary context switches */
 +} uv_rusage_t;
 +
 +UV_EXTERN int uv_getrusage(uv_rusage_t* rusage);
 +
 +UV_EXTERN int uv_os_homedir(char* buffer, size_t* size);
 +UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size);
 +UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd);
 +UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd);
 +
 +UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count);
 +UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count);
 +
 +UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses,
 +                                     int* count);
 +UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses,
 +                                           int count);
 +
 +UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size);
 +UV_EXTERN int uv_os_setenv(const char* name, const char* value);
 +UV_EXTERN int uv_os_unsetenv(const char* name);
 +
++UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size);
++
 +
 +typedef enum {
 +  UV_FS_UNKNOWN = -1,
 +  UV_FS_CUSTOM,
 +  UV_FS_OPEN,
 +  UV_FS_CLOSE,
 +  UV_FS_READ,
 +  UV_FS_WRITE,
 +  UV_FS_SENDFILE,
 +  UV_FS_STAT,
 +  UV_FS_LSTAT,
 +  UV_FS_FSTAT,
 +  UV_FS_FTRUNCATE,
 +  UV_FS_UTIME,
 +  UV_FS_FUTIME,
 +  UV_FS_ACCESS,
 +  UV_FS_CHMOD,
 +  UV_FS_FCHMOD,
 +  UV_FS_FSYNC,
 +  UV_FS_FDATASYNC,
 +  UV_FS_UNLINK,
 +  UV_FS_RMDIR,
 +  UV_FS_MKDIR,
 +  UV_FS_MKDTEMP,
 +  UV_FS_RENAME,
 +  UV_FS_SCANDIR,
 +  UV_FS_LINK,
 +  UV_FS_SYMLINK,
 +  UV_FS_READLINK,
 +  UV_FS_CHOWN,
 +  UV_FS_FCHOWN,
 +  UV_FS_REALPATH
 +} uv_fs_type;
 +
 +/* uv_fs_t is a subclass of uv_req_t. */
 +struct uv_fs_s {
 +  UV_REQ_FIELDS
 +  uv_fs_type fs_type;
 +  uv_loop_t* loop;
 +  uv_fs_cb cb;
 +  ssize_t result;
 +  void* ptr;
 +  const char* path;
 +  uv_stat_t statbuf;  /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */
 +  UV_FS_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req);
 +UV_EXTERN int uv_fs_close(uv_loop_t* loop,
 +                          uv_fs_t* req,
 +                          uv_file file,
 +                          uv_fs_cb cb);
 +UV_EXTERN int uv_fs_open(uv_loop_t* loop,
 +                         uv_fs_t* req,
 +                         const char* path,
 +                         int flags,
 +                         int mode,
 +                         uv_fs_cb cb);
 +UV_EXTERN int uv_fs_read(uv_loop_t* loop,
 +                         uv_fs_t* req,
 +                         uv_file file,
 +                         const uv_buf_t bufs[],
 +                         unsigned int nbufs,
 +                         int64_t offset,
 +                         uv_fs_cb cb);
 +UV_EXTERN int uv_fs_unlink(uv_loop_t* loop,
 +                           uv_fs_t* req,
 +                           const char* path,
 +                           uv_fs_cb cb);
 +UV_EXTERN int uv_fs_write(uv_loop_t* loop,
 +                          uv_fs_t* req,
 +                          uv_file file,
 +                          const uv_buf_t bufs[],
 +                          unsigned int nbufs,
 +                          int64_t offset,
 +                          uv_fs_cb cb);
 +UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop,
 +                          uv_fs_t* req,
 +                          const char* path,
 +                          int mode,
 +                          uv_fs_cb cb);
 +UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop,
 +                            uv_fs_t* req,
 +                            const char* tpl,
 +                            uv_fs_cb cb);
 +UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop,
 +                          uv_fs_t* req,
 +                          const char* path,
 +                          uv_fs_cb cb);
 +UV_EXTERN int uv_fs_scandir(uv_loop_t* loop,
 +                            uv_fs_t* req,
 +                            const char* path,
 +                            int flags,
 +                            uv_fs_cb cb);
 +UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req,
 +                                 uv_dirent_t* ent);
 +UV_EXTERN int uv_fs_stat(uv_loop_t* loop,
 +                         uv_fs_t* req,
 +                         const char* path,
 +                         uv_fs_cb cb);
 +UV_EXTERN int uv_fs_fstat(uv_loop_t* loop,
 +                          uv_fs_t* req,
 +                          uv_file file,
 +                          uv_fs_cb cb);
 +UV_EXTERN int uv_fs_rename(uv_loop_t* loop,
 +                           uv_fs_t* req,
 +                           const char* path,
 +                           const char* new_path,
 +                           uv_fs_cb cb);
 +UV_EXTERN int uv_fs_fsync(uv_loop_t* loop,
 +                          uv_fs_t* req,
 +                          uv_file file,
 +                          uv_fs_cb cb);
 +UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop,
 +                              uv_fs_t* req,
 +                              uv_file file,
 +                              uv_fs_cb cb);
 +UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop,
 +                              uv_fs_t* req,
 +                              uv_file file,
 +                              int64_t offset,
 +                              uv_fs_cb cb);
 +UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop,
 +                             uv_fs_t* req,
 +                             uv_file out_fd,
 +                             uv_file in_fd,
 +                             int64_t in_offset,
 +                             size_t length,
 +                             uv_fs_cb cb);
 +UV_EXTERN int uv_fs_access(uv_loop_t* loop,
 +                           uv_fs_t* req,
 +                           const char* path,
 +                           int mode,
 +                           uv_fs_cb cb);
 +UV_EXTERN int uv_fs_chmod(uv_loop_t* loop,
 +                          uv_fs_t* req,
 +                          const char* path,
 +                          int mode,
 +                          uv_fs_cb cb);
 +UV_EXTERN int uv_fs_utime(uv_loop_t* loop,
 +                          uv_fs_t* req,
 +                          const char* path,
 +                          double atime,
 +                          double mtime,
 +                          uv_fs_cb cb);
 +UV_EXTERN int uv_fs_futime(uv_loop_t* loop,
 +                           uv_fs_t* req,
 +                           uv_file file,
 +                           double atime,
 +                           double mtime,
 +                           uv_fs_cb cb);
 +UV_EXTERN int uv_fs_lstat(uv_loop_t* loop,
 +                          uv_fs_t* req,
 +                          const char* path,
 +                          uv_fs_cb cb);
 +UV_EXTERN 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.
 + */
 +#define UV_FS_SYMLINK_DIR          0x0001
 +
 +/*
 + * This flag can be used with uv_fs_symlink() on Windows to specify whether
 + * the symlink is to be created using junction points.
 + */
 +#define UV_FS_SYMLINK_JUNCTION     0x0002
 +
 +UV_EXTERN int uv_fs_symlink(uv_loop_t* loop,
 +                            uv_fs_t* req,
 +                            const char* path,
 +                            const char* new_path,
 +                            int flags,
 +                            uv_fs_cb cb);
 +UV_EXTERN int uv_fs_readlink(uv_loop_t* loop,
 +                             uv_fs_t* req,
 +                             const char* path,
 +                             uv_fs_cb cb);
 +UV_EXTERN int uv_fs_realpath(uv_loop_t* loop,
 +                             uv_fs_t* req,
 +                             const char* path,
 +                             uv_fs_cb cb);
 +UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop,
 +                           uv_fs_t* req,
 +                           uv_file file,
 +                           int mode,
 +                           uv_fs_cb cb);
 +UV_EXTERN int uv_fs_chown(uv_loop_t* loop,
 +                          uv_fs_t* req,
 +                          const char* path,
 +                          uv_uid_t uid,
 +                          uv_gid_t gid,
 +                          uv_fs_cb cb);
 +UV_EXTERN int uv_fs_fchown(uv_loop_t* loop,
 +                           uv_fs_t* req,
 +                           uv_file file,
 +                           uv_uid_t uid,
 +                           uv_gid_t gid,
 +                           uv_fs_cb cb);
 +
 +
 +enum uv_fs_event {
 +  UV_RENAME = 1,
 +  UV_CHANGE = 2
 +};
 +
 +
 +struct uv_fs_event_s {
 +  UV_HANDLE_FIELDS
 +  /* private */
 +  char* path;
 +  UV_FS_EVENT_PRIVATE_FIELDS
 +};
 +
 +
 +/*
 + * uv_fs_stat() based polling file watcher.
 + */
 +struct uv_fs_poll_s {
 +  UV_HANDLE_FIELDS
 +  /* Private, don't touch. */
 +  void* poll_ctx;
 +};
 +
 +UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle);
 +UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle,
 +                               uv_fs_poll_cb poll_cb,
 +                               const char* path,
 +                               unsigned int interval);
 +UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle);
 +UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle,
 +                                 char* buffer,
 +                                 size_t* size);
 +
 +
 +struct uv_signal_s {
 +  UV_HANDLE_FIELDS
 +  uv_signal_cb signal_cb;
 +  int signum;
 +  UV_SIGNAL_PRIVATE_FIELDS
 +};
 +
 +UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle);
 +UV_EXTERN int uv_signal_start(uv_signal_t* handle,
 +                              uv_signal_cb signal_cb,
 +                              int signum);
 +UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle,
 +                                      uv_signal_cb signal_cb,
 +                                      int signum);
 +UV_EXTERN int uv_signal_stop(uv_signal_t* handle);
 +
 +UV_EXTERN void uv_loadavg(double avg[3]);
 +
 +
 +/*
 + * Flags to be passed to uv_fs_event_start().
 + */
 +enum uv_fs_event_flags {
 +  /*
 +   * By default, if the fs event watcher is given a directory name, we will
 +   * watch for all events in that directory. This flags overrides this behavior
 +   * and makes fs_event report only changes to the directory entry itself. This
 +   * flag does not affect individual files watched.
 +   * This flag is currently not implemented yet on any backend.
 +   */
 +  UV_FS_EVENT_WATCH_ENTRY = 1,
 +
 +  /*
 +   * By default uv_fs_event will try to use a kernel interface such as inotify
 +   * or kqueue to detect events. This may not work on remote filesystems such
 +   * as NFS mounts. This flag makes fs_event fall back to calling stat() on a
 +   * regular interval.
 +   * This flag is currently not implemented yet on any backend.
 +   */
 +  UV_FS_EVENT_STAT = 2,
 +
 +  /*
 +   * By default, event watcher, when watching directory, is not registering
 +   * (is ignoring) changes in it's subdirectories.
 +   * This flag will override this behaviour on platforms that support it.
 +   */
 +  UV_FS_EVENT_RECURSIVE = 4
 +};
 +
 +
 +UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle);
 +UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle,
 +                                uv_fs_event_cb cb,
 +                                const char* path,
 +                                unsigned int flags);
 +UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle);
 +UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle,
 +                                  char* buffer,
 +                                  size_t* size);
 +
 +UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr);
 +UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr);
 +
 +UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size);
 +UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size);
 +
 +UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size);
 +UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst);
 +
 +UV_EXTERN int uv_exepath(char* buffer, size_t* size);
 +
 +UV_EXTERN int uv_cwd(char* buffer, size_t* size);
 +
 +UV_EXTERN int uv_chdir(const char* dir);
 +
 +UV_EXTERN uint64_t uv_get_free_memory(void);
 +UV_EXTERN uint64_t uv_get_total_memory(void);
 +
 +UV_EXTERN uint64_t uv_hrtime(void);
 +
 +UV_EXTERN void uv_disable_stdio_inheritance(void);
 +
 +UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib);
 +UV_EXTERN void uv_dlclose(uv_lib_t* lib);
 +UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr);
 +UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib);
 +
 +UV_EXTERN int uv_mutex_init(uv_mutex_t* handle);
 +UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle);
 +UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle);
 +UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle);
 +UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle);
 +
 +UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock);
 +UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock);
 +UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock);
 +UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock);
 +UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock);
 +UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock);
 +UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock);
 +UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock);
 +
 +UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value);
 +UV_EXTERN void uv_sem_destroy(uv_sem_t* sem);
 +UV_EXTERN void uv_sem_post(uv_sem_t* sem);
 +UV_EXTERN void uv_sem_wait(uv_sem_t* sem);
 +UV_EXTERN int uv_sem_trywait(uv_sem_t* sem);
 +
 +UV_EXTERN int uv_cond_init(uv_cond_t* cond);
 +UV_EXTERN void uv_cond_destroy(uv_cond_t* cond);
 +UV_EXTERN void uv_cond_signal(uv_cond_t* cond);
 +UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond);
 +
 +UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count);
 +UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier);
 +UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier);
 +
 +UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex);
 +UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond,
 +                                uv_mutex_t* mutex,
 +                                uint64_t timeout);
 +
 +UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void));
 +
 +UV_EXTERN int uv_key_create(uv_key_t* key);
 +UV_EXTERN void uv_key_delete(uv_key_t* key);
 +UV_EXTERN void* uv_key_get(uv_key_t* key);
 +UV_EXTERN void uv_key_set(uv_key_t* key, void* value);
 +
 +typedef void (*uv_thread_cb)(void* arg);
 +
 +UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);
 +UV_EXTERN uv_thread_t uv_thread_self(void);
 +UV_EXTERN int uv_thread_join(uv_thread_t *tid);
 +UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2);
 +
 +/* The presence of these unions force similar struct layout. */
 +#define XX(_, name) uv_ ## name ## _t name;
 +union uv_any_handle {
 +  UV_HANDLE_TYPE_MAP(XX)
 +};
 +
 +union uv_any_req {
 +  UV_REQ_TYPE_MAP(XX)
 +};
 +#undef XX
 +
 +
 +struct uv_loop_s {
 +  /* User data - use this for whatever. */
 +  void* data;
 +  /* Loop reference counting. */
 +  unsigned int active_handles;
 +  void* handle_queue[2];
 +  void* active_reqs[2];
 +  /* Internal flag to signal loop stop. */
 +  unsigned int stop_flag;
 +  UV_LOOP_PRIVATE_FIELDS
 +};
 +
 +
 +/* Don't export the private CPP symbols. */
 +#undef UV_HANDLE_TYPE_PRIVATE
 +#undef UV_REQ_TYPE_PRIVATE
 +#undef UV_REQ_PRIVATE_FIELDS
 +#undef UV_STREAM_PRIVATE_FIELDS
 +#undef UV_TCP_PRIVATE_FIELDS
 +#undef UV_PREPARE_PRIVATE_FIELDS
 +#undef UV_CHECK_PRIVATE_FIELDS
 +#undef UV_IDLE_PRIVATE_FIELDS
 +#undef UV_ASYNC_PRIVATE_FIELDS
 +#undef UV_TIMER_PRIVATE_FIELDS
 +#undef UV_GETADDRINFO_PRIVATE_FIELDS
 +#undef UV_GETNAMEINFO_PRIVATE_FIELDS
 +#undef UV_FS_REQ_PRIVATE_FIELDS
 +#undef UV_WORK_PRIVATE_FIELDS
 +#undef UV_FS_EVENT_PRIVATE_FIELDS
 +#undef UV_SIGNAL_PRIVATE_FIELDS
 +#undef UV_LOOP_PRIVATE_FIELDS
 +#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS
 +
 +#ifdef __cplusplus
 +}
 +#endif
 +#endif /* UV_H */
diff --cc Utilities/cmlibuv/src/unix/cygwin.c
index 0000000,5a887dd..5a887dd
mode 000000,100644..100644
--- a/Utilities/cmlibuv/src/unix/cygwin.c
+++ b/Utilities/cmlibuv/src/unix/cygwin.c
diff --cc Utilities/cmlibuv/src/unix/no-fsevents.c
index 0000000,38fb6ab..38fb6ab
mode 000000,100644..100644
--- a/Utilities/cmlibuv/src/unix/no-fsevents.c
+++ b/Utilities/cmlibuv/src/unix/no-fsevents.c
diff --cc Utilities/cmlibuv/src/unix/no-proctitle.c
index 0000000,a5c19fb..a5c19fb
mode 000000,100644..100644
--- a/Utilities/cmlibuv/src/unix/no-proctitle.c
+++ b/Utilities/cmlibuv/src/unix/no-proctitle.c
diff --cc Utilities/cmlibuv/src/unix/pipe.c
index 023e965,0000000..7ba1bf8
mode 100644,000000..100644
--- a/Utilities/cmlibuv/src/unix/pipe.c
+++ b/Utilities/cmlibuv/src/unix/pipe.c
@@@ -1,294 -1,0 +1,302 @@@
 +/* 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.
 + */
 +
 +#include "uv.h"
 +#include "internal.h"
 +
 +#include <assert.h>
 +#include <errno.h>
 +#include <string.h>
 +#include <sys/un.h>
 +#include <unistd.h>
 +#include <stdlib.h>
 +
 +
 +int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
 +  uv__stream_init(loop, (uv_stream_t*)handle, UV_NAMED_PIPE);
 +  handle->shutdown_req = NULL;
 +  handle->connect_req = NULL;
 +  handle->pipe_fname = NULL;
 +  handle->ipc = ipc;
 +  return 0;
 +}
 +
 +
 +int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
 +  struct sockaddr_un saddr;
 +  const char* pipe_fname = NULL;
 +  int sockfd = -1;
 +  int err;
 +
 +  /* Already bound? */
 +  if (uv__stream_fd(handle) >= 0)
 +    return -EINVAL;
 +
 +  /* Make a copy of the file name, it outlives this function's scope. */
 +  pipe_fname = uv__strdup(name);
 +  if (pipe_fname == NULL)
 +    return -ENOMEM;
 +
 +  /* We've got a copy, don't touch the original any more. */
 +  name = NULL;
 +
 +  err = uv__socket(AF_UNIX, SOCK_STREAM, 0);
 +  if (err < 0)
 +    goto err_socket;
 +  sockfd = err;
 +
 +  memset(&saddr, 0, sizeof saddr);
 +  strncpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path) - 1);
 +  saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0';
 +  saddr.sun_family = AF_UNIX;
 +
 +  if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr)) {
 +    err = -errno;
 +    /* Convert ENOENT to EACCES for compatibility with Windows. */
 +    if (err == -ENOENT)
 +      err = -EACCES;
 +
 +    uv__close(sockfd);
 +    goto err_socket;
 +  }
 +
 +  /* Success. */
 +  handle->flags |= UV_HANDLE_BOUND;
 +  handle->pipe_fname = pipe_fname; /* Is a strdup'ed copy. */
 +  handle->io_watcher.fd = sockfd;
 +  return 0;
 +
 +err_socket:
 +  uv__free((void*)pipe_fname);
 +  return err;
 +}
 +
 +
 +int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
 +  if (uv__stream_fd(handle) == -1)
 +    return -EINVAL;
 +
 +#if defined(__MVS__)
 +  /* On zOS, backlog=0 has undefined behaviour */
 +  if (backlog == 0)
 +    backlog = 1;
 +  else if (backlog < 0)
 +    backlog = SOMAXCONN;
 +#endif
 +
 +  if (listen(uv__stream_fd(handle), backlog))
 +    return -errno;
 +
 +  handle->connection_cb = cb;
 +  handle->io_watcher.cb = uv__server_io;
 +  uv__io_start(handle->loop, &handle->io_watcher, POLLIN);
 +  return 0;
 +}
 +
 +
 +void uv__pipe_close(uv_pipe_t* handle) {
 +  if (handle->pipe_fname) {
 +    /*
 +     * Unlink the file system entity before closing the file descriptor.
 +     * Doing it the other way around introduces a race where our process
 +     * unlinks a socket with the same name that's just been created by
 +     * another thread or process.
 +     */
 +    unlink(handle->pipe_fname);
 +    uv__free((void*)handle->pipe_fname);
 +    handle->pipe_fname = NULL;
 +  }
 +
 +  uv__stream_close((uv_stream_t*)handle);
 +}
 +
 +
 +int uv_pipe_open(uv_pipe_t* handle, uv_file fd) {
 +  int err;
 +
 +  err = uv__nonblock(fd, 1);
 +  if (err)
 +    return err;
 +
 +#if defined(__APPLE__)
 +  err = uv__stream_try_select((uv_stream_t*) handle, &fd);
 +  if (err)
 +    return err;
 +#endif /* defined(__APPLE__) */
 +
 +  return uv__stream_open((uv_stream_t*)handle,
 +                         fd,
 +                         UV_STREAM_READABLE | UV_STREAM_WRITABLE);
 +}
 +
 +
 +void uv_pipe_connect(uv_connect_t* req,
 +                    uv_pipe_t* handle,
 +                    const char* name,
 +                    uv_connect_cb cb) {
 +  struct sockaddr_un saddr;
 +  int new_sock;
 +  int err;
 +  int r;
 +
 +  new_sock = (uv__stream_fd(handle) == -1);
 +
 +  if (new_sock) {
 +    err = uv__socket(AF_UNIX, SOCK_STREAM, 0);
 +    if (err < 0)
 +      goto out;
 +    handle->io_watcher.fd = err;
 +  }
 +
 +  memset(&saddr, 0, sizeof saddr);
 +  strncpy(saddr.sun_path, name, sizeof(saddr.sun_path) - 1);
 +  saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0';
 +  saddr.sun_family = AF_UNIX;
 +
 +  do {
 +    r = connect(uv__stream_fd(handle),
 +                (struct sockaddr*)&saddr, sizeof saddr);
 +  }
 +  while (r == -1 && errno == EINTR);
 +
 +  if (r == -1 && errno != EINPROGRESS) {
 +    err = -errno;
++#if defined(__CYGWIN__) || defined(__MSYS__)
++    /* EBADF is supposed to mean that the socket fd is bad, but
++       Cygwin reports EBADF instead of ENOTSOCK when the file is
++       not a socket.  We do not expect to see a bad fd here
++       (e.g. due to new_sock), so translate the error.  */
++    if (err == -EBADF)
++      err = -ENOTSOCK;
++#endif
 +    goto out;
 +  }
 +
 +  err = 0;
 +  if (new_sock) {
 +    err = uv__stream_open((uv_stream_t*)handle,
 +                          uv__stream_fd(handle),
 +                          UV_STREAM_READABLE | UV_STREAM_WRITABLE);
 +  }
 +
 +  if (err == 0)
 +    uv__io_start(handle->loop, &handle->io_watcher, POLLIN | POLLOUT);
 +
 +out:
 +  handle->delayed_error = err;
 +  handle->connect_req = req;
 +
 +  uv__req_init(handle->loop, req, UV_CONNECT);
 +  req->handle = (uv_stream_t*)handle;
 +  req->cb = cb;
 +  QUEUE_INIT(&req->queue);
 +
 +  /* Force callback to run on next tick in case of error. */
 +  if (err)
 +    uv__io_feed(handle->loop, &handle->io_watcher);
 +
 +}
 +
 +
 +typedef int (*uv__peersockfunc)(int, struct sockaddr*, socklen_t*);
 +
 +
 +static int uv__pipe_getsockpeername(const uv_pipe_t* handle,
 +                                    uv__peersockfunc func,
 +                                    char* buffer,
 +                                    size_t* size) {
 +  struct sockaddr_un sa;
 +  socklen_t addrlen;
 +  int err;
 +
 +  addrlen = sizeof(sa);
 +  memset(&sa, 0, addrlen);
 +  err = func(uv__stream_fd(handle), (struct sockaddr*) &sa, &addrlen);
 +  if (err < 0) {
 +    *size = 0;
 +    return -errno;
 +  }
 +
 +#if defined(__linux__)
 +  if (sa.sun_path[0] == 0)
 +    /* Linux abstract namespace */
 +    addrlen -= offsetof(struct sockaddr_un, sun_path);
 +  else
 +#endif
 +    addrlen = strlen(sa.sun_path);
 +
 +
 +  if (addrlen >= *size) {
 +    *size = addrlen + 1;
 +    return UV_ENOBUFS;
 +  }
 +
 +  memcpy(buffer, sa.sun_path, addrlen);
 +  *size = addrlen;
 +
 +  /* only null-terminate if it's not an abstract socket */
 +  if (buffer[0] != '\0')
 +    buffer[addrlen] = '\0';
 +
 +  return 0;
 +}
 +
 +
 +int uv_pipe_getsockname(const uv_pipe_t* handle, char* buffer, size_t* size) {
 +  return uv__pipe_getsockpeername(handle, getsockname, buffer, size);
 +}
 +
 +
 +int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size) {
 +  return uv__pipe_getsockpeername(handle, getpeername, buffer, size);
 +}
 +
 +
 +void uv_pipe_pending_instances(uv_pipe_t* handle, int count) {
 +}
 +
 +
 +int uv_pipe_pending_count(uv_pipe_t* handle) {
 +  uv__stream_queued_fds_t* queued_fds;
 +
 +  if (!handle->ipc)
 +    return 0;
 +
 +  if (handle->accepted_fd == -1)
 +    return 0;
 +
 +  if (handle->queued_fds == NULL)
 +    return 1;
 +
 +  queued_fds = handle->queued_fds;
 +  return queued_fds->offset + 1;
 +}
 +
 +
 +uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) {
 +  if (!handle->ipc)
 +    return UV_UNKNOWN_HANDLE;
 +
 +  if (handle->accepted_fd == -1)
 +    return UV_UNKNOWN_HANDLE;
 +  else
 +    return uv__handle_type(handle->accepted_fd);
 +}
diff --cc Utilities/cmlibuv/src/unix/posix-poll.c
index 0000000,3fba96e..3fba96e
mode 000000,100644..100644
--- a/Utilities/cmlibuv/src/unix/posix-poll.c
+++ b/Utilities/cmlibuv/src/unix/posix-poll.c
diff --cc Utilities/cmlibuv/src/unix/procfs-exepath.c
index 0000000,5fdb611..5fdb611
mode 000000,100644..100644
--- a/Utilities/cmlibuv/src/unix/procfs-exepath.c
+++ b/Utilities/cmlibuv/src/unix/procfs-exepath.c
diff --cc Utilities/cmlibuv/src/unix/sunos.c
index d100263,0000000..041f3f3
mode 100644,000000..100644
--- a/Utilities/cmlibuv/src/unix/sunos.c
+++ b/Utilities/cmlibuv/src/unix/sunos.c
@@@ -1,844 -1,0 +1,825 @@@
 +/* 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.
 + */
 +
 +#include "uv.h"
 +#include "internal.h"
 +
 +#include <stdio.h>
 +#include <stdint.h>
 +#include <stdlib.h>
 +#include <string.h>
 +#include <assert.h>
 +#include <errno.h>
 +
 +#if !defined(SUNOS_NO_IFADDRS) && _XOPEN_SOURCE < 600
 +#define SUNOS_NO_IFADDRS
 +#endif
 +
 +#ifndef SUNOS_NO_IFADDRS
 +# include <ifaddrs.h>
 +#endif
 +#include <net/if.h>
 +#include <net/if_dl.h>
 +#include <net/if_arp.h>
 +#include <sys/sockio.h>
 +
 +#include <sys/loadavg.h>
 +#include <sys/time.h>
 +#include <unistd.h>
 +#include <kstat.h>
 +#include <fcntl.h>
 +
 +#include <sys/port.h>
 +#include <port.h>
 +
 +#define PORT_FIRED 0x69
 +#define PORT_UNUSED 0x0
 +#define PORT_LOADED 0x99
 +#define PORT_DELETED -1
 +
 +#if (!defined(_LP64)) && (_FILE_OFFSET_BITS - 0 == 64)
 +#define PROCFS_FILE_OFFSET_BITS_HACK 1
 +#undef _FILE_OFFSET_BITS
 +#else
 +#define PROCFS_FILE_OFFSET_BITS_HACK 0
 +#endif
 +
 +#include <procfs.h>
 +
 +#if (PROCFS_FILE_OFFSET_BITS_HACK - 0 == 1)
 +#define _FILE_OFFSET_BITS 64
 +#endif
 +
 +
 +int uv__platform_loop_init(uv_loop_t* loop) {
 +  int err;
 +  int fd;
 +
 +  loop->fs_fd = -1;
 +  loop->backend_fd = -1;
 +
 +  fd = port_create();
 +  if (fd == -1)
 +    return -errno;
 +
 +  err = uv__cloexec(fd, 1);
 +  if (err) {
 +    uv__close(fd);
 +    return err;
 +  }
 +  loop->backend_fd = fd;
 +
 +  return 0;
 +}
 +
 +
 +void uv__platform_loop_delete(uv_loop_t* loop) {
 +  if (loop->fs_fd != -1) {
 +    uv__close(loop->fs_fd);
 +    loop->fs_fd = -1;
 +  }
 +
 +  if (loop->backend_fd != -1) {
 +    uv__close(loop->backend_fd);
 +    loop->backend_fd = -1;
 +  }
 +}
 +
 +
 +int uv__io_fork(uv_loop_t* loop) {
 +#if defined(PORT_SOURCE_FILE)
 +  if (loop->fs_fd != -1) {
 +    /* stop the watcher before we blow away its fileno */
 +    uv__io_stop(loop, &loop->fs_event_watcher, POLLIN);
 +  }
 +#endif
 +  uv__platform_loop_delete(loop);
 +  return uv__platform_loop_init(loop);
 +}
 +
 +
 +void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
 +  struct port_event* events;
 +  uintptr_t i;
 +  uintptr_t nfds;
 +
 +  assert(loop->watchers != NULL);
 +
 +  events = (struct port_event*) loop->watchers[loop->nwatchers];
 +  nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
 +  if (events == NULL)
 +    return;
 +
 +  /* Invalidate events with same file descriptor */
 +  for (i = 0; i < nfds; i++)
 +    if ((int) events[i].portev_object == fd)
 +      events[i].portev_object = -1;
 +}
 +
 +
 +int uv__io_check_fd(uv_loop_t* loop, int fd) {
 +  if (port_associate(loop->backend_fd, PORT_SOURCE_FD, fd, POLLIN, 0))
 +    return -errno;
 +
 +  if (port_dissociate(loop->backend_fd, PORT_SOURCE_FD, fd))
 +    abort();
 +
 +  return 0;
 +}
 +
 +
 +void uv__io_poll(uv_loop_t* loop, int timeout) {
 +  struct port_event events[1024];
 +  struct port_event* pe;
 +  struct timespec spec;
 +  QUEUE* q;
 +  uv__io_t* w;
 +  sigset_t* pset;
 +  sigset_t set;
 +  uint64_t base;
 +  uint64_t diff;
 +  unsigned int nfds;
 +  unsigned int i;
 +  int saved_errno;
 +  int have_signals;
 +  int nevents;
 +  int count;
 +  int err;
 +  int fd;
 +
 +  if (loop->nfds == 0) {
 +    assert(QUEUE_EMPTY(&loop->watcher_queue));
 +    return;
 +  }
 +
 +  while (!QUEUE_EMPTY(&loop->watcher_queue)) {
 +    q = QUEUE_HEAD(&loop->watcher_queue);
 +    QUEUE_REMOVE(q);
 +    QUEUE_INIT(q);
 +
 +    w = QUEUE_DATA(q, uv__io_t, watcher_queue);
 +    assert(w->pevents != 0);
 +
 +    if (port_associate(loop->backend_fd, PORT_SOURCE_FD, w->fd, w->pevents, 0))
 +      abort();
 +
 +    w->events = w->pevents;
 +  }
 +
 +  pset = NULL;
 +  if (loop->flags & UV_LOOP_BLOCK_SIGPROF) {
 +    pset = &set;
 +    sigemptyset(pset);
 +    sigaddset(pset, SIGPROF);
 +  }
 +
 +  assert(timeout >= -1);
 +  base = loop->time;
 +  count = 48; /* Benchmarks suggest this gives the best throughput. */
 +
 +  for (;;) {
 +    if (timeout != -1) {
 +      spec.tv_sec = timeout / 1000;
 +      spec.tv_nsec = (timeout % 1000) * 1000000;
 +    }
 +
 +    /* Work around a kernel bug where nfds is not updated. */
 +    events[0].portev_source = 0;
 +
 +    nfds = 1;
 +    saved_errno = 0;
 +
 +    if (pset != NULL)
 +      pthread_sigmask(SIG_BLOCK, pset, NULL);
 +
 +    err = port_getn(loop->backend_fd,
 +                    events,
 +                    ARRAY_SIZE(events),
 +                    &nfds,
 +                    timeout == -1 ? NULL : &spec);
 +
 +    if (pset != NULL)
 +      pthread_sigmask(SIG_UNBLOCK, pset, NULL);
 +
 +    if (err) {
 +      /* Work around another kernel bug: port_getn() may return events even
 +       * on error.
 +       */
 +      if (errno == EINTR || errno == ETIME)
 +        saved_errno = errno;
 +      else
 +        abort();
 +    }
 +
 +    /* Update loop->time unconditionally. It's tempting to skip the update when
 +     * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the
 +     * operating system didn't reschedule our process while in the syscall.
 +     */
 +    SAVE_ERRNO(uv__update_time(loop));
 +
 +    if (events[0].portev_source == 0) {
 +      if (timeout == 0)
 +        return;
 +
 +      if (timeout == -1)
 +        continue;
 +
 +      goto update_timeout;
 +    }
 +
 +    if (nfds == 0) {
 +      assert(timeout != -1);
 +      return;
 +    }
 +
 +    have_signals = 0;
 +    nevents = 0;
 +
 +    assert(loop->watchers != NULL);
 +    loop->watchers[loop->nwatchers] = (void*) events;
 +    loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds;
 +    for (i = 0; i < nfds; i++) {
 +      pe = events + i;
 +      fd = pe->portev_object;
 +
 +      /* Skip invalidated events, see uv__platform_invalidate_fd */
 +      if (fd == -1)
 +        continue;
 +
 +      assert(fd >= 0);
 +      assert((unsigned) fd < loop->nwatchers);
 +
 +      w = loop->watchers[fd];
 +
 +      /* File descriptor that we've stopped watching, ignore. */
 +      if (w == NULL)
 +        continue;
 +
 +      /* Run signal watchers last.  This also affects child process watchers
 +       * because those are implemented in terms of signal watchers.
 +       */
 +      if (w == &loop->signal_io_watcher)
 +        have_signals = 1;
 +      else
 +        w->cb(loop, w, pe->portev_events);
 +
 +      nevents++;
 +
 +      if (w != loop->watchers[fd])
 +        continue;  /* Disabled by callback. */
 +
 +      /* Events Ports operates in oneshot mode, rearm timer on next run. */
 +      if (w->pevents != 0 && QUEUE_EMPTY(&w->watcher_queue))
 +        QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
 +    }
 +
 +    if (have_signals != 0)
 +      loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN);
 +
 +    loop->watchers[loop->nwatchers] = NULL;
 +    loop->watchers[loop->nwatchers + 1] = NULL;
 +
 +    if (have_signals != 0)
 +      return;  /* Event loop should cycle now so don't poll again. */
 +
 +    if (nevents != 0) {
 +      if (nfds == ARRAY_SIZE(events) && --count != 0) {
 +        /* Poll for more events but don't block this time. */
 +        timeout = 0;
 +        continue;
 +      }
 +      return;
 +    }
 +
 +    if (saved_errno == ETIME) {
 +      assert(timeout != -1);
 +      return;
 +    }
 +
 +    if (timeout == 0)
 +      return;
 +
 +    if (timeout == -1)
 +      continue;
 +
 +update_timeout:
 +    assert(timeout > 0);
 +
 +    diff = loop->time - base;
 +    if (diff >= (uint64_t) timeout)
 +      return;
 +
 +    timeout -= diff;
 +  }
 +}
 +
 +
 +uint64_t uv__hrtime(uv_clocktype_t type) {
 +  return gethrtime();
 +}
 +
 +
 +/*
 + * We could use a static buffer for the path manipulations that we need outside
 + * of the function, but this function could be called by multiple consumers and
 + * we don't want to potentially create a race condition in the use of snprintf.
 + */
 +int uv_exepath(char* buffer, size_t* size) {
 +  ssize_t res;
 +  char buf[128];
 +
 +  if (buffer == NULL || size == NULL || *size == 0)
 +    return -EINVAL;
 +
 +  snprintf(buf, sizeof(buf), "/proc/%lu/path/a.out", (unsigned long) getpid());
 +
 +  res = *size - 1;
 +  if (res > 0)
 +    res = readlink(buf, buffer, res);
 +
 +  if (res == -1)
 +    return -errno;
 +
 +  buffer[res] = '\0';
 +  *size = res;
 +  return 0;
 +}
 +
 +
 +uint64_t uv_get_free_memory(void) {
 +  return (uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES);
 +}
 +
 +
 +uint64_t uv_get_total_memory(void) {
 +  return (uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES);
 +}
 +
 +
 +void uv_loadavg(double avg[3]) {
 +  (void) getloadavg(avg, 3);
 +}
 +
 +
 +#if defined(PORT_SOURCE_FILE)
 +
 +static int uv__fs_event_rearm(uv_fs_event_t *handle) {
 +  if (handle->fd == -1)
 +    return -EBADF;
 +
 +  if (port_associate(handle->loop->fs_fd,
 +                     PORT_SOURCE_FILE,
 +                     (uintptr_t) &handle->fo,
 +                     FILE_ATTRIB | FILE_MODIFIED,
 +                     handle) == -1) {
 +    return -errno;
 +  }
 +  handle->fd = PORT_LOADED;
 +
 +  return 0;
 +}
 +
 +
 +static void uv__fs_event_read(uv_loop_t* loop,
 +                              uv__io_t* w,
 +                              unsigned int revents) {
 +  uv_fs_event_t *handle = NULL;
 +  timespec_t timeout;
 +  port_event_t pe;
 +  int events;
 +  int r;
 +
 +  (void) w;
 +  (void) revents;
 +
 +  do {
 +    uint_t n = 1;
 +
 +    /*
 +     * Note that our use of port_getn() here (and not port_get()) is deliberate:
 +     * there is a bug in event ports (Sun bug 6456558) whereby a zeroed timeout
 +     * causes port_get() to return success instead of ETIME when there aren't
 +     * actually any events (!); by using port_getn() in lieu of port_get(),
 +     * we can at least workaround the bug by checking for zero returned events
 +     * and treating it as we would ETIME.
 +     */
 +    do {
 +      memset(&timeout, 0, sizeof timeout);
 +      r = port_getn(loop->fs_fd, &pe, 1, &n, &timeout);
 +    }
 +    while (r == -1 && errno == EINTR);
 +
 +    if ((r == -1 && errno == ETIME) || n == 0)
 +      break;
 +
 +    handle = (uv_fs_event_t*) pe.portev_user;
 +    assert((r == 0) && "unexpected port_get() error");
 +
 +    events = 0;
 +    if (pe.portev_events & (FILE_ATTRIB | FILE_MODIFIED))
 +      events |= UV_CHANGE;
 +    if (pe.portev_events & ~(FILE_ATTRIB | FILE_MODIFIED))
 +      events |= UV_RENAME;
 +    assert(events != 0);
 +    handle->fd = PORT_FIRED;
 +    handle->cb(handle, NULL, events, 0);
 +
 +    if (handle->fd != PORT_DELETED) {
 +      r = uv__fs_event_rearm(handle);
 +      if (r != 0)
 +        handle->cb(handle, NULL, 0, r);
 +    }
 +  }
 +  while (handle->fd != PORT_DELETED);
 +}
 +
 +
 +int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
 +  uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT);
 +  return 0;
 +}
 +
 +
 +int uv_fs_event_start(uv_fs_event_t* handle,
 +                      uv_fs_event_cb cb,
 +                      const char* path,
 +                      unsigned int flags) {
 +  int portfd;
 +  int first_run;
 +  int err;
 +
 +  if (uv__is_active(handle))
 +    return -EINVAL;
 +
 +  first_run = 0;
 +  if (handle->loop->fs_fd == -1) {
 +    portfd = port_create();
 +    if (portfd == -1)
 +      return -errno;
 +    handle->loop->fs_fd = portfd;
 +    first_run = 1;
 +  }
 +
 +  uv__handle_start(handle);
 +  handle->path = uv__strdup(path);
 +  handle->fd = PORT_UNUSED;
 +  handle->cb = cb;
 +
 +  memset(&handle->fo, 0, sizeof handle->fo);
 +  handle->fo.fo_name = handle->path;
 +  err = uv__fs_event_rearm(handle);
 +  if (err != 0) {
 +    uv_fs_event_stop(handle);
 +    return err;
 +  }
 +
 +  if (first_run) {
 +    uv__io_init(&handle->loop->fs_event_watcher, uv__fs_event_read, portfd);
 +    uv__io_start(handle->loop, &handle->loop->fs_event_watcher, POLLIN);
 +  }
 +
 +  return 0;
 +}
 +
 +
 +int uv_fs_event_stop(uv_fs_event_t* handle) {
 +  if (!uv__is_active(handle))
 +    return 0;
 +
 +  if (handle->fd == PORT_FIRED || handle->fd == PORT_LOADED) {
 +    port_dissociate(handle->loop->fs_fd,
 +                    PORT_SOURCE_FILE,
 +                    (uintptr_t) &handle->fo);
 +  }
 +
 +  handle->fd = PORT_DELETED;
 +  uv__free(handle->path);
 +  handle->path = NULL;
 +  handle->fo.fo_name = NULL;
 +  uv__handle_stop(handle);
 +
 +  return 0;
 +}
 +
 +void uv__fs_event_close(uv_fs_event_t* handle) {
 +  uv_fs_event_stop(handle);
 +}
 +
 +#else /* !defined(PORT_SOURCE_FILE) */
 +
 +int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
 +  return -ENOSYS;
 +}
 +
 +
 +int uv_fs_event_start(uv_fs_event_t* handle,
 +                      uv_fs_event_cb cb,
 +                      const char* filename,
 +                      unsigned int flags) {
 +  return -ENOSYS;
 +}
 +
 +
 +int uv_fs_event_stop(uv_fs_event_t* handle) {
 +  return -ENOSYS;
 +}
 +
 +
 +void uv__fs_event_close(uv_fs_event_t* handle) {
 +  UNREACHABLE();
 +}
 +
 +#endif /* defined(PORT_SOURCE_FILE) */
 +
 +
- char** uv_setup_args(int argc, char** argv) {
-   return argv;
- }
- 
- 
- int uv_set_process_title(const char* title) {
-   return 0;
- }
- 
- 
- int uv_get_process_title(char* buffer, size_t size) {
-   if (buffer == NULL || size == 0)
-     return -EINVAL;
- 
-   buffer[0] = '\0';
-   return 0;
- }
- 
- 
 +int uv_resident_set_memory(size_t* rss) {
 +  psinfo_t psinfo;
 +  int err;
 +  int fd;
 +
 +  fd = open("/proc/self/psinfo", O_RDONLY);
 +  if (fd == -1)
 +    return -errno;
 +
 +  /* FIXME(bnoordhuis) Handle EINTR. */
 +  err = -EINVAL;
 +  if (read(fd, &psinfo, sizeof(psinfo)) == sizeof(psinfo)) {
 +    *rss = (size_t)psinfo.pr_rssize * 1024;
 +    err = 0;
 +  }
 +  uv__close(fd);
 +
 +  return err;
 +}
 +
 +
 +int uv_uptime(double* uptime) {
 +  kstat_ctl_t   *kc;
 +  kstat_t       *ksp;
 +  kstat_named_t *knp;
 +
 +  long hz = sysconf(_SC_CLK_TCK);
 +
 +  kc = kstat_open();
 +  if (kc == NULL)
 +    return -EPERM;
 +
 +  ksp = kstat_lookup(kc, (char*) "unix", 0, (char*) "system_misc");
 +  if (kstat_read(kc, ksp, NULL) == -1) {
 +    *uptime = -1;
 +  } else {
 +    knp = (kstat_named_t*)  kstat_data_lookup(ksp, (char*) "clk_intr");
 +    *uptime = knp->value.ul / hz;
 +  }
 +  kstat_close(kc);
 +
 +  return 0;
 +}
 +
 +
 +int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
 +  int           lookup_instance;
 +  kstat_ctl_t   *kc;
 +  kstat_t       *ksp;
 +  kstat_named_t *knp;
 +  uv_cpu_info_t* cpu_info;
 +
 +  kc = kstat_open();
 +  if (kc == NULL)
 +    return -EPERM;
 +
 +  /* Get count of cpus */
 +  lookup_instance = 0;
 +  while ((ksp = kstat_lookup(kc, (char*) "cpu_info", lookup_instance, NULL))) {
 +    lookup_instance++;
 +  }
 +
 +  *cpu_infos = uv__malloc(lookup_instance * sizeof(**cpu_infos));
 +  if (!(*cpu_infos)) {
 +    kstat_close(kc);
 +    return -ENOMEM;
 +  }
 +
 +  *count = lookup_instance;
 +
 +  cpu_info = *cpu_infos;
 +  lookup_instance = 0;
 +  while ((ksp = kstat_lookup(kc, (char*) "cpu_info", lookup_instance, NULL))) {
 +    if (kstat_read(kc, ksp, NULL) == -1) {
 +      cpu_info->speed = 0;
 +      cpu_info->model = NULL;
 +    } else {
 +      knp = kstat_data_lookup(ksp, (char*) "clock_MHz");
 +      assert(knp->data_type == KSTAT_DATA_INT32 ||
 +             knp->data_type == KSTAT_DATA_INT64);
 +      cpu_info->speed = (knp->data_type == KSTAT_DATA_INT32) ? knp->value.i32
 +                                                             : knp->value.i64;
 +
 +      knp = kstat_data_lookup(ksp, (char*) "brand");
 +      assert(knp->data_type == KSTAT_DATA_STRING);
 +      cpu_info->model = uv__strdup(KSTAT_NAMED_STR_PTR(knp));
 +    }
 +
 +    lookup_instance++;
 +    cpu_info++;
 +  }
 +
 +  cpu_info = *cpu_infos;
 +  lookup_instance = 0;
 +  for (;;) {
 +    ksp = kstat_lookup(kc, (char*) "cpu", lookup_instance, (char*) "sys");
 +
 +    if (ksp == NULL)
 +      break;
 +
 +    if (kstat_read(kc, ksp, NULL) == -1) {
 +      cpu_info->cpu_times.user = 0;
 +      cpu_info->cpu_times.nice = 0;
 +      cpu_info->cpu_times.sys = 0;
 +      cpu_info->cpu_times.idle = 0;
 +      cpu_info->cpu_times.irq = 0;
 +    } else {
 +      knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_user");
 +      assert(knp->data_type == KSTAT_DATA_UINT64);
 +      cpu_info->cpu_times.user = knp->value.ui64;
 +
 +      knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_kernel");
 +      assert(knp->data_type == KSTAT_DATA_UINT64);
 +      cpu_info->cpu_times.sys = knp->value.ui64;
 +
 +      knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_idle");
 +      assert(knp->data_type == KSTAT_DATA_UINT64);
 +      cpu_info->cpu_times.idle = knp->value.ui64;
 +
 +      knp = kstat_data_lookup(ksp, (char*) "intr");
 +      assert(knp->data_type == KSTAT_DATA_UINT64);
 +      cpu_info->cpu_times.irq = knp->value.ui64;
 +      cpu_info->cpu_times.nice = 0;
 +    }
 +
 +    lookup_instance++;
 +    cpu_info++;
 +  }
 +
 +  kstat_close(kc);
 +
 +  return 0;
 +}
 +
 +
 +void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
 +  int i;
 +
 +  for (i = 0; i < count; i++) {
 +    uv__free(cpu_infos[i].model);
 +  }
 +
 +  uv__free(cpu_infos);
 +}
 +
 +#ifdef SUNOS_NO_IFADDRS
 +int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
 +  return -ENOSYS;
 +}
 +#else  /* SUNOS_NO_IFADDRS */
 +/*
 + * Inspired By:
 + * https://blogs.oracle.com/paulie/entry/retrieving_mac_address_in_solaris
 + * http://www.pauliesworld.org/project/getmac.c
 + */
 +static int uv__set_phys_addr(uv_interface_address_t* address,
 +                             struct ifaddrs* ent) {
 +
 +  struct sockaddr_dl* sa_addr;
 +  int sockfd;
 +  int i;
 +  struct arpreq arpreq;
 +
 +  /* This appears to only work as root */
 +  sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
 +  memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
 +  for (i = 0; i < sizeof(address->phys_addr); i++) {
 +    if (address->phys_addr[i] != 0)
 +      return 0;
 +  }
 +  memset(&arpreq, 0, sizeof(arpreq));
 +  if (address->address.address4.sin_family == AF_INET) {
 +    struct sockaddr_in* sin = ((struct sockaddr_in*)&arpreq.arp_pa);
 +    sin->sin_addr.s_addr = address->address.address4.sin_addr.s_addr;
 +  } else if (address->address.address4.sin_family == AF_INET6) {
 +    struct sockaddr_in6* sin = ((struct sockaddr_in6*)&arpreq.arp_pa);
 +    memcpy(sin->sin6_addr.s6_addr,
 +           address->address.address6.sin6_addr.s6_addr,
 +           sizeof(address->address.address6.sin6_addr.s6_addr));
 +  } else {
 +    return 0;
 +  }
 +
 +  sockfd = socket(AF_INET, SOCK_DGRAM, 0);
 +  if (sockfd < 0)
 +    return -errno;
 +
 +  if (ioctl(sockfd, SIOCGARP, (char*)&arpreq) == -1) {
 +    uv__close(sockfd);
 +    return -errno;
 +  }
 +  memcpy(address->phys_addr, arpreq.arp_ha.sa_data, sizeof(address->phys_addr));
 +  uv__close(sockfd);
 +  return 0;
 +}
 +
 +
 +static int uv__ifaddr_exclude(struct ifaddrs *ent) {
 +  if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
 +    return 1;
 +  if (ent->ifa_addr == NULL)
 +    return 1;
 +  if (ent->ifa_addr->sa_family == PF_PACKET)
 +    return 1;
 +  return 0;
 +}
 +
 +int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
 +  uv_interface_address_t* address;
 +  struct ifaddrs* addrs;
 +  struct ifaddrs* ent;
 +  int i;
 +
 +  if (getifaddrs(&addrs))
 +    return -errno;
 +
 +  *count = 0;
 +
 +  /* Count the number of interfaces */
 +  for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
 +    if (uv__ifaddr_exclude(ent))
 +      continue;
 +    (*count)++;
 +  }
 +
 +  *addresses = uv__malloc(*count * sizeof(**addresses));
 +  if (!(*addresses)) {
 +    freeifaddrs(addrs);
 +    return -ENOMEM;
 +  }
 +
 +  address = *addresses;
 +
 +  for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
 +    if (uv__ifaddr_exclude(ent))
 +      continue;
 +
 +    address->name = uv__strdup(ent->ifa_name);
 +
 +    if (ent->ifa_addr->sa_family == AF_INET6) {
 +      address->address.address6 = *((struct sockaddr_in6*) ent->ifa_addr);
 +    } else {
 +      address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr);
 +    }
 +
 +    if (ent->ifa_netmask->sa_family == AF_INET6) {
 +      address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask);
 +    } else {
 +      address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask);
 +    }
 +
 +    address->is_internal = !!((ent->ifa_flags & IFF_PRIVATE) ||
 +                           (ent->ifa_flags & IFF_LOOPBACK));
 +
 +    uv__set_phys_addr(address, ent);
 +    address++;
 +  }
 +
 +  freeifaddrs(addrs);
 +
 +  return 0;
 +}
 +#endif  /* SUNOS_NO_IFADDRS */
 +
 +void uv_free_interface_addresses(uv_interface_address_t* addresses,
 +  int count) {
 +  int i;
 +
 +  for (i = 0; i < count; i++) {
 +    uv__free(addresses[i].name);
 +  }
 +
 +  uv__free(addresses);
 +}
diff --cc Utilities/cmlibuv/src/unix/sysinfo-loadavg.c
index 0000000,ebad0e8..ebad0e8
mode 000000,100644..100644
--- a/Utilities/cmlibuv/src/unix/sysinfo-loadavg.c
+++ b/Utilities/cmlibuv/src/unix/sysinfo-loadavg.c
diff --cc Utilities/cmlibuv/src/unix/sysinfo-memory.c
index 0000000,23b4fc6..23b4fc6
mode 000000,100644..100644
--- a/Utilities/cmlibuv/src/unix/sysinfo-memory.c
+++ b/Utilities/cmlibuv/src/unix/sysinfo-memory.c

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=362435f02a52008a90a1c19862f09b01f1b5bd7f
commit 362435f02a52008a90a1c19862f09b01f1b5bd7f
Author:     libuv upstream <libuv at googlegroups.com>
AuthorDate: Thu May 25 17:51:45 2017 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri May 26 13:33:40 2017 -0400

    libuv 2017-05-25 (dc596109)
    
    Code extracted from:
    
        https://github.com/libuv/libuv.git
    
    at commit dc596109d5a22db1dbf57098630eebd30fce8068 (v1.x).

diff --git a/include/uv-posix.h b/include/uv-posix.h
new file mode 100644
index 0000000..9a96634
--- /dev/null
+++ b/include/uv-posix.h
@@ -0,0 +1,31 @@
+/* Copyright libuv project 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_POSIX_H
+#define UV_POSIX_H
+
+#define UV_PLATFORM_LOOP_FIELDS                                               \
+  struct pollfd* poll_fds;                                                    \
+  size_t poll_fds_used;                                                       \
+  size_t poll_fds_size;                                                       \
+  unsigned char poll_fds_iterating;                                           \
+
+#endif /* UV_POSIX_H */
diff --git a/include/uv-unix.h b/include/uv-unix.h
index 5440729..d775450 100644
--- a/include/uv-unix.h
+++ b/include/uv-unix.h
@@ -60,6 +60,8 @@
       defined(__OpenBSD__)         || \
       defined(__NetBSD__)
 # include "uv-bsd.h"
+#elif defined(__CYGWIN__) || defined(__MSYS__)
+# include "uv-posix.h"
 #endif
 
 #ifndef PTHREAD_BARRIER_SERIAL_THREAD
diff --git a/include/uv.h b/include/uv.h
index 14e09e4..40f5a4b 100644
--- a/include/uv.h
+++ b/include/uv.h
@@ -1078,6 +1078,8 @@ UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size);
 UV_EXTERN int uv_os_setenv(const char* name, const char* value);
 UV_EXTERN int uv_os_unsetenv(const char* name);
 
+UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size);
+
 
 typedef enum {
   UV_FS_UNKNOWN = -1,
diff --git a/src/unix/bsd-ifaddrs.c b/src/unix/bsd-ifaddrs.c
index 0b5653d..4147894 100644
--- a/src/unix/bsd-ifaddrs.c
+++ b/src/unix/bsd-ifaddrs.c
@@ -27,7 +27,9 @@
 
 #include <ifaddrs.h>
 #include <net/if.h>
+#if !defined(__CYGWIN__) && !defined(__MSYS__)
 #include <net/if_dl.h>
+#endif
 
 static int uv__ifaddr_exclude(struct ifaddrs *ent) {
   if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
@@ -107,9 +109,13 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
 
     for (i = 0; i < *count; i++) {
       if (strcmp(address->name, ent->ifa_name) == 0) {
+#if defined(__CYGWIN__) || defined(__MSYS__)
+        memset(address->phys_addr, 0, sizeof(address->phys_addr));
+#else
         struct sockaddr_dl* sa_addr;
         sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
         memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
+#endif
       }
       address++;
     }
diff --git a/src/unix/core.c b/src/unix/core.c
index 96495b8..30cdaef 100644
--- a/src/unix/core.c
+++ b/src/unix/core.c
@@ -28,6 +28,7 @@
 #include <errno.h>
 #include <assert.h>
 #include <unistd.h>
+#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -42,6 +43,7 @@
 #include <pwd.h>
 
 #ifdef __sun
+# include <netdb.h> /* MAXHOSTNAMELEN on Solaris */
 # include <sys/filio.h>
 # include <sys/types.h>
 # include <sys/wait.h>
@@ -80,6 +82,11 @@
 #include <sys/ioctl.h>
 #endif
 
+/* Fallback for the maximum hostname length */
+#ifndef MAXHOSTNAMELEN
+# define MAXHOSTNAMELEN 256
+#endif
+
 static int uv__run_pending(uv_loop_t* loop);
 
 /* Verify that uv_buf_t is ABI-compatible with struct iovec. */
@@ -538,6 +545,7 @@ int uv__nonblock_ioctl(int fd, int set) {
 }
 
 
+#if !defined(__CYGWIN__) && !defined(__MSYS__)
 int uv__cloexec_ioctl(int fd, int set) {
   int r;
 
@@ -550,6 +558,7 @@ int uv__cloexec_ioctl(int fd, int set) {
 
   return 0;
 }
+#endif
 
 
 int uv__nonblock_fcntl(int fd, int set) {
@@ -1285,3 +1294,33 @@ int uv_os_unsetenv(const char* name) {
 
   return 0;
 }
+
+
+int uv_os_gethostname(char* buffer, size_t* size) {
+  /*
+    On some platforms, if the input buffer is not large enough, gethostname()
+    succeeds, but truncates the result. libuv can detect this and return ENOBUFS
+    instead by creating a large enough buffer and comparing the hostname length
+    to the size input.
+  */
+  char buf[MAXHOSTNAMELEN + 1];
+  size_t len;
+
+  if (buffer == NULL || size == NULL || *size == 0)
+    return -EINVAL;
+
+  if (gethostname(buf, sizeof(buf)) != 0)
+    return -errno;
+
+  buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */
+  len = strlen(buf);
+
+  if (len >= *size) {
+    *size = len + 1;
+    return -ENOBUFS;
+  }
+
+  memcpy(buffer, buf, len + 1);
+  *size = len;
+  return 0;
+}
diff --git a/src/unix/cygwin.c b/src/unix/cygwin.c
new file mode 100644
index 0000000..5a887dd
--- /dev/null
+++ b/src/unix/cygwin.c
@@ -0,0 +1,54 @@
+/* Copyright libuv project 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.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <sys/sysinfo.h>
+#include <unistd.h>
+
+int uv_uptime(double* uptime) {
+  struct sysinfo info;
+
+  if (sysinfo(&info) < 0)
+    return -errno;
+
+  *uptime = info.uptime;
+  return 0;
+}
+
+int uv_resident_set_memory(size_t* rss) {
+  /* FIXME: read /proc/meminfo? */
+  *rss = 0;
+  return UV_ENOSYS;
+}
+
+int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
+  /* FIXME: read /proc/stat? */
+  *cpu_infos = NULL;
+  *count = 0;
+  return UV_ENOSYS;
+}
+
+void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
+  (void)cpu_infos;
+  (void)count;
+}
diff --git a/src/unix/fsevents.c b/src/unix/fsevents.c
index d331a13..643e233 100644
--- a/src/unix/fsevents.c
+++ b/src/unix/fsevents.c
@@ -378,9 +378,6 @@ static void uv__fsevents_destroy_stream(uv_loop_t* loop) {
   if (state->fsevent_stream == NULL)
     return;
 
-  /* Flush all accumulated events */
-  pFSEventStreamFlushSync(state->fsevent_stream);
-
   /* Stop emitting events */
   pFSEventStreamStop(state->fsevent_stream);
 
diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c
index 646be4f..2866e93 100644
--- a/src/unix/linux-core.c
+++ b/src/unix/linux-core.c
@@ -472,55 +472,6 @@ uint64_t uv__hrtime(uv_clocktype_t type) {
 }
 
 
-void uv_loadavg(double avg[3]) {
-  struct sysinfo info;
-
-  if (sysinfo(&info) < 0) return;
-
-  avg[0] = (double) info.loads[0] / 65536.0;
-  avg[1] = (double) info.loads[1] / 65536.0;
-  avg[2] = (double) info.loads[2] / 65536.0;
-}
-
-
-int uv_exepath(char* buffer, size_t* size) {
-  ssize_t n;
-
-  if (buffer == NULL || size == NULL || *size == 0)
-    return -EINVAL;
-
-  n = *size - 1;
-  if (n > 0)
-    n = readlink("/proc/self/exe", buffer, n);
-
-  if (n == -1)
-    return -errno;
-
-  buffer[n] = '\0';
-  *size = n;
-
-  return 0;
-}
-
-
-uint64_t uv_get_free_memory(void) {
-  struct sysinfo info;
-
-  if (sysinfo(&info) == 0)
-    return (uint64_t) info.freeram * info.mem_unit;
-  return 0;
-}
-
-
-uint64_t uv_get_total_memory(void) {
-  struct sysinfo info;
-
-  if (sysinfo(&info) == 0)
-    return (uint64_t) info.totalram * info.mem_unit;
-  return 0;
-}
-
-
 int uv_resident_set_memory(size_t* rss) {
   char buf[1024];
   const char* s;
diff --git a/src/unix/no-fsevents.c b/src/unix/no-fsevents.c
new file mode 100644
index 0000000..38fb6ab
--- /dev/null
+++ b/src/unix/no-fsevents.c
@@ -0,0 +1,42 @@
+/* Copyright libuv project 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.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <errno.h>
+
+int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
+  return -ENOSYS;
+}
+
+int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb,
+                      const char* filename, unsigned int flags) {
+  return -ENOSYS;
+}
+
+int uv_fs_event_stop(uv_fs_event_t* handle) {
+  return -ENOSYS;
+}
+
+void uv__fs_event_close(uv_fs_event_t* handle) {
+  UNREACHABLE();
+}
diff --git a/src/unix/no-proctitle.c b/src/unix/no-proctitle.c
new file mode 100644
index 0000000..a5c19fb
--- /dev/null
+++ b/src/unix/no-proctitle.c
@@ -0,0 +1,42 @@
+/* Copyright libuv project 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.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <errno.h>
+#include <stddef.h>
+
+char** uv_setup_args(int argc, char** argv) {
+  return argv;
+}
+
+int uv_set_process_title(const char* title) {
+  return 0;
+}
+
+int uv_get_process_title(char* buffer, size_t size) {
+  if (buffer == NULL || size == 0)
+    return -EINVAL;
+
+  buffer[0] = '\0';
+  return 0;
+}
diff --git a/src/unix/openbsd.c b/src/unix/openbsd.c
index 7e4b253..56f0af1 100644
--- a/src/unix/openbsd.c
+++ b/src/unix/openbsd.c
@@ -30,7 +30,6 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <kvm.h>
 #include <paths.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/unix/os390.c b/src/unix/os390.c
index e9ba90c..2ba5abf 100644
--- a/src/unix/os390.c
+++ b/src/unix/os390.c
@@ -663,28 +663,6 @@ int uv__io_check_fd(uv_loop_t* loop, int fd) {
   return 0;
 }
 
-
-void uv__fs_event_close(uv_fs_event_t* handle) {
-  UNREACHABLE();
-}
-
-
-int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
-  return -ENOSYS;
-}
-
-
-int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb,
-                      const char* filename, unsigned int flags) {
-  return -ENOSYS;
-}
-
-
-int uv_fs_event_stop(uv_fs_event_t* handle) {
-  return -ENOSYS;
-}
-
-
 void uv__io_poll(uv_loop_t* loop, int timeout) {
   static const int max_safe_timeout = 1789569;
   struct epoll_event events[1024];
diff --git a/src/unix/pipe.c b/src/unix/pipe.c
index dd3d034..4a81295 100644
--- a/src/unix/pipe.c
+++ b/src/unix/pipe.c
@@ -181,6 +181,14 @@ void uv_pipe_connect(uv_connect_t* req,
 
   if (r == -1 && errno != EINPROGRESS) {
     err = -errno;
+#if defined(__CYGWIN__) || defined(__MSYS__)
+    /* EBADF is supposed to mean that the socket fd is bad, but
+       Cygwin reports EBADF instead of ENOTSOCK when the file is
+       not a socket.  We do not expect to see a bad fd here
+       (e.g. due to new_sock), so translate the error.  */
+    if (err == -EBADF)
+      err = -ENOTSOCK;
+#endif
     goto out;
   }
 
diff --git a/src/unix/posix-poll.c b/src/unix/posix-poll.c
new file mode 100644
index 0000000..3fba96e
--- /dev/null
+++ b/src/unix/posix-poll.c
@@ -0,0 +1,324 @@
+/* Copyright libuv project 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.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+/* POSIX defines poll() as a portable way to wait on file descriptors.
+ * Here we maintain a dynamically sized array of file descriptors and
+ * events to pass as the first argument to poll().
+ */
+
+#include <assert.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <errno.h>
+#include <unistd.h>
+
+int uv__platform_loop_init(uv_loop_t* loop) {
+  loop->poll_fds = NULL;
+  loop->poll_fds_used = 0;
+  loop->poll_fds_size = 0;
+  loop->poll_fds_iterating = 0;
+  return 0;
+}
+
+void uv__platform_loop_delete(uv_loop_t* loop) {
+  uv__free(loop->poll_fds);
+  loop->poll_fds = NULL;
+}
+
+int uv__io_fork(uv_loop_t* loop) {
+  uv__platform_loop_delete(loop);
+  return uv__platform_loop_init(loop);
+}
+
+/* Allocate or dynamically resize our poll fds array.  */
+static void uv__pollfds_maybe_resize(uv_loop_t* loop) {
+  size_t i;
+  size_t n;
+  struct pollfd* p;
+
+  if (loop->poll_fds_used < loop->poll_fds_size)
+    return;
+
+  n = loop->poll_fds_size ? loop->poll_fds_size * 2 : 64;
+  p = uv__realloc(loop->poll_fds, n * sizeof(*loop->poll_fds));
+  if (p == NULL)
+    abort();
+
+  loop->poll_fds = p;
+  for (i = loop->poll_fds_size; i < n; i++) {
+    loop->poll_fds[i].fd = -1;
+    loop->poll_fds[i].events = 0;
+    loop->poll_fds[i].revents = 0;
+  }
+  loop->poll_fds_size = n;
+}
+
+/* Primitive swap operation on poll fds array elements.  */
+static void uv__pollfds_swap(uv_loop_t* loop, size_t l, size_t r) {
+  struct pollfd pfd;
+  pfd = loop->poll_fds[l];
+  loop->poll_fds[l] = loop->poll_fds[r];
+  loop->poll_fds[r] = pfd;
+}
+
+/* Add a watcher's fd to our poll fds array with its pending events.  */
+static void uv__pollfds_add(uv_loop_t* loop, uv__io_t* w) {
+  size_t i;
+  struct pollfd* pe;
+
+  /* If the fd is already in the set just update its events.  */
+  assert(!loop->poll_fds_iterating);
+  for (i = 0; i < loop->poll_fds_used; ++i) {
+    if (loop->poll_fds[i].fd == w->fd) {
+      loop->poll_fds[i].events = w->pevents;
+      return;
+    }
+  }
+
+  /* Otherwise, allocate a new slot in the set for the fd.  */
+  uv__pollfds_maybe_resize(loop);
+  pe = &loop->poll_fds[loop->poll_fds_used++];
+  pe->fd = w->fd;
+  pe->events = w->pevents;
+}
+
+/* Remove a watcher's fd from our poll fds array.  */
+static void uv__pollfds_del(uv_loop_t* loop, int fd) {
+  size_t i;
+  assert(!loop->poll_fds_iterating);
+  for (i = 0; i < loop->poll_fds_used; ++i) {
+    if (loop->poll_fds[i].fd == fd) {
+      /* swap to last position and remove */
+      --loop->poll_fds_used;
+      uv__pollfds_swap(loop, i, loop->poll_fds_used);
+      loop->poll_fds[loop->poll_fds_used].fd = -1;
+      loop->poll_fds[loop->poll_fds_used].events = 0;
+      loop->poll_fds[loop->poll_fds_used].revents = 0;
+      return;
+    }
+  }
+}
+
+
+void uv__io_poll(uv_loop_t* loop, int timeout) {
+  sigset_t* pset;
+  sigset_t set;
+  uint64_t time_base;
+  uint64_t time_diff;
+  QUEUE* q;
+  uv__io_t* w;
+  size_t i;
+  unsigned int nevents;
+  int nfds;
+  int have_signals;
+  struct pollfd* pe;
+  int fd;
+
+  if (loop->nfds == 0) {
+    assert(QUEUE_EMPTY(&loop->watcher_queue));
+    return;
+  }
+
+  /* Take queued watchers and add their fds to our poll fds array.  */
+  while (!QUEUE_EMPTY(&loop->watcher_queue)) {
+    q = QUEUE_HEAD(&loop->watcher_queue);
+    QUEUE_REMOVE(q);
+    QUEUE_INIT(q);
+
+    w = QUEUE_DATA(q, uv__io_t, watcher_queue);
+    assert(w->pevents != 0);
+    assert(w->fd >= 0);
+    assert(w->fd < (int) loop->nwatchers);
+
+    uv__pollfds_add(loop, w);
+
+    w->events = w->pevents;
+  }
+
+  /* Prepare a set of signals to block around poll(), if any.  */
+  pset = NULL;
+  if (loop->flags & UV_LOOP_BLOCK_SIGPROF) {
+    pset = &set;
+    sigemptyset(pset);
+    sigaddset(pset, SIGPROF);
+  }
+
+  assert(timeout >= -1);
+  time_base = loop->time;
+
+  /* Loop calls to poll() and processing of results.  If we get some
+   * results from poll() but they turn out not to be interesting to
+   * our caller then we need to loop around and poll() again.
+   */
+  for (;;) {
+    if (pset != NULL)
+      if (pthread_sigmask(SIG_BLOCK, pset, NULL))
+        abort();
+    nfds = poll(loop->poll_fds, (nfds_t)loop->poll_fds_used, timeout);
+    if (pset != NULL)
+      if (pthread_sigmask(SIG_UNBLOCK, pset, NULL))
+        abort();
+
+    /* Update loop->time unconditionally. It's tempting to skip the update when
+     * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the
+     * operating system didn't reschedule our process while in the syscall.
+     */
+    SAVE_ERRNO(uv__update_time(loop));
+
+    if (nfds == 0) {
+      assert(timeout != -1);
+      return;
+    }
+
+    if (nfds == -1) {
+      if (errno != EINTR)
+        abort();
+
+      if (timeout == -1)
+        continue;
+
+      if (timeout == 0)
+        return;
+
+      /* Interrupted by a signal. Update timeout and poll again. */
+      goto update_timeout;
+    }
+
+    /* Tell uv__platform_invalidate_fd not to manipulate our array
+     * while we are iterating over it.
+     */
+    loop->poll_fds_iterating = 1;
+
+    /* Initialize a count of events that we care about.  */
+    nevents = 0;
+    have_signals = 0;
+
+    /* Loop over the entire poll fds array looking for returned events.  */
+    for (i = 0; i < loop->poll_fds_used; i++) {
+      pe = loop->poll_fds + i;
+      fd = pe->fd;
+
+      /* Skip invalidated events, see uv__platform_invalidate_fd.  */
+      if (fd == -1)
+        continue;
+
+      assert(fd >= 0);
+      assert((unsigned) fd < loop->nwatchers);
+
+      w = loop->watchers[fd];
+
+      if (w == NULL) {
+        /* File descriptor that we've stopped watching, ignore.  */
+        uv__platform_invalidate_fd(loop, fd);
+        continue;
+      }
+
+      /* Filter out events that user has not requested us to watch
+       * (e.g. POLLNVAL).
+       */
+      pe->revents &= w->pevents | POLLERR | POLLHUP;
+
+      if (pe->revents != 0) {
+        /* Run signal watchers last.  */
+        if (w == &loop->signal_io_watcher) {
+          have_signals = 1;
+        } else {
+          w->cb(loop, w, pe->revents);
+        }
+
+        nevents++;
+      }
+    }
+
+    if (have_signals != 0)
+      loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN);
+
+    loop->poll_fds_iterating = 0;
+
+    /* Purge invalidated fds from our poll fds array.  */
+    uv__pollfds_del(loop, -1);
+
+    if (have_signals != 0)
+      return;  /* Event loop should cycle now so don't poll again. */
+
+    if (nevents != 0)
+      return;
+
+    if (timeout == 0)
+      return;
+
+    if (timeout == -1)
+      continue;
+
+update_timeout:
+    assert(timeout > 0);
+
+    time_diff = loop->time - time_base;
+    if (time_diff >= (uint64_t) timeout)
+      return;
+
+    timeout -= time_diff;
+  }
+}
+
+/* Remove the given fd from our poll fds array because no one
+ * is interested in its events anymore.
+ */
+void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
+  size_t i;
+
+  if (loop->poll_fds_iterating) {
+    /* uv__io_poll is currently iterating.  Just invalidate fd.  */
+    for (i = 0; i < loop->poll_fds_used; i++)
+      if (loop->poll_fds[i].fd == fd) {
+        loop->poll_fds[i].fd = -1;
+        loop->poll_fds[i].events = 0;
+        loop->poll_fds[i].revents = 0;
+      }
+  } else {
+    /* uv__io_poll is not iterating.  Delete fd from the set.  */
+    uv__pollfds_del(loop, fd);
+  }
+}
+
+/* Check whether the given fd is supported by poll().  */
+int uv__io_check_fd(uv_loop_t* loop, int fd) {
+  struct pollfd p[1];
+  int rv;
+
+  p[0].fd = fd;
+  p[0].events = POLLIN;
+
+  do
+    rv = poll(p, 1, 0);
+  while (rv == -1 && (errno == EINTR || errno == EAGAIN));
+
+  if (rv == -1)
+    return -errno;
+
+  if (p[0].revents & POLLNVAL)
+    return -EINVAL;
+
+  return 0;
+}
diff --git a/src/unix/procfs-exepath.c b/src/unix/procfs-exepath.c
new file mode 100644
index 0000000..5fdb611
--- /dev/null
+++ b/src/unix/procfs-exepath.c
@@ -0,0 +1,45 @@
+/* Copyright libuv project 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.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <stddef.h>
+#include <unistd.h>
+
+int uv_exepath(char* buffer, size_t* size) {
+  ssize_t n;
+
+  if (buffer == NULL || size == NULL || *size == 0)
+    return -EINVAL;
+
+  n = *size - 1;
+  if (n > 0)
+    n = readlink("/proc/self/exe", buffer, n);
+
+  if (n == -1)
+    return -errno;
+
+  buffer[n] = '\0';
+  *size = n;
+
+  return 0;
+}
diff --git a/src/unix/stream.c b/src/unix/stream.c
index dbd04f2..7b23d16 100644
--- a/src/unix/stream.c
+++ b/src/unix/stream.c
@@ -390,7 +390,7 @@ failed_malloc:
 
 
 int uv__stream_open(uv_stream_t* stream, int fd, int flags) {
-#if defined(__APPLE__) || defined(__MVS__)
+#if defined(__APPLE__)
   int enable;
 #endif
 
@@ -409,7 +409,7 @@ int uv__stream_open(uv_stream_t* stream, int fd, int flags) {
       return -errno;
   }
 
-#if defined(__APPLE__) || defined(__MVS__)
+#if defined(__APPLE__)
   enable = 1;
   if (setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &enable, sizeof(enable)) &&
       errno != ENOTSOCK &&
@@ -1173,6 +1173,11 @@ static void uv__read(uv_stream_t* stream) {
           uv__stream_osx_interrupt_select(stream);
         }
         stream->read_cb(stream, 0, &buf);
+#if defined(__CYGWIN__) || defined(__MSYS__)
+      } else if (errno == ECONNRESET && stream->type == UV_NAMED_PIPE) {
+        uv__stream_eof(stream, &buf);
+        return;
+#endif
       } else {
         /* Error. User should call uv_close(). */
         stream->read_cb(stream, -errno, &buf);
@@ -1405,6 +1410,12 @@ int uv_write2(uv_write_t* req,
      */
     if (uv__handle_fd((uv_handle_t*) send_handle) < 0)
       return -EBADF;
+
+#if defined(__CYGWIN__) || defined(__MSYS__)
+    /* Cygwin recvmsg always sets msg_controllen to zero, so we cannot send it.
+       See https://github.com/mirror/newlib-cygwin/blob/86fc4bf0/winsup/cygwin/fhandler_socket.cc#L1736-L1743 */
+    return -ENOSYS;
+#endif
   }
 
   /* It's legal for write_queue_size > 0 even when the write_queue is empty;
diff --git a/src/unix/sunos.c b/src/unix/sunos.c
index c34b870..2dc02ae 100644
--- a/src/unix/sunos.c
+++ b/src/unix/sunos.c
@@ -545,25 +545,6 @@ void uv__fs_event_close(uv_fs_event_t* handle) {
 #endif /* defined(PORT_SOURCE_FILE) */
 
 
-char** uv_setup_args(int argc, char** argv) {
-  return argv;
-}
-
-
-int uv_set_process_title(const char* title) {
-  return 0;
-}
-
-
-int uv_get_process_title(char* buffer, size_t size) {
-  if (buffer == NULL || size == 0)
-    return -EINVAL;
-
-  buffer[0] = '\0';
-  return 0;
-}
-
-
 int uv_resident_set_memory(size_t* rss) {
   psinfo_t psinfo;
   int err;
diff --git a/src/unix/sysinfo-loadavg.c b/src/unix/sysinfo-loadavg.c
new file mode 100644
index 0000000..ebad0e8
--- /dev/null
+++ b/src/unix/sysinfo-loadavg.c
@@ -0,0 +1,36 @@
+/* Copyright libuv project 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.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <stdint.h>
+#include <sys/sysinfo.h>
+
+void uv_loadavg(double avg[3]) {
+  struct sysinfo info;
+
+  if (sysinfo(&info) < 0) return;
+
+  avg[0] = (double) info.loads[0] / 65536.0;
+  avg[1] = (double) info.loads[1] / 65536.0;
+  avg[2] = (double) info.loads[2] / 65536.0;
+}
diff --git a/src/unix/sysinfo-memory.c b/src/unix/sysinfo-memory.c
new file mode 100644
index 0000000..23b4fc6
--- /dev/null
+++ b/src/unix/sysinfo-memory.c
@@ -0,0 +1,42 @@
+/* Copyright libuv project 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.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <stdint.h>
+#include <sys/sysinfo.h>
+
+uint64_t uv_get_free_memory(void) {
+  struct sysinfo info;
+
+  if (sysinfo(&info) == 0)
+    return (uint64_t) info.freeram * info.mem_unit;
+  return 0;
+}
+
+uint64_t uv_get_total_memory(void) {
+  struct sysinfo info;
+
+  if (sysinfo(&info) == 0)
+    return (uint64_t) info.totalram * info.mem_unit;
+  return 0;
+}
diff --git a/src/win/util.c b/src/win/util.c
index 1d64d4c..d2e7f77 100644
--- a/src/win/util.c
+++ b/src/win/util.c
@@ -59,6 +59,14 @@
 # define UNLEN 256
 #endif
 
+/*
+  Max hostname length. The Windows gethostname() documentation states that 256
+  bytes will always be large enough to hold the null-terminated hostname.
+*/
+#ifndef MAXHOSTNAMELEN
+# define MAXHOSTNAMELEN 256
+#endif
+
 /* Maximum environment variable size, including the terminating null */
 #define MAX_ENV_VAR_LENGTH 32767
 
@@ -1540,3 +1548,29 @@ int uv_os_unsetenv(const char* name) {
 
   return 0;
 }
+
+
+int uv_os_gethostname(char* buffer, size_t* size) {
+  char buf[MAXHOSTNAMELEN + 1];
+  size_t len;
+
+  if (buffer == NULL || size == NULL || *size == 0)
+    return UV_EINVAL;
+
+  uv__once_init(); /* Initialize winsock */
+
+  if (gethostname(buf, sizeof(buf)) != 0)
+    return uv_translate_sys_error(WSAGetLastError());
+
+  buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */
+  len = strlen(buf);
+
+  if (len >= *size) {
+    *size = len + 1;
+    return UV_ENOBUFS;
+  }
+
+  memcpy(buffer, buf, len + 1);
+  *size = len;
+  return 0;
+}

-----------------------------------------------------------------------

Summary of changes:
 Utilities/cmlibuv/CMakeLists.txt                   |    4 +
 .../cmlibuv/include/{uv-os390.h => uv-posix.h}     |   13 +-
 Utilities/cmlibuv/include/uv-unix.h                |    2 +
 Utilities/cmlibuv/include/uv.h                     |    2 +
 Utilities/cmlibuv/src/unix/bsd-ifaddrs.c           |    6 +
 Utilities/cmlibuv/src/unix/core.c                  |   39 +++
 .../cmlibuv/src/unix/{posix-hrtime.c => cygwin.c}  |   35 ++-
 Utilities/cmlibuv/src/unix/fsevents.c              |    3 -
 Utilities/cmlibuv/src/unix/linux-core.c            |   49 ---
 .../src/unix/{posix-hrtime.c => no-fsevents.c}     |   23 +-
 .../src/unix/{posix-hrtime.c => no-proctitle.c}    |   23 +-
 Utilities/cmlibuv/src/unix/openbsd.c               |    1 -
 Utilities/cmlibuv/src/unix/os390.c                 |   22 --
 Utilities/cmlibuv/src/unix/pipe.c                  |    8 +
 Utilities/cmlibuv/src/unix/posix-poll.c            |  324 ++++++++++++++++++++
 .../src/unix/{posix-hrtime.c => procfs-exepath.c}  |   26 +-
 Utilities/cmlibuv/src/unix/stream.c                |   15 +-
 Utilities/cmlibuv/src/unix/sunos.c                 |   19 --
 .../src/unix/{posix-hrtime.c => sysinfo-loadavg.c} |   15 +-
 .../src/unix/{posix-hrtime.c => sysinfo-memory.c}  |   21 +-
 Utilities/cmlibuv/src/win/util.c                   |   34 ++
 21 files changed, 536 insertions(+), 148 deletions(-)
 copy Utilities/cmlibuv/include/{uv-os390.h => uv-posix.h} (77%)
 copy Utilities/cmlibuv/src/unix/{posix-hrtime.c => cygwin.c} (68%)
 copy Utilities/cmlibuv/src/unix/{posix-hrtime.c => no-fsevents.c} (75%)
 copy Utilities/cmlibuv/src/unix/{posix-hrtime.c => no-proctitle.c} (79%)
 create mode 100644 Utilities/cmlibuv/src/unix/posix-poll.c
 copy Utilities/cmlibuv/src/unix/{posix-hrtime.c => procfs-exepath.c} (78%)
 copy Utilities/cmlibuv/src/unix/{posix-hrtime.c => sysinfo-loadavg.c} (82%)
 copy Utilities/cmlibuv/src/unix/{posix-hrtime.c => sysinfo-memory.c} (78%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list