view release on metacpan or search on metacpan
libuv/test/test-ipc.c
libuv/test/test-list.h
libuv/test/test-loop-alive.c
libuv/test/test-loop-close.c
libuv/test/test-loop-configure.c
libuv/test/test-loop-handles.c
libuv/test/test-loop-stop.c
libuv/test/test-loop-time.c
libuv/test/test-multiple-listen.c
libuv/test/test-mutexes.c
libuv/test/test-osx-select.c
libuv/test/test-pass-always.c
libuv/test/test-ping-pong.c
libuv/test/test-pipe-bind-error.c
libuv/test/test-pipe-close-stdout-read-stdin.c
libuv/test/test-pipe-connect-error.c
libuv/test/test-pipe-connect-multiple.c
libuv/test/test-pipe-connect-prepare.c
libuv/test/test-pipe-getsockname.c
libuv/test/test-pipe-pending-instances.c
libuv/test/test-pipe-sendmsg.c
libuv/CMakeLists.txt view on Meta::CPAN
test/test-ipc-send-recv.c
test/test-ipc.c
test/test-loop-alive.c
test/test-loop-close.c
test/test-loop-configure.c
test/test-loop-handles.c
test/test-loop-stop.c
test/test-loop-time.c
test/test-multiple-listen.c
test/test-mutexes.c
test/test-osx-select.c
test/test-pass-always.c
test/test-ping-pong.c
test/test-pipe-bind-error.c
test/test-pipe-close-stdout-read-stdin.c
test/test-pipe-connect-error.c
test/test-pipe-connect-multiple.c
test/test-pipe-connect-prepare.c
test/test-pipe-getsockname.c
test/test-pipe-pending-instances.c
test/test-pipe-sendmsg.c
libuv/CONTRIBUTING.md view on Meta::CPAN
Check README.md file to find out how to run the test suite and make sure that
there are no test regressions.
### PUSH
```
$ git push origin my-feature-branch
```
Go to https://github.com/username/libuv and select your feature branch. Click
the 'Pull Request' button and fill out the form.
Pull requests are usually reviewed within a few days. If there are comments
to address, apply your changes in a separate commit and push that to your
feature branch. Post a comment in the pull request afterwards; GitHub does
not send out notifications when you add commits.
[issue tracker]: https://github.com/libuv/libuv/issues
[libuv mailing list]: http://groups.google.com/group/libuv
libuv/ChangeLog view on Meta::CPAN
2016.10.25, Version 1.10.0 (Stable), c8a373c729b4c9392e0e14fc53cd6b67b3051ab9
Changes since version 1.9.1:
* Now working on version 1.9.2 (Saúl Ibarra Corretgé)
* doc: add cjihrig GPG ID (cjihrig)
* win,build: fix compilation on old Windows / MSVC (Saúl Ibarra Corretgé)
* darwin: fix setting fd to non-blocking in select(() trick (Saúl Ibarra
Corretgé)
* unix: allow nesting of kqueue fds in uv_poll_start (Ben Noordhuis)
* doc: fix generation the first time livehtml runs (Saúl Ibarra Corretgé)
* test: fix test_close_accept flakiness on Centos5 (Santiago Gimeno)
* license: libuv is no longer a Node project (Saúl Ibarra Corretgé)
libuv/ChangeLog view on Meta::CPAN
* win,fs: Fixes align(8) directive on mingw (Stefano Cristiano)
* unix, win: prevent replacing fd in uv_{udp,tcp,pipe}_t (Saúl Ibarra Corretgé)
* win: move logic to set socket non-inheritable to uv_tcp_set_socket (Saúl
Ibarra Corretgé)
* unix, win: add ability to create tcp/udp sockets early (Saúl Ibarra Corretgé)
* test: retry select() on EINTR, honor milliseconds (Ben Noordhuis)
* unix: consolidate tcp and udp bind error (Saúl Ibarra Corretgé)
* test: conditionally skip udp_ipv6_multicast_join6 (heshamsafi)
* core: add UV_VERSION_HEX macro (Saúl Ibarra Corretgé)
* doc: add section with version-checking macros and functions (Saúl Ibarra
Corretgé)
libuv/ChangeLog view on Meta::CPAN
* windows: MSVC 2015 has snprintf() (Rui Abreu Ferreira)
* windows: Add VS2015 support to vcbuild.bat (Jason Williams)
* doc: fix typo in tcp.rst (Igor Soarez)
* linux: work around epoll bug in kernels < 2.6.37 (Ben Noordhuis)
* unix,win: add uv_os_homedir() (cjihrig)
* stream: fix `select()` race condition (Fedor Indutny)
* unix: prevent infinite loop in uv__run_pending (Saúl Ibarra Corretgé)
* unix: make sure UDP send callbacks are asynchronous (Saúl Ibarra Corretgé)
* test: fix `platform_output` netmask printing. (Andrew Paprocki)
* aix: add ahafs autoconf detection and README notes (Andrew Paprocki)
* core: add ability to customize memory allocator (Saúl Ibarra Corretgé)
libuv/ChangeLog view on Meta::CPAN
* doc: link system and library calls to man pages (Saúl Ibarra Corretgé)
* doc: document uv_getnameinfo_t.{host|service} (Saúl Ibarra Corretgé)
* build: update the location of gyp (Stephen von Takach)
* win: name all anonymous structs and unions (TomCrypto)
* linux: work around epoll bug in kernels 3.10-3.19 (Ben Noordhuis)
* darwin: fix size calculation in select() fallback (Ole André Vadla Ravnås)
* solaris: fix setsockopt for multicast options (Julien Gilli)
* test: fix race condition in multithreaded test (Ben Noordhuis)
* doc: fix long lines in tty.rst (Ben Noordhuis)
* test: use UV_TTY_MODE_* values in tty test (Ben Noordhuis)
* unix: don't clobber errno in uv_tty_reset_mode() (Ben Noordhuis)
libuv/ChangeLog view on Meta::CPAN
* test: back-port uv_loop_configure() test (Ben Noordhuis)
2015.01.15, Version 1.2.1 (Stable), 4ca78e989062a1099dc4b9ad182a98e8374134b1
Changes since version 1.2.0:
* unix: remove unused dtrace file (Saúl Ibarra Corretgé)
* test: skip TTY select test if /dev/tty can't be opened (Saúl Ibarra Corretgé)
* doc: clarify the behavior of uv_tty_init (Saúl Ibarra Corretgé)
* doc: clarify how uv_async_send behaves (Saúl Ibarra Corretgé)
* build: make dist now generates a full tarball (Johan Bergström)
* freebsd: make uv_exepath more resilient (Saúl Ibarra Corretgé)
* unix: make setting the tty mode to the same value a no-op (Saúl Ibarra
libuv/ChangeLog view on Meta::CPAN
* doc: indicate what version uv_loop_configure was added on (Saúl Ibarra
Corretgé)
* doc: fix sphinx warning (Saúl Ibarra Corretgé)
* test: skip spawn_setuid_setgid if we get EACCES (Saúl Ibarra Corretgé)
* test: silence some Clang warnings (Saúl Ibarra Corretgé)
* test: relax osx_select_many_fds (Saúl Ibarra Corretgé)
* test: fix compilation warnings when building with Clang (Saúl Ibarra
Corretgé)
* win: fix autotools build of tests (Luis Lavena)
* gitignore: ignore Visual Studio files (Marc Schlaich)
* win: set fallback message if FormatMessage fails (Marc Schlaich)
libuv/ChangeLog view on Meta::CPAN
* Revert "unix: use cfmakeraw() for setting raw TTY mode" (Ben Noordhuis)
* doc: document how to get result of uv_fs_mkdtemp (Tim Caswell)
* unix: add flag for blocking SIGPROF during poll (Ben Noordhuis)
* unix, windows: add uv_loop_configure() function (Ben Noordhuis)
* win: keep a reference to AFD_POLL_INFO in cancel poll (Marc Schlaich)
* test: raise fd limit for OSX select test (Saúl Ibarra Corretgé)
* unix: remove overzealous assert in uv_read_stop (Saúl Ibarra Corretgé)
* unix: reset the reading flag when a stream gets EOF (Saúl Ibarra Corretgé)
* unix: stop reading if an error is produced (Saúl Ibarra Corretgé)
* cleanup: remove all dead assignments (Maciej MaÅecki)
* linux: return early if we have no interfaces (Maciej MaÅecki)
libuv/ChangeLog view on Meta::CPAN
* unix, windows: add uv_thread_equal (Tomasz KoÅodziejski)
* windows: fix fs_write with nbufs > 1 and offset (Unknown W. Brackets)
2014.10.21, Version 0.10.29 (Stable), 2d728542d3790183417f8f122a110693cd85db14
Changes since version 0.10.28:
* darwin: allocate enough space for select() hack (Fedor Indutny)
* linux: try epoll_pwait if epoll_wait is missing (Michael Hudson-Doyle)
* windows: map ERROR_INVALID_DRIVE to UV_ENOENT (Saúl Ibarra Corretgé)
2014.09.18, Version 1.0.0-rc1 (Unstable), 0c28bbf7b42882853d1799ab96ff68b07f7f8d49
Changes since version 0.11.29:
libuv/ChangeLog view on Meta::CPAN
* version: add ability to specify a version suffix (Saúl Ibarra Corretgé)
* doc: add API documentation (Saúl Ibarra Corretgé)
* test: don't close connection on write error (Trevor Norris)
* windows: further simplify the code for timers (Saúl Ibarra Corretgé)
* gyp: remove UNLIMITED_SELECT from dependent define (Fedor Indutny)
* darwin: allocate enough space for select() hack (Fedor Indutny)
* unix, windows: don't allow a NULL callback on timers (Saúl Ibarra Corretgé)
* windows: simplify code in uv_timer_again (Saúl Ibarra Corretgé)
* test: use less requests on tcp-write-queue-order (Saúl Ibarra Corretgé)
* unix: stop child process watcher after last one exits (Saúl Ibarra Corretgé)
* unix: simplify how process handle queue is managed (Saúl Ibarra Corretgé)
libuv/ChangeLog view on Meta::CPAN
* stream: allow multiple buffers for uv_try_write (Fedor Indutny)
* unix: fix a possible memory leak in uv_fs_readdir (Alex Crichton)
* unix, windows: add uv_loop_alive() function (Sam Roberts)
* windows: avoid assertion failure when pipe server is closed (Bert Belder)
* osx: Fix a possible segfault in uv__io_poll (Alex Crichton)
* stream: fix uv__stream_osx_select (Fedor Indutny)
2013.12.14, Version 0.11.16 (Unstable), ae0ed8c49d0d313c935c22077511148b6e8408a4
Changes since version 0.11.15:
* fsevents: remove kFSEventStreamCreateFlagNoDefer polyfill (ci-innoq)
* libuv: add more getaddrinfo errors (Steven Kabbes)
libuv/ChangeLog view on Meta::CPAN
* include: document uv_update_time() and uv_now() (Ben Noordhuis)
* linux: fix cpu model parsing on newer arm kernels (Ben Noordhuis)
* linux: fix a memory leak in uv_cpu_info() error path (Ben Noordhuis)
* linux: don't ignore out-of-memory errors in uv_cpu_info() (Ben Noordhuis)
* unix, windows: move uv_now() to uv-common.c (Ben Noordhuis)
* test: fix a compilation problem in test-osx-select.c that was caused by the
use of c-style comments (Bert Belder)
* darwin: use uv_fs_sendfile() use the sendfile api correctly (Wynn Wilkes)
2013.05.30, Version 0.11.4 (Unstable), e43e5b3d954a0989db5588aa110e1fe4fe6e0219
Changes since version 0.11.3:
* windows: make uv_spawn not fail when the libuv embedding application is run
under external job control (Bert Belder)
* darwin: assume CFRunLoopStop() isn't thread-safe, fixing a race condition
when stopping the 'stdin select hack' thread (Fedor Indutny)
* win: fix UV_EALREADY not being reported correctly to the libuv user in some
cases (Bert Belder)
* darwin: make the uv__cf_loop_runner and uv__cf_loop_cb functions static (Ben
Noordhuis)
* darwin: task_info() cannot fail (Ben Noordhuis)
* unix: add error mapping for ENETDOWN (Ben Noordhuis)
libuv/ChangeLog view on Meta::CPAN
* include: document uv_update_time() and uv_now() (Ben Noordhuis)
* linux: fix cpu model parsing on newer arm kernels (Ben Noordhuis)
* linux: fix a memory leak in uv_cpu_info() error path (Ben Noordhuis)
* linux: don't ignore out-of-memory errors in uv_cpu_info() (Ben Noordhuis)
* unix, windows: move uv_now() to uv-common.c (Ben Noordhuis)
* test: fix a compilation problem in test-osx-select.c that was caused by the
use of c-style comments (Bert Belder)
* darwin: use uv_fs_sendfile() use the sendfile api correctly (Wynn Wilkes)
* windows: call idle handles on every loop iteration, something the unix
implementation already did (Bert Belder)
* test: update the idle-starvation test to verify that idle handles are called
in every loop iteration (Bert Belder)
libuv/ChangeLog view on Meta::CPAN
Changes since version 0.10.6:
* windows: kill child processes when the parent dies (Bert Belder)
2013.05.15, Version 0.10.6 (Stable), 11e6613e6260d95c8cf11bf89a2759c24649319a
Changes since version 0.10.5:
* stream: fix osx select hack (Fedor Indutny)
* stream: fix small nit in select hack, add test (Fedor Indutny)
* build: link with libkvm on openbsd (Ben Noordhuis)
* stream: use harder sync restrictions for osx-hack (Fedor Indutny)
* unix: fix EMFILE error handling (Ben Noordhuis)
* darwin: fix unnecessary include headers (Daisuke Murase)
* darwin: rename darwin-getproctitle.m (Ben Noordhuis)
libuv/ChangeLog view on Meta::CPAN
Changes since version 0.10.2:
* include: remove extraneous const from uv_version() (Ben Noordhuis)
* doc: update README, replace `OS` by `PLATFORM` (Ben Noordhuis)
* build: simplify .buildstamp rule (Ben Noordhuis)
* build: disable -Wstrict-aliasing on darwin (Ben Noordhuis)
* darwin: don't select(&exceptfds) in fallback path (Ben Noordhuis)
* unix: don't clear flags after closing UDP handle (Saúl Ibarra Corretgé)
2013.03.25, Version 0.10.2 (Stable), 0f36a00568f3e7608f97f6c6cdb081f4800a50c9
This is the first officially versioned release of libuv. Starting now
libuv will make releases independently of Node.js.
Changes since Node.js v0.10.0:
* test: add tap output for windows (Timothy J. Fontaine)
* unix: fix uv_tcp_simultaneous_accepts() logic (Ben Noordhuis)
* include: bump UV_VERSION_MINOR (Ben Noordhuis)
* unix: improve uv_guess_handle() implementation (Ben Noordhuis)
* stream: run try_select only for pipes and ttys (Fedor Indutny)
Changes since Node.js v0.10.1:
* build: rename OS to PLATFORM (Ben Noordhuis)
* unix: make uv_timer_init() initialize repeat (Brian Mazza)
* unix: make timers handle large timeouts (Ben Noordhuis)
* build: add OBJC makefile var (Ben Noordhuis)
libuv/Makefile.am view on Meta::CPAN
test/test-ipc.c \
test/test-list.h \
test/test-loop-handles.c \
test/test-loop-alive.c \
test/test-loop-close.c \
test/test-loop-stop.c \
test/test-loop-time.c \
test/test-loop-configure.c \
test/test-multiple-listen.c \
test/test-mutexes.c \
test/test-osx-select.c \
test/test-pass-always.c \
test/test-ping-pong.c \
test/test-pipe-bind-error.c \
test/test-pipe-connect-error.c \
test/test-pipe-connect-multiple.c \
test/test-pipe-connect-prepare.c \
test/test-pipe-getsockname.c \
test/test-pipe-pending-instances.c \
test/test-pipe-sendmsg.c \
test/test-pipe-server-close.c \
libuv/README.md view on Meta::CPAN
Prerequisites:
* [Python 2.6 or 2.7][] as it is required
by [GYP][].
If python is not in your path, set the environment variable `PYTHON` to its
location. For example: `set PYTHON=C:\Python27\python.exe`
* One of:
* [Visual C++ Build Tools][]
* [Visual Studio 2015 Update 3][], all editions
including the Community edition (remember to select
"Common Tools for Visual C++ 2015" feature during installation).
* [Visual Studio 2017][], any edition (including the Build Tools SKU).
**Required Components:** "MSbuild", "VC++ 2017 v141 toolset" and one of the
Windows SDKs (10 or 8.1).
* Basic Unix tools required for some tests,
[Git for Windows][] includes Git Bash
and tools which can be included in the global `PATH`.
To build, launch a git shell (e.g. Cmd or PowerShell), run `vcbuild.bat`
(to build with VS2017 you need to explicitly add a `vs2017` argument),
libuv/README.md view on Meta::CPAN
$ make -C out
```
or for x86_64
```bash
$ source ./android-configure-x86_64 NDK_PATH gyp [API_LEVEL]
$ make -C out
```
The default API level is 24, but a different one can be selected as follows:
```bash
$ source ./android-configure-arm ~/android-ndk-r15b gyp 21
$ make -C out
```
Note for UNIX users: compile your project with `-D_LARGEFILE_SOURCE` and
`-D_FILE_OFFSET_BITS=64`. GYP builds take care of that automatically.
### Using Ninja
libuv/include/uv/darwin.h view on Meta::CPAN
char* realpath; \
int realpath_len; \
int cf_flags; \
uv_async_t* cf_cb; \
void* cf_events[2]; \
void* cf_member[2]; \
int cf_error; \
uv_mutex_t cf_mutex; \
#define UV_STREAM_PRIVATE_PLATFORM_FIELDS \
void* select; \
#define UV_HAVE_KQUEUE 1
#endif /* UV_DARWIN_H */
libuv/samples/socks5-proxy/client.c view on Meta::CPAN
if (size != 0) {
/* Could allow a round-trip saving shortcut here if the requested auth
* method is S5_AUTH_NONE (provided unauthenticated traffic is allowed.)
* Requires client support however.
*/
pr_err("junk in handshake");
return do_kill(cx);
}
if (err != s5_auth_select) {
pr_err("handshake error: %s", s5_strerror(err));
return do_kill(cx);
}
methods = s5_auth_methods(parser);
if ((methods & S5_AUTH_NONE) && can_auth_none(cx->sx, cx)) {
s5_select_auth(parser, S5_AUTH_NONE);
conn_write(incoming, "\5\0", 2); /* No auth required. */
return s_req_start;
}
if ((methods & S5_AUTH_PASSWD) && can_auth_passwd(cx->sx, cx)) {
/* TODO(bnoordhuis) Implement username/password auth. */
}
conn_write(incoming, "\5\377", 2); /* No acceptable auth. */
return s_kill;
libuv/samples/socks5-proxy/s5.c view on Meta::CPAN
cx->methods |= S5_AUTH_GSSAPI;
break;
case 2:
cx->methods |= S5_AUTH_PASSWD;
break;
/* Ignore everything we don't understand. */
}
cx->arg0 += 1;
}
if (cx->arg0 == cx->arg1) {
err = s5_auth_select;
goto out;
}
break;
case s5_auth_pw_version:
if (c != 1) {
err = s5_bad_version;
goto out;
}
cx->state = s5_auth_pw_userlen;
libuv/samples/socks5-proxy/s5.c view on Meta::CPAN
out:
*data = p + i;
*size = n - i;
return err;
}
unsigned int s5_auth_methods(const s5_ctx *cx) {
return cx->methods;
}
int s5_select_auth(s5_ctx *cx, s5_auth_method method) {
int err;
err = 0;
switch (method) {
case S5_AUTH_NONE:
cx->state = s5_req_version;
break;
case S5_AUTH_PASSWD:
cx->state = s5_auth_pw_version;
break;
libuv/samples/socks5-proxy/s5.h view on Meta::CPAN
#define S5_H_
#include <stddef.h>
#include <stdint.h>
#define S5_ERR_MAP(V) \
V(-1, bad_version, "Bad protocol version.") \
V(-2, bad_cmd, "Bad protocol command.") \
V(-3, bad_atyp, "Bad address type.") \
V(0, ok, "No error.") \
V(1, auth_select, "Select authentication method.") \
V(2, auth_verify, "Verify authentication.") \
V(3, exec_cmd, "Execute command.") \
typedef enum {
#define S5_ERR_GEN(code, name, _) s5_ ## name = code,
S5_ERR_MAP(S5_ERR_GEN)
#undef S5_ERR_GEN
s5_max_errors
} s5_err;
libuv/samples/socks5-proxy/s5.h view on Meta::CPAN
} s5_ctx;
void s5_init(s5_ctx *ctx);
s5_err s5_parse(s5_ctx *cx, uint8_t **data, size_t *size);
/* Only call after s5_parse() has returned s5_want_auth_method. */
unsigned int s5_auth_methods(const s5_ctx *cx);
/* Call after s5_parse() has returned s5_want_auth_method. */
int s5_select_auth(s5_ctx *cx, s5_auth_method method);
const char *s5_strerror(s5_err err);
#endif /* S5_H_ */
libuv/src/unix/aix.c view on Meta::CPAN
*fd = 0; errno = 0;
/* Open the monitor file, creating it if necessary */
*fd = open(mon_file, O_CREAT|O_RDWR);
if (*fd < 0)
return UV__ERR(errno);
/* Write out the monitoring specifications.
* In this case, we are monitoring for a state change event type
* CHANGED=YES
* We will be waiting in select call, rather than a read:
* WAIT_TYPE=WAIT_IN_SELECT
* We only want minimal information for files:
* INFO_LVL=1
* For directories, we want more information to track what file
* caused the change
* INFO_LVL=2
*/
if (file_is_directory == 0)
sprintf(mon_file_write_string, "CHANGED=YES;WAIT_TYPE=WAIT_IN_SELECT;INFO_LVL=2");
libuv/src/unix/aix.c view on Meta::CPAN
uv__io_start(handle->loop, &handle->event_watcher, POLLIN);
/* AHAFS wants someone to poll for it to start mointoring.
* so kick-start it so that we don't miss an event in the
* eventuality of an event that occurs in the current loop. */
do {
memset(&zt, 0, sizeof(zt));
FD_ZERO(&pollfd);
FD_SET(fd, &pollfd);
rc = select(fd + 1, &pollfd, NULL, NULL, &zt);
} while (rc == -1 && errno == EINTR);
return 0;
#else
return UV_ENOSYS;
#endif
}
int uv_fs_event_stop(uv_fs_event_t* handle) {
#ifdef HAVE_SYS_AHAFS_EVPRODS_H
libuv/src/unix/fsevents.c view on Meta::CPAN
/* Initialize context */
ctx.version = 0;
ctx.info = loop;
ctx.retain = NULL;
ctx.release = NULL;
ctx.copyDescription = NULL;
latency = 0.05;
/* Explanation of selected flags:
* 1. NoDefer - without this flag, events that are happening continuously
* (i.e. each event is happening after time interval less than `latency`,
* counted from previous event), will be deferred and passed to callback
* once they'll either fill whole OS buffer, or when this continuous stream
* will stop (i.e. there'll be delay between events, bigger than
* `latency`).
* Specifying this flag will invoke callback after `latency` time passed
* since event.
* 2. FileEvents - fire callback for file changes too (by default it is firing
* it only for directory changes).
libuv/src/unix/internal.h view on Meta::CPAN
void uv__run_idle(uv_loop_t* loop);
void uv__run_check(uv_loop_t* loop);
void uv__run_prepare(uv_loop_t* loop);
/* stream */
void uv__stream_init(uv_loop_t* loop, uv_stream_t* stream,
uv_handle_type type);
int uv__stream_open(uv_stream_t*, int fd, int flags);
void uv__stream_destroy(uv_stream_t* stream);
#if defined(__APPLE__)
int uv__stream_try_select(uv_stream_t* stream, int* fd);
#endif /* defined(__APPLE__) */
void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events);
int uv__accept(int sockfd);
int uv__dup2_cloexec(int oldfd, int newfd);
int uv__open_cloexec(const char* path, int flags);
/* tcp */
int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb);
int uv__tcp_nodelay(int fd, int on);
int uv__tcp_keepalive(int fd, int on, unsigned int delay);
libuv/src/unix/pipe.c view on Meta::CPAN
while (mode == -1 && errno == EINTR);
if (mode == -1)
return UV__ERR(errno); /* according to docs, must be EBADF */
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__) */
mode &= O_ACCMODE;
if (mode != O_WRONLY)
flags |= UV_HANDLE_READABLE;
if (mode != O_RDONLY)
flags |= UV_HANDLE_WRITABLE;
libuv/src/unix/stream.c view on Meta::CPAN
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <unistd.h>
#include <limits.h> /* IOV_MAX */
#if defined(__APPLE__)
# include <sys/event.h>
# include <sys/time.h>
# include <sys/select.h>
/* Forward declaration */
typedef struct uv__stream_select_s uv__stream_select_t;
struct uv__stream_select_s {
uv_stream_t* stream;
uv_thread_t thread;
uv_sem_t close_sem;
uv_sem_t async_sem;
uv_async_t async;
int events;
int fake_fd;
int int_fd;
int fd;
fd_set* sread;
libuv/src/unix/stream.c view on Meta::CPAN
if (err < 0)
/* In the rare case that "/dev/null" isn't mounted open "/"
* instead.
*/
err = uv__open_cloexec("/", O_RDONLY);
if (err >= 0)
loop->emfile_fd = err;
}
#if defined(__APPLE__)
stream->select = NULL;
#endif /* defined(__APPLE_) */
uv__io_init(&stream->io_watcher, uv__stream_io, -1);
}
static void uv__stream_osx_interrupt_select(uv_stream_t* stream) {
#if defined(__APPLE__)
/* Notify select() thread about state change */
uv__stream_select_t* s;
int r;
s = stream->select;
if (s == NULL)
return;
/* Interrupt select() loop
* NOTE: fake_fd and int_fd are socketpair(), thus writing to one will
* emit read event on other side
*/
do
r = write(s->fake_fd, "x", 1);
while (r == -1 && errno == EINTR);
assert(r == 1);
#else /* !defined(__APPLE__) */
/* No-op on any other platform */
#endif /* !defined(__APPLE__) */
}
#if defined(__APPLE__)
static void uv__stream_osx_select(void* arg) {
uv_stream_t* stream;
uv__stream_select_t* s;
char buf[1024];
int events;
int fd;
int r;
int max_fd;
stream = arg;
s = stream->select;
fd = s->fd;
if (fd > s->int_fd)
max_fd = fd;
else
max_fd = s->int_fd;
while (1) {
/* Terminate on semaphore */
if (uv_sem_trywait(&s->close_sem) == 0)
break;
/* Watch fd using select(2) */
memset(s->sread, 0, s->sread_sz);
memset(s->swrite, 0, s->swrite_sz);
if (uv__io_active(&stream->io_watcher, POLLIN))
FD_SET(fd, s->sread);
if (uv__io_active(&stream->io_watcher, POLLOUT))
FD_SET(fd, s->swrite);
FD_SET(s->int_fd, s->sread);
/* Wait indefinitely for fd events */
r = select(max_fd + 1, s->sread, s->swrite, NULL, NULL);
if (r == -1) {
if (errno == EINTR)
continue;
/* XXX: Possible?! */
abort();
}
/* Ignore timeouts */
if (r == 0)
libuv/src/unix/stream.c view on Meta::CPAN
uv_async_send(&s->async);
uv_sem_wait(&s->async_sem);
/* Should be processed at this stage */
assert((s->events == 0) || (stream->flags & UV_HANDLE_CLOSING));
}
}
}
static void uv__stream_osx_select_cb(uv_async_t* handle) {
uv__stream_select_t* s;
uv_stream_t* stream;
int events;
s = container_of(handle, uv__stream_select_t, async);
stream = s->stream;
/* Get and reset stream's events */
events = s->events;
ACCESS_ONCE(int, s->events) = 0;
assert(events != 0);
assert(events == (events & (POLLIN | POLLOUT)));
/* Invoke callback on event-loop */
if ((events & POLLIN) && uv__io_active(&stream->io_watcher, POLLIN))
uv__stream_io(stream->loop, &stream->io_watcher, POLLIN);
if ((events & POLLOUT) && uv__io_active(&stream->io_watcher, POLLOUT))
uv__stream_io(stream->loop, &stream->io_watcher, POLLOUT);
if (stream->flags & UV_HANDLE_CLOSING)
return;
/* NOTE: It is important to do it here, otherwise `select()` might be called
* before the actual `uv__read()`, leading to the blocking syscall
*/
uv_sem_post(&s->async_sem);
}
static void uv__stream_osx_cb_close(uv_handle_t* async) {
uv__stream_select_t* s;
s = container_of(async, uv__stream_select_t, async);
uv__free(s);
}
int uv__stream_try_select(uv_stream_t* stream, int* fd) {
/*
* kqueue doesn't work with some files from /dev mount on osx.
* select(2) in separate thread for those fds
*/
struct kevent filter[1];
struct kevent events[1];
struct timespec timeout;
uv__stream_select_t* s;
int fds[2];
int err;
int ret;
int kq;
int old_fd;
int max_fd;
size_t sread_sz;
size_t swrite_sz;
kq = kqueue();
libuv/src/unix/stream.c view on Meta::CPAN
if (ret == -1)
return UV__ERR(errno);
if (ret == 0 || (events[0].flags & EV_ERROR) == 0 || events[0].data != EINVAL)
return 0;
/* At this point we definitely know that this fd won't work with kqueue */
/*
* Create fds for io watcher and to interrupt the select() loop.
* NOTE: do it ahead of malloc below to allocate enough space for fd_sets
*/
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds))
return UV__ERR(errno);
max_fd = *fd;
if (fds[1] > max_fd)
max_fd = fds[1];
sread_sz = ROUND_UP(max_fd + 1, sizeof(uint32_t) * NBBY) / NBBY;
libuv/src/unix/stream.c view on Meta::CPAN
goto failed_malloc;
}
s->events = 0;
s->fd = *fd;
s->sread = (fd_set*) ((char*) s + sizeof(*s));
s->sread_sz = sread_sz;
s->swrite = (fd_set*) ((char*) s->sread + sread_sz);
s->swrite_sz = swrite_sz;
err = uv_async_init(stream->loop, &s->async, uv__stream_osx_select_cb);
if (err)
goto failed_async_init;
s->async.flags |= UV_HANDLE_INTERNAL;
uv__handle_unref(&s->async);
err = uv_sem_init(&s->close_sem, 0);
if (err != 0)
goto failed_close_sem_init;
err = uv_sem_init(&s->async_sem, 0);
if (err != 0)
goto failed_async_sem_init;
s->fake_fd = fds[0];
s->int_fd = fds[1];
old_fd = *fd;
s->stream = stream;
stream->select = s;
*fd = s->fake_fd;
err = uv_thread_create(&s->thread, uv__stream_osx_select, stream);
if (err != 0)
goto failed_thread_create;
return 0;
failed_thread_create:
s->stream = NULL;
stream->select = NULL;
*fd = old_fd;
uv_sem_destroy(&s->async_sem);
failed_async_sem_init:
uv_sem_destroy(&s->close_sem);
failed_close_sem_init:
uv__close(fds[0]);
uv__close(fds[1]);
libuv/src/unix/stream.c view on Meta::CPAN
return err;
}
static void uv__drain(uv_stream_t* stream) {
uv_shutdown_t* req;
int err;
assert(QUEUE_EMPTY(&stream->write_queue));
uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT);
uv__stream_osx_interrupt_select(stream);
/* Shutdown? */
if ((stream->flags & UV_HANDLE_SHUTTING) &&
!(stream->flags & UV_HANDLE_CLOSING) &&
!(stream->flags & UV_HANDLE_SHUT)) {
assert(stream->shutdown_req);
req = stream->shutdown_req;
stream->shutdown_req = NULL;
stream->flags &= ~UV_HANDLE_SHUTTING;
libuv/src/unix/stream.c view on Meta::CPAN
return; /* TODO(bnoordhuis) Start trying to write the next request. */
}
/* If this is a blocking stream, try again. */
if (stream->flags & UV_HANDLE_BLOCKING_WRITES)
goto start;
/* We're not done. */
uv__io_start(stream->loop, &stream->io_watcher, POLLOUT);
/* Notify select() thread about state change */
uv__stream_osx_interrupt_select(stream);
return;
error:
req->error = err;
uv__write_req_finish(req);
uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT);
if (!uv__io_active(&stream->io_watcher, POLLIN))
uv__handle_stop(stream);
uv__stream_osx_interrupt_select(stream);
}
static void uv__write_callbacks(uv_stream_t* stream) {
uv_write_t* req;
QUEUE* q;
QUEUE pq;
if (QUEUE_EMPTY(&stream->write_completed_queue))
return;
libuv/src/unix/stream.c view on Meta::CPAN
return UV_UNKNOWN_HANDLE;
}
static void uv__stream_eof(uv_stream_t* stream, const uv_buf_t* buf) {
stream->flags |= UV_HANDLE_READ_EOF;
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
if (!uv__io_active(&stream->io_watcher, POLLOUT))
uv__handle_stop(stream);
uv__stream_osx_interrupt_select(stream);
stream->read_cb(stream, UV_EOF, buf);
stream->flags &= ~UV_HANDLE_READING;
}
static int uv__stream_queue_fd(uv_stream_t* stream, int fd) {
uv__stream_queued_fds_t* queued_fds;
unsigned int queue_size;
queued_fds = stream->queued_fds;
libuv/src/unix/stream.c view on Meta::CPAN
}
while (nread < 0 && errno == EINTR);
}
if (nread < 0) {
/* Error */
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* Wait for the next one. */
if (stream->flags & UV_HANDLE_READING) {
uv__io_start(stream->loop, &stream->io_watcher, POLLIN);
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, UV__ERR(errno), &buf);
if (stream->flags & UV_HANDLE_READING) {
stream->flags &= ~UV_HANDLE_READING;
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
if (!uv__io_active(&stream->io_watcher, POLLOUT))
uv__handle_stop(stream);
uv__stream_osx_interrupt_select(stream);
}
}
return;
} else if (nread == 0) {
uv__stream_eof(stream, &buf);
return;
} else {
/* Successful read */
ssize_t buflen = buf.len;
libuv/src/unix/stream.c view on Meta::CPAN
assert(uv__stream_fd(stream) >= 0);
/* Initialize request */
uv__req_init(stream->loop, req, UV_SHUTDOWN);
req->handle = stream;
req->cb = cb;
stream->shutdown_req = req;
stream->flags |= UV_HANDLE_SHUTTING;
uv__io_start(stream->loop, &stream->io_watcher, POLLOUT);
uv__stream_osx_interrupt_select(stream);
return 0;
}
static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
uv_stream_t* stream;
stream = container_of(w, uv_stream_t, io_watcher);
libuv/src/unix/stream.c view on Meta::CPAN
uv__write(stream);
}
else {
/*
* blocking streams should never have anything in the queue.
* if this assert fires then somehow the blocking stream isn't being
* sufficiently flushed in uv__write.
*/
assert(!(stream->flags & UV_HANDLE_BLOCKING_WRITES));
uv__io_start(stream->loop, &stream->io_watcher, POLLOUT);
uv__stream_osx_interrupt_select(stream);
}
return 0;
}
/* The buffers to be written must remain valid until the callback is called.
* This is not required for the uv_buf_t array.
*/
int uv_write(uv_write_t* req,
libuv/src/unix/stream.c view on Meta::CPAN
/* Unqueue request, regardless of immediateness */
QUEUE_REMOVE(&req.queue);
uv__req_unregister(stream->loop, &req);
if (req.bufs != req.bufsml)
uv__free(req.bufs);
req.bufs = NULL;
/* Do not poll for writable, if we wasn't before calling this */
if (!has_pollout) {
uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT);
uv__stream_osx_interrupt_select(stream);
}
if (written == 0 && req_size != 0)
return UV_EAGAIN;
else
return written;
}
int uv_read_start(uv_stream_t* stream,
libuv/src/unix/stream.c view on Meta::CPAN
* not start the IO watcher.
*/
assert(uv__stream_fd(stream) >= 0);
assert(alloc_cb);
stream->read_cb = read_cb;
stream->alloc_cb = alloc_cb;
uv__io_start(stream->loop, &stream->io_watcher, POLLIN);
uv__handle_start(stream);
uv__stream_osx_interrupt_select(stream);
return 0;
}
int uv_read_stop(uv_stream_t* stream) {
if (!(stream->flags & UV_HANDLE_READING))
return 0;
stream->flags &= ~UV_HANDLE_READING;
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
if (!uv__io_active(&stream->io_watcher, POLLOUT))
uv__handle_stop(stream);
uv__stream_osx_interrupt_select(stream);
stream->read_cb = NULL;
stream->alloc_cb = NULL;
return 0;
}
int uv_is_readable(const uv_stream_t* stream) {
return !!(stream->flags & UV_HANDLE_READABLE);
}
int uv_is_writable(const uv_stream_t* stream) {
return !!(stream->flags & UV_HANDLE_WRITABLE);
}
#if defined(__APPLE__)
int uv___stream_fd(const uv_stream_t* handle) {
const uv__stream_select_t* s;
assert(handle->type == UV_TCP ||
handle->type == UV_TTY ||
handle->type == UV_NAMED_PIPE);
s = handle->select;
if (s != NULL)
return s->fd;
return handle->io_watcher.fd;
}
#endif /* defined(__APPLE__) */
void uv__stream_close(uv_stream_t* handle) {
unsigned int i;
uv__stream_queued_fds_t* queued_fds;
#if defined(__APPLE__)
/* Terminate select loop first */
if (handle->select != NULL) {
uv__stream_select_t* s;
s = handle->select;
uv_sem_post(&s->close_sem);
uv_sem_post(&s->async_sem);
uv__stream_osx_interrupt_select(handle);
uv_thread_join(&s->thread);
uv_sem_destroy(&s->close_sem);
uv_sem_destroy(&s->async_sem);
uv__close(s->fake_fd);
uv__close(s->int_fd);
uv_close((uv_handle_t*) &s->async, uv__stream_osx_cb_close);
handle->select = NULL;
}
#endif /* defined(__APPLE__) */
uv__io_close(handle->loop, &handle->io_watcher);
uv_read_stop(handle);
uv__handle_stop(handle);
handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
if (handle->io_watcher.fd != -1) {
/* Don't close stdio file descriptors. Nothing good comes from it. */
libuv/src/unix/tty.c view on Meta::CPAN
uv__stream_init(loop, (uv_stream_t*) tty, UV_TTY);
/* If anything fails beyond this point we need to remove the handle from
* the handle queue, since it was added by uv__handle_init in uv_stream_init.
*/
if (!(flags & UV_HANDLE_BLOCKING_WRITES))
uv__nonblock(fd, 1);
#if defined(__APPLE__)
r = uv__stream_try_select((uv_stream_t*) tty, &fd);
if (r) {
int rc = r;
if (newfd != -1)
uv__close(newfd);
QUEUE_REMOVE(&tty->handle_queue);
do
r = fcntl(fd, F_SETFL, saved_flags);
while (r == -1 && errno == EINTR);
return rc;
}
libuv/src/win/poll.c view on Meta::CPAN
mask_events = handle->mask_events_1;
} else if (req == &handle->poll_req_2) {
afd_poll_info = &handle->afd_poll_info_2;
handle->submitted_events_2 = 0;
mask_events = handle->mask_events_2;
} else {
assert(0);
return;
}
/* Report an error unless the select was just interrupted. */
if (!REQ_SUCCESS(req)) {
DWORD error = GET_REQ_SOCK_ERROR(req);
if (error != WSAEINTR && handle->events != 0) {
handle->events = 0; /* Stop the watcher */
handle->poll_cb(handle, uv_translate_sys_error(error), 0);
}
} else if (afd_poll_info->NumberOfHandles >= 1) {
unsigned char events = 0;
libuv/src/win/poll.c view on Meta::CPAN
if (handle->events & UV_WRITABLE) {
wfds.fd_count = 1;
wfds.fd_array[0] = handle->socket;
efds.fd_count = 1;
efds.fd_array[0] = handle->socket;
} else {
wfds.fd_count = 0;
efds.fd_count = 0;
}
/* Make the select() time out after 3 minutes. If select() hangs because the
* user closed the socket, we will at least not hang indefinitely. */
timeout.tv_sec = 3 * 60;
timeout.tv_usec = 0;
r = select(1, (fd_set*) &rfds, (fd_set*) &wfds, (fd_set*) &efds, &timeout);
if (r == SOCKET_ERROR) {
/* Queue this req, reporting an error. */
SET_REQ_ERROR(&handle->poll_req_1, WSAGetLastError());
POST_COMPLETION_FOR_REQ(handle->loop, req);
return 0;
}
reported_events = 0;
if (r > 0) {
libuv/test/runner-unix.c view on Meta::CPAN
#include <unistd.h> /* readlink, usleep */
#include <string.h> /* strdup */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <assert.h>
#include <sys/select.h>
#include <sys/time.h>
#include <pthread.h>
extern char** environ;
static void closefd(int fd) {
if (close(fd) == 0 || errno == EINTR || errno == EINPROGRESS)
return;
perror("close");
libuv/test/runner-unix.c view on Meta::CPAN
r = 0; /* Timeout. */
if (elapsed_ms >= (unsigned) timeout)
break;
tv.tv_sec = (timeout - elapsed_ms) / 1000;
tv.tv_usec = (timeout - elapsed_ms) % 1000 * 1000;
FD_ZERO(&fds);
FD_SET(args.pipe[0], &fds);
r = select(args.pipe[0] + 1, &fds, NULL, NULL, &tv);
if (!(r == -1 && errno == EINTR))
break;
if (gettimeofday(&tv, NULL))
abort();
}
if (r == -1) {
perror("select()");
retval = -1;
} else if (r) {
/* The thread completed successfully. */
retval = 0;
} else {
/* Timeout. Kill all the children. */
for (i = 0; i < n; i++) {
p = (process_info_t*)(vec + i * sizeof(process_info_t));
libuv/test/test-list.h view on Meta::CPAN
TEST_DECLARE (spawn_fs_open)
TEST_DECLARE (spawn_setuid_setgid)
TEST_DECLARE (we_get_signal)
TEST_DECLARE (we_get_signals)
TEST_DECLARE (we_get_signal_one_shot)
TEST_DECLARE (we_get_signals_mixed)
TEST_DECLARE (signal_multiple_loops)
TEST_DECLARE (closed_fd_events)
#endif
#ifdef __APPLE__
TEST_DECLARE (osx_select)
TEST_DECLARE (osx_select_many_fds)
#endif
HELPER_DECLARE (tcp4_echo_server)
HELPER_DECLARE (tcp6_echo_server)
HELPER_DECLARE (udp4_echo_server)
HELPER_DECLARE (pipe_echo_server)
TEST_DECLARE (queue_foreach_delete)
TEST_DECLARE (handle_type_name)
TEST_DECLARE (req_type_name)
libuv/test/test-list.h view on Meta::CPAN
TEST_ENTRY (spawn_setuid_setgid)
TEST_ENTRY (we_get_signal)
TEST_ENTRY (we_get_signals)
TEST_ENTRY (we_get_signal_one_shot)
TEST_ENTRY (we_get_signals_mixed)
TEST_ENTRY (signal_multiple_loops)
TEST_ENTRY (closed_fd_events)
#endif
#ifdef __APPLE__
TEST_ENTRY (osx_select)
TEST_ENTRY (osx_select_many_fds)
#endif
TEST_ENTRY (fs_file_noent)
TEST_ENTRY (fs_file_nametoolong)
TEST_ENTRY (fs_file_loop)
TEST_ENTRY (fs_file_async)
TEST_ENTRY (fs_file_sync)
TEST_ENTRY (fs_file_write_null_buffer)
TEST_ENTRY (fs_async_dir)
TEST_ENTRY (fs_async_sendfile)
libuv/test/test-osx-select.c view on Meta::CPAN
static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) {
fprintf(stdout, "got data %d\n", ++read_count);
fflush(stdout);
if (read_count == 3)
uv_close((uv_handle_t*) stream, NULL);
}
TEST_IMPL(osx_select) {
int r;
int fd;
size_t i;
size_t len;
const char* str;
uv_tty_t tty;
fd = open("/dev/tty", O_RDONLY);
if (fd < 0) {
fprintf(stderr, "Cannot open /dev/tty as read-only: %s\n", strerror(errno));
libuv/test/test-osx-select.c view on Meta::CPAN
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(read_count == 3);
MAKE_VALGRIND_HAPPY();
return 0;
}
TEST_IMPL(osx_select_many_fds) {
int r;
int fd;
size_t i;
size_t len;
const char* str;
struct sockaddr_in addr;
uv_tty_t tty;
uv_tcp_t tcps[1500];
TEST_FILE_LIMIT(ARRAY_SIZE(tcps) + 100);
libuv/test/test.gyp view on Meta::CPAN
'test-list.h',
'test-loop-handles.c',
'test-loop-alive.c',
'test-loop-close.c',
'test-loop-stop.c',
'test-loop-time.c',
'test-loop-configure.c',
'test-walk-handles.c',
'test-watcher-cross-stop.c',
'test-multiple-listen.c',
'test-osx-select.c',
'test-pass-always.c',
'test-ping-pong.c',
'test-pipe-bind-error.c',
'test-pipe-connect-error.c',
'test-pipe-connect-multiple.c',
'test-pipe-connect-prepare.c',
'test-pipe-getsockname.c',
'test-pipe-pending-instances.c',
'test-pipe-sendmsg.c',
'test-pipe-server-close.c',
libuv/vcbuild.bat view on Meta::CPAN
if /i "%1"=="x86" set target_arch=ia32&set msbuild_platform=WIN32&set vs_toolset=x86&goto arg-ok
if /i "%1"=="ia32" set target_arch=ia32&set msbuild_platform=WIN32&set vs_toolset=x86&goto arg-ok
if /i "%1"=="x64" set target_arch=x64&set msbuild_platform=x64&set vs_toolset=x64&goto arg-ok
if /i "%1"=="shared" set library=shared_library&goto arg-ok
if /i "%1"=="static" set library=static_library&goto arg-ok
:arg-ok
shift
goto next-arg
:args-done
if defined WindowsSDKDir goto select-target
if defined VCINSTALLDIR goto select-target
@rem Look for Visual Studio 2017 only if explicitly requested.
if "%target_env%" NEQ "vs2017" goto vs-set-2015
echo Looking for Visual Studio 2017
@rem Check if VS2017 is already setup, and for the requested arch.
if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%vs_toolset%_" goto found_vs2017
set "VSINSTALLDIR="
call tools\vswhere_usability_wrapper.cmd
if "_%VCINSTALLDIR%_" == "__" goto vs-set-2015
@rem Need to clear VSINSTALLDIR for vcvarsall to work as expected.
@rem Keep current working directory after call to vcvarsall
set "VSCMD_START_DIR=%CD%"
set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vs_toolset%
echo calling: %vcvars_call%
call %vcvars_call%
:found_vs2017
echo Found MSVS version %VisualStudioVersion%
if %VSCMD_ARG_TGT_ARCH%==x64 set target_arch=x64&set msbuild_platform=x64&set vs_toolset=x64
set GYP_MSVS_VERSION=2017
goto select-target
@rem Look for Visual Studio 2015
:vs-set-2015
if not defined VS140COMNTOOLS goto vc-set-2013
if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2013
call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2015
echo Using Visual Studio 2015
goto select-target
:vc-set-2013
@rem Look for Visual Studio 2013
if not defined VS120COMNTOOLS goto vc-set-2012
if not exist "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2012
call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2013
echo Using Visual Studio 2013
goto select-target
:vc-set-2012
@rem Look for Visual Studio 2012
if not defined VS110COMNTOOLS goto vc-set-2010
if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010
call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2012
echo Using Visual Studio 2012
goto select-target
:vc-set-2010
@rem Look for Visual Studio 2010
if not defined VS100COMNTOOLS goto vc-set-2008
if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008
call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2010
echo Using Visual Studio 2010
goto select-target
:vc-set-2008
@rem Look for Visual Studio 2008
if not defined VS90COMNTOOLS goto vc-set-notfound
if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound
call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2008
echo Using Visual Studio 2008
goto select-target
:vc-set-notfound
echo Warning: Visual Studio not found
:select-target
if not "%config%"=="" goto project-gen
if "%run%"=="run-tests.exe" set config=Debug& goto project-gen
if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen
set config=Debug
:project-gen
@rem Skip project generation if requested.
if defined noprojgen goto msbuild
@rem Generate the VS project.