Browse Source

deps: upgrade libuv to b9ed1a6

v0.9.3-release
Ben Noordhuis 12 years ago
parent
commit
ee77a6a953
  1. 3
      deps/uv/LICENSE
  2. 7
      deps/uv/README.md
  3. 5
      deps/uv/common.gypi
  4. 30
      deps/uv/config-unix.mk
  5. 12
      deps/uv/gyp_uv
  6. 403
      deps/uv/include/uv-private/eio.h
  7. 37
      deps/uv/include/uv-private/ngx-queue.h
  8. 35
      deps/uv/include/uv-private/uv-unix.h
  9. 21
      deps/uv/include/uv-private/uv-win.h
  10. 88
      deps/uv/include/uv.h
  11. 22
      deps/uv/src/fs-poll.c
  12. 128
      deps/uv/src/unix/core.c
  13. 63
      deps/uv/src/unix/eio/Changes
  14. 36
      deps/uv/src/unix/eio/LICENSE
  15. 15
      deps/uv/src/unix/eio/Makefile.am
  16. 8957
      deps/uv/src/unix/eio/aclocal.m4
  17. 3
      deps/uv/src/unix/eio/autogen.sh
  18. 86
      deps/uv/src/unix/eio/config.h.in
  19. 84
      deps/uv/src/unix/eio/config_aix.h
  20. 80
      deps/uv/src/unix/eio/config_cygwin.h
  21. 141
      deps/uv/src/unix/eio/config_darwin.h
  22. 81
      deps/uv/src/unix/eio/config_freebsd.h
  23. 94
      deps/uv/src/unix/eio/config_linux.h
  24. 81
      deps/uv/src/unix/eio/config_netbsd.h
  25. 137
      deps/uv/src/unix/eio/config_openbsd.h
  26. 84
      deps/uv/src/unix/eio/config_sunos.h
  27. 22
      deps/uv/src/unix/eio/configure.ac
  28. 194
      deps/uv/src/unix/eio/demo.c
  29. 370
      deps/uv/src/unix/eio/ecb.h
  30. 3428
      deps/uv/src/unix/eio/eio.3
  31. 2593
      deps/uv/src/unix/eio/eio.c
  32. 969
      deps/uv/src/unix/eio/eio.pod
  33. 195
      deps/uv/src/unix/eio/libeio.m4
  34. 164
      deps/uv/src/unix/eio/xthread.h
  35. 1
      deps/uv/src/unix/error.c
  36. 1174
      deps/uv/src/unix/fs.c
  37. 25
      deps/uv/src/unix/fsevents.c
  38. 144
      deps/uv/src/unix/getaddrinfo.c
  39. 13
      deps/uv/src/unix/internal.h
  40. 10
      deps/uv/src/unix/linux/linux-core.c
  41. 27
      deps/uv/src/unix/loop.c
  42. 2
      deps/uv/src/unix/stream.c
  43. 112
      deps/uv/src/unix/thread.c
  44. 176
      deps/uv/src/unix/threadpool.c
  45. 107
      deps/uv/src/unix/uv-eio.c
  46. 13
      deps/uv/src/unix/uv-eio.h
  47. 247
      deps/uv/src/win/thread.c
  48. 20
      deps/uv/src/win/winapi.c
  49. 24
      deps/uv/src/win/winapi.h
  50. 1
      deps/uv/test/benchmark-multi-accept.c
  51. 34
      deps/uv/test/runner-unix.c
  52. 3
      deps/uv/test/runner-win.c
  53. 1
      deps/uv/test/runner-win.h
  54. 16
      deps/uv/test/runner.c
  55. 2
      deps/uv/test/runner.h
  56. 2
      deps/uv/test/test-async.c
  57. 173
      deps/uv/test/test-condvar.c
  58. 67
      deps/uv/test/test-fs-event.c
  59. 1
      deps/uv/test/test-fs-poll.c
  60. 38
      deps/uv/test/test-fs.c
  61. 2
      deps/uv/test/test-getsockname.c
  62. 12
      deps/uv/test/test-list.h
  63. 33
      deps/uv/test/test-ping-pong.c
  64. 37
      deps/uv/test/test-ref.c
  65. 2
      deps/uv/test/test-tcp-writealot.c
  66. 24
      deps/uv/uv.gyp
  67. 47
      deps/uv/vcbuild.bat

3
deps/uv/LICENSE

@ -36,9 +36,6 @@ The externally maintained libraries used by libuv are:
- libev, located at ev/ is copyright Marc Alexander Lehmann, and - libev, located at ev/ is copyright Marc Alexander Lehmann, and
dual-licensed under the MIT license and GPL2. dual-licensed under the MIT license and GPL2.
- libeio, located at eio/ is copyright Marc Alexander Lehmann, and
dual-licensed under the MIT license and GPL2.
- inet_pton and inet_ntop implementations, contained in src/inet.c, are - inet_pton and inet_ntop implementations, contained in src/inet.c, are
copyright the Internet Systems Consortium, Inc., and licensed under the ISC copyright the Internet Systems Consortium, Inc., and licensed under the ISC
license. license.

7
deps/uv/README.md

@ -36,6 +36,9 @@ http://nodejs.org/
* IPC and socket sharing between processes `uv_write2` * IPC and socket sharing between processes `uv_write2`
## Community
* [Mailing list](http://groups.google.com/group/libuv)
## Documentation ## Documentation
@ -43,6 +46,10 @@ http://nodejs.org/
— API documentation in the form of detailed header comments. — API documentation in the form of detailed header comments.
* [An Introduction to libuv](http://nikhilm.github.com/uvbook/) — An * [An Introduction to libuv](http://nikhilm.github.com/uvbook/) — An
overview of libuv with tutorials. overview of libuv with tutorials.
* [LXJS 2012 talk](http://www.youtube.com/watch?v=nGn60vDSxQ4) - High-level
introductory talk about libuv.
* [Tests and benchmarks](https://github.com/joyent/libuv/tree/master/test) -
API specification and usage examples.
## Build Instructions ## Build Instructions

5
deps/uv/common.gypi

@ -117,6 +117,11 @@
# POSIX names # POSIX names
'_CRT_NONSTDC_NO_DEPRECATE', '_CRT_NONSTDC_NO_DEPRECATE',
], ],
'target_conditions': [
['target_arch=="x64"', {
'msvs_configuration_platform': 'x64'
}]
]
}], }],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', { [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
'cflags': [ '-Wall' ], 'cflags': [ '-Wall' ],

30
deps/uv/config-unix.mk

@ -32,6 +32,7 @@ OBJS += src/unix/core.o
OBJS += src/unix/dl.o OBJS += src/unix/dl.o
OBJS += src/unix/error.o OBJS += src/unix/error.o
OBJS += src/unix/fs.o OBJS += src/unix/fs.o
OBJS += src/unix/getaddrinfo.o
OBJS += src/unix/loop.o OBJS += src/unix/loop.o
OBJS += src/unix/loop-watcher.o OBJS += src/unix/loop-watcher.o
OBJS += src/unix/pipe.o OBJS += src/unix/pipe.o
@ -41,21 +42,20 @@ OBJS += src/unix/signal.o
OBJS += src/unix/stream.o OBJS += src/unix/stream.o
OBJS += src/unix/tcp.o OBJS += src/unix/tcp.o
OBJS += src/unix/thread.o OBJS += src/unix/thread.o
OBJS += src/unix/threadpool.o
OBJS += src/unix/timer.o OBJS += src/unix/timer.o
OBJS += src/unix/tty.o OBJS += src/unix/tty.o
OBJS += src/unix/udp.o OBJS += src/unix/udp.o
ifeq (SunOS,$(uname_S)) ifeq (SunOS,$(uname_S))
EV_CONFIG=config_sunos.h EV_CONFIG=config_sunos.h
EIO_CONFIG=config_sunos.h
CPPFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 CPPFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
LINKFLAGS+=-lsocket -lnsl -lkstat LINKFLAGS+=-lkstat -lnsl -lsendfile -lsocket
OBJS += src/unix/sunos.o OBJS += src/unix/sunos.o
endif endif
ifeq (AIX,$(uname_S)) ifeq (AIX,$(uname_S))
EV_CONFIG=config_aix.h EV_CONFIG=config_aix.h
EIO_CONFIG=config_aix.h
CPPFLAGS += -Isrc/ares/config_aix -D_ALL_SOURCE -D_XOPEN_SOURCE=500 CPPFLAGS += -Isrc/ares/config_aix -D_ALL_SOURCE -D_XOPEN_SOURCE=500
LINKFLAGS+= -lperfstat LINKFLAGS+= -lperfstat
OBJS += src/unix/aix.o OBJS += src/unix/aix.o
@ -63,7 +63,6 @@ endif
ifeq (Darwin,$(uname_S)) ifeq (Darwin,$(uname_S))
EV_CONFIG=config_darwin.h EV_CONFIG=config_darwin.h
EIO_CONFIG=config_darwin.h
CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
LINKFLAGS+=-framework CoreServices LINKFLAGS+=-framework CoreServices
OBJS += src/unix/darwin.o OBJS += src/unix/darwin.o
@ -73,7 +72,6 @@ endif
ifeq (Linux,$(uname_S)) ifeq (Linux,$(uname_S))
EV_CONFIG=config_linux.h EV_CONFIG=config_linux.h
EIO_CONFIG=config_linux.h
CSTDFLAG += -D_GNU_SOURCE CSTDFLAG += -D_GNU_SOURCE
LINKFLAGS+=-ldl -lrt LINKFLAGS+=-ldl -lrt
OBJS += src/unix/linux/linux-core.o \ OBJS += src/unix/linux/linux-core.o \
@ -83,7 +81,6 @@ endif
ifeq (FreeBSD,$(uname_S)) ifeq (FreeBSD,$(uname_S))
EV_CONFIG=config_freebsd.h EV_CONFIG=config_freebsd.h
EIO_CONFIG=config_freebsd.h
LINKFLAGS+=-lkvm LINKFLAGS+=-lkvm
OBJS += src/unix/freebsd.o OBJS += src/unix/freebsd.o
OBJS += src/unix/kqueue.o OBJS += src/unix/kqueue.o
@ -91,7 +88,6 @@ endif
ifeq (DragonFly,$(uname_S)) ifeq (DragonFly,$(uname_S))
EV_CONFIG=config_freebsd.h EV_CONFIG=config_freebsd.h
EIO_CONFIG=config_freebsd.h
LINKFLAGS+= LINKFLAGS+=
OBJS += src/unix/freebsd.o OBJS += src/unix/freebsd.o
OBJS += src/unix/kqueue.o OBJS += src/unix/kqueue.o
@ -99,7 +95,6 @@ endif
ifeq (NetBSD,$(uname_S)) ifeq (NetBSD,$(uname_S))
EV_CONFIG=config_netbsd.h EV_CONFIG=config_netbsd.h
EIO_CONFIG=config_netbsd.h
LINKFLAGS+=-lkvm LINKFLAGS+=-lkvm
OBJS += src/unix/netbsd.o OBJS += src/unix/netbsd.o
OBJS += src/unix/kqueue.o OBJS += src/unix/kqueue.o
@ -107,7 +102,6 @@ endif
ifeq (OpenBSD,$(uname_S)) ifeq (OpenBSD,$(uname_S))
EV_CONFIG=config_openbsd.h EV_CONFIG=config_openbsd.h
EIO_CONFIG=config_openbsd.h
LINKFLAGS+=-lkvm LINKFLAGS+=-lkvm
OBJS += src/unix/openbsd.o OBJS += src/unix/openbsd.o
OBJS += src/unix/kqueue.o OBJS += src/unix/kqueue.o
@ -115,7 +109,6 @@ endif
ifneq (,$(findstring CYGWIN,$(uname_S))) ifneq (,$(findstring CYGWIN,$(uname_S)))
EV_CONFIG=config_cygwin.h EV_CONFIG=config_cygwin.h
EIO_CONFIG=config_cygwin.h
# We drop the --std=c89, it hides CLOCK_MONOTONIC on cygwin # We drop the --std=c89, it hides CLOCK_MONOTONIC on cygwin
CSTDFLAG = -D_GNU_SOURCE CSTDFLAG = -D_GNU_SOURCE
LINKFLAGS+= LINKFLAGS+=
@ -135,7 +128,7 @@ endif
RUNNER_LIBS= RUNNER_LIBS=
RUNNER_SRC=test/runner-unix.c RUNNER_SRC=test/runner-unix.c
uv.a: $(OBJS) src/fs-poll.o src/inet.o src/uv-common.o src/unix/ev/ev.o src/unix/uv-eio.o src/unix/eio/eio.o uv.a: $(OBJS) src/fs-poll.o src/inet.o src/uv-common.o src/unix/ev/ev.o
$(AR) rcs uv.a $^ $(AR) rcs uv.a $^
src/%.o: src/%.c include/uv.h include/uv-private/uv-unix.h src/%.o: src/%.c include/uv.h include/uv-private/uv-unix.h
@ -147,29 +140,14 @@ src/unix/%.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/in
src/unix/ev/ev.o: src/unix/ev/ev.c src/unix/ev/ev.o: src/unix/ev/ev.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c src/unix/ev/ev.c -o src/unix/ev/ev.o -DEV_CONFIG_H=\"$(EV_CONFIG)\" $(CC) $(CPPFLAGS) $(CFLAGS) -c src/unix/ev/ev.c -o src/unix/ev/ev.o -DEV_CONFIG_H=\"$(EV_CONFIG)\"
EIO_CPPFLAGS += $(CPPFLAGS)
EIO_CPPFLAGS += -DEIO_CONFIG_H=\"$(EIO_CONFIG)\"
EIO_CPPFLAGS += -DEIO_STACKSIZE=262144
EIO_CPPFLAGS += -D_GNU_SOURCE
src/unix/eio/eio.o: src/unix/eio/eio.c
$(CC) $(EIO_CPPFLAGS) $(CFLAGS) -c src/unix/eio/eio.c -o src/unix/eio/eio.o
src/unix/uv-eio.o: src/unix/uv-eio.c
$(CC) $(CPPFLAGS) -Isrc/unix/eio/ $(CSTDFLAG) $(CFLAGS) -c src/unix/uv-eio.c -o src/unix/uv-eio.o
clean-platform: clean-platform:
-rm -f src/unix/*.o -rm -f src/unix/*.o
-rm -f src/unix/ev/*.o -rm -f src/unix/ev/*.o
-rm -f src/unix/eio/*.o
-rm -f src/unix/linux/*.o -rm -f src/unix/linux/*.o
-rm -rf test/run-tests.dSYM run-benchmarks.dSYM -rm -rf test/run-tests.dSYM run-benchmarks.dSYM
distclean-platform: distclean-platform:
-rm -f src/unix/*.o -rm -f src/unix/*.o
-rm -f src/unix/ev/*.o -rm -f src/unix/ev/*.o
-rm -f src/unix/eio/*.o
-rm -f src/unix/linux/*.o -rm -f src/unix/linux/*.o
-rm -rf test/run-tests.dSYM run-benchmarks.dSYM -rm -rf test/run-tests.dSYM run-benchmarks.dSYM

12
deps/uv/gyp_uv

@ -45,6 +45,9 @@ if __name__ == '__main__':
args.append(os.path.join(uv_root, 'uv.gyp')) args.append(os.path.join(uv_root, 'uv.gyp'))
common_fn = os.path.join(uv_root, 'common.gypi') common_fn = os.path.join(uv_root, 'common.gypi')
options_fn = os.path.join(uv_root, 'options.gypi') options_fn = os.path.join(uv_root, 'options.gypi')
# we force vs 2010 over 2008 which would otherwise be the default for gyp
if not os.environ.get('GYP_MSVS_VERSION'):
os.environ['GYP_MSVS_VERSION'] = '2010'
else: else:
args.append(os.path.join(os.path.abspath(uv_root), 'uv.gyp')) args.append(os.path.join(os.path.abspath(uv_root), 'uv.gyp'))
common_fn = os.path.join(os.path.abspath(uv_root), 'common.gypi') common_fn = os.path.join(os.path.abspath(uv_root), 'common.gypi')
@ -69,9 +72,14 @@ if __name__ == '__main__':
args.append('-Dgcc_version=%d' % (10 * major + minor)) args.append('-Dgcc_version=%d' % (10 * major + minor))
args.append('-Dclang=%d' % int(is_clang)) args.append('-Dclang=%d' % int(is_clang))
args.append('-Dtarget_arch=ia32') if not any(a.startswith('-Dtarget_arch') for a in args):
args.append('-Dtarget_arch=ia32')
if not any(a.startswith('-Dlibrary') for a in args):
args.append('-Dlibrary=static_library')
args.append('-Dcomponent=static_library') args.append('-Dcomponent=static_library')
args.append('-Dlibrary=static_library')
gyp_args = list(args) gyp_args = list(args)
print gyp_args print gyp_args
run_gyp(gyp_args) run_gyp(gyp_args)

403
deps/uv/include/uv-private/eio.h

@ -1,403 +0,0 @@
/*
* libeio API header
*
* Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libeio@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU General Public License ("GPL") version 2 or any later version,
* in which case the provisions of the GPL are applicable instead of
* the above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use your
* version of this file under the BSD license, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete the
* provisions above, a recipient may use your version of this file under
* either the BSD or the GPL.
*/
#ifndef EIO_H_
#define EIO_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <signal.h>
#include <sys/types.h>
typedef struct eio_req eio_req;
typedef struct eio_dirent eio_dirent;
typedef int (*eio_cb)(eio_req *req);
#ifndef EIO_REQ_MEMBERS
# define EIO_REQ_MEMBERS
#endif
#ifndef EIO_STRUCT_STAT
# ifdef _WIN32
# define EIO_STRUCT_STAT struct _stati64
# define EIO_STRUCT_STATI64
# else
# define EIO_STRUCT_STAT struct stat
# endif
#endif
#ifdef _WIN32
typedef int eio_uid_t;
typedef int eio_gid_t;
typedef int eio_mode_t;
#ifdef __MINGW32__ /* no intptr_t */
typedef ssize_t eio_ssize_t;
#else
typedef intptr_t eio_ssize_t; /* or SSIZE_T */
#endif
#if __GNUC__
typedef long long eio_ino_t;
#else
typedef __int64 eio_ino_t; /* unsigned not supported by msvc */
#endif
#else
typedef uid_t eio_uid_t;
typedef gid_t eio_gid_t;
typedef ssize_t eio_ssize_t;
typedef ino_t eio_ino_t;
typedef mode_t eio_mode_t;
#endif
#ifndef EIO_STRUCT_STATVFS
# define EIO_STRUCT_STATVFS struct statvfs
#endif
/* for readdir */
/* eio_readdir flags */
enum
{
EIO_READDIR_DENTS = 0x01, /* ptr2 contains eio_dirents, not just the (unsorted) names */
EIO_READDIR_DIRS_FIRST = 0x02, /* dirents gets sorted into a good stat() ing order to find directories first */
EIO_READDIR_STAT_ORDER = 0x04, /* dirents gets sorted into a good stat() ing order to quickly stat all files */
EIO_READDIR_FOUND_UNKNOWN = 0x80, /* set by eio_readdir when *_ARRAY was set and any TYPE=UNKNOWN's were found */
EIO_READDIR_CUSTOM1 = 0x100, /* for use by apps */
EIO_READDIR_CUSTOM2 = 0x200 /* for use by apps */
};
/* using "typical" values in the hope that the compiler will do something sensible */
enum eio_dtype
{
EIO_DT_UNKNOWN = 0,
EIO_DT_FIFO = 1,
EIO_DT_CHR = 2,
EIO_DT_MPC = 3, /* multiplexed char device (v7+coherent) */
EIO_DT_DIR = 4,
EIO_DT_NAM = 5, /* xenix special named file */
EIO_DT_BLK = 6,
EIO_DT_MPB = 7, /* multiplexed block device (v7+coherent) */
EIO_DT_REG = 8,
EIO_DT_NWK = 9, /* HP-UX network special */
EIO_DT_CMP = 9, /* VxFS compressed */
EIO_DT_LNK = 10,
/* DT_SHAD = 11,*/
EIO_DT_SOCK = 12,
EIO_DT_DOOR = 13, /* solaris door */
EIO_DT_WHT = 14,
EIO_DT_MAX = 15 /* highest DT_VALUE ever, hopefully */
};
struct eio_dirent
{
int nameofs; /* offset of null-terminated name string in (char *)req->ptr2 */
unsigned short namelen; /* size of filename without trailing 0 */
unsigned char type; /* one of EIO_DT_* */
signed char score; /* internal use */
eio_ino_t inode; /* the inode number, if available, otherwise unspecified */
};
/* eio_msync flags */
enum
{
EIO_MS_ASYNC = 1,
EIO_MS_INVALIDATE = 2,
EIO_MS_SYNC = 4
};
/* eio_mtouch flags */
enum
{
EIO_MT_MODIFY = 1
};
/* eio_sync_file_range flags */
enum
{
EIO_SYNC_FILE_RANGE_WAIT_BEFORE = 1,
EIO_SYNC_FILE_RANGE_WRITE = 2,
EIO_SYNC_FILE_RANGE_WAIT_AFTER = 4
};
/* eio_fallocate flags */
enum
{
EIO_FALLOC_FL_KEEP_SIZE = 1 /* MUST match the value in linux/falloc.h */
};
/* timestamps and differences - feel free to use double in your code directly */
typedef double eio_tstamp;
/* the eio request structure */
enum
{
EIO_CUSTOM,
EIO_OPEN, EIO_CLOSE, EIO_DUP2,
EIO_READ, EIO_WRITE,
EIO_READAHEAD, EIO_SENDFILE,
EIO_STAT, EIO_LSTAT, EIO_FSTAT,
EIO_STATVFS, EIO_FSTATVFS,
EIO_TRUNCATE, EIO_FTRUNCATE,
EIO_UTIME, EIO_FUTIME,
EIO_CHMOD, EIO_FCHMOD,
EIO_CHOWN, EIO_FCHOWN,
EIO_SYNC, EIO_FSYNC, EIO_FDATASYNC, EIO_SYNCFS,
EIO_MSYNC, EIO_MTOUCH, EIO_SYNC_FILE_RANGE, EIO_FALLOCATE,
EIO_MLOCK, EIO_MLOCKALL,
EIO_UNLINK, EIO_RMDIR, EIO_MKDIR, EIO_RENAME,
EIO_MKNOD, EIO_READDIR,
EIO_LINK, EIO_SYMLINK, EIO_READLINK, EIO_REALPATH,
EIO_GROUP, EIO_NOP,
EIO_BUSY
};
/* mlockall constants */
enum
{
EIO_MCL_CURRENT = 1,
EIO_MCL_FUTURE = 2
};
/* request priorities */
enum {
EIO_PRI_MIN = -4,
EIO_PRI_MAX = 4,
EIO_PRI_DEFAULT = 0
};
#define ETP_PRI_MIN EIO_PRI_MIN
#define ETP_PRI_MAX EIO_PRI_MAX
#define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1)
#define ETP_REQ eio_req
/*
* a somewhat faster data structure might be nice, but
* with 8 priorities this actually needs <20 insns
* per shift, the most expensive operation.
*/
typedef struct {
ETP_REQ *qs[ETP_NUM_PRI], *qe[ETP_NUM_PRI]; /* qstart, qend */
int size;
} etp_reqq;
typedef struct {
etp_reqq res_queue; /* queue of outstanding responses for this channel */
void *data; /* use this for what you want */
} eio_channel;
/* eio request structure */
/* this structure is mostly read-only */
/* when initialising it, all members must be zero-initialised */
struct eio_req
{
eio_req volatile *next; /* private ETP */
eio_ssize_t result; /* result of syscall, e.g. result = read (... */
off_t offs; /* read, write, truncate, readahead, sync_file_range, fallocate: file offset, mknod: dev_t */
size_t size; /* read, write, readahead, sendfile, msync, mlock, sync_file_range, fallocate: length */
void *ptr1; /* all applicable requests: pathname, old name; readdir: optional eio_dirents */
void *ptr2; /* all applicable requests: new name or memory buffer; readdir: name strings */
eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */
eio_tstamp nv2; /* utime, futime: mtime */
int type; /* EIO_xxx constant ETP */
int int1; /* all applicable requests: file descriptor; sendfile: output fd; open, msync, mlockall, readdir: flags */
long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode, sync_file_range, fallocate: flags */
long int3; /* chown, fchown: gid */
int errorno; /* errno value on syscall return */
eio_channel *channel; /* data used to direct poll callbacks arising from this req */
#if defined(__i386) || defined(__amd64)
unsigned char cancelled;
#else
sig_atomic_t cancelled;
#endif
unsigned char flags; /* private */
signed char pri; /* the priority */
void *data;
eio_cb finish;
void (*destroy)(eio_req *req); /* called when request no longer needed */
void (*feed)(eio_req *req); /* only used for group requests */
EIO_REQ_MEMBERS
eio_req *grp, *grp_prev, *grp_next, *grp_first; /* private */
};
/* _private_ request flags */
enum {
EIO_FLAG_PTR1_FREE = 0x01, /* need to free(ptr1) */
EIO_FLAG_PTR2_FREE = 0x02, /* need to free(ptr2) */
EIO_FLAG_GROUPADD = 0x04 /* some request was added to the group */
};
/* undocumented/unsupported/private helper */
/*void eio_page_align (void **addr, size_t *length);*/
/* returns < 0 on error, errno set
* need_poll, if non-zero, will be called when results are available
* and eio_poll_cb needs to be invoked (it MUST NOT call eio_poll_cb itself).
* done_poll is called when the need to poll is gone.
*/
int eio_init (void (*want_poll)(eio_channel *), void (*done_poll)(eio_channel *));
/* initialises a channel */
void eio_channel_init(eio_channel *, void *data);
/* must be called regularly to handle pending requests */
/* returns 0 if all requests were handled, -1 if not, or the value of EIO_FINISH if != 0 */
int eio_poll (eio_channel *channel);
/* stop polling if poll took longer than duration seconds */
void eio_set_max_poll_time (eio_tstamp nseconds);
/* do not handle more then count requests in one call to eio_poll_cb */
void eio_set_max_poll_reqs (unsigned int nreqs);
/* set minimum required number
* maximum wanted number
* or maximum idle number of threads */
void eio_set_min_parallel (unsigned int nthreads);
void eio_set_max_parallel (unsigned int nthreads);
void eio_set_max_idle (unsigned int nthreads);
void eio_set_idle_timeout (unsigned int seconds);
unsigned int eio_nreqs (void); /* number of requests in-flight */
unsigned int eio_nready (void); /* number of not-yet handled requests */
unsigned int eio_npending (void); /* number of finished but unhandled requests */
unsigned int eio_nthreads (void); /* number of worker threads in use currently */
/*****************************************************************************/
/* convenience wrappers */
#ifndef EIO_NO_WRAPPERS
eio_req *eio_nop (int pri, eio_cb cb, void *data, eio_channel *channel); /* does nothing except go through the whole process */
eio_req *eio_busy (eio_tstamp delay, int pri, eio_cb cb, void *data, eio_channel *channel); /* ties a thread for this long, simulating busyness */
eio_req *eio_sync (int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_fsync (int fd, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_syncfs (int fd, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_mlock (void *addr, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_mlockall (int flags, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_fallocate (int fd, int mode, off_t offset, size_t len, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_close (int fd, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */
eio_req *eio_fstatvfs (int fd, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */
eio_req *eio_futime (int fd, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_fchmod (int fd, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_fchown (int fd, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_open (const char *path, int flags, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_utime (const char *path, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_chown (const char *path, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_chmod (const char *path, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_mkdir (const char *path, eio_mode_t mode, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *data, eio_channel *channel); /* result=ptr2 allocated dynamically */
eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* result=ptr2 allocated dynamically */
eio_req *eio_realpath (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* result=ptr2 allocated dynamically */
eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */
eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */
eio_req *eio_statvfs (const char *path, int pri, eio_cb cb, void *data, eio_channel *channel); /* stat buffer=ptr2 allocated dynamically */
eio_req *eio_mknod (const char *path, eio_mode_t mode, dev_t dev, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data, eio_channel *channel);
eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data, eio_channel *channel);
#endif
/*****************************************************************************/
/* groups */
eio_req *eio_grp (eio_cb cb, void *data, eio_channel *channel);
void eio_grp_feed (eio_req *grp, void (*feed)(eio_req *req), int limit);
void eio_grp_limit (eio_req *grp, int limit);
void eio_grp_add (eio_req *grp, eio_req *req);
void eio_grp_cancel (eio_req *grp); /* cancels all sub requests but not the group */
/*****************************************************************************/
/* request api */
/* true if the request was cancelled, useful in the invoke callback */
#define EIO_CANCELLED(req) ((req)->cancelled)
#define EIO_RESULT(req) ((req)->result)
/* returns a pointer to the result buffer allocated by eio */
#define EIO_BUF(req) ((req)->ptr2)
#define EIO_STAT_BUF(req) ((EIO_STRUCT_STAT *)EIO_BUF(req))
#define EIO_STATVFS_BUF(req) ((EIO_STRUCT_STATVFS *)EIO_BUF(req))
#define EIO_PATH(req) ((char *)(req)->ptr1)
/* submit a request for execution */
void eio_submit (eio_req *req);
/* cancel a request as soon fast as possible, if possible */
void eio_cancel (eio_req *req);
/*****************************************************************************/
/* convenience functions */
eio_ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count);
eio_ssize_t eio__pread (int fd, void *buf, size_t count, off_t offset);
eio_ssize_t eio__pwrite (int fd, void *buf, size_t count, off_t offset);
#ifdef __cplusplus
}
#endif
#endif

37
deps/uv/include/uv-private/ngx-queue.h

@ -17,8 +17,11 @@ struct ngx_queue_s {
#define ngx_queue_init(q) \ #define ngx_queue_init(q) \
do { \
(q)->prev = q; \ (q)->prev = q; \
(q)->next = q (q)->next = q; \
} \
while (0)
#define ngx_queue_empty(h) \ #define ngx_queue_empty(h) \
@ -26,20 +29,26 @@ struct ngx_queue_s {
#define ngx_queue_insert_head(h, x) \ #define ngx_queue_insert_head(h, x) \
do { \
(x)->next = (h)->next; \ (x)->next = (h)->next; \
(x)->next->prev = x; \ (x)->next->prev = x; \
(x)->prev = h; \ (x)->prev = h; \
(h)->next = x (h)->next = x; \
} \
while (0)
#define ngx_queue_insert_after ngx_queue_insert_head #define ngx_queue_insert_after ngx_queue_insert_head
#define ngx_queue_insert_tail(h, x) \ #define ngx_queue_insert_tail(h, x) \
do { \
(x)->prev = (h)->prev; \ (x)->prev = (h)->prev; \
(x)->prev->next = x; \ (x)->prev->next = x; \
(x)->next = h; \ (x)->next = h; \
(h)->prev = x (h)->prev = x; \
} \
while (0)
#define ngx_queue_head(h) \ #define ngx_queue_head(h) \
@ -65,38 +74,50 @@ struct ngx_queue_s {
#if defined(NGX_DEBUG) #if defined(NGX_DEBUG)
#define ngx_queue_remove(x) \ #define ngx_queue_remove(x) \
do { \
(x)->next->prev = (x)->prev; \ (x)->next->prev = (x)->prev; \
(x)->prev->next = (x)->next; \ (x)->prev->next = (x)->next; \
(x)->prev = NULL; \ (x)->prev = NULL; \
(x)->next = NULL (x)->next = NULL; \
} \
while (0)
#else #else
#define ngx_queue_remove(x) \ #define ngx_queue_remove(x) \
do { \
(x)->next->prev = (x)->prev; \ (x)->next->prev = (x)->prev; \
(x)->prev->next = (x)->next (x)->prev->next = (x)->next; \
} \
while (0)
#endif #endif
#define ngx_queue_split(h, q, n) \ #define ngx_queue_split(h, q, n) \
do { \
(n)->prev = (h)->prev; \ (n)->prev = (h)->prev; \
(n)->prev->next = n; \ (n)->prev->next = n; \
(n)->next = q; \ (n)->next = q; \
(h)->prev = (q)->prev; \ (h)->prev = (q)->prev; \
(h)->prev->next = h; \ (h)->prev->next = h; \
(q)->prev = n; (q)->prev = n; \
} \
while (0)
#define ngx_queue_add(h, n) \ #define ngx_queue_add(h, n) \
do { \
(h)->prev->next = (n)->next; \ (h)->prev->next = (n)->next; \
(n)->next->prev = (h)->prev; \ (n)->next->prev = (h)->prev; \
(h)->prev = (n)->prev; \ (h)->prev = (n)->prev; \
(h)->prev->next = h; (h)->prev->next = h; \
} \
while (0)
#define ngx_queue_data(q, type, link) \ #define ngx_queue_data(q, type, link) \
(type *) ((unsigned char *) q - offsetof(type, link)) ((type *) ((unsigned char *) q - offsetof(type, link)))
#define ngx_queue_foreach(q, h) \ #define ngx_queue_foreach(q, h) \

35
deps/uv/include/uv-private/uv-unix.h

@ -25,7 +25,6 @@
#include "ngx-queue.h" #include "ngx-queue.h"
#include "ev.h" #include "ev.h"
#include "eio.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -54,6 +53,13 @@ struct uv__io_s {
ev_io io_watcher; ev_io io_watcher;
}; };
struct uv__work {
void (*work)(struct uv__work *w);
void (*done)(struct uv__work *w);
struct uv_loop_s* loop;
ngx_queue_t wq;
};
#if defined(__linux__) #if defined(__linux__)
# include "uv-linux.h" # include "uv-linux.h"
#elif defined(__sun) #elif defined(__sun)
@ -100,6 +106,7 @@ typedef pthread_t uv_thread_t;
typedef pthread_mutex_t uv_mutex_t; typedef pthread_mutex_t uv_mutex_t;
typedef pthread_rwlock_t uv_rwlock_t; typedef pthread_rwlock_t uv_rwlock_t;
typedef UV_PLATFORM_SEM_T uv_sem_t; typedef UV_PLATFORM_SEM_T uv_sem_t;
typedef pthread_cond_t uv_cond_t;
/* Platform-specific definitions for uv_spawn support. */ /* Platform-specific definitions for uv_spawn support. */
typedef gid_t uv_gid_t; typedef gid_t uv_gid_t;
@ -115,13 +122,10 @@ typedef struct {
#define UV_LOOP_PRIVATE_FIELDS \ #define UV_LOOP_PRIVATE_FIELDS \
unsigned long flags; \ unsigned long flags; \
/* Poll result queue */ \
eio_channel uv_eio_channel; \
struct ev_loop* ev; \ struct ev_loop* ev; \
/* Various thing for libeio. */ \ ngx_queue_t wq; \
uv_async_t uv_eio_want_poll_notifier; \ uv_mutex_t wq_mutex; \
uv_async_t uv_eio_done_poll_notifier; \ uv_async_t wq_async; \
uv_idle_t uv_eio_poller; \
uv_handle_t* closing_handles; \ uv_handle_t* closing_handles; \
ngx_queue_t process_handles[1]; \ ngx_queue_t process_handles[1]; \
ngx_queue_t prepare_handles; \ ngx_queue_t prepare_handles; \
@ -233,6 +237,7 @@ typedef struct {
uint64_t repeat; uint64_t repeat;
#define UV_GETADDRINFO_PRIVATE_FIELDS \ #define UV_GETADDRINFO_PRIVATE_FIELDS \
struct uv__work work_req; \
uv_getaddrinfo_cb cb; \ uv_getaddrinfo_cb cb; \
struct addrinfo* hints; \ struct addrinfo* hints; \
char* hostname; \ char* hostname; \
@ -245,12 +250,22 @@ typedef struct {
int errorno; \ int errorno; \
#define UV_FS_PRIVATE_FIELDS \ #define UV_FS_PRIVATE_FIELDS \
struct stat statbuf; \ const char *new_path; \
uv_file file; \ uv_file file; \
eio_req* eio; \ int flags; \
mode_t mode; \
void* buf; \
size_t len; \
off_t off; \
uid_t uid; \
gid_t gid; \
double atime; \
double mtime; \
struct uv__work work_req; \
struct stat statbuf; \
#define UV_WORK_PRIVATE_FIELDS \ #define UV_WORK_PRIVATE_FIELDS \
eio_req* eio; struct uv__work work_req;
#define UV_TTY_PRIVATE_FIELDS \ #define UV_TTY_PRIVATE_FIELDS \
struct termios orig_termios; \ struct termios orig_termios; \

21
deps/uv/include/uv-private/uv-win.h

@ -171,6 +171,10 @@ typedef int (WSAAPI* LPFN_WSARECVFROM)
typedef NTSTATUS *PNTSTATUS; typedef NTSTATUS *PNTSTATUS;
#endif #endif
#ifndef RTL_CONDITION_VARIABLE_INIT
typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE;
#endif
typedef struct _AFD_POLL_HANDLE_INFO { typedef struct _AFD_POLL_HANDLE_INFO {
HANDLE Handle; HANDLE Handle;
ULONG Events; ULONG Events;
@ -208,6 +212,23 @@ typedef HANDLE uv_sem_t;
typedef CRITICAL_SECTION uv_mutex_t; typedef CRITICAL_SECTION uv_mutex_t;
/* This condition variable implementation is based on the SetEvent solution
* (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
* We could not use the SignalObjectAndWait solution (section 3.4) because
* it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and
* uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs.
*/
typedef union {
CONDITION_VARIABLE cond_var;
struct {
unsigned int waiters_count;
CRITICAL_SECTION waiters_count_lock;
HANDLE signal_event;
HANDLE broadcast_event;
} fallback;
} uv_cond_t;
typedef union { typedef union {
/* srwlock_ has type SRWLOCK, but not all toolchains define this type in */ /* srwlock_ has type SRWLOCK, but not all toolchains define this type in */
/* windows.h. */ /* windows.h. */

88
deps/uv/include/uv.h

@ -139,11 +139,13 @@ typedef enum {
XX(CHECK, check) \ XX(CHECK, check) \
XX(FS_EVENT, fs_event) \ XX(FS_EVENT, fs_event) \
XX(FS_POLL, fs_poll) \ XX(FS_POLL, fs_poll) \
XX(HANDLE, handle) \
XX(IDLE, idle) \ XX(IDLE, idle) \
XX(NAMED_PIPE, pipe) \ XX(NAMED_PIPE, pipe) \
XX(POLL, poll) \ XX(POLL, poll) \
XX(PREPARE, prepare) \ XX(PREPARE, prepare) \
XX(PROCESS, process) \ XX(PROCESS, process) \
XX(STREAM, stream) \
XX(TCP, tcp) \ XX(TCP, tcp) \
XX(TIMER, timer) \ XX(TIMER, timer) \
XX(TTY, tty) \ XX(TTY, tty) \
@ -151,6 +153,7 @@ typedef enum {
XX(SIGNAL, signal) \ XX(SIGNAL, signal) \
#define UV_REQ_TYPE_MAP(XX) \ #define UV_REQ_TYPE_MAP(XX) \
XX(REQ, req) \
XX(CONNECT, connect) \ XX(CONNECT, connect) \
XX(WRITE, write) \ XX(WRITE, write) \
XX(SHUTDOWN, shutdown) \ XX(SHUTDOWN, shutdown) \
@ -209,7 +212,6 @@ typedef struct uv_fs_s uv_fs_t;
typedef struct uv_work_s uv_work_t; typedef struct uv_work_s uv_work_t;
/* None of the above. */ /* None of the above. */
typedef struct uv_counters_s uv_counters_t;
typedef struct uv_cpu_info_s uv_cpu_info_t; typedef struct uv_cpu_info_s uv_cpu_info_t;
typedef struct uv_interface_address_s uv_interface_address_t; typedef struct uv_interface_address_s uv_interface_address_t;
@ -386,12 +388,11 @@ struct uv_shutdown_s {
#define UV_HANDLE_FIELDS \ #define UV_HANDLE_FIELDS \
/* read-only */ \
uv_loop_t* loop; \
/* public */ \ /* public */ \
uv_close_cb close_cb; \ uv_close_cb close_cb; \
void* data; \ void* data; \
/* read-only */ \ /* read-only */ \
uv_loop_t* loop; \
uv_handle_type type; \ uv_handle_type type; \
/* private */ \ /* private */ \
ngx_queue_t handle_queue; \ ngx_queue_t handle_queue; \
@ -607,12 +608,14 @@ UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock);
/* Enable/disable Nagle's algorithm. */ /* Enable/disable Nagle's algorithm. */
UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable);
/* Enable/disable TCP keep-alive. /*
* Enable/disable TCP keep-alive.
* *
* `ms` is the initial delay in seconds, ignored when `enable` is zero. * `delay` is the initial delay in seconds, ignored when `enable` is zero.
*/ */
UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, int enable, UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle,
unsigned int delay); int enable,
unsigned int delay);
/* /*
* This setting applies to Windows only. * This setting applies to Windows only.
@ -937,8 +940,8 @@ UV_EXTERN uv_handle_type uv_guess_handle(uv_file file);
struct uv_pipe_s { struct uv_pipe_s {
UV_HANDLE_FIELDS UV_HANDLE_FIELDS
UV_STREAM_FIELDS UV_STREAM_FIELDS
UV_PIPE_PRIVATE_FIELDS
int ipc; /* non-zero if this pipe is used for passing handles */ int ipc; /* non-zero if this pipe is used for passing handles */
UV_PIPE_PRIVATE_FIELDS
}; };
/* /*
@ -1564,16 +1567,6 @@ struct uv_fs_poll_s {
UV_HANDLE_FIELDS UV_HANDLE_FIELDS
/* Private, don't touch. */ /* Private, don't touch. */
void* poll_ctx; void* poll_ctx;
/* v0.8 ABI compatibility */
char padding[sizeof(int)
+ sizeof(unsigned int)
+ sizeof(uint64_t)
+ sizeof(char*)
+ sizeof(uv_fs_poll_cb)
+ sizeof(uv_timer_t)
+ sizeof(uv_fs_t*)
+ sizeof(uv_statbuf_t)
- sizeof(void*)];
}; };
UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle);
@ -1637,8 +1630,8 @@ UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle);
struct uv_signal_s { struct uv_signal_s {
UV_HANDLE_FIELDS UV_HANDLE_FIELDS
uv_signal_cb signal_cb; uv_signal_cb signal_cb;
UV_SIGNAL_PRIVATE_FIELDS
int signum; int signum;
UV_SIGNAL_PRIVATE_FIELDS
}; };
/* These functions are no-ops on Windows. */ /* These functions are no-ops on Windows. */
@ -1799,6 +1792,36 @@ UV_EXTERN void uv_sem_post(uv_sem_t* sem);
UV_EXTERN void uv_sem_wait(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_sem_trywait(uv_sem_t* sem);
/*
* Same goes for the condition variable functions.
*/
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);
/* Waits on a condition variable without a timeout.
*
* Note:
* 1. callers should be prepared to deal with spurious wakeups.
*/
UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex);
/* Waits on a condition variable with a timeout in nano seconds.
* Returns 0 for success or -1 on timeout, * aborts when other errors happen.
*
* Note:
* 1. callers should be prepared to deal with spurious wakeups.
* 2. the granularity of timeout on Windows is never less than one millisecond.
* 3. uv_cond_timedwait takes a relative timeout, not an absolute time.
* 4. the precision of timeout on OSX is never less than one microsecond.
* Here is the reason.
* OSX doesn't support CLOCK_MONOTONIC nor pthread_condattr_setclock()
* (see man pthread_cond_init on OSX).
* An example in man pthread_cond_timedwait on OSX uses gettimeofday()
* and its resolution is a microsecond.
*/
UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex,
uint64_t timeout);
/* Runs a function once and only once. Concurrent calls to uv_once() with the /* Runs a function once and only once. Concurrent calls to uv_once() with the
* same guard will block all callers except one (it's unspecified which one). * same guard will block all callers except one (it's unspecified which one).
* The guard should be initialized statically with the UV_ONCE_INIT macro. * The guard should be initialized statically with the UV_ONCE_INIT macro.
@ -1841,37 +1864,16 @@ union uv_any_req {
}; };
struct uv_counters_s {
uint64_t async_init;
uint64_t check_init;
uint64_t eio_init;
uint64_t fs_event_init;
uint64_t fs_poll_init;
uint64_t handle_init;
uint64_t idle_init;
uint64_t pipe_init;
uint64_t poll_init;
uint64_t prepare_init;
uint64_t process_init;
uint64_t req_init;
uint64_t stream_init;
uint64_t tcp_init;
uint64_t timer_init;
uint64_t tty_init;
uint64_t udp_init;
};
struct uv_loop_s { struct uv_loop_s {
UV_LOOP_PRIVATE_FIELDS /* User data - use this for whatever. */
void* data;
/* The last error */ /* The last error */
uv_err_t last_err; uv_err_t last_err;
/* Loop reference counting */ /* Loop reference counting */
unsigned int active_handles; unsigned int active_handles;
ngx_queue_t handle_queue; ngx_queue_t handle_queue;
ngx_queue_t active_reqs; ngx_queue_t active_reqs;
/* User data - use this for whatever. */ UV_LOOP_PRIVATE_FIELDS
void* data;
}; };

22
deps/uv/src/fs-poll.c

@ -103,11 +103,15 @@ int uv_fs_poll_stop(uv_fs_poll_t* handle) {
ctx = handle->poll_ctx; ctx = handle->poll_ctx;
assert(ctx != NULL); assert(ctx != NULL);
assert(ctx->parent_handle != NULL); assert(ctx->parent_handle != NULL);
ctx->parent_handle = NULL; ctx->parent_handle = NULL;
uv_timer_stop(&ctx->timer_handle);
handle->poll_ctx = NULL; handle->poll_ctx = NULL;
/* Close the timer if it's active. If it's inactive, there's a stat request
* in progress and poll_cb will take care of the cleanup.
*/
if (uv__is_active(&ctx->timer_handle))
uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
uv__handle_stop(handle); uv__handle_stop(handle);
return 0; return 0;
@ -123,12 +127,7 @@ static void timer_cb(uv_timer_t* timer, int status) {
struct poll_ctx* ctx; struct poll_ctx* ctx;
ctx = container_of(timer, struct poll_ctx, timer_handle); ctx = container_of(timer, struct poll_ctx, timer_handle);
assert(ctx->parent_handle != NULL);
if (ctx->parent_handle == NULL) { /* handle has been stopped or closed */
uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
return;
}
assert(ctx->parent_handle->poll_ctx == ctx); assert(ctx->parent_handle->poll_ctx == ctx);
ctx->start_time = uv_now(ctx->loop); ctx->start_time = uv_now(ctx->loop);
@ -171,6 +170,11 @@ static void poll_cb(uv_fs_t* req) {
out: out:
uv_fs_req_cleanup(req); uv_fs_req_cleanup(req);
if (ctx->parent_handle == NULL) { /* handle has been stopped by callback */
uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
return;
}
/* Reschedule timer, subtract the delay from doing the stat(). */ /* Reschedule timer, subtract the delay from doing the stat(). */
interval = ctx->interval; interval = ctx->interval;
interval -= (uv_now(ctx->loop) - ctx->start_time) % interval; interval -= (uv_now(ctx->loop) - ctx->start_time) % interval;

128
deps/uv/src/unix/core.c

@ -299,134 +299,6 @@ int uv_is_active(const uv_handle_t* handle) {
} }
static int uv_getaddrinfo_done(eio_req* req_) {
uv_getaddrinfo_t* req = req_->data;
struct addrinfo *res = req->res;
#if __sun
size_t hostlen = strlen(req->hostname);
#endif
req->res = NULL;
uv__req_unregister(req->loop, req);
/* see initialization in uv_getaddrinfo() */
if (req->hints)
free(req->hints);
else if (req->service)
free(req->service);
else if (req->hostname)
free(req->hostname);
else
assert(0);
if (req->retcode == 0) {
/* OK */
#if EAI_NODATA /* FreeBSD deprecated EAI_NODATA */
} else if (req->retcode == EAI_NONAME || req->retcode == EAI_NODATA) {
#else
} else if (req->retcode == EAI_NONAME) {
#endif
uv__set_sys_error(req->loop, ENOENT); /* FIXME compatibility hack */
#if __sun
} else if (req->retcode == EAI_MEMORY && hostlen >= MAXHOSTNAMELEN) {
uv__set_sys_error(req->loop, ENOENT);
#endif
} else {
req->loop->last_err.code = UV_EADDRINFO;
req->loop->last_err.sys_errno_ = req->retcode;
}
req->cb(req, req->retcode, res);
return 0;
}
static void getaddrinfo_thread_proc(eio_req *req_) {
uv_getaddrinfo_t* req = req_->data;
req->retcode = getaddrinfo(req->hostname,
req->service,
req->hints,
&req->res);
}
int uv_getaddrinfo(uv_loop_t* loop,
uv_getaddrinfo_t* req,
uv_getaddrinfo_cb cb,
const char* hostname,
const char* service,
const struct addrinfo* hints) {
size_t hostname_len;
size_t service_len;
size_t hints_len;
eio_req* req_;
size_t len;
char* buf;
if (req == NULL || cb == NULL || (hostname == NULL && service == NULL))
return uv__set_artificial_error(loop, UV_EINVAL);
uv_eio_init(loop);
hostname_len = hostname ? strlen(hostname) + 1 : 0;
service_len = service ? strlen(service) + 1 : 0;
hints_len = hints ? sizeof(*hints) : 0;
buf = malloc(hostname_len + service_len + hints_len);
if (buf == NULL)
return uv__set_artificial_error(loop, UV_ENOMEM);
uv__req_init(loop, req, UV_GETADDRINFO);
req->loop = loop;
req->cb = cb;
req->res = NULL;
req->hints = NULL;
req->service = NULL;
req->hostname = NULL;
req->retcode = 0;
/* order matters, see uv_getaddrinfo_done() */
len = 0;
if (hints) {
req->hints = memcpy(buf + len, hints, sizeof(*hints));
len += sizeof(*hints);
}
if (service) {
req->service = memcpy(buf + len, service, service_len);
len += service_len;
}
if (hostname) {
req->hostname = memcpy(buf + len, hostname, hostname_len);
len += hostname_len;
}
req_ = eio_custom(getaddrinfo_thread_proc,
EIO_PRI_DEFAULT,
uv_getaddrinfo_done,
req,
&loop->uv_eio_channel);
if (req_)
return 0;
free(buf);
return uv__set_artificial_error(loop, UV_ENOMEM);
}
void uv_freeaddrinfo(struct addrinfo* ai) {
if (ai)
freeaddrinfo(ai);
}
/* Open a socket in non-blocking close-on-exec mode, atomically if possible. */ /* Open a socket in non-blocking close-on-exec mode, atomically if possible. */
int uv__socket(int domain, int type, int protocol) { int uv__socket(int domain, int type, int protocol) {
int sockfd; int sockfd;

63
deps/uv/src/unix/eio/Changes

@ -1,63 +0,0 @@
Revision history for libeio
TODO: maybe add mincore support? available on at least darwin, solaris, linux, freebsd
TODO: openbsd requires stdint.h for intptr_t - why posix?
TODO: make mtouch/readdir maybe others cancellable in-request
TODO: fadvise request
1.0
- fix a deadlock where a wakeup signal could be missed when
a timeout occured at the same time.
- use nonstandard but maybe-working-on-bsd fork technique.
- use fewer time() syscalls when waiting for new requests.
- fix a path-memory-leak in readdir when using the wrappers
(reported by Thomas L. Shinnick).
- support a max_idle value of 0.
- support setting of idle timeout value (eio_set_idle_timeout).
- readdir: correctly handle malloc failures.
- readdir: new flags argument, can return inode
and possibly filetype, can sort in various ways.
- readdir: stop immediately when cancelled, do
not continue reading the directory.
- fix return value of eio_sendfile_sync.
- include sys/mman.h for msync.
- added EIO_STACKSIZE.
- added msync, mtouch support (untested).
- added sync_file_range (untested).
- fixed custom support.
- use a more robust feed-add detection method.
- "outbundled" from IO::AIO.
- eio_set_max_polltime did not properly convert time to ticks.
- tentatively support darwin in sendfile.
- fix freebsd/darwin sendfile.
- also use sendfile emulation for ENOTSUP and EOPNOTSUPP
error codes.
- add OS-independent EIO_MT_* and EIO_MS_* flag enums.
- add eio_statvfs/eio_fstatvfs.
- add eio_mlock/eio_mlockall and OS-independent MCL_* flag enums.
- no longer set errno to 0 before making syscalls, this only lures
people into the trap of believing errno shows success or failure.
- "fix" demo.c so that it works as non-root.
- suppoert utimes seperately from futimes, as some systems have
utimes but not futimes.
- use _POSIX_MEMLOCK_RANGE for mlock.
- do not (errornously) overwrite CFLAGS in configure.ac.
- mknod used int3 for dev_t (§2 bit), not offs (64 bit).
- fix memory corruption in eio_readdirx for the flags
combination EIO_READDIR_STAT_ORDER | EIO_READDIR_DIRS_FIRST.
- port to openbsd (another blatantly broken non-UNIX/POSIX platform).
- fix eio_custom prototype.
- work around a Linux (and likely FreeBSD and other kernels) bug
where sendfile would not transfer all the requested bytes on
large transfers, using a heuristic.
- use libecb, and apply lots of minor space optimisations.
- disable sendfile on darwin, broken as everything else.
- add realpath request and implementation.
- cancelled requests will still invoke their request callbacks.
- add fallocate.
- do not acquire any locks when forking.
- incorporated some mingw32 changes by traviscline.
- added syncfs support, using direct syscall.
- set thread name on linux (ps -L/Hcx, top, gdb).
- remove useless use of volatile variables.

36
deps/uv/src/unix/eio/LICENSE

@ -1,36 +0,0 @@
All files in libeio are Copyright (C)2007,2008 Marc Alexander Lehmann.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Alternatively, the contents of this package may be used under the terms
of the GNU General Public License ("GPL") version 2 or any later version,
in which case the provisions of the GPL are applicable instead of the
above. If you wish to allow the use of your version of this package only
under the terms of the GPL and not to allow others to use your version of
this file under the BSD license, indicate your decision by deleting the
provisions above and replace them with the notice and other provisions
required by the GPL in this and the other files of this package. If you do
not delete the provisions above, a recipient may use your version of this
file under either the BSD or the GPL.

15
deps/uv/src/unix/eio/Makefile.am

@ -1,15 +0,0 @@
AUTOMAKE_OPTIONS = foreign no-dependencies
VERSION_INFO = 1:0
EXTRA_DIST = LICENSE Changes autogen.sh
#man_MANS = ev.3
include_HEADERS = eio.h
lib_LTLIBRARIES = libeio.la
libeio_la_SOURCES = eio.c ecb.h xthread.h config.h
libeio_la_LDFLAGS = -version-info $(VERSION_INFO)

8957
deps/uv/src/unix/eio/aclocal.m4

File diff suppressed because it is too large

3
deps/uv/src/unix/eio/autogen.sh

@ -1,3 +0,0 @@
#!/bin/sh
autoreconf --install --symlink --force

86
deps/uv/src/unix/eio/config.h.in

@ -1,86 +0,0 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* fdatasync(2) is available */
#undef HAVE_FDATASYNC
/* futimes(2) is available */
#undef HAVE_FUTIMES
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* posix_fadvise(2) is available */
#undef HAVE_POSIX_FADVISE
/* posix_madvise(2) is available */
#undef HAVE_POSIX_MADVISE
/* pread(2) and pwrite(2) are available */
#undef HAVE_PREADWRITE
/* readahead(2) is available (linux) */
#undef HAVE_READAHEAD
/* sendfile(2) is available and supported */
#undef HAVE_SENDFILE
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* sync_file_range(2) is available */
#undef HAVE_SYNC_FILE_RANGE
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* utimes(2) is available */
#undef HAVE_UTIMES
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

84
deps/uv/src/unix/eio/config_aix.h

@ -1,84 +0,0 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* fdatasync(2) is available */
/* #undef HAVE_FDATASYNC */
/* utimes(2) is available */
#define HAVE_UTIMES 1
/* futimes(2) is available */
/* #undef HAVE_FUTIMES */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* pread(2) and pwrite(2) are available */
#define HAVE_PREADWRITE 1
/* readahead(2) is available (linux) */
/* #undef HAVE_READAHEAD */
/* sendfile(2) is available and supported */
/* #undef HAVE_SENDFILE */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* sync_file_range(2) is available */
/* #undef HAVE_SYNC_FILE_RANGE */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "libeio"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.0"

80
deps/uv/src/unix/eio/config_cygwin.h

@ -1,80 +0,0 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* fdatasync(2) is available */
#define HAVE_FDATASYNC 1
/* utimes(2) is available */
#define HAVE_UTIMES 1
/* futimes(2) is available */
#define HAVE_FUTIMES 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* pread(2) and pwrite(2) are available */
#define HAVE_PREADWRITE 1
/* readahead(2) is available (linux) */
/* #undef HAVE_READAHEAD */
/* sendfile(2) is available and supported */
/* #undef HAVE_SENDFILE */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* sync_file_range(2) is available */
/* #undef HAVE_SYNC_FILE_RANGE */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Name of package */
#define PACKAGE "libeio"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.0"

141
deps/uv/src/unix/eio/config_darwin.h

@ -1,141 +0,0 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* fallocate(2) is available */
/* #undef HAVE_FALLOCATE */
/* fdatasync(2) is available */
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060
#define HAVE_FDATASYNC 1
#else
#define HAVE_FDATASYNC 0
#endif
/* futimes(2) is available */
#define HAVE_FUTIMES 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* posix_fadvise(2) is available */
/* #undef HAVE_POSIX_FADVISE */
/* posix_madvise(2) is available */
#define HAVE_POSIX_MADVISE 1
/* prctl(PR_SET_NAME) is available */
/* #undef HAVE_PRCTL_SET_NAME */
/* pread(2) and pwrite(2) are available */
#define HAVE_PREADWRITE 1
/* readahead(2) is available (linux) */
/* #undef HAVE_READAHEAD */
/* sendfile(2) is available and supported */
#define HAVE_SENDFILE 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* sync_file_range(2) is available */
/* #undef HAVE_SYNC_FILE_RANGE */
/* Define to 1 if you have the <sys/prctl.h> header file. */
/* #undef HAVE_SYS_PRCTL_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* syscall(__NR_syncfs) is available */
/* #undef HAVE_SYS_SYNCFS */
/* Define to 1 if you have the <sys/syscall.h> header file. */
#define HAVE_SYS_SYSCALL_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* utimes(2) is available */
#define HAVE_UTIMES 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "libeio"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
/* Version number of package */
#define VERSION "1.0"
/* Define to 1 if on MINIX. */
/* #undef _MINIX */
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */

81
deps/uv/src/unix/eio/config_freebsd.h

@ -1,81 +0,0 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* fdatasync(2) is available */
/* #undef HAVE_FDATASYNC */
/* utimes(2) is available */
#define HAVE_UTIMES 1
/* futimes(2) is available */
#define HAVE_FUTIMES 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* pread(2) and pwrite(2) are available */
#define HAVE_PREADWRITE 1
/* readahead(2) is available (linux) */
/* #undef HAVE_READAHEAD */
/* sendfile(2) is available and supported */
#define HAVE_SENDFILE 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* sync_file_range(2) is available */
/* #undef HAVE_SYNC_FILE_RANGE */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "libeio"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.0"

94
deps/uv/src/unix/eio/config_linux.h

@ -1,94 +0,0 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
#include <linux/version.h>
#include <features.h>
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* fdatasync(2) is available */
#define HAVE_FDATASYNC 1
/* utimes(2) is available */
#define HAVE_UTIMES 1
/* futimes(2) is available but we make the syscall directly. */
#undef HAVE_FUTIMES
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* pread(2) and pwrite(2) are available */
#define HAVE_PREADWRITE 1
/* readahead(2) is available (linux) */
#define HAVE_READAHEAD 1
/* sendfile(2) is available and supported */
#define HAVE_SENDFILE 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* sync_file_range(2) is available if kernel >= 2.6.17 and glibc >= 2.6 */
#if LINUX_VERSION_CODE >= 0x020611 && __GLIBC_PREREQ(2, 6)
#define HAVE_SYNC_FILE_RANGE 1
#else
#define HAVE_SYNC_FILE_RANGE 0
#endif
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/syscall.h> header file. */
#define HAVE_SYS_SYSCALL_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "libeio"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.0"

81
deps/uv/src/unix/eio/config_netbsd.h

@ -1,81 +0,0 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* fdatasync(2) is available */
/* #undef HAVE_FDATASYNC */
/* utimes(2) is available */
#define HAVE_UTIMES 1
/* futimes(2) is available */
#define HAVE_FUTIMES 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* pread(2) and pwrite(2) are available */
#define HAVE_PREADWRITE 1
/* readahead(2) is available (linux) */
/* #undef HAVE_READAHEAD */
/* sendfile(2) is available and supported */
#define HAVE_SENDFILE 0
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* sync_file_range(2) is available */
/* #undef HAVE_SYNC_FILE_RANGE */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "libeio"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.0"

137
deps/uv/src/unix/eio/config_openbsd.h

@ -1,137 +0,0 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* fallocate(2) is available */
/* #undef HAVE_FALLOCATE */
/* fdatasync(2) is available */
/* #undef HAVE_FDATASYNC */
/* futimes(2) is available */
#define HAVE_FUTIMES 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* posix_fadvise(2) is available */
/* #undef HAVE_POSIX_FADVISE */
/* posix_madvise(2) is available */
#define HAVE_POSIX_MADVISE 1
/* prctl(PR_SET_NAME) is available */
/* #undef HAVE_PRCTL_SET_NAME */
/* pread(2) and pwrite(2) are available */
#define HAVE_PREADWRITE 1
/* readahead(2) is available (linux) */
/* #undef HAVE_READAHEAD */
/* sendfile(2) is available and supported */
/* #undef HAVE_SENDFILE */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* sync_file_range(2) is available */
/* #undef HAVE_SYNC_FILE_RANGE */
/* Define to 1 if you have the <sys/prctl.h> header file. */
/* #undef HAVE_SYS_PRCTL_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* syscall(__NR_syncfs) is available */
/* #undef HAVE_SYS_SYNCFS */
/* Define to 1 if you have the <sys/syscall.h> header file. */
#define HAVE_SYS_SYSCALL_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* utimes(2) is available */
#define HAVE_UTIMES 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "libeio"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
/* Version number of package */
#define VERSION "1.0"
/* Define to 1 if on MINIX. */
/* #undef _MINIX */
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */

84
deps/uv/src/unix/eio/config_sunos.h

@ -1,84 +0,0 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* fdatasync(2) is available */
#define HAVE_FDATASYNC 1
/* utimes(2) is available */
#define HAVE_UTIMES 1
/* futimes(2) is available */
#define HAVE_FUTIMES 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* pread(2) and pwrite(2) are available */
#define HAVE_PREADWRITE 1
/* readahead(2) is available (linux) */
/* #undef HAVE_READAHEAD */
/* sendfile(2) is available and supported */
/* #undef HAVE_SENDFILE */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* sync_file_range(2) is available */
/* #undef HAVE_SYNC_FILE_RANGE */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "libeio"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME ""
/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.0"

22
deps/uv/src/unix/eio/configure.ac

@ -1,22 +0,0 @@
AC_PREREQ(2.59)
AC_INIT
AC_CONFIG_SRCDIR([eio.h])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(libeio,1.0)
AM_MAINTAINER_MODE
AC_GNU_SOURCE
AC_PROG_LIBTOOL
AC_PROG_CC
if test "x$GCC" = xyes ; then
CFLAGS="-O3 $CFLAGS"
fi
m4_include([libeio.m4])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

194
deps/uv/src/unix/eio/demo.c

@ -1,194 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <poll.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "eio.h"
int respipe [2];
void
want_poll (void)
{
char dummy;
printf ("want_poll ()\n");
write (respipe [1], &dummy, 1);
}
void
done_poll (void)
{
char dummy;
printf ("done_poll ()\n");
read (respipe [0], &dummy, 1);
}
void
event_loop (void)
{
// an event loop. yeah.
struct pollfd pfd;
pfd.fd = respipe [0];
pfd.events = POLLIN;
printf ("\nentering event loop\n");
while (eio_nreqs ())
{
poll (&pfd, 1, -1);
printf ("eio_poll () = %d\n", eio_poll ());
}
printf ("leaving event loop\n");
}
int
res_cb (eio_req *req)
{
printf ("res_cb(%d|%s) = %d\n", req->type, req->data ? req->data : "?", EIO_RESULT (req));
if (req->result < 0)
abort ();
return 0;
}
int
readdir_cb (eio_req *req)
{
char *buf = (char *)EIO_BUF (req);
printf ("readdir_cb = %d\n", EIO_RESULT (req));
if (EIO_RESULT (req) < 0)
return 0;
while (EIO_RESULT (req)--)
{
printf ("readdir = <%s>\n", buf);
buf += strlen (buf) + 1;
}
return 0;
}
int
stat_cb (eio_req *req)
{
struct stat *buf = EIO_STAT_BUF (req);
if (req->type == EIO_FSTAT)
printf ("fstat_cb = %d\n", EIO_RESULT (req));
else
printf ("stat_cb(%s) = %d\n", EIO_PATH (req), EIO_RESULT (req));
if (!EIO_RESULT (req))
printf ("stat size %d perm 0%o\n", buf->st_size, buf->st_mode & 0777);
return 0;
}
int
read_cb (eio_req *req)
{
unsigned char *buf = (unsigned char *)EIO_BUF (req);
printf ("read_cb = %d (%02x%02x%02x%02x %02x%02x%02x%02x)\n",
EIO_RESULT (req),
buf [0], buf [1], buf [2], buf [3],
buf [4], buf [5], buf [6], buf [7]);
return 0;
}
int last_fd;
int
open_cb (eio_req *req)
{
printf ("open_cb = %d\n", EIO_RESULT (req));
last_fd = EIO_RESULT (req);
return 0;
}
int
main (void)
{
printf ("pipe ()\n");
if (pipe (respipe)) abort ();
printf ("eio_init ()\n");
if (eio_init (want_poll, done_poll)) abort ();
do
{
/* avoid relative paths yourself(!) */
eio_mkdir ("eio-test-dir", 0777, 0, res_cb, "mkdir");
eio_nop (0, res_cb, "nop");
event_loop ();
eio_stat ("eio-test-dir", 0, stat_cb, "stat");
eio_lstat ("eio-test-dir", 0, stat_cb, "stat");
eio_open ("eio-test-dir/eio-test-file", O_RDWR | O_CREAT, 0777, 0, open_cb, "open");
eio_symlink ("test", "eio-test-dir/eio-symlink", 0, res_cb, "symlink");
eio_mknod ("eio-test-dir/eio-fifo", S_IFIFO, 0, 0, res_cb, "mknod");
event_loop ();
eio_utime ("eio-test-dir", 12345.678, 23456.789, 0, res_cb, "utime");
eio_futime (last_fd, 92345.678, 93456.789, 0, res_cb, "futime");
eio_chown ("eio-test-dir", getuid (), getgid (), 0, res_cb, "chown");
eio_fchown (last_fd, getuid (), getgid (), 0, res_cb, "fchown");
eio_fchmod (last_fd, 0723, 0, res_cb, "fchmod");
eio_readdir ("eio-test-dir", 0, 0, readdir_cb, "readdir");
eio_readdir ("/nonexistant", 0, 0, readdir_cb, "readdir");
eio_fstat (last_fd, 0, stat_cb, "stat");
eio_write (last_fd, "test\nfail\n", 10, 4, 0, res_cb, "write");
event_loop ();
eio_read (last_fd, 0, 8, 0, EIO_PRI_DEFAULT, read_cb, "read");
eio_readlink ("eio-test-dir/eio-symlink", 0, res_cb, "readlink");
event_loop ();
eio_dup2 (1, 2, EIO_PRI_DEFAULT, res_cb, "dup"); // dup stdout to stderr
eio_chmod ("eio-test-dir", 0765, 0, res_cb, "chmod");
eio_ftruncate (last_fd, 9, 0, res_cb, "ftruncate");
eio_fdatasync (last_fd, 0, res_cb, "fdatasync");
eio_fsync (last_fd, 0, res_cb, "fsync");
eio_sync (0, res_cb, "sync");
eio_busy (0.5, 0, res_cb, "busy");
event_loop ();
eio_sendfile (1, last_fd, 4, 5, 0, res_cb, "sendfile"); // write "test\n" to stdout
eio_fstat (last_fd, 0, stat_cb, "stat");
event_loop ();
eio_truncate ("eio-test-dir/eio-test-file", 6, 0, res_cb, "truncate");
eio_readahead (last_fd, 0, 64, 0, res_cb, "readahead");
event_loop ();
eio_close (last_fd, 0, res_cb, "close");
eio_link ("eio-test-dir/eio-test-file", "eio-test-dir/eio-test-file-2", 0, res_cb, "link");
event_loop ();
eio_rename ("eio-test-dir/eio-test-file", "eio-test-dir/eio-test-file-renamed", 0, res_cb, "rename");
event_loop ();
eio_unlink ("eio-test-dir/eio-fifo", 0, res_cb, "unlink");
eio_unlink ("eio-test-dir/eio-symlink", 0, res_cb, "unlink");
eio_unlink ("eio-test-dir/eio-test-file-2", 0, res_cb, "unlink");
eio_unlink ("eio-test-dir/eio-test-file-renamed", 0, res_cb, "unlink");
event_loop ();
eio_rmdir ("eio-test-dir", 0, res_cb, "rmdir");
event_loop ();
}
while (0);
return 0;
}

370
deps/uv/src/unix/eio/ecb.h

@ -1,370 +0,0 @@
/*
* libecb - http://software.schmorp.de/pkg/libecb
*
* Copyright (©) 2009-2011 Marc Alexander Lehmann <libecb@schmorp.de>
* Copyright (©) 2011 Emanuele Giaquinta
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ECB_H
#define ECB_H
#ifdef _WIN32
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
#if __GNUC__
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#else /* _MSC_VER || __BORLANDC__ */
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif
#else
#include <inttypes.h>
#endif
/* many compilers define _GNUC_ to some versions but then only implement
* what their idiot authors think are the "more important" extensions,
* causing enourmous grief in return for some better fake benchmark numbers.
* or so.
* we try to detect these and simply assume they are not gcc - if they have
* an issue with that they should have done it right in the first place.
*/
#ifndef ECB_GCC_VERSION
#if !defined(__GNUC_MINOR__) || defined(__INTEL_COMPILER) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__llvm__) || defined(__clang__)
#define ECB_GCC_VERSION(major,minor) 0
#else
#define ECB_GCC_VERSION(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
#endif
#endif
/*****************************************************************************/
#ifndef ECB_MEMORY_FENCE
#if ECB_GCC_VERSION(2,5)
#if defined(__x86) || defined(__i386)
#define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory")
#define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE /* non-lock xchg might be enough */
#define ECB_MEMORY_FENCE_RELEASE do { } while (0) /* unlikely to change in future cpus */
#elif __amd64
#define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory")
#define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("lfence" : : : "memory")
#define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("sfence") /* play safe - not needed in any current cpu */
#endif
#endif
#endif
#ifndef ECB_MEMORY_FENCE
#if ECB_GCC_VERSION(4,4)
#define ECB_MEMORY_FENCE __sync_synchronize ()
#define ECB_MEMORY_FENCE_ACQUIRE ({ char dummy = 0; __sync_lock_test_and_set (&dummy, 1); })
#define ECB_MEMORY_FENCE_RELEASE ({ char dummy = 1; __sync_lock_release (&dummy ); })
#elif _MSC_VER >= 1400 /* VC++ 2005 */
#pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier)
#define ECB_MEMORY_FENCE _ReadWriteBarrier ()
#define ECB_MEMORY_FENCE_ACQUIRE _ReadWriteBarrier () /* according to msdn, _ReadBarrier is not a load fence */
#define ECB_MEMORY_FENCE_RELEASE _WriteBarrier ()
#elif defined(_WIN32)
#include <WinNT.h>
#define ECB_MEMORY_FENCE MemoryBarrier () /* actually just xchg on x86... scary */
#define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE
#define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE
#endif
#endif
#ifndef ECB_MEMORY_FENCE
/*
* if you get undefined symbol references to pthread_mutex_lock,
* or failure to find pthread.h, then you should implement
* the ECB_MEMORY_FENCE operations for your cpu/compiler
* OR proide pthread.h and link against the posix thread library
* of your system.
*/
#include <pthread.h>
static pthread_mutex_t ecb_mf_lock = PTHREAD_MUTEX_INITIALIZER;
#define ECB_MEMORY_FENCE do { pthread_mutex_lock (&ecb_mf_lock); pthread_mutex_unlock (&ecb_mf_lock); } while (0)
#define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE
#define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE
#endif
/*****************************************************************************/
#define ECB_C99 (__STDC_VERSION__ >= 199901L)
#if __cplusplus
#define ecb_inline static inline
#elif ECB_GCC_VERSION(2,5)
#define ecb_inline static __inline__
#elif ECB_C99
#define ecb_inline static inline
#else
#define ecb_inline static
#endif
#if ECB_GCC_VERSION(3,3)
#define ecb_restrict __restrict__
#elif ECB_C99
#define ecb_restrict restrict
#else
#define ecb_restrict
#endif
typedef int ecb_bool;
#define ECB_CONCAT_(a, b) a ## b
#define ECB_CONCAT(a, b) ECB_CONCAT_(a, b)
#define ECB_STRINGIFY_(a) # a
#define ECB_STRINGIFY(a) ECB_STRINGIFY_(a)
#define ecb_function_ ecb_inline
#if ECB_GCC_VERSION(3,1)
#define ecb_attribute(attrlist) __attribute__(attrlist)
#define ecb_is_constant(expr) __builtin_constant_p (expr)
#define ecb_expect(expr,value) __builtin_expect ((expr),(value))
#define ecb_prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality)
#else
#define ecb_attribute(attrlist)
#define ecb_is_constant(expr) 0
#define ecb_expect(expr,value) (expr)
#define ecb_prefetch(addr,rw,locality)
#endif
/* no emulation for ecb_decltype */
#if ECB_GCC_VERSION(4,5)
#define ecb_decltype(x) __decltype(x)
#elif ECB_GCC_VERSION(3,0)
#define ecb_decltype(x) __typeof(x)
#endif
#define ecb_noinline ecb_attribute ((__noinline__))
#define ecb_noreturn ecb_attribute ((__noreturn__))
#define ecb_unused ecb_attribute ((__unused__))
#define ecb_const ecb_attribute ((__const__))
#define ecb_pure ecb_attribute ((__pure__))
#if ECB_GCC_VERSION(4,3)
#define ecb_artificial ecb_attribute ((__artificial__))
#define ecb_hot ecb_attribute ((__hot__))
#define ecb_cold ecb_attribute ((__cold__))
#else
#define ecb_artificial
#define ecb_hot
#define ecb_cold
#endif
/* put around conditional expressions if you are very sure that the */
/* expression is mostly true or mostly false. note that these return */
/* booleans, not the expression. */
#define ecb_expect_false(expr) ecb_expect (!!(expr), 0)
#define ecb_expect_true(expr) ecb_expect (!!(expr), 1)
/* for compatibility to the rest of the world */
#define ecb_likely(expr) ecb_expect_true (expr)
#define ecb_unlikely(expr) ecb_expect_false (expr)
/* count trailing zero bits and count # of one bits */
#if ECB_GCC_VERSION(3,4)
/* we assume int == 32 bit, long == 32 or 64 bit and long long == 64 bit */
#define ecb_ld32(x) (__builtin_clz (x) ^ 31)
#define ecb_ld64(x) (__builtin_clzll (x) ^ 63)
#define ecb_ctz32(x) __builtin_ctz (x)
#define ecb_ctz64(x) __builtin_ctzll (x)
#define ecb_popcount32(x) __builtin_popcount (x)
/* no popcountll */
#else
ecb_function_ int ecb_ctz32 (uint32_t x) ecb_const;
ecb_function_ int
ecb_ctz32 (uint32_t x)
{
int r = 0;
x &= ~x + 1; /* this isolates the lowest bit */
#if ECB_branchless_on_i386
r += !!(x & 0xaaaaaaaa) << 0;
r += !!(x & 0xcccccccc) << 1;
r += !!(x & 0xf0f0f0f0) << 2;
r += !!(x & 0xff00ff00) << 3;
r += !!(x & 0xffff0000) << 4;
#else
if (x & 0xaaaaaaaa) r += 1;
if (x & 0xcccccccc) r += 2;
if (x & 0xf0f0f0f0) r += 4;
if (x & 0xff00ff00) r += 8;
if (x & 0xffff0000) r += 16;
#endif
return r;
}
ecb_function_ int ecb_ctz64 (uint64_t x) ecb_const;
ecb_function_ int
ecb_ctz64 (uint64_t x)
{
int shift = x & 0xffffffffU ? 0 : 32;
return ecb_ctz32 (x >> shift) + shift;
}
ecb_function_ int ecb_popcount32 (uint32_t x) ecb_const;
ecb_function_ int
ecb_popcount32 (uint32_t x)
{
x -= (x >> 1) & 0x55555555;
x = ((x >> 2) & 0x33333333) + (x & 0x33333333);
x = ((x >> 4) + x) & 0x0f0f0f0f;
x *= 0x01010101;
return x >> 24;
}
/* you have the choice beetween something with a table lookup, */
/* something using lots of bit arithmetic and a simple loop */
/* we went for the loop */
ecb_function_ int ecb_ld32 (uint32_t x) ecb_const;
ecb_function_ int ecb_ld32 (uint32_t x)
{
int r = 0;
if (x >> 16) { x >>= 16; r += 16; }
if (x >> 8) { x >>= 8; r += 8; }
if (x >> 4) { x >>= 4; r += 4; }
if (x >> 2) { x >>= 2; r += 2; }
if (x >> 1) { r += 1; }
return r;
}
ecb_function_ int ecb_ld64 (uint64_t x) ecb_const;
ecb_function_ int ecb_ld64 (uint64_t x)
{
int r = 0;
if (x >> 32) { x >>= 32; r += 32; }
return r + ecb_ld32 (x);
}
#endif
/* popcount64 is only available on 64 bit cpus as gcc builtin */
/* so for this version we are lazy */
ecb_function_ int ecb_popcount64 (uint64_t x) ecb_const;
ecb_function_ int
ecb_popcount64 (uint64_t x)
{
return ecb_popcount32 (x) + ecb_popcount32 (x >> 32);
}
ecb_inline uint8_t ecb_rotl8 (uint8_t x, unsigned int count) ecb_const;
ecb_inline uint8_t ecb_rotr8 (uint8_t x, unsigned int count) ecb_const;
ecb_inline uint16_t ecb_rotl16 (uint16_t x, unsigned int count) ecb_const;
ecb_inline uint16_t ecb_rotr16 (uint16_t x, unsigned int count) ecb_const;
ecb_inline uint32_t ecb_rotl32 (uint32_t x, unsigned int count) ecb_const;
ecb_inline uint32_t ecb_rotr32 (uint32_t x, unsigned int count) ecb_const;
ecb_inline uint64_t ecb_rotl64 (uint64_t x, unsigned int count) ecb_const;
ecb_inline uint64_t ecb_rotr64 (uint64_t x, unsigned int count) ecb_const;
ecb_inline uint8_t ecb_rotl8 (uint8_t x, unsigned int count) { return (x >> ( 8 - count)) | (x << count); }
ecb_inline uint8_t ecb_rotr8 (uint8_t x, unsigned int count) { return (x << ( 8 - count)) | (x >> count); }
ecb_inline uint16_t ecb_rotl16 (uint16_t x, unsigned int count) { return (x >> (16 - count)) | (x << count); }
ecb_inline uint16_t ecb_rotr16 (uint16_t x, unsigned int count) { return (x << (16 - count)) | (x >> count); }
ecb_inline uint32_t ecb_rotl32 (uint32_t x, unsigned int count) { return (x >> (32 - count)) | (x << count); }
ecb_inline uint32_t ecb_rotr32 (uint32_t x, unsigned int count) { return (x << (32 - count)) | (x >> count); }
ecb_inline uint64_t ecb_rotl64 (uint64_t x, unsigned int count) { return (x >> (64 - count)) | (x << count); }
ecb_inline uint64_t ecb_rotr64 (uint64_t x, unsigned int count) { return (x << (64 - count)) | (x >> count); }
#if ECB_GCC_VERSION(4,3)
#define ecb_bswap16(x) (__builtin_bswap32 (x) >> 16)
#define ecb_bswap32(x) __builtin_bswap32 (x)
#define ecb_bswap64(x) __builtin_bswap64 (x)
#else
ecb_function_ uint16_t ecb_bswap16 (uint16_t x) ecb_const;
ecb_function_ uint16_t
ecb_bswap16 (uint16_t x)
{
return ecb_rotl16 (x, 8);
}
ecb_function_ uint32_t ecb_bswap32 (uint32_t x) ecb_const;
ecb_function_ uint32_t
ecb_bswap32 (uint32_t x)
{
return (((uint32_t)ecb_bswap16 (x)) << 16) | ecb_bswap16 (x >> 16);
}
ecb_function_ uint64_t ecb_bswap64 (uint64_t x) ecb_const;
ecb_function_ uint64_t
ecb_bswap64 (uint64_t x)
{
return (((uint64_t)ecb_bswap32 (x)) << 32) | ecb_bswap32 (x >> 32);
}
#endif
#if ECB_GCC_VERSION(4,5)
#define ecb_unreachable() __builtin_unreachable ()
#else
/* this seems to work fine, but gcc always emits a warning for it :/ */
ecb_function_ void ecb_unreachable (void) ecb_noreturn;
ecb_function_ void ecb_unreachable (void) { }
#endif
/* try to tell the compiler that some condition is definitely true */
#define ecb_assume(cond) do { if (!(cond)) ecb_unreachable (); } while (0)
ecb_function_ unsigned char ecb_byteorder_helper (void) ecb_const;
ecb_function_ unsigned char
ecb_byteorder_helper (void)
{
const uint32_t u = 0x11223344;
return *(unsigned char *)&u;
}
ecb_function_ ecb_bool ecb_big_endian (void) ecb_const;
ecb_function_ ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; }
ecb_function_ ecb_bool ecb_little_endian (void) ecb_const;
ecb_function_ ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () == 0x44; }
#if ECB_GCC_VERSION(3,0) || ECB_C99
#define ecb_mod(m,n) ((m) % (n) + ((m) % (n) < 0 ? (n) : 0))
#else
#define ecb_mod(m,n) ((m) < 0 ? ((n) - 1 - ((-1 - (m)) % (n))) : ((m) % (n)))
#endif
#if ecb_cplusplus_does_not_suck
/* does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm) */
template<typename T, int N>
static inline int ecb_array_length (const T (&arr)[N])
{
return N;
}
#else
#define ecb_array_length(name) (sizeof (name) / sizeof (name [0]))
#endif
#endif

3428
deps/uv/src/unix/eio/eio.3

File diff suppressed because it is too large

2593
deps/uv/src/unix/eio/eio.c

File diff suppressed because it is too large

969
deps/uv/src/unix/eio/eio.pod

@ -1,969 +0,0 @@
=head1 NAME
libeio - truly asynchronous POSIX I/O
=head1 SYNOPSIS
#include <eio.h>
=head1 DESCRIPTION
The newest version of this document is also available as an html-formatted
web page you might find easier to navigate when reading it for the first
time: L<http://pod.tst.eu/http://cvs.schmorp.de/libeio/eio.pod>.
Note that this library is a by-product of the C<IO::AIO> perl
module, and many of the subtler points regarding requests lifetime
and so on are only documented in its documentation at the
moment: L<http://pod.tst.eu/http://cvs.schmorp.de/IO-AIO/AIO.pm>.
=head2 FEATURES
This library provides fully asynchronous versions of most POSIX functions
dealing with I/O. Unlike most asynchronous libraries, this not only
includes C<read> and C<write>, but also C<open>, C<stat>, C<unlink> and
similar functions, as well as less rarely ones such as C<mknod>, C<futime>
or C<readlink>.
It also offers wrappers around C<sendfile> (Solaris, Linux, HP-UX and
FreeBSD, with emulation on other platforms) and C<readahead> (Linux, with
emulation elsewhere>).
The goal is to enable you to write fully non-blocking programs. For
example, in a game server, you would not want to freeze for a few seconds
just because the server is running a backup and you happen to call
C<readdir>.
=head2 TIME REPRESENTATION
Libeio represents time as a single floating point number, representing the
(fractional) number of seconds since the (POSIX) epoch (somewhere near
the beginning of 1970, details are complicated, don't ask). This type is
called C<eio_tstamp>, but it is guaranteed to be of type C<double> (or
better), so you can freely use C<double> yourself.
Unlike the name component C<stamp> might indicate, it is also used for
time differences throughout libeio.
=head2 FORK SUPPORT
Usage of pthreads in a program changes the semantics of fork
considerably. Specifically, only async-safe functions can be called after
fork. Libeio uses pthreads, so this applies, and makes using fork hard for
anything but relatively fork + exec uses.
This library only works in the process that initialised it: Forking is
fully supported, but using libeio in any other process than the one that
called C<eio_init> is not.
You might get around by not I<using> libeio before (or after) forking in
the parent, and using it in the child afterwards. You could also try to
call the L<eio_init> function again in the child, which will brutally
reinitialise all data structures, which isn't POSIX conformant, but
typically works.
Otherwise, the only recommendation you should follow is: treat fork code
the same way you treat signal handlers, and only ever call C<eio_init> in
the process that uses it, and only once ever.
=head1 INITIALISATION/INTEGRATION
Before you can call any eio functions you first have to initialise the
library. The library integrates into any event loop, but can also be used
without one, including in polling mode.
You have to provide the necessary glue yourself, however.
=over 4
=item int eio_init (void (*want_poll)(void), void (*done_poll)(void))
This function initialises the library. On success it returns C<0>, on
failure it returns C<-1> and sets C<errno> appropriately.
It accepts two function pointers specifying callbacks as argument, both of
which can be C<0>, in which case the callback isn't called.
There is currently no way to change these callbacks later, or to
"uninitialise" the library again.
=item want_poll callback
The C<want_poll> callback is invoked whenever libeio wants attention (i.e.
it wants to be polled by calling C<eio_poll>). It is "edge-triggered",
that is, it will only be called once when eio wants attention, until all
pending requests have been handled.
This callback is called while locks are being held, so I<you must
not call any libeio functions inside this callback>. That includes
C<eio_poll>. What you should do is notify some other thread, or wake up
your event loop, and then call C<eio_poll>.
=item done_poll callback
This callback is invoked when libeio detects that all pending requests
have been handled. It is "edge-triggered", that is, it will only be
called once after C<want_poll>. To put it differently, C<want_poll> and
C<done_poll> are invoked in pairs: after C<want_poll> you have to call
C<eio_poll ()> until either C<eio_poll> indicates that everything has been
handled or C<done_poll> has been called, which signals the same.
Note that C<eio_poll> might return after C<done_poll> and C<want_poll>
have been called again, so watch out for races in your code.
As with C<want_poll>, this callback is called while locks are being held,
so you I<must not call any libeio functions form within this callback>.
=item int eio_poll ()
This function has to be called whenever there are pending requests that
need finishing. You usually call this after C<want_poll> has indicated
that you should do so, but you can also call this function regularly to
poll for new results.
If any request invocation returns a non-zero value, then C<eio_poll ()>
immediately returns with that value as return value.
Otherwise, if all requests could be handled, it returns C<0>. If for some
reason not all requests have been handled, i.e. some are still pending, it
returns C<-1>.
=back
For libev, you would typically use an C<ev_async> watcher: the
C<want_poll> callback would invoke C<ev_async_send> to wake up the event
loop. Inside the callback set for the watcher, one would call C<eio_poll
()>.
If C<eio_poll ()> is configured to not handle all results in one go
(i.e. it returns C<-1>) then you should start an idle watcher that calls
C<eio_poll> until it returns something C<!= -1>.
A full-featured connector between libeio and libev would look as follows
(if C<eio_poll> is handling all requests, it can of course be simplified a
lot by removing the idle watcher logic):
static struct ev_loop *loop;
static ev_idle repeat_watcher;
static ev_async ready_watcher;
/* idle watcher callback, only used when eio_poll */
/* didn't handle all results in one call */
static void
repeat (EV_P_ ev_idle *w, int revents)
{
if (eio_poll () != -1)
ev_idle_stop (EV_A_ w);
}
/* eio has some results, process them */
static void
ready (EV_P_ ev_async *w, int revents)
{
if (eio_poll () == -1)
ev_idle_start (EV_A_ &repeat_watcher);
}
/* wake up the event loop */
static void
want_poll (void)
{
ev_async_send (loop, &ready_watcher)
}
void
my_init_eio ()
{
loop = EV_DEFAULT;
ev_idle_init (&repeat_watcher, repeat);
ev_async_init (&ready_watcher, ready);
ev_async_start (loop &watcher);
eio_init (want_poll, 0);
}
For most other event loops, you would typically use a pipe - the event
loop should be told to wait for read readiness on the read end. In
C<want_poll> you would write a single byte, in C<done_poll> you would try
to read that byte, and in the callback for the read end, you would call
C<eio_poll>.
You don't have to take special care in the case C<eio_poll> doesn't handle
all requests, as the done callback will not be invoked, so the event loop
will still signal readiness for the pipe until I<all> results have been
processed.
=head1 HIGH LEVEL REQUEST API
Libeio has both a high-level API, which consists of calling a request
function with a callback to be called on completion, and a low-level API
where you fill out request structures and submit them.
This section describes the high-level API.
=head2 REQUEST SUBMISSION AND RESULT PROCESSING
You submit a request by calling the relevant C<eio_TYPE> function with the
required parameters, a callback of type C<int (*eio_cb)(eio_req *req)>
(called C<eio_cb> below) and a freely usable C<void *data> argument.
The return value will either be 0, in case something went really wrong
(which can basically only happen on very fatal errors, such as C<malloc>
returning 0, which is rather unlikely), or a pointer to the newly-created
and submitted C<eio_req *>.
The callback will be called with an C<eio_req *> which contains the
results of the request. The members you can access inside that structure
vary from request to request, except for:
=over 4
=item C<ssize_t result>
This contains the result value from the call (usually the same as the
syscall of the same name).
=item C<int errorno>
This contains the value of C<errno> after the call.
=item C<void *data>
The C<void *data> member simply stores the value of the C<data> argument.
=back
The return value of the callback is normally C<0>, which tells libeio to
continue normally. If a callback returns a nonzero value, libeio will
stop processing results (in C<eio_poll>) and will return the value to its
caller.
Memory areas passed to libeio must stay valid as long as a request
executes, with the exception of paths, which are being copied
internally. Any memory libeio itself allocates will be freed after the
finish callback has been called. If you want to manage all memory passed
to libeio yourself you can use the low-level API.
For example, to open a file, you could do this:
static int
file_open_done (eio_req *req)
{
if (req->result < 0)
{
/* open() returned -1 */
errno = req->errorno;
perror ("open");
}
else
{
int fd = req->result;
/* now we have the new fd in fd */
}
return 0;
}
/* the first three arguments are passed to open(2) */
/* the remaining are priority, callback and data */
if (!eio_open ("/etc/passwd", O_RDONLY, 0, 0, file_open_done, 0))
abort (); /* something went wrong, we will all die!!! */
Note that you additionally need to call C<eio_poll> when the C<want_cb>
indicates that requests are ready to be processed.
=head2 CANCELLING REQUESTS
Sometimes the need for a request goes away before the request is
finished. In that case, one can cancel the request by a call to
C<eio_cancel>:
=over 4
=item eio_cancel (eio_req *req)
Cancel the request (and all its subrequests). If the request is currently
executing it might still continue to execute, and in other cases it might
still take a while till the request is cancelled.
Even if cancelled, the finish callback will still be invoked - the
callbacks of all cancellable requests need to check whether the request
has been cancelled by calling C<EIO_CANCELLED (req)>:
static int
my_eio_cb (eio_req *req)
{
if (EIO_CANCELLED (req))
return 0;
}
In addition, cancelled requests will I<either> have C<< req->result >>
set to C<-1> and C<errno> to C<ECANCELED>, or I<otherwise> they were
successfully executed, despite being cancelled (e.g. when they have
already been executed at the time they were cancelled).
C<EIO_CANCELLED> is still true for requests that have successfully
executed, as long as C<eio_cancel> was called on them at some point.
=back
=head2 AVAILABLE REQUESTS
The following request functions are available. I<All> of them return the
C<eio_req *> on success and C<0> on failure, and I<all> of them have the
same three trailing arguments: C<pri>, C<cb> and C<data>. The C<cb> is
mandatory, but in most cases, you pass in C<0> as C<pri> and C<0> or some
custom data value as C<data>.
=head3 POSIX API WRAPPERS
These requests simply wrap the POSIX call of the same name, with the same
arguments. If a function is not implemented by the OS and cannot be emulated
in some way, then all of these return C<-1> and set C<errorno> to C<ENOSYS>.
=over 4
=item eio_open (const char *path, int flags, mode_t mode, int pri, eio_cb cb, void *data)
=item eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data)
=item eio_chown (const char *path, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data)
=item eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data)
=item eio_mkdir (const char *path, mode_t mode, int pri, eio_cb cb, void *data)
=item eio_rmdir (const char *path, int pri, eio_cb cb, void *data)
=item eio_unlink (const char *path, int pri, eio_cb cb, void *data)
=item eio_utime (const char *path, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data)
=item eio_mknod (const char *path, mode_t mode, dev_t dev, int pri, eio_cb cb, void *data)
=item eio_link (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
=item eio_symlink (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
=item eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
=item eio_mlock (void *addr, size_t length, int pri, eio_cb cb, void *data)
=item eio_close (int fd, int pri, eio_cb cb, void *data)
=item eio_sync (int pri, eio_cb cb, void *data)
=item eio_fsync (int fd, int pri, eio_cb cb, void *data)
=item eio_fdatasync (int fd, int pri, eio_cb cb, void *data)
=item eio_futime (int fd, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data)
=item eio_ftruncate (int fd, off_t offset, int pri, eio_cb cb, void *data)
=item eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data)
=item eio_fchown (int fd, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data)
=item eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data)
These have the same semantics as the syscall of the same name, their
return value is available as C<< req->result >> later.
=item eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
=item eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
These two requests are called C<read> and C<write>, but actually wrap
C<pread> and C<pwrite>. On systems that lack these calls (such as cygwin),
libeio uses lseek/read_or_write/lseek and a mutex to serialise the
requests, so all these requests run serially and do not disturb each
other. However, they still disturb the file offset while they run, so it's
not safe to call these functions concurrently with non-libeio functions on
the same fd on these systems.
Not surprisingly, pread and pwrite are not thread-safe on Darwin (OS/X),
so it is advised not to submit multiple requests on the same fd on this
horrible pile of garbage.
=item eio_mlockall (int flags, int pri, eio_cb cb, void *data)
Like C<mlockall>, but the flag value constants are called
C<EIO_MCL_CURRENT> and C<EIO_MCL_FUTURE>.
=item eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data)
Just like msync, except that the flag values are called C<EIO_MS_ASYNC>,
C<EIO_MS_INVALIDATE> and C<EIO_MS_SYNC>.
=item eio_readlink (const char *path, int pri, eio_cb cb, void *data)
If successful, the path read by C<readlink(2)> can be accessed via C<<
req->ptr2 >> and is I<NOT> null-terminated, with the length specified as
C<< req->result >>.
if (req->result >= 0)
{
char *target = strndup ((char *)req->ptr2, req->result);
free (target);
}
=item eio_realpath (const char *path, int pri, eio_cb cb, void *data)
Similar to the realpath libc function, but unlike that one, C<<
req->result >> is C<-1> on failure. On success, the result is the length
of the returned path in C<ptr2> (which is I<NOT> 0-terminated) - this is
similar to readlink.
=item eio_stat (const char *path, int pri, eio_cb cb, void *data)
=item eio_lstat (const char *path, int pri, eio_cb cb, void *data)
=item eio_fstat (int fd, int pri, eio_cb cb, void *data)
Stats a file - if C<< req->result >> indicates success, then you can
access the C<struct stat>-like structure via C<< req->ptr2 >>:
EIO_STRUCT_STAT *statdata = (EIO_STRUCT_STAT *)req->ptr2;
=item eio_statvfs (const char *path, int pri, eio_cb cb, void *data)
=item eio_fstatvfs (int fd, int pri, eio_cb cb, void *data)
Stats a filesystem - if C<< req->result >> indicates success, then you can
access the C<struct statvfs>-like structure via C<< req->ptr2 >>:
EIO_STRUCT_STATVFS *statdata = (EIO_STRUCT_STATVFS *)req->ptr2;
=back
=head3 READING DIRECTORIES
Reading directories sounds simple, but can be rather demanding, especially
if you want to do stuff such as traversing a directory hierarchy or
processing all files in a directory. Libeio can assist these complex tasks
with it's C<eio_readdir> call.
=over 4
=item eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *data)
This is a very complex call. It basically reads through a whole directory
(via the C<opendir>, C<readdir> and C<closedir> calls) and returns either
the names or an array of C<struct eio_dirent>, depending on the C<flags>
argument.
The C<< req->result >> indicates either the number of files found, or
C<-1> on error. On success, null-terminated names can be found as C<< req->ptr2 >>,
and C<struct eio_dirents>, if requested by C<flags>, can be found via C<<
req->ptr1 >>.
Here is an example that prints all the names:
int i;
char *names = (char *)req->ptr2;
for (i = 0; i < req->result; ++i)
{
printf ("name #%d: %s\n", i, names);
/* move to next name */
names += strlen (names) + 1;
}
Pseudo-entries such as F<.> and F<..> are never returned by C<eio_readdir>.
C<flags> can be any combination of:
=over 4
=item EIO_READDIR_DENTS
If this flag is specified, then, in addition to the names in C<ptr2>,
also an array of C<struct eio_dirent> is returned, in C<ptr1>. A C<struct
eio_dirent> looks like this:
struct eio_dirent
{
int nameofs; /* offset of null-terminated name string in (char *)req->ptr2 */
unsigned short namelen; /* size of filename without trailing 0 */
unsigned char type; /* one of EIO_DT_* */
signed char score; /* internal use */
ino_t inode; /* the inode number, if available, otherwise unspecified */
};
The only members you normally would access are C<nameofs>, which is the
byte-offset from C<ptr2> to the start of the name, C<namelen> and C<type>.
C<type> can be one of:
C<EIO_DT_UNKNOWN> - if the type is not known (very common) and you have to C<stat>
the name yourself if you need to know,
one of the "standard" POSIX file types (C<EIO_DT_REG>, C<EIO_DT_DIR>, C<EIO_DT_LNK>,
C<EIO_DT_FIFO>, C<EIO_DT_SOCK>, C<EIO_DT_CHR>, C<EIO_DT_BLK>)
or some OS-specific type (currently
C<EIO_DT_MPC> - multiplexed char device (v7+coherent),
C<EIO_DT_NAM> - xenix special named file,
C<EIO_DT_MPB> - multiplexed block device (v7+coherent),
C<EIO_DT_NWK> - HP-UX network special,
C<EIO_DT_CMP> - VxFS compressed,
C<EIO_DT_DOOR> - solaris door, or
C<EIO_DT_WHT>).
This example prints all names and their type:
int i;
struct eio_dirent *ents = (struct eio_dirent *)req->ptr1;
char *names = (char *)req->ptr2;
for (i = 0; i < req->result; ++i)
{
struct eio_dirent *ent = ents + i;
char *name = names + ent->nameofs;
printf ("name #%d: %s (type %d)\n", i, name, ent->type);
}
=item EIO_READDIR_DIRS_FIRST
When this flag is specified, then the names will be returned in an order
where likely directories come first, in optimal C<stat> order. This is
useful when you need to quickly find directories, or you want to find all
directories while avoiding to stat() each entry.
If the system returns type information in readdir, then this is used
to find directories directly. Otherwise, likely directories are names
beginning with ".", or otherwise names with no dots, of which names with
short names are tried first.
=item EIO_READDIR_STAT_ORDER
When this flag is specified, then the names will be returned in an order
suitable for stat()'ing each one. That is, when you plan to stat()
all files in the given directory, then the returned order will likely
be fastest.
If both this flag and C<EIO_READDIR_DIRS_FIRST> are specified, then the
likely directories come first, resulting in a less optimal stat order.
=item EIO_READDIR_FOUND_UNKNOWN
This flag should not be specified when calling C<eio_readdir>. Instead,
it is being set by C<eio_readdir> (you can access the C<flags> via C<<
req->int1 >>, when any of the C<type>'s found were C<EIO_DT_UNKNOWN>. The
absence of this flag therefore indicates that all C<type>'s are known,
which can be used to speed up some algorithms.
A typical use case would be to identify all subdirectories within a
directory - you would ask C<eio_readdir> for C<EIO_READDIR_DIRS_FIRST>. If
then this flag is I<NOT> set, then all the entries at the beginning of the
returned array of type C<EIO_DT_DIR> are the directories. Otherwise, you
should start C<stat()>'ing the entries starting at the beginning of the
array, stopping as soon as you found all directories (the count can be
deduced by the link count of the directory).
=back
=back
=head3 OS-SPECIFIC CALL WRAPPERS
These wrap OS-specific calls (usually Linux ones), and might or might not
be emulated on other operating systems. Calls that are not emulated will
return C<-1> and set C<errno> to C<ENOSYS>.
=over 4
=item eio_sendfile (int out_fd, int in_fd, off_t in_offset, size_t length, int pri, eio_cb cb, void *data)
Wraps the C<sendfile> syscall. The arguments follow the Linux version, but
libeio supports and will use similar calls on FreeBSD, HP/UX, Solaris and
Darwin.
If the OS doesn't support some sendfile-like call, or the call fails,
indicating support for the given file descriptor type (for example,
Linux's sendfile might not support file to file copies), then libeio will
emulate the call in userspace, so there are almost no limitations on its
use.
=item eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb, void *data)
Calls C<readahead(2)>. If the syscall is missing, then the call is
emulated by simply reading the data (currently in 64kiB chunks).
=item eio_syncfs (int fd, int pri, eio_cb cb, void *data)
Calls Linux' C<syncfs> syscall, if available. Returns C<-1> and sets
C<errno> to C<ENOSYS> if the call is missing I<but still calls sync()>,
if the C<fd> is C<< >= 0 >>, so you can probe for the availability of the
syscall with a negative C<fd> argument and checking for C<-1/ENOSYS>.
=item eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data)
Calls C<sync_file_range>. If the syscall is missing, then this is the same
as calling C<fdatasync>.
Flags can be any combination of C<EIO_SYNC_FILE_RANGE_WAIT_BEFORE>,
C<EIO_SYNC_FILE_RANGE_WRITE> and C<EIO_SYNC_FILE_RANGE_WAIT_AFTER>.
=item eio_fallocate (int fd, int mode, off_t offset, off_t len, int pri, eio_cb cb, void *data)
Calls C<fallocate> (note: I<NOT> C<posix_fallocate>!). If the syscall is
missing, then it returns failure and sets C<errno> to C<ENOSYS>.
The C<mode> argument can be C<0> (for behaviour similar to
C<posix_fallocate>), or C<EIO_FALLOC_FL_KEEP_SIZE>, which keeps the size
of the file unchanged (but still preallocates space beyond end of file).
=back
=head3 LIBEIO-SPECIFIC REQUESTS
These requests are specific to libeio and do not correspond to any OS call.
=over 4
=item eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data)
Reads (C<flags == 0>) or modifies (C<flags == EIO_MT_MODIFY) the given
memory area, page-wise, that is, it reads (or reads and writes back) the
first octet of every page that spans the memory area.
This can be used to page in some mmapped file, or dirty some pages. Note
that dirtying is an unlocked read-write access, so races can ensue when
the some other thread modifies the data stored in that memory area.
=item eio_custom (void (*)(eio_req *) execute, int pri, eio_cb cb, void *data)
Executes a custom request, i.e., a user-specified callback.
The callback gets the C<eio_req *> as parameter and is expected to read
and modify any request-specific members. Specifically, it should set C<<
req->result >> to the result value, just like other requests.
Here is an example that simply calls C<open>, like C<eio_open>, but it
uses the C<data> member as filename and uses a hardcoded C<O_RDONLY>. If
you want to pass more/other parameters, you either need to pass some
struct or so via C<data> or provide your own wrapper using the low-level
API.
static int
my_open_done (eio_req *req)
{
int fd = req->result;
return 0;
}
static void
my_open (eio_req *req)
{
req->result = open (req->data, O_RDONLY);
}
eio_custom (my_open, 0, my_open_done, "/etc/passwd");
=item eio_busy (eio_tstamp delay, int pri, eio_cb cb, void *data)
This is a request that takes C<delay> seconds to execute, but otherwise
does nothing - it simply puts one of the worker threads to sleep for this
long.
This request can be used to artificially increase load, e.g. for debugging
or benchmarking reasons.
=item eio_nop (int pri, eio_cb cb, void *data)
This request does nothing, except go through the whole request cycle. This
can be used to measure latency or in some cases to simplify code, but is
not really of much use.
=back
=head3 GROUPING AND LIMITING REQUESTS
There is one more rather special request, C<eio_grp>. It is a very special
aio request: Instead of doing something, it is a container for other eio
requests.
There are two primary use cases for this: a) bundle many requests into a
single, composite, request with a definite callback and the ability to
cancel the whole request with its subrequests and b) limiting the number
of "active" requests.
Further below you will find more discussion of these topics - first
follows the reference section detailing the request generator and other
methods.
=over 4
=item eio_req *grp = eio_grp (eio_cb cb, void *data)
Creates, submits and returns a group request. Note that it doesn't have a
priority, unlike all other requests.
=item eio_grp_add (eio_req *grp, eio_req *req)
Adds a request to the request group.
=item eio_grp_cancel (eio_req *grp)
Cancels all requests I<in> the group, but I<not> the group request
itself. You can cancel the group request I<and> all subrequests via a
normal C<eio_cancel> call.
=back
=head4 GROUP REQUEST LIFETIME
Left alone, a group request will instantly move to the pending state and
will be finished at the next call of C<eio_poll>.
The usefulness stems from the fact that, if a subrequest is added to a
group I<before> a call to C<eio_poll>, via C<eio_grp_add>, then the group
will not finish until all the subrequests have finished.
So the usage cycle of a group request is like this: after it is created,
you normally instantly add a subrequest. If none is added, the group
request will finish on it's own. As long as subrequests are added before
the group request is finished it will be kept from finishing, that is the
callbacks of any subrequests can, in turn, add more requests to the group,
and as long as any requests are active, the group request itself will not
finish.
=head4 CREATING COMPOSITE REQUESTS
Imagine you wanted to create an C<eio_load> request that opens a file,
reads it and closes it. This means it has to execute at least three eio
requests, but for various reasons it might be nice if that request looked
like any other eio request.
This can be done with groups:
=over 4
=item 1) create the request object
Create a group that contains all further requests. This is the request you
can return as "the load request".
=item 2) open the file, maybe
Next, open the file with C<eio_open> and add the request to the group
request and you are finished setting up the request.
If, for some reason, you cannot C<eio_open> (path is a null ptr?) you
can set C<< grp->result >> to C<-1> to signal an error and let the group
request finish on its own.
=item 3) open callback adds more requests
In the open callback, if the open was not successful, copy C<<
req->errorno >> to C<< grp->errorno >> and set C<< grp->errorno >> to
C<-1> to signal an error.
Otherwise, malloc some memory or so and issue a read request, adding the
read request to the group.
=item 4) continue issuing requests till finished
In the real callback, check for errors and possibly continue with
C<eio_close> or any other eio request in the same way.
As soon as no new requests are added the group request will finish. Make
sure you I<always> set C<< grp->result >> to some sensible value.
=back
=head4 REQUEST LIMITING
#TODO
void eio_grp_limit (eio_req *grp, int limit);
=back
=head1 LOW LEVEL REQUEST API
#TODO
=head1 ANATOMY AND LIFETIME OF AN EIO REQUEST
A request is represented by a structure of type C<eio_req>. To initialise
it, clear it to all zero bytes:
eio_req req;
memset (&req, 0, sizeof (req));
A more common way to initialise a new C<eio_req> is to use C<calloc>:
eio_req *req = calloc (1, sizeof (*req));
In either case, libeio neither allocates, initialises or frees the
C<eio_req> structure for you - it merely uses it.
zero
#TODO
=head2 CONFIGURATION
The functions in this section can sometimes be useful, but the default
configuration will do in most case, so you should skip this section on
first reading.
=over 4
=item eio_set_max_poll_time (eio_tstamp nseconds)
This causes C<eio_poll ()> to return after it has detected that it was
running for C<nsecond> seconds or longer (this number can be fractional).
This can be used to limit the amount of time spent handling eio requests,
for example, in interactive programs, you might want to limit this time to
C<0.01> seconds or so.
Note that:
=over 4
=item a) libeio doesn't know how long your request callbacks take, so the
time spent in C<eio_poll> is up to one callback invocation longer then
this interval.
=item b) this is implemented by calling C<gettimeofday> after each
request, which can be costly.
=item c) at least one request will be handled.
=back
=item eio_set_max_poll_reqs (unsigned int nreqs)
When C<nreqs> is non-zero, then C<eio_poll> will not handle more than
C<nreqs> requests per invocation. This is a less costly way to limit the
amount of work done by C<eio_poll> then setting a time limit.
If you know your callbacks are generally fast, you could use this to
encourage interactiveness in your programs by setting it to C<10>, C<100>
or even C<1000>.
=item eio_set_min_parallel (unsigned int nthreads)
Make sure libeio can handle at least this many requests in parallel. It
might be able handle more.
=item eio_set_max_parallel (unsigned int nthreads)
Set the maximum number of threads that libeio will spawn.
=item eio_set_max_idle (unsigned int nthreads)
Libeio uses threads internally to handle most requests, and will start and stop threads on demand.
This call can be used to limit the number of idle threads (threads without
work to do): libeio will keep some threads idle in preparation for more
requests, but never longer than C<nthreads> threads.
In addition to this, libeio will also stop threads when they are idle for
a few seconds, regardless of this setting.
=item unsigned int eio_nthreads ()
Return the number of worker threads currently running.
=item unsigned int eio_nreqs ()
Return the number of requests currently handled by libeio. This is the
total number of requests that have been submitted to libeio, but not yet
destroyed.
=item unsigned int eio_nready ()
Returns the number of ready requests, i.e. requests that have been
submitted but have not yet entered the execution phase.
=item unsigned int eio_npending ()
Returns the number of pending requests, i.e. requests that have been
executed and have results, but have not been finished yet by a call to
C<eio_poll>).
=back
=head1 EMBEDDING
Libeio can be embedded directly into programs. This functionality is not
documented and not (yet) officially supported.
Note that, when including C<libeio.m4>, you are responsible for defining
the compilation environment (C<_LARGEFILE_SOURCE>, C<_GNU_SOURCE> etc.).
If you need to know how, check the C<IO::AIO> perl module, which does
exactly that.
=head1 COMPILETIME CONFIGURATION
These symbols, if used, must be defined when compiling F<eio.c>.
=over 4
=item EIO_STACKSIZE
This symbol governs the stack size for each eio thread. Libeio itself
was written to use very little stackspace, but when using C<EIO_CUSTOM>
requests, you might want to increase this.
If this symbol is undefined (the default) then libeio will use its default
stack size (C<sizeof (void *) * 4096> currently). If it is defined, but
C<0>, then the default operating system stack size will be used. In all
other cases, the value must be an expression that evaluates to the desired
stack size.
=back
=head1 PORTABILITY REQUIREMENTS
In addition to a working ISO-C implementation, libeio relies on a few
additional extensions:
=over 4
=item POSIX threads
To be portable, this module uses threads, specifically, the POSIX threads
library must be available (and working, which partially excludes many xBSD
systems, where C<fork ()> is buggy).
=item POSIX-compatible filesystem API
This is actually a harder portability requirement: The libeio API is quite
demanding regarding POSIX API calls (symlinks, user/group management
etc.).
=item C<double> must hold a time value in seconds with enough accuracy
The type C<double> is used to represent timestamps. It is required to
have at least 51 bits of mantissa (and 9 bits of exponent), which is good
enough for at least into the year 4000. This requirement is fulfilled by
implementations implementing IEEE 754 (basically all existing ones).
=back
If you know of other additional requirements drop me a note.
=head1 AUTHOR
Marc Lehmann <libeio@schmorp.de>.

195
deps/uv/src/unix/eio/libeio.m4

@ -1,195 +0,0 @@
dnl openbsd in it's neverending brokenness requires stdint.h for intptr_t,
dnl but that header isn't very portable...
AC_CHECK_HEADERS([stdint.h sys/syscall.h sys/prctl.h])
AC_SEARCH_LIBS(
pthread_create,
[pthread pthreads pthreadVC2],
,
[AC_MSG_ERROR(pthread functions not found)]
)
AC_CACHE_CHECK(for utimes, ac_cv_utimes, [AC_LINK_IFELSE([[
#include <sys/types.h>
#include <sys/time.h>
#include <utime.h>
struct timeval tv[2];
int res;
int main (void)
{
res = utimes ("/", tv);
return 0;
}
]],ac_cv_utimes=yes,ac_cv_utimes=no)])
test $ac_cv_utimes = yes && AC_DEFINE(HAVE_UTIMES, 1, utimes(2) is available)
AC_CACHE_CHECK(for futimes, ac_cv_futimes, [AC_LINK_IFELSE([[
#include <sys/types.h>
#include <sys/time.h>
#include <utime.h>
struct timeval tv[2];
int res;
int fd;
int main (void)
{
res = futimes (fd, tv);
return 0;
}
]],ac_cv_futimes=yes,ac_cv_futimes=no)])
test $ac_cv_futimes = yes && AC_DEFINE(HAVE_FUTIMES, 1, futimes(2) is available)
AC_CACHE_CHECK(for readahead, ac_cv_readahead, [AC_LINK_IFELSE([
#include <fcntl.h>
int main (void)
{
int fd = 0;
size_t count = 2;
ssize_t res;
res = readahead (fd, 0, count);
return 0;
}
],ac_cv_readahead=yes,ac_cv_readahead=no)])
test $ac_cv_readahead = yes && AC_DEFINE(HAVE_READAHEAD, 1, readahead(2) is available (linux))
AC_CACHE_CHECK(for fdatasync, ac_cv_fdatasync, [AC_LINK_IFELSE([
#include <unistd.h>
int main (void)
{
int fd = 0;
fdatasync (fd);
return 0;
}
],ac_cv_fdatasync=yes,ac_cv_fdatasync=no)])
test $ac_cv_fdatasync = yes && AC_DEFINE(HAVE_FDATASYNC, 1, fdatasync(2) is available)
AC_CACHE_CHECK(for pread and pwrite, ac_cv_preadwrite, [AC_LINK_IFELSE([
#include <unistd.h>
int main (void)
{
int fd = 0;
size_t count = 1;
char buf;
off_t offset = 1;
ssize_t res;
res = pread (fd, &buf, count, offset);
res = pwrite (fd, &buf, count, offset);
return 0;
}
],ac_cv_preadwrite=yes,ac_cv_preadwrite=no)])
test $ac_cv_preadwrite = yes && AC_DEFINE(HAVE_PREADWRITE, 1, pread(2) and pwrite(2) are available)
AC_CACHE_CHECK(for sendfile, ac_cv_sendfile, [AC_LINK_IFELSE([
# include <sys/types.h>
#if __linux
# include <sys/sendfile.h>
#elif __FreeBSD__ || defined __APPLE__
# include <sys/socket.h>
# include <sys/uio.h>
#elif __hpux
# include <sys/socket.h>
#else
# error unsupported architecture
#endif
int main (void)
{
int fd = 0;
off_t offset = 1;
size_t count = 2;
ssize_t res;
#if __linux
res = sendfile (fd, fd, offset, count);
#elif __FreeBSD__
res = sendfile (fd, fd, offset, count, 0, &offset, 0);
#elif __hpux
res = sendfile (fd, fd, offset, count, 0, 0);
#endif
return 0;
}
],ac_cv_sendfile=yes,ac_cv_sendfile=no)])
test $ac_cv_sendfile = yes && AC_DEFINE(HAVE_SENDFILE, 1, sendfile(2) is available and supported)
AC_CACHE_CHECK(for sync_file_range, ac_cv_sync_file_range, [AC_LINK_IFELSE([
#include <fcntl.h>
int main (void)
{
int fd = 0;
off64_t offset = 1;
off64_t nbytes = 1;
unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE|SYNC_FILE_RANGE_WAIT_AFTER;
ssize_t res;
res = sync_file_range (fd, offset, nbytes, flags);
return 0;
}
],ac_cv_sync_file_range=yes,ac_cv_sync_file_range=no)])
test $ac_cv_sync_file_range = yes && AC_DEFINE(HAVE_SYNC_FILE_RANGE, 1, sync_file_range(2) is available)
AC_CACHE_CHECK(for fallocate, ac_cv_fallocate, [AC_LINK_IFELSE([
#include <fcntl.h>
int main (void)
{
int fd = 0;
int mode = 0;
off_t offset = 1;
off_t len = 1;
int res;
res = fallocate (fd, mode, offset, len);
return 0;
}
],ac_cv_fallocate=yes,ac_cv_fallocate=no)])
test $ac_cv_fallocate = yes && AC_DEFINE(HAVE_FALLOCATE, 1, fallocate(2) is available)
AC_CACHE_CHECK(for sys_syncfs, ac_cv_sys_syncfs, [AC_LINK_IFELSE([
#include <unistd.h>
#include <sys/syscall.h>
int main (void)
{
int res = syscall (__NR_syncfs, (int)0);
}
],ac_cv_sys_syncfs=yes,ac_cv_sys_syncfs=no)])
test $ac_cv_sys_syncfs = yes && AC_DEFINE(HAVE_SYS_SYNCFS, 1, syscall(__NR_syncfs) is available)
AC_CACHE_CHECK(for prctl_set_name, ac_cv_prctl_set_name, [AC_LINK_IFELSE([
#include <sys/prctl.h>
int main (void)
{
char name[] = "test123";
int res = prctl (PR_SET_NAME, (unsigned long)name, 0, 0, 0);
}
],ac_cv_prctl_set_name=yes,ac_cv_prctl_set_name=no)])
test $ac_cv_prctl_set_name = yes && AC_DEFINE(HAVE_PRCTL_SET_NAME, 1, prctl(PR_SET_NAME) is available)
dnl #############################################################################
dnl # these checks exist for the benefit of IO::AIO
dnl at least uclibc defines _POSIX_ADVISORY_INFO without *any* of the required
dnl functionality actually being present. ugh.
AC_CACHE_CHECK(for posix_madvise, ac_cv_posix_madvise, [AC_LINK_IFELSE([
#include <sys/mman.h>
int main (void)
{
int res = posix_madvise ((void *)0, (size_t)0, POSIX_MADV_NORMAL);
int a = POSIX_MADV_SEQUENTIAL;
int b = POSIX_MADV_RANDOM;
int c = POSIX_MADV_WILLNEED;
int d = POSIX_MADV_DONTNEED;
return 0;
}
],ac_cv_posix_madvise=yes,ac_cv_posix_madvise=no)])
test $ac_cv_posix_madvise = yes && AC_DEFINE(HAVE_POSIX_MADVISE, 1, posix_madvise(2) is available)
AC_CACHE_CHECK(for posix_fadvise, ac_cv_posix_fadvise, [AC_LINK_IFELSE([
#define _XOPEN_SOURCE 600
#include <fcntl.h>
int main (void)
{
int res = posix_fadvise ((int)0, (off_t)0, (off_t)0, POSIX_FADV_NORMAL);
int a = POSIX_FADV_SEQUENTIAL;
int b = POSIX_FADV_NOREUSE;
int c = POSIX_FADV_RANDOM;
int d = POSIX_FADV_WILLNEED;
int e = POSIX_FADV_DONTNEED;
return 0;
}
],ac_cv_posix_fadvise=yes,ac_cv_posix_fadvise=no)])
test $ac_cv_posix_fadvise = yes && AC_DEFINE(HAVE_POSIX_FADVISE, 1, posix_fadvise(2) is available)

164
deps/uv/src/unix/eio/xthread.h

@ -1,164 +0,0 @@
#ifndef XTHREAD_H_
#define XTHREAD_H_
/* whether word reads are potentially non-atomic.
* this is conservative, likely most arches this runs
* on have atomic word read/writes.
*/
#ifndef WORDACCESS_UNSAFE
# if __i386 || __x86_64
# define WORDACCESS_UNSAFE 0
# else
# define WORDACCESS_UNSAFE 1
# endif
#endif
/////////////////////////////////////////////////////////////////////////////
#ifdef _WIN32
#include <stdio.h>//D
#include <fcntl.h>
#include <io.h>
#include <time.h>
#include <winsock2.h>
#include <process.h>
#include <windows.h>
#include <pthread.h>
#define sigset_t int
#define sigfillset(a)
#define pthread_sigmask(a,b,c)
#define sigaddset(a,b)
#define sigemptyset(s)
typedef pthread_mutex_t xmutex_t;
#define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
#define X_MUTEX_CREATE(mutex) pthread_mutex_init (&(mutex), 0)
#define X_LOCK(mutex) pthread_mutex_lock (&(mutex))
#define X_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
typedef pthread_cond_t xcond_t;
#define X_COND_INIT PTHREAD_COND_INITIALIZER
#define X_COND_CREATE(cond) pthread_cond_init (&(cond), 0)
#define X_COND_SIGNAL(cond) pthread_cond_signal (&(cond))
#define X_COND_WAIT(cond,mutex) pthread_cond_wait (&(cond), &(mutex))
#define X_COND_TIMEDWAIT(cond,mutex,to) pthread_cond_timedwait (&(cond), &(mutex), &(to))
typedef pthread_t xthread_t;
#define X_THREAD_PROC(name) void *name (void *thr_arg)
#define X_THREAD_ATFORK(a,b,c)
static int
xthread_create (xthread_t *tid, void *(*proc)(void *), void *arg)
{
int retval;
pthread_attr_t attr;
pthread_attr_init (&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
retval = pthread_create (tid, &attr, proc, arg) == 0;
pthread_attr_destroy (&attr);
return retval;
}
#define respipe_read(a,b,c) PerlSock_recv ((a), (b), (c), 0)
#define respipe_write(a,b,c) send ((a), (b), (c), 0)
#define respipe_close(a) PerlSock_closesocket ((a))
#else
/////////////////////////////////////////////////////////////////////////////
#if __linux && !defined(_GNU_SOURCE)
# define _GNU_SOURCE
#endif
/* just in case */
#define _REENTRANT 1
#if __solaris
# define _POSIX_PTHREAD_SEMANTICS 1
/* try to bribe solaris headers into providing a current pthread API
* despite environment being configured for an older version.
*/
# define __EXTENSIONS__ 1
#endif
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <limits.h>
#include <pthread.h>
typedef pthread_mutex_t xmutex_t;
#if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP)
# define X_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
# define X_MUTEX_CREATE(mutex) \
do { \
pthread_mutexattr_t attr; \
pthread_mutexattr_init (&attr); \
pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_ADAPTIVE_NP); \
pthread_mutex_init (&(mutex), &attr); \
} while (0)
#else
# define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
# define X_MUTEX_CREATE(mutex) pthread_mutex_init (&(mutex), 0)
#endif
#define X_LOCK(mutex) pthread_mutex_lock (&(mutex))
#define X_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
typedef pthread_cond_t xcond_t;
#define X_COND_INIT PTHREAD_COND_INITIALIZER
#define X_COND_CREATE(cond) pthread_cond_init (&(cond), 0)
#define X_COND_SIGNAL(cond) pthread_cond_signal (&(cond))
#define X_COND_WAIT(cond,mutex) pthread_cond_wait (&(cond), &(mutex))
#define X_COND_TIMEDWAIT(cond,mutex,to) pthread_cond_timedwait (&(cond), &(mutex), &(to))
typedef pthread_t xthread_t;
#define X_THREAD_PROC(name) static void *name (void *thr_arg)
#define X_THREAD_ATFORK(prepare,parent,child) pthread_atfork (prepare, parent, child)
// the broken bsd's once more
#ifndef PTHREAD_STACK_MIN
# define PTHREAD_STACK_MIN 0
#endif
#ifndef XTHREAD_STACKSIZE
# define XTHREAD_STACKSIZE sizeof (void *) * 4096
#endif
static int
xthread_create (xthread_t *tid, void *(*proc)(void *), void *arg)
{
int retval;
sigset_t fullsigset, oldsigset;
pthread_attr_t attr;
pthread_attr_init (&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN < X_STACKSIZE ? X_STACKSIZE : PTHREAD_STACK_MIN);
#ifdef PTHREAD_SCOPE_PROCESS
pthread_attr_setscope (&attr, PTHREAD_SCOPE_PROCESS);
#endif
sigfillset (&fullsigset);
pthread_sigmask (SIG_SETMASK, &fullsigset, &oldsigset);
retval = pthread_create (tid, &attr, proc, arg) == 0;
pthread_sigmask (SIG_SETMASK, &oldsigset, 0);
pthread_attr_destroy (&attr);
return retval;
}
#define respipe_read(a,b,c) read ((a), (b), (c))
#define respipe_write(a,b,c) write ((a), (b), (c))
#define respipe_close(a) close ((a))
#endif
#endif

1
deps/uv/src/unix/error.c

@ -102,6 +102,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case ENOSPC: return UV_ENOSPC; case ENOSPC: return UV_ENOSPC;
case EROFS: return UV_EROFS; case EROFS: return UV_EROFS;
case ENOMEM: return UV_ENOMEM; case ENOMEM: return UV_ENOMEM;
case EDQUOT: return UV_ENOSPC;
default: return UV_UNKNOWN; default: return UV_UNKNOWN;
} }
UNREACHABLE(); UNREACHABLE();

1174
deps/uv/src/unix/fs.c

File diff suppressed because it is too large

25
deps/uv/src/unix/fsevents.c

@ -66,14 +66,9 @@ void uv__fsevents_cb(uv_async_t* cb, int status) {
handle = cb->data; handle = cb->data;
UV__FSEVENTS_WALK(handle, { UV__FSEVENTS_WALK(handle, {
if (handle->fd != -1) { if (handle->fd != -1)
#ifdef MAC_OS_X_VERSION_10_7 handle->cb(handle, event->path[0] ? event->path : NULL, event->events, 0);
handle->cb(handle, event->path, event->events, 0); });
#else
handle->cb(handle, NULL, event->events, 0);
#endif /* MAC_OS_X_VERSION_10_7 */
}
})
if ((handle->flags & (UV_CLOSING | UV_CLOSED)) == 0 && handle->fd == -1) if ((handle->flags & (UV_CLOSING | UV_CLOSED)) == 0 && handle->fd == -1)
uv__fsevents_close(handle); uv__fsevents_close(handle);
@ -94,6 +89,17 @@ void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
uv_fs_event_t* handle; uv_fs_event_t* handle;
uv__fsevents_event_t* event; uv__fsevents_event_t* event;
ngx_queue_t add_list; ngx_queue_t add_list;
int kFSEventsModified;
int kFSEventsRenamed;
kFSEventsModified = kFSEventStreamEventFlagItemFinderInfoMod |
kFSEventStreamEventFlagItemModified |
kFSEventStreamEventFlagItemInodeMetaMod |
kFSEventStreamEventFlagItemChangeOwner |
kFSEventStreamEventFlagItemXattrMod;
kFSEventsRenamed = kFSEventStreamEventFlagItemCreated |
kFSEventStreamEventFlagItemRemoved |
kFSEventStreamEventFlagItemRenamed;
handle = info; handle = info;
paths = eventPaths; paths = eventPaths;
@ -151,7 +157,8 @@ void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
memcpy(event->path, path, len + 1); memcpy(event->path, path, len + 1);
if (eventFlags[i] & kFSEventStreamEventFlagItemModified) if ((eventFlags[i] & kFSEventsModified) != 0 &&
(eventFlags[i] & kFSEventsRenamed) == 0)
event->events = UV_CHANGE; event->events = UV_CHANGE;
else else
event->events = UV_RENAME; event->events = UV_RENAME;

144
deps/uv/src/unix/getaddrinfo.c

@ -0,0 +1,144 @@
/* 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 <errno.h>
#include <stddef.h> /* NULL */
#include <stdlib.h>
#include <string.h>
static void uv__getaddrinfo_work(struct uv__work* w) {
uv_getaddrinfo_t* req = container_of(w, uv_getaddrinfo_t, work_req);
req->retcode = getaddrinfo(req->hostname,
req->service,
req->hints,
&req->res);
}
static void uv__getaddrinfo_done(struct uv__work* w) {
uv_getaddrinfo_t* req = container_of(w, uv_getaddrinfo_t, work_req);
struct addrinfo *res = req->res;
#if __sun
size_t hostlen = strlen(req->hostname);
#endif
req->res = NULL;
uv__req_unregister(req->loop, req);
/* see initialization in uv_getaddrinfo() */
if (req->hints)
free(req->hints);
else if (req->service)
free(req->service);
else if (req->hostname)
free(req->hostname);
else
assert(0);
if (req->retcode == 0) {
/* OK */
#if EAI_NODATA /* FreeBSD deprecated EAI_NODATA */
} else if (req->retcode == EAI_NONAME || req->retcode == EAI_NODATA) {
#else
} else if (req->retcode == EAI_NONAME) {
#endif
uv__set_sys_error(req->loop, ENOENT); /* FIXME compatibility hack */
#if __sun
} else if (req->retcode == EAI_MEMORY && hostlen >= MAXHOSTNAMELEN) {
uv__set_sys_error(req->loop, ENOENT);
#endif
} else {
req->loop->last_err.code = UV_EADDRINFO;
req->loop->last_err.sys_errno_ = req->retcode;
}
req->cb(req, req->retcode, res);
}
int uv_getaddrinfo(uv_loop_t* loop,
uv_getaddrinfo_t* req,
uv_getaddrinfo_cb cb,
const char* hostname,
const char* service,
const struct addrinfo* hints) {
size_t hostname_len;
size_t service_len;
size_t hints_len;
size_t len;
char* buf;
if (req == NULL || cb == NULL || (hostname == NULL && service == NULL))
return uv__set_artificial_error(loop, UV_EINVAL);
hostname_len = hostname ? strlen(hostname) + 1 : 0;
service_len = service ? strlen(service) + 1 : 0;
hints_len = hints ? sizeof(*hints) : 0;
buf = malloc(hostname_len + service_len + hints_len);
if (buf == NULL)
return uv__set_artificial_error(loop, UV_ENOMEM);
uv__req_init(loop, req, UV_GETADDRINFO);
req->loop = loop;
req->cb = cb;
req->res = NULL;
req->hints = NULL;
req->service = NULL;
req->hostname = NULL;
req->retcode = 0;
/* order matters, see uv_getaddrinfo_done() */
len = 0;
if (hints) {
req->hints = memcpy(buf + len, hints, sizeof(*hints));
len += sizeof(*hints);
}
if (service) {
req->service = memcpy(buf + len, service, service_len);
len += service_len;
}
if (hostname) {
req->hostname = memcpy(buf + len, hostname, hostname_len);
len += hostname_len;
}
uv__work_submit(loop,
&req->work_req,
uv__getaddrinfo_work,
uv__getaddrinfo_done);
return 0;
}
void uv_freeaddrinfo(struct addrinfo* ai) {
if (ai)
freeaddrinfo(ai);
}

13
deps/uv/src/unix/internal.h

@ -23,7 +23,6 @@
#define UV_UNIX_INTERNAL_H_ #define UV_UNIX_INTERNAL_H_
#include "uv-common.h" #include "uv-common.h"
#include "uv-eio.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> /* abort */ #include <stdlib.h> /* abort */
@ -101,11 +100,6 @@ enum {
UV_TCP_SINGLE_ACCEPT = 0x400 /* Only accept() when idle. */ UV_TCP_SINGLE_ACCEPT = 0x400 /* Only accept() when idle. */
}; };
/* loop flags */
enum {
UV_LOOP_EIO_INITIALIZED = 1
};
__attribute__((unused)) __attribute__((unused))
__attribute__((always_inline)) __attribute__((always_inline))
static void uv__req_init(uv_loop_t* loop, uv_req_t* req, uv_req_type type) { static void uv__req_init(uv_loop_t* loop, uv_req_t* req, uv_req_type type) {
@ -165,6 +159,13 @@ unsigned int uv__next_timeout(uv_loop_t* loop);
void uv__signal_close(uv_signal_t* handle); void uv__signal_close(uv_signal_t* handle);
void uv__signal_unregister(uv_loop_t* loop); void uv__signal_unregister(uv_loop_t* loop);
/* thread pool */
void uv__work_submit(uv_loop_t* loop,
struct uv__work *w,
void (*work)(struct uv__work *w),
void (*done)(struct uv__work *w));
void uv__work_done(uv_async_t* handle, int status);
/* platform specific */ /* platform specific */
int uv__platform_loop_init(uv_loop_t* loop, int default_loop); int uv__platform_loop_init(uv_loop_t* loop, int default_loop);
void uv__platform_loop_delete(uv_loop_t* loop); void uv__platform_loop_delete(uv_loop_t* loop);

10
deps/uv/src/unix/linux/linux-core.c

@ -57,6 +57,7 @@
#endif #endif
static char buf[MAXPATHLEN + 1]; static char buf[MAXPATHLEN + 1];
static void* args_mem;
static struct { static struct {
char *str; char *str;
@ -69,6 +70,12 @@ static void read_times(unsigned int numcpus, uv_cpu_info_t* ci);
static unsigned long read_cpufreq(unsigned int cpunum); static unsigned long read_cpufreq(unsigned int cpunum);
__attribute__((destructor))
static void free_args_mem(void) {
free(args_mem); /* keep valgrind happy */
}
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) { int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
loop->inotify_watchers = NULL; loop->inotify_watchers = NULL;
loop->inotify_fd = -1; loop->inotify_fd = -1;
@ -147,11 +154,12 @@ char** uv_setup_args(int argc, char** argv) {
size += (argc + 1) * sizeof(char **); size += (argc + 1) * sizeof(char **);
size += (envc + 1) * sizeof(char **); size += (envc + 1) * sizeof(char **);
if ((s = (char *) malloc(size)) == NULL) { if (NULL == (s = malloc(size))) {
process_title.str = NULL; process_title.str = NULL;
process_title.len = 0; process_title.len = 0;
return argv; return argv;
} }
args_mem = s;
new_argv = (char **) s; new_argv = (char **) s;
new_env = new_argv + argc + 1; new_env = new_argv + argc + 1;

27
deps/uv/src/unix/loop.c

@ -38,8 +38,8 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) {
#endif #endif
memset(loop, 0, sizeof(*loop)); memset(loop, 0, sizeof(*loop));
RB_INIT(&loop->timer_handles); RB_INIT(&loop->timer_handles);
ngx_queue_init(&loop->wq);
ngx_queue_init(&loop->active_reqs); ngx_queue_init(&loop->active_reqs);
ngx_queue_init(&loop->idle_handles); ngx_queue_init(&loop->idle_handles);
ngx_queue_init(&loop->async_handles); ngx_queue_init(&loop->async_handles);
@ -54,7 +54,6 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) {
loop->emfile_fd = -1; loop->emfile_fd = -1;
loop->ev = (default_loop ? ev_default_loop : ev_loop_new)(flags); loop->ev = (default_loop ? ev_default_loop : ev_loop_new)(flags);
ev_set_userdata(loop->ev, loop); ev_set_userdata(loop->ev, loop);
eio_channel_init(&loop->uv_eio_channel, loop);
uv_signal_init(loop, &loop->child_watcher); uv_signal_init(loop, &loop->child_watcher);
uv__handle_unref(&loop->child_watcher); uv__handle_unref(&loop->child_watcher);
@ -63,6 +62,15 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) {
for (i = 0; i < ARRAY_SIZE(loop->process_handles); i++) for (i = 0; i < ARRAY_SIZE(loop->process_handles); i++)
ngx_queue_init(loop->process_handles + i); ngx_queue_init(loop->process_handles + i);
if (uv_mutex_init(&loop->wq_mutex))
abort();
if (uv_async_init(loop, &loop->wq_async, uv__work_done))
abort();
uv__handle_unref(&loop->wq_async);
loop->wq_async.flags |= UV__HANDLE_INTERNAL;
if (uv__platform_loop_init(loop, default_loop)) if (uv__platform_loop_init(loop, default_loop))
return -1; return -1;
@ -75,8 +83,23 @@ void uv__loop_delete(uv_loop_t* loop) {
uv__signal_unregister(loop); uv__signal_unregister(loop);
ev_loop_destroy(loop->ev); ev_loop_destroy(loop->ev);
if (loop->async_pipefd[0] != -1) {
close(loop->async_pipefd[0]);
loop->async_pipefd[0] = -1;
}
if (loop->async_pipefd[1] != -1) {
close(loop->async_pipefd[1]);
loop->async_pipefd[1] = -1;
}
if (loop->emfile_fd != -1) { if (loop->emfile_fd != -1) {
close(loop->emfile_fd); close(loop->emfile_fd);
loop->emfile_fd = -1; loop->emfile_fd = -1;
} }
uv_mutex_lock(&loop->wq_mutex);
assert(ngx_queue_empty(&loop->wq) && "thread pool work queue not empty!");
uv_mutex_unlock(&loop->wq_mutex);
uv_mutex_destroy(&loop->wq_mutex);
} }

2
deps/uv/src/unix/stream.c

@ -101,6 +101,8 @@ void uv__stream_init(uv_loop_t* loop,
uv_stream_t* stream, uv_stream_t* stream,
uv_handle_type type) { uv_handle_type type) {
uv__handle_init(loop, (uv_handle_t*)stream, type); uv__handle_init(loop, (uv_handle_t*)stream, type);
stream->read_cb = NULL;
stream->read2_cb = NULL;
stream->alloc_cb = NULL; stream->alloc_cb = NULL;
stream->close_cb = NULL; stream->close_cb = NULL;
stream->connection_cb = NULL; stream->connection_cb = NULL;

112
deps/uv/src/unix/thread.c

@ -26,6 +26,12 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#if defined(__APPLE__) && defined(__MACH__)
#include <sys/time.h>
#endif /* defined(__APPLE__) && defined(__MACH__) */
#undef NANOSEC
#define NANOSEC ((uint64_t) 1e9)
int uv_thread_join(uv_thread_t *tid) { int uv_thread_join(uv_thread_t *tid) {
if (pthread_join(*tid, NULL)) if (pthread_join(*tid, NULL))
@ -258,3 +264,109 @@ int uv_sem_trywait(uv_sem_t* sem) {
} }
#endif /* defined(__APPLE__) && defined(__MACH__) */ #endif /* defined(__APPLE__) && defined(__MACH__) */
#if defined(__APPLE__) && defined(__MACH__)
int uv_cond_init(uv_cond_t* cond) {
if (pthread_cond_init(cond, NULL))
return -1;
else
return 0;
}
#else /* !(defined(__APPLE__) && defined(__MACH__)) */
int uv_cond_init(uv_cond_t* cond) {
pthread_condattr_t attr;
if (pthread_condattr_init(&attr))
return -1;
if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
goto error2;
if (pthread_cond_init(cond, &attr))
goto error2;
if (pthread_condattr_destroy(&attr))
goto error;
return 0;
error:
pthread_cond_destroy(cond);
error2:
pthread_condattr_destroy(&attr);
return -1;
}
#endif /* defined(__APPLE__) && defined(__MACH__) */
void uv_cond_destroy(uv_cond_t* cond) {
if (pthread_cond_destroy(cond))
abort();
}
void uv_cond_signal(uv_cond_t* cond) {
if (pthread_cond_signal(cond))
abort();
}
void uv_cond_broadcast(uv_cond_t* cond) {
if (pthread_cond_broadcast(cond))
abort();
}
void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
if (pthread_cond_wait(cond, mutex))
abort();
}
#if defined(__APPLE__) && defined(__MACH__)
int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
int r;
struct timeval tv;
struct timespec ts;
uint64_t abstime;
gettimeofday(&tv, NULL);
abstime = tv.tv_sec * 1e9 + tv.tv_usec * 1e3 + timeout;
ts.tv_sec = abstime / NANOSEC;
ts.tv_nsec = abstime % NANOSEC;
r = pthread_cond_timedwait(cond, mutex, &ts);
if (r == 0)
return 0;
if (r == ETIMEDOUT)
return -1;
abort();
return -1; /* Satisfy the compiler. */
}
#else /* !(defined(__APPLE__) && defined(__MACH__)) */
int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
int r;
struct timespec ts;
uint64_t abstime;
abstime = uv_hrtime() + timeout;
ts.tv_sec = abstime / NANOSEC;
ts.tv_nsec = abstime % NANOSEC;
r = pthread_cond_timedwait(cond, mutex, &ts);
if (r == 0)
return 0;
if (r == ETIMEDOUT)
return -1;
abort();
return -1; /* Satisfy the compiler. */
}
#endif /* defined(__APPLE__) && defined(__MACH__) */

176
deps/uv/src/unix/threadpool.c

@ -0,0 +1,176 @@
/* 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 "internal.h"
#include <errno.h>
#include <pthread.h>
/* TODO add condvar support to libuv */
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_t threads[4];
static ngx_queue_t exit_message;
static ngx_queue_t wq = { &wq, &wq };
static void* worker(void* arg) {
struct uv__work* w;
ngx_queue_t* q;
(void) arg;
for (;;) {
if (pthread_mutex_lock(&mutex))
abort();
while (ngx_queue_empty(&wq))
if (pthread_cond_wait(&cond, &mutex))
abort();
q = ngx_queue_head(&wq);
if (q == &exit_message)
pthread_cond_signal(&cond);
else
ngx_queue_remove(q);
if (pthread_mutex_unlock(&mutex))
abort();
if (q == &exit_message)
break;
w = ngx_queue_data(q, struct uv__work, wq);
w->work(w);
uv_mutex_lock(&w->loop->wq_mutex);
ngx_queue_insert_tail(&w->loop->wq, &w->wq);
uv_mutex_unlock(&w->loop->wq_mutex);
uv_async_send(&w->loop->wq_async);
}
return NULL;
}
static void post(ngx_queue_t* q) {
pthread_mutex_lock(&mutex);
ngx_queue_insert_tail(&wq, q);
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
}
static void init_once(void) {
unsigned int i;
ngx_queue_init(&wq);
for (i = 0; i < ARRAY_SIZE(threads); i++)
if (pthread_create(threads + i, NULL, worker, NULL))
abort();
}
__attribute__((destructor))
static void cleanup(void) {
unsigned int i;
int err;
post(&exit_message);
for (i = 0; i < ARRAY_SIZE(threads); i++) {
err = pthread_join(threads[i], NULL);
assert(err == 0 || err == EINVAL || err == ESRCH);
(void) err; /* Silence compiler warning in release builds. */
}
}
void uv__work_submit(uv_loop_t* loop,
struct uv__work* w,
void (*work)(struct uv__work* w),
void (*done)(struct uv__work* w)) {
pthread_once(&once, init_once);
w->loop = loop;
w->work = work;
w->done = done;
post(&w->wq);
}
void uv__work_done(uv_async_t* handle, int status) {
struct uv__work* w;
uv_loop_t* loop;
ngx_queue_t* q;
ngx_queue_t wq;
loop = container_of(handle, uv_loop_t, wq_async);
ngx_queue_init(&wq);
uv_mutex_lock(&loop->wq_mutex);
if (!ngx_queue_empty(&loop->wq)) {
q = ngx_queue_head(&loop->wq);
ngx_queue_split(&loop->wq, q, &wq);
}
uv_mutex_unlock(&loop->wq_mutex);
while (!ngx_queue_empty(&wq)) {
q = ngx_queue_head(&wq);
ngx_queue_remove(q);
w = container_of(q, struct uv__work, wq);
w->done(w);
}
}
static void uv__queue_work(struct uv__work* w) {
uv_work_t* req = container_of(w, uv_work_t, work_req);
if (req->work_cb)
req->work_cb(req);
}
static void uv__queue_done(struct uv__work* w) {
uv_work_t* req = container_of(w, uv_work_t, work_req);
uv__req_unregister(req->loop, req);
if (req->after_work_cb)
req->after_work_cb(req);
}
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__req_init(loop, req, UV_WORK);
req->loop = loop;
req->work_cb = work_cb;
req->after_work_cb = after_work_cb;
uv__work_submit(loop, &req->work_req, uv__queue_work, uv__queue_done);
return 0;
}

107
deps/uv/src/unix/uv-eio.c

@ -1,107 +0,0 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/* This file integrates the libuv event loop with the libeio thread pool */
#include "uv.h"
#include "eio.h"
#include "internal.h"
#include <assert.h>
#include <stdio.h>
static uv_once_t uv__eio_init_once_guard = UV_ONCE_INIT;
static void uv_eio_do_poll(uv_idle_t* watcher, int status) {
uv_loop_t* loop = watcher->loop;
assert(watcher == &loop->uv_eio_poller);
if (eio_poll(&loop->uv_eio_channel) != -1)
uv_idle_stop(watcher);
}
/* Called from the main thread. */
static void uv_eio_want_poll_notifier_cb(uv_async_t* watcher, int status) {
uv_loop_t* loop = watcher->loop;
assert(watcher == &loop->uv_eio_want_poll_notifier);
if (eio_poll(&loop->uv_eio_channel) == -1)
uv_idle_start(&loop->uv_eio_poller, uv_eio_do_poll);
}
static void uv_eio_done_poll_notifier_cb(uv_async_t* watcher, int revents) {
uv_loop_t* loop = watcher->loop;
assert(watcher == &loop->uv_eio_done_poll_notifier);
if (eio_poll(&loop->uv_eio_channel) != -1)
uv_idle_stop(&loop->uv_eio_poller);
}
/*
* uv_eio_want_poll() is called from the EIO thread pool each time an EIO
* request (that is, one of the node.fs.* functions) has completed.
*/
static void uv_eio_want_poll(eio_channel *channel) {
/* Signal the main thread that eio_poll need to be processed. */
uv_loop_t* loop = channel->data;
uv_async_send(&loop->uv_eio_want_poll_notifier);
}
static void uv_eio_done_poll(eio_channel *channel) {
/*
* Signal the main thread that we should stop calling eio_poll().
* from the idle watcher.
*/
uv_loop_t* loop = channel->data;
uv_async_send(&loop->uv_eio_done_poll_notifier);
}
static void uv__eio_init(void) {
eio_init(uv_eio_want_poll, uv_eio_done_poll);
}
void uv_eio_init(uv_loop_t* loop) {
if (loop->flags & UV_LOOP_EIO_INITIALIZED) return;
loop->flags |= UV_LOOP_EIO_INITIALIZED;
uv_idle_init(loop, &loop->uv_eio_poller);
uv_idle_start(&loop->uv_eio_poller, uv_eio_do_poll);
loop->uv_eio_poller.flags |= UV__HANDLE_INTERNAL;
loop->uv_eio_want_poll_notifier.data = loop;
uv_async_init(loop,
&loop->uv_eio_want_poll_notifier,
uv_eio_want_poll_notifier_cb);
loop->uv_eio_want_poll_notifier.flags |= UV__HANDLE_INTERNAL;
uv__handle_unref(&loop->uv_eio_want_poll_notifier);
uv_async_init(loop,
&loop->uv_eio_done_poll_notifier,
uv_eio_done_poll_notifier_cb);
loop->uv_eio_done_poll_notifier.flags |= UV__HANDLE_INTERNAL;
uv__handle_unref(&loop->uv_eio_done_poll_notifier);
uv_once(&uv__eio_init_once_guard, uv__eio_init);
}

13
deps/uv/src/unix/uv-eio.h

@ -1,13 +0,0 @@
/* This header is private to libuv */
#ifndef UV_EIO_H_
#define UV_EIO_H_
#include "eio.h"
/*
* Call this function to integrate libeio into the libuv event loop. It is
* safe to call more than once.
* TODO: uv_eio_deinit
*/
void uv_eio_init(uv_loop_t*);
#endif

247
deps/uv/src/win/thread.c

@ -27,6 +27,7 @@
#define HAVE_SRWLOCK_API() (pTryAcquireSRWLockShared != NULL) #define HAVE_SRWLOCK_API() (pTryAcquireSRWLockShared != NULL)
#define HAVE_CONDVAR_API() (pInitializeConditionVariable != NULL)
#ifdef _MSC_VER /* msvc */ #ifdef _MSC_VER /* msvc */
# define inline __inline # define inline __inline
@ -56,6 +57,23 @@ inline static int uv__rwlock_fallback_trywrlock(uv_rwlock_t* rwlock);
inline static void uv__rwlock_fallback_wrunlock(uv_rwlock_t* rwlock); inline static void uv__rwlock_fallback_wrunlock(uv_rwlock_t* rwlock);
inline static int uv_cond_fallback_init(uv_cond_t* cond);
inline static void uv_cond_fallback_destroy(uv_cond_t* cond);
inline static void uv_cond_fallback_signal(uv_cond_t* cond);
inline static void uv_cond_fallback_broadcast(uv_cond_t* cond);
inline static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex);
inline static int uv_cond_fallback_timedwait(uv_cond_t* cond,
uv_mutex_t* mutex, uint64_t timeout);
inline static int uv_cond_condvar_init(uv_cond_t* cond);
inline static void uv_cond_condvar_destroy(uv_cond_t* cond);
inline static void uv_cond_condvar_signal(uv_cond_t* cond);
inline static void uv_cond_condvar_broadcast(uv_cond_t* cond);
inline static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex);
inline static int uv_cond_condvar_timedwait(uv_cond_t* cond,
uv_mutex_t* mutex, uint64_t timeout);
static NOINLINE void uv__once_inner(uv_once_t* guard, static NOINLINE void uv__once_inner(uv_once_t* guard,
void (*callback)(void)) { void (*callback)(void)) {
DWORD result; DWORD result;
@ -81,7 +99,7 @@ static NOINLINE void uv__once_inner(uv_once_t* guard,
} else { } else {
/* We lost the race. Destroy the event we created and wait for the */ /* We lost the race. Destroy the event we created and wait for the */
/* existing one to become signaled. */ /* existing one todv become signaled. */
CloseHandle(created_event); CloseHandle(created_event);
result = WaitForSingleObject(existing_event, INFINITE); result = WaitForSingleObject(existing_event, INFINITE);
assert(result == WAIT_OBJECT_0); assert(result == WAIT_OBJECT_0);
@ -140,6 +158,8 @@ void uv_mutex_unlock(uv_mutex_t* mutex) {
int uv_rwlock_init(uv_rwlock_t* rwlock) { int uv_rwlock_init(uv_rwlock_t* rwlock) {
uv__once_init();
if (HAVE_SRWLOCK_API()) if (HAVE_SRWLOCK_API())
return uv__rwlock_srwlock_init(rwlock); return uv__rwlock_srwlock_init(rwlock);
else else
@ -365,3 +385,228 @@ inline static int uv__rwlock_fallback_trywrlock(uv_rwlock_t* rwlock) {
inline static void uv__rwlock_fallback_wrunlock(uv_rwlock_t* rwlock) { inline static void uv__rwlock_fallback_wrunlock(uv_rwlock_t* rwlock) {
uv_mutex_unlock(&rwlock->fallback_.write_mutex_); uv_mutex_unlock(&rwlock->fallback_.write_mutex_);
} }
/* This condition variable implementation is based on the SetEvent solution
* (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
* We could not use the SignalObjectAndWait solution (section 3.4) because
* it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and
* uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs.
*/
inline static int uv_cond_fallback_init(uv_cond_t* cond) {
/* Initialize the count to 0. */
cond->fallback.waiters_count = 0;
InitializeCriticalSection(&cond->fallback.waiters_count_lock);
/* Create an auto-reset event. */
cond->fallback.signal_event = CreateEvent(NULL, /* no security */
FALSE, /* auto-reset event */
FALSE, /* non-signaled initially */
NULL); /* unnamed */
if (!cond->fallback.signal_event)
goto error2;
/* Create a manual-reset event. */
cond->fallback.broadcast_event = CreateEvent(NULL, /* no security */
TRUE, /* manual-reset */
FALSE, /* non-signaled */
NULL); /* unnamed */
if (!cond->fallback.broadcast_event)
goto error;
return 0;
error:
CloseHandle(cond->fallback.signal_event);
error2:
DeleteCriticalSection(&cond->fallback.waiters_count_lock);
return -1;
}
inline static int uv_cond_condvar_init(uv_cond_t* cond) {
pInitializeConditionVariable(&cond->cond_var);
return 0;
}
int uv_cond_init(uv_cond_t* cond) {
uv__once_init();
if (HAVE_CONDVAR_API())
return uv_cond_condvar_init(cond);
else
return uv_cond_fallback_init(cond);
}
inline static void uv_cond_fallback_destroy(uv_cond_t* cond) {
if (!CloseHandle(cond->fallback.broadcast_event))
abort();
if (!CloseHandle(cond->fallback.signal_event))
abort();
DeleteCriticalSection(&cond->fallback.waiters_count_lock);
}
inline static void uv_cond_condvar_destroy(uv_cond_t* cond) {
/* nothing to do */
}
void uv_cond_destroy(uv_cond_t* cond) {
if (HAVE_CONDVAR_API())
uv_cond_condvar_destroy(cond);
else
uv_cond_fallback_destroy(cond);
}
inline static void uv_cond_fallback_signal(uv_cond_t* cond) {
int have_waiters;
/* Avoid race conditions. */
EnterCriticalSection(&cond->fallback.waiters_count_lock);
have_waiters = cond->fallback.waiters_count > 0;
LeaveCriticalSection(&cond->fallback.waiters_count_lock);
if (have_waiters)
SetEvent(cond->fallback.signal_event);
}
inline static void uv_cond_condvar_signal(uv_cond_t* cond) {
pWakeConditionVariable(&cond->cond_var);
}
void uv_cond_signal(uv_cond_t* cond) {
if (HAVE_CONDVAR_API())
uv_cond_condvar_signal(cond);
else
uv_cond_fallback_signal(cond);
}
inline static void uv_cond_fallback_broadcast(uv_cond_t* cond) {
int have_waiters;
/* Avoid race conditions. */
EnterCriticalSection(&cond->fallback.waiters_count_lock);
have_waiters = cond->fallback.waiters_count > 0;
LeaveCriticalSection(&cond->fallback.waiters_count_lock);
if (have_waiters)
SetEvent(cond->fallback.broadcast_event);
}
inline static void uv_cond_condvar_broadcast(uv_cond_t* cond) {
pWakeAllConditionVariable(&cond->cond_var);
}
void uv_cond_broadcast(uv_cond_t* cond) {
if (HAVE_CONDVAR_API())
uv_cond_condvar_broadcast(cond);
else
uv_cond_fallback_broadcast(cond);
}
inline int uv_cond_wait_helper(uv_cond_t* cond, uv_mutex_t* mutex,
DWORD dwMilliseconds) {
DWORD result;
int last_waiter;
HANDLE handles[2] = {
cond->fallback.signal_event,
cond->fallback.broadcast_event
};
/* Avoid race conditions. */
EnterCriticalSection(&cond->fallback.waiters_count_lock);
cond->fallback.waiters_count++;
LeaveCriticalSection(&cond->fallback.waiters_count_lock);
/* It's ok to release the <mutex> here since Win32 manual-reset events */
/* maintain state when used with <SetEvent>. This avoids the "lost wakeup" */
/* bug. */
uv_mutex_unlock(mutex);
/* Wait for either event to become signaled due to <uv_cond_signal> being */
/* called or <uv_cond_broadcast> being called. */
result = WaitForMultipleObjects(2, handles, FALSE, dwMilliseconds);
EnterCriticalSection(&cond->fallback.waiters_count_lock);
cond->fallback.waiters_count--;
last_waiter = result == WAIT_OBJECT_0 + 1
&& cond->fallback.waiters_count == 0;
LeaveCriticalSection(&cond->fallback.waiters_count_lock);
/* Some thread called <pthread_cond_broadcast>. */
if (last_waiter) {
/* We're the last waiter to be notified or to stop waiting, so reset the */
/* the manual-reset event. */
ResetEvent(cond->fallback.broadcast_event);
}
/* Reacquire the <mutex>. */
uv_mutex_lock(mutex);
if (result == WAIT_OBJECT_0 || result == WAIT_OBJECT_0 + 1)
return 0;
if (result == WAIT_TIMEOUT)
return -1;
abort();
return -1; /* Satisfy the compiler. */
}
inline static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
if (uv_cond_wait_helper(cond, mutex, INFINITE))
abort();
}
inline static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
if (!pSleepConditionVariableCS(&cond->cond_var, mutex, INFINITE))
abort();
}
void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
if (HAVE_CONDVAR_API())
uv_cond_condvar_wait(cond, mutex);
else
uv_cond_fallback_wait(cond, mutex);
}
inline static int uv_cond_fallback_timedwait(uv_cond_t* cond,
uv_mutex_t* mutex, uint64_t timeout) {
return uv_cond_wait_helper(cond, mutex, (DWORD)(timeout / 1e6));
}
inline static int uv_cond_condvar_timedwait(uv_cond_t* cond,
uv_mutex_t* mutex, uint64_t timeout) {
if (pSleepConditionVariableCS(&cond->cond_var, mutex, (DWORD)(timeout / 1e6)))
return 0;
if (GetLastError() != ERROR_TIMEOUT)
abort();
return -1;
}
int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex,
uint64_t timeout) {
if (HAVE_CONDVAR_API())
return uv_cond_condvar_timedwait(cond, mutex, timeout);
else
return uv_cond_fallback_timedwait(cond, mutex, timeout);
}

20
deps/uv/src/win/winapi.c

@ -45,6 +45,11 @@ sTryAcquireSRWLockShared pTryAcquireSRWLockShared;
sTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive; sTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive;
sReleaseSRWLockShared pReleaseSRWLockShared; sReleaseSRWLockShared pReleaseSRWLockShared;
sReleaseSRWLockExclusive pReleaseSRWLockExclusive; sReleaseSRWLockExclusive pReleaseSRWLockExclusive;
sInitializeConditionVariable pInitializeConditionVariable;
sSleepConditionVariableCS pSleepConditionVariableCS;
sSleepConditionVariableSRW pSleepConditionVariableSRW;
sWakeAllConditionVariable pWakeAllConditionVariable;
sWakeConditionVariable pWakeConditionVariable;
void uv_winapi_init() { void uv_winapi_init() {
@ -129,4 +134,19 @@ void uv_winapi_init() {
pReleaseSRWLockExclusive = (sReleaseSRWLockExclusive) pReleaseSRWLockExclusive = (sReleaseSRWLockExclusive)
GetProcAddress(kernel32_module, "ReleaseSRWLockExclusive"); GetProcAddress(kernel32_module, "ReleaseSRWLockExclusive");
pInitializeConditionVariable = (sInitializeConditionVariable)
GetProcAddress(kernel32_module, "InitializeConditionVariable");
pSleepConditionVariableCS = (sSleepConditionVariableCS)
GetProcAddress(kernel32_module, "SleepConditionVariableCS");
pSleepConditionVariableSRW = (sSleepConditionVariableSRW)
GetProcAddress(kernel32_module, "SleepConditionVariableSRW");
pWakeAllConditionVariable = (sWakeAllConditionVariable)
GetProcAddress(kernel32_module, "WakeAllConditionVariable");
pWakeConditionVariable = (sWakeConditionVariable)
GetProcAddress(kernel32_module, "WakeConditionVariable");
} }

24
deps/uv/src/win/winapi.h

@ -4426,6 +4426,25 @@ typedef VOID (WINAPI* sReleaseSRWLockShared)
typedef VOID (WINAPI* sReleaseSRWLockExclusive) typedef VOID (WINAPI* sReleaseSRWLockExclusive)
(PSRWLOCK SRWLock); (PSRWLOCK SRWLock);
typedef VOID (WINAPI* sInitializeConditionVariable)
(PCONDITION_VARIABLE ConditionVariable);
typedef BOOL (WINAPI* sSleepConditionVariableCS)
(PCONDITION_VARIABLE ConditionVariable,
PCRITICAL_SECTION CriticalSection,
DWORD dwMilliseconds);
typedef BOOL (WINAPI* sSleepConditionVariableSRW)
(PCONDITION_VARIABLE ConditionVariable,
PSRWLOCK SRWLock,
DWORD dwMilliseconds,
ULONG Flags);
typedef VOID (WINAPI* sWakeAllConditionVariable)
(PCONDITION_VARIABLE ConditionVariable);
typedef VOID (WINAPI* sWakeConditionVariable)
(PCONDITION_VARIABLE ConditionVariable);
/* Ntdll function pointers */ /* Ntdll function pointers */
@ -4448,5 +4467,10 @@ extern sTryAcquireSRWLockShared pTryAcquireSRWLockShared;
extern sTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive; extern sTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive;
extern sReleaseSRWLockShared pReleaseSRWLockShared; extern sReleaseSRWLockShared pReleaseSRWLockShared;
extern sReleaseSRWLockExclusive pReleaseSRWLockExclusive; extern sReleaseSRWLockExclusive pReleaseSRWLockExclusive;
extern sInitializeConditionVariable pInitializeConditionVariable;
extern sSleepConditionVariableCS pSleepConditionVariableCS;
extern sSleepConditionVariableSRW pSleepConditionVariableSRW;
extern sWakeAllConditionVariable pWakeAllConditionVariable;
extern sWakeConditionVariable pWakeConditionVariable;
#endif /* UV_WIN_WINAPI_H_ */ #endif /* UV_WIN_WINAPI_H_ */

1
deps/uv/test/benchmark-multi-accept.c

@ -415,7 +415,6 @@ static int test_tcp(unsigned int num_servers, unsigned int num_clients) {
free(clients); free(clients);
free(servers); free(servers);
uv_loop_delete(uv_default_loop()); /* Silence valgrind. */
return 0; return 0;
} }

34
deps/uv/test/runner-unix.c

@ -55,8 +55,13 @@ void platform_init(int argc, char **argv) {
/* Invoke "argv[0] test-name [test-part]". Store process info in *p. */ /* Invoke "argv[0] test-name [test-part]". Store process info in *p. */
/* Make sure that all stdio output of the processes is buffered up. */ /* Make sure that all stdio output of the processes is buffered up. */
int process_start(char* name, char* part, process_info_t* p) { int process_start(char* name, char* part, process_info_t* p, int is_helper) {
FILE* stdout_file = tmpfile(); FILE* stdout_file;
const char* arg;
char* args[16];
int n;
stdout_file = tmpfile();
if (!stdout_file) { if (!stdout_file) {
perror("tmpfile"); perror("tmpfile");
return -1; return -1;
@ -68,17 +73,34 @@ int process_start(char* name, char* part, process_info_t* p) {
pid_t pid = fork(); pid_t pid = fork();
if (pid < 0) { if (pid < 0) {
perror("vfork"); perror("fork");
return -1; return -1;
} }
if (pid == 0) { if (pid == 0) {
/* child */ /* child */
arg = getenv("UV_USE_VALGRIND");
n = 0;
/* Disable valgrind for helpers, it complains about helpers leaking memory.
* They're killed after the test and as such never get a chance to clean up.
*/
if (is_helper == 0 && arg != NULL && atoi(arg) != 0) {
args[n++] = "valgrind";
args[n++] = "--quiet";
args[n++] = "--leak-check=full";
args[n++] = "--show-reachable=yes";
args[n++] = "--error-exitcode=125";
}
args[n++] = executable_path;
args[n++] = name;
args[n++] = part;
args[n++] = NULL;
dup2(fileno(stdout_file), STDOUT_FILENO); dup2(fileno(stdout_file), STDOUT_FILENO);
dup2(fileno(stdout_file), STDERR_FILENO); dup2(fileno(stdout_file), STDERR_FILENO);
execvp(args[0], args);
char* args[] = { executable_path, name, part, NULL };
execvp(executable_path, args);
perror("execvp()"); perror("execvp()");
_exit(127); _exit(127);
} }

3
deps/uv/test/runner-win.c

@ -24,7 +24,6 @@
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include <process.h> #include <process.h>
#include <windows.h>
#include "task.h" #include "task.h"
#include "runner.h" #include "runner.h"
@ -57,7 +56,7 @@ void platform_init(int argc, char **argv) {
} }
int process_start(char *name, char *part, process_info_t *p) { int process_start(char *name, char *part, process_info_t *p, int is_helper) {
HANDLE file = INVALID_HANDLE_VALUE; HANDLE file = INVALID_HANDLE_VALUE;
HANDLE nul = INVALID_HANDLE_VALUE; HANDLE nul = INVALID_HANDLE_VALUE;
WCHAR path[MAX_PATH], filename[MAX_PATH]; WCHAR path[MAX_PATH], filename[MAX_PATH];

1
deps/uv/test/runner-win.h

@ -26,6 +26,7 @@
#pragma warning(disable : 4996) #pragma warning(disable : 4996)
#include <winsock2.h>
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>

16
deps/uv/test/runner.c

@ -24,6 +24,7 @@
#include "runner.h" #include "runner.h"
#include "task.h" #include "task.h"
#include "uv.h"
char executable_path[PATHMAX] = { '\0' }; char executable_path[PATHMAX] = { '\0' };
@ -147,7 +148,8 @@ int run_test(const char* test, int timeout, int benchmark_output) {
if (process_start(task->task_name, if (process_start(task->task_name,
task->process_name, task->process_name,
&processes[process_count]) == -1) { &processes[process_count],
1 /* is_helper */) == -1) {
snprintf(errmsg, snprintf(errmsg,
sizeof errmsg, sizeof errmsg,
"Process `%s` failed to start.", "Process `%s` failed to start.",
@ -173,7 +175,8 @@ int run_test(const char* test, int timeout, int benchmark_output) {
if (process_start(task->task_name, if (process_start(task->task_name,
task->process_name, task->process_name,
&processes[process_count]) == -1) { &processes[process_count],
0 /* !is_helper */) == -1) {
snprintf(errmsg, snprintf(errmsg,
sizeof errmsg, sizeof errmsg,
"Process `%s` failed to start.", "Process `%s` failed to start.",
@ -291,11 +294,14 @@ out:
*/ */
int run_test_part(const char* test, const char* part) { int run_test_part(const char* test, const char* part) {
task_entry_t* task; task_entry_t* task;
int r;
for (task = TASKS; task->main; task++) { for (task = TASKS; task->main; task++) {
if (strcmp(test, task->task_name) == 0 if (strcmp(test, task->task_name) == 0 &&
&& strcmp(part, task->process_name) == 0) { strcmp(part, task->process_name) == 0) {
return task->main(); r = task->main();
uv_loop_delete(uv_default_loop());
return r;
} }
} }

2
deps/uv/test/runner.h

@ -127,7 +127,7 @@ void platform_init();
/* Invoke "argv[0] test-name [test-part]". Store process info in *p. */ /* Invoke "argv[0] test-name [test-part]". Store process info in *p. */
/* Make sure that all stdio output of the processes is buffered up. */ /* Make sure that all stdio output of the processes is buffered up. */
int process_start(char *name, char* part, process_info_t *p); int process_start(char *name, char* part, process_info_t *p, int is_helper);
/* Wait for all `n` processes in `vec` to terminate. */ /* Wait for all `n` processes in `vec` to terminate. */
/* Time out after `timeout` msec, or never if timeout == -1 */ /* Time out after `timeout` msec, or never if timeout == -1 */

2
deps/uv/test/test-async.c

@ -114,5 +114,7 @@ TEST_IMPL(async) {
ASSERT(async_cb_called == 3); ASSERT(async_cb_called == 3);
ASSERT(close_cb_called == 2); ASSERT(close_cb_called == 2);
ASSERT(0 == uv_thread_join(&thread));
return 0; return 0;
} }

173
deps/uv/test/test-condvar.c

@ -0,0 +1,173 @@
/* 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 "task.h"
#include <string.h>
#include <errno.h>
typedef struct {
uv_mutex_t mutex;
uv_cond_t cond;
int delay;
int use_broadcast;
volatile int posted;
} worker_config;
static void worker(void* arg) {
worker_config* c = arg;
if (c->delay)
uv_sleep(c->delay);
uv_mutex_lock(&c->mutex);
ASSERT(c->posted == 0);
c->posted = 1;
if (c->use_broadcast)
uv_cond_broadcast(&c->cond);
else
uv_cond_signal(&c->cond);
uv_mutex_unlock(&c->mutex);
}
TEST_IMPL(condvar_1) {
uv_thread_t thread;
worker_config wc;
memset(&wc, 0, sizeof(wc));
ASSERT(0 == uv_cond_init(&wc.cond));
ASSERT(0 == uv_mutex_init(&wc.mutex));
ASSERT(0 == uv_thread_create(&thread, worker, &wc));
uv_mutex_lock(&wc.mutex);
uv_sleep(100);
uv_cond_wait(&wc.cond, &wc.mutex);
ASSERT(wc.posted == 1);
uv_mutex_unlock(&wc.mutex);
ASSERT(0 == uv_thread_join(&thread));
uv_mutex_destroy(&wc.mutex);
uv_cond_destroy(&wc.cond);
return 0;
}
TEST_IMPL(condvar_2) {
uv_thread_t thread;
worker_config wc;
memset(&wc, 0, sizeof(wc));
wc.delay = 100;
ASSERT(0 == uv_cond_init(&wc.cond));
ASSERT(0 == uv_mutex_init(&wc.mutex));
ASSERT(0 == uv_thread_create(&thread, worker, &wc));
uv_mutex_lock(&wc.mutex);
uv_cond_wait(&wc.cond, &wc.mutex);
uv_mutex_unlock(&wc.mutex);
ASSERT(0 == uv_thread_join(&thread));
uv_mutex_destroy(&wc.mutex);
uv_cond_destroy(&wc.cond);
return 0;
}
TEST_IMPL(condvar_3) {
uv_thread_t thread;
worker_config wc;
int r;
memset(&wc, 0, sizeof(wc));
wc.delay = 100;
ASSERT(0 == uv_cond_init(&wc.cond));
ASSERT(0 == uv_mutex_init(&wc.mutex));
ASSERT(0 == uv_thread_create(&thread, worker, &wc));
uv_mutex_lock(&wc.mutex);
r = uv_cond_timedwait(&wc.cond, &wc.mutex, (uint64_t)(50 * 1e6));
ASSERT(r == -1);
uv_mutex_unlock(&wc.mutex);
ASSERT(0 == uv_thread_join(&thread));
uv_mutex_destroy(&wc.mutex);
uv_cond_destroy(&wc.cond);
return 0;
}
TEST_IMPL(condvar_4) {
uv_thread_t thread;
worker_config wc;
int r;
memset(&wc, 0, sizeof(wc));
wc.delay = 100;
ASSERT(0 == uv_cond_init(&wc.cond));
ASSERT(0 == uv_mutex_init(&wc.mutex));
ASSERT(0 == uv_thread_create(&thread, worker, &wc));
uv_mutex_lock(&wc.mutex);
r = uv_cond_timedwait(&wc.cond, &wc.mutex, (uint64_t)(150 * 1e6));
ASSERT(r == 0);
uv_mutex_unlock(&wc.mutex);
ASSERT(0 == uv_thread_join(&thread));
uv_mutex_destroy(&wc.mutex);
uv_cond_destroy(&wc.cond);
return 0;
}
TEST_IMPL(condvar_5) {
uv_thread_t thread;
worker_config wc;
memset(&wc, 0, sizeof(wc));
wc.use_broadcast = 1;
ASSERT(0 == uv_cond_init(&wc.cond));
ASSERT(0 == uv_mutex_init(&wc.mutex));
ASSERT(0 == uv_thread_create(&thread, worker, &wc));
uv_mutex_lock(&wc.mutex);
uv_sleep(100);
uv_cond_wait(&wc.cond, &wc.mutex);
ASSERT(wc.posted == 1);
uv_mutex_unlock(&wc.mutex);
ASSERT(0 == uv_thread_join(&thread));
uv_mutex_destroy(&wc.mutex);
uv_cond_destroy(&wc.cond);
return 0;
}

67
deps/uv/test/test-fs-event.c

@ -174,14 +174,13 @@ static void timer_cb_watch_twice(uv_timer_t* handle, int status) {
} }
TEST_IMPL(fs_event_watch_dir) { TEST_IMPL(fs_event_watch_dir) {
uv_fs_t fs_req;
uv_loop_t* loop = uv_default_loop(); uv_loop_t* loop = uv_default_loop();
int r; int r;
/* Setup */ /* Setup */
uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); remove("watch_dir/file2");
uv_fs_unlink(loop, &fs_req, "watch_dir/file2", NULL); remove("watch_dir/file1");
uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); remove("watch_dir/");
create_dir(loop, "watch_dir"); create_dir(loop, "watch_dir");
r = uv_fs_event_init(loop, &fs_event, "watch_dir", fs_event_cb_dir, 0); r = uv_fs_event_init(loop, &fs_event, "watch_dir", fs_event_cb_dir, 0);
@ -198,22 +197,21 @@ TEST_IMPL(fs_event_watch_dir) {
ASSERT(close_cb_called == 2); ASSERT(close_cb_called == 2);
/* Cleanup */ /* Cleanup */
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); remove("watch_dir/file2");
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file2", NULL); remove("watch_dir/file1");
r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); remove("watch_dir/");
return 0; return 0;
} }
TEST_IMPL(fs_event_watch_file) { TEST_IMPL(fs_event_watch_file) {
uv_fs_t fs_req;
uv_loop_t* loop = uv_default_loop(); uv_loop_t* loop = uv_default_loop();
int r; int r;
/* Setup */ /* Setup */
uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); remove("watch_dir/file2");
uv_fs_unlink(loop, &fs_req, "watch_dir/file2", NULL); remove("watch_dir/file1");
uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); remove("watch_dir/");
create_dir(loop, "watch_dir"); create_dir(loop, "watch_dir");
create_file(loop, "watch_dir/file1"); create_file(loop, "watch_dir/file1");
create_file(loop, "watch_dir/file2"); create_file(loop, "watch_dir/file2");
@ -232,9 +230,9 @@ TEST_IMPL(fs_event_watch_file) {
ASSERT(close_cb_called == 2); ASSERT(close_cb_called == 2);
/* Cleanup */ /* Cleanup */
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); remove("watch_dir/file2");
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file2", NULL); remove("watch_dir/file1");
r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); remove("watch_dir/");
return 0; return 0;
} }
@ -260,13 +258,12 @@ TEST_IMPL(fs_event_watch_file_twice) {
TEST_IMPL(fs_event_watch_file_current_dir) { TEST_IMPL(fs_event_watch_file_current_dir) {
uv_timer_t timer; uv_timer_t timer;
uv_loop_t* loop; uv_loop_t* loop;
uv_fs_t fs_req;
int r; int r;
loop = uv_default_loop(); loop = uv_default_loop();
/* Setup */ /* Setup */
uv_fs_unlink(loop, &fs_req, "watch_file", NULL); remove("watch_file");
create_file(loop, "watch_file"); create_file(loop, "watch_file");
r = uv_fs_event_init(loop, &fs_event, "watch_file", r = uv_fs_event_init(loop, &fs_event, "watch_file",
@ -290,19 +287,19 @@ TEST_IMPL(fs_event_watch_file_current_dir) {
ASSERT(close_cb_called == 1); ASSERT(close_cb_called == 1);
/* Cleanup */ /* Cleanup */
r = uv_fs_unlink(loop, &fs_req, "watch_file", NULL); remove("watch_file");
return 0; return 0;
} }
TEST_IMPL(fs_event_no_callback_on_close) { TEST_IMPL(fs_event_no_callback_on_close) {
uv_fs_t fs_req;
uv_loop_t* loop = uv_default_loop(); uv_loop_t* loop = uv_default_loop();
int r; int r;
/* Setup */ /* Setup */
uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); remove("watch_dir/file1");
uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); remove("watch_dir/");
create_dir(loop, "watch_dir"); create_dir(loop, "watch_dir");
create_file(loop, "watch_dir/file1"); create_file(loop, "watch_dir/file1");
@ -321,8 +318,8 @@ TEST_IMPL(fs_event_no_callback_on_close) {
ASSERT(close_cb_called == 1); ASSERT(close_cb_called == 1);
/* Cleanup */ /* Cleanup */
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); remove("watch_dir/file1");
r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL); remove("watch_dir/");
return 0; return 0;
} }
@ -370,7 +367,6 @@ TEST_IMPL(fs_event_immediate_close) {
TEST_IMPL(fs_event_close_with_pending_event) { TEST_IMPL(fs_event_close_with_pending_event) {
uv_loop_t* loop; uv_loop_t* loop;
uv_fs_t fs_req;
int r; int r;
loop = uv_default_loop(); loop = uv_default_loop();
@ -391,10 +387,8 @@ TEST_IMPL(fs_event_close_with_pending_event) {
ASSERT(close_cb_called == 1); ASSERT(close_cb_called == 1);
/* Clean up */ /* Clean up */
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file", NULL); remove("watch_dir/file");
ASSERT(r == 0); remove("watch_dir/");
r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL);
ASSERT(r == 0);
return 0; return 0;
} }
@ -427,7 +421,6 @@ static void fs_event_cb_close(uv_fs_event_t* handle, const char* filename,
TEST_IMPL(fs_event_close_in_callback) { TEST_IMPL(fs_event_close_in_callback) {
uv_loop_t* loop; uv_loop_t* loop;
uv_fs_t fs_req;
int r; int r;
loop = uv_default_loop(); loop = uv_default_loop();
@ -455,18 +448,12 @@ TEST_IMPL(fs_event_close_in_callback) {
ASSERT(fs_event_cb_called == 3); ASSERT(fs_event_cb_called == 3);
/* Clean up */ /* Clean up */
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL); remove("watch_dir/file1");
ASSERT(r == 0); remove("watch_dir/file2");
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file2", NULL); remove("watch_dir/file3");
ASSERT(r == 0); remove("watch_dir/file4");
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file3", NULL); remove("watch_dir/file5");
ASSERT(r == 0); remove("watch_dir/");
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file4", NULL);
ASSERT(r == 0);
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file5", NULL);
ASSERT(r == 0);
r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL);
ASSERT(r == 0);
return 0; return 0;
} }

1
deps/uv/test/test-fs-poll.c

@ -140,7 +140,6 @@ TEST_IMPL(fs_poll) {
ASSERT(poll_cb_called == 5); ASSERT(poll_cb_called == 5);
ASSERT(timer_cb_called == 2); ASSERT(timer_cb_called == 2);
ASSERT(close_cb_called == 1); ASSERT(close_cb_called == 1);
uv_loop_delete(loop);
return 0; return 0;
} }

38
deps/uv/test/test-fs.c

@ -53,6 +53,7 @@ typedef struct {
} utime_check_t; } utime_check_t;
static int dummy_cb_count;
static int close_cb_count; static int close_cb_count;
static int create_cb_count; static int create_cb_count;
static int open_cb_count; static int open_cb_count;
@ -127,6 +128,12 @@ void check_permission(const char* filename, int mode) {
} }
static void dummy_cb(uv_fs_t* req) {
(void) req;
dummy_cb_count++;
}
static void link_cb(uv_fs_t* req) { static void link_cb(uv_fs_t* req) {
ASSERT(req->fs_type == UV_FS_LINK); ASSERT(req->fs_type == UV_FS_LINK);
ASSERT(req->result == 0); ASSERT(req->result == 0);
@ -787,7 +794,7 @@ TEST_IMPL(fs_async_dir) {
ASSERT(r == 0); ASSERT(r == 0);
uv_run(loop); uv_run(loop);
r = uv_fs_stat(loop, &stat_req, "test_dir\\", stat_cb); r = uv_fs_stat(loop, &stat_req, "test_dir/", stat_cb);
ASSERT(r == 0); ASSERT(r == 0);
uv_run(loop); uv_run(loop);
@ -795,7 +802,7 @@ TEST_IMPL(fs_async_dir) {
ASSERT(r == 0); ASSERT(r == 0);
uv_run(loop); uv_run(loop);
r = uv_fs_lstat(loop, &stat_req, "test_dir\\", stat_cb); r = uv_fs_lstat(loop, &stat_req, "test_dir/", stat_cb);
ASSERT(r == 0); ASSERT(r == 0);
uv_run(loop); uv_run(loop);
@ -1183,6 +1190,28 @@ TEST_IMPL(fs_link) {
} }
TEST_IMPL(fs_readlink) {
uv_fs_t req;
loop = uv_default_loop();
ASSERT(0 == uv_fs_readlink(loop, &req, "no_such_file", dummy_cb));
ASSERT(0 == uv_run(loop));
ASSERT(dummy_cb_count == 1);
ASSERT(req.ptr == NULL);
ASSERT(req.result == -1);
ASSERT(req.errorno == UV_ENOENT);
uv_fs_req_cleanup(&req);
ASSERT(-1 == uv_fs_readlink(loop, &req, "no_such_file", NULL));
ASSERT(req.ptr == NULL);
ASSERT(req.result == -1);
ASSERT(req.errorno == UV_ENOENT);
uv_fs_req_cleanup(&req);
return 0;
}
TEST_IMPL(fs_symlink) { TEST_IMPL(fs_symlink) {
int r; int r;
uv_fs_t req; uv_fs_t req;
@ -1251,6 +1280,8 @@ TEST_IMPL(fs_symlink) {
r = uv_fs_symlink(loop, &req, "test_file_symlink", "test_file_symlink_symlink", 0, NULL); r = uv_fs_symlink(loop, &req, "test_file_symlink", "test_file_symlink_symlink", 0, NULL);
ASSERT(r != -1); ASSERT(r != -1);
uv_fs_req_cleanup(&req);
r = uv_fs_readlink(loop, &req, "test_file_symlink_symlink", NULL); r = uv_fs_readlink(loop, &req, "test_file_symlink_symlink", NULL);
ASSERT(r != -1); ASSERT(r != -1);
ASSERT(strcmp(req.ptr, "test_file_symlink") == 0); ASSERT(strcmp(req.ptr, "test_file_symlink") == 0);
@ -1278,6 +1309,8 @@ TEST_IMPL(fs_symlink) {
r = uv_fs_symlink(loop, &req, "test_file_symlink2", "test_file_symlink2_symlink", 0, NULL); r = uv_fs_symlink(loop, &req, "test_file_symlink2", "test_file_symlink2_symlink", 0, NULL);
ASSERT(r != -1); ASSERT(r != -1);
uv_fs_req_cleanup(&req);
r = uv_fs_readlink(loop, &req, "test_file_symlink2_symlink", readlink_cb); r = uv_fs_readlink(loop, &req, "test_file_symlink2_symlink", readlink_cb);
ASSERT(r != -1); ASSERT(r != -1);
uv_run(loop); uv_run(loop);
@ -1608,6 +1641,7 @@ TEST_IMPL(fs_readdir_file) {
r = uv_fs_readdir(loop, &readdir_req, path, 0, NULL); r = uv_fs_readdir(loop, &readdir_req, path, 0, NULL);
ASSERT(r == -1); ASSERT(r == -1);
ASSERT(uv_last_error(loop).code == UV_ENOTDIR); ASSERT(uv_last_error(loop).code == UV_ENOTDIR);
uv_fs_req_cleanup(&readdir_req);
r = uv_fs_readdir(loop, &readdir_req, path, 0, file_readdir_cb); r = uv_fs_readdir(loop, &readdir_req, path, 0, file_readdir_cb);
ASSERT(r == 0); ASSERT(r == 0);

2
deps/uv/test/test-getsockname.c

@ -238,9 +238,9 @@ static void udp_recv(uv_udp_t* handle,
int r; int r;
ASSERT(nread >= 0); ASSERT(nread >= 0);
free(buf.base);
if (nread == 0) { if (nread == 0) {
free(buf.base);
return; return;
} }

12
deps/uv/test/test-list.h

@ -22,6 +22,11 @@
TEST_DECLARE (platform_output) TEST_DECLARE (platform_output)
TEST_DECLARE (callback_order) TEST_DECLARE (callback_order)
TEST_DECLARE (run_once) TEST_DECLARE (run_once)
TEST_DECLARE (condvar_1)
TEST_DECLARE (condvar_2)
TEST_DECLARE (condvar_3)
TEST_DECLARE (condvar_4)
TEST_DECLARE (condvar_5)
TEST_DECLARE (semaphore_1) TEST_DECLARE (semaphore_1)
TEST_DECLARE (semaphore_2) TEST_DECLARE (semaphore_2)
TEST_DECLARE (semaphore_3) TEST_DECLARE (semaphore_3)
@ -152,6 +157,7 @@ TEST_DECLARE (fs_fstat)
TEST_DECLARE (fs_chmod) TEST_DECLARE (fs_chmod)
TEST_DECLARE (fs_chown) TEST_DECLARE (fs_chown)
TEST_DECLARE (fs_link) TEST_DECLARE (fs_link)
TEST_DECLARE (fs_readlink)
TEST_DECLARE (fs_symlink) TEST_DECLARE (fs_symlink)
TEST_DECLARE (fs_symlink_dir) TEST_DECLARE (fs_symlink_dir)
TEST_DECLARE (fs_utime) TEST_DECLARE (fs_utime)
@ -207,6 +213,11 @@ TASK_LIST_START
TEST_ENTRY (callback_order) TEST_ENTRY (callback_order)
#endif #endif
TEST_ENTRY (run_once) TEST_ENTRY (run_once)
TEST_ENTRY (condvar_1)
TEST_ENTRY (condvar_2)
TEST_ENTRY (condvar_3)
TEST_ENTRY (condvar_4)
TEST_ENTRY (condvar_5)
TEST_ENTRY (semaphore_1) TEST_ENTRY (semaphore_1)
TEST_ENTRY (semaphore_2) TEST_ENTRY (semaphore_2)
TEST_ENTRY (semaphore_3) TEST_ENTRY (semaphore_3)
@ -405,6 +416,7 @@ TASK_LIST_START
TEST_ENTRY (fs_chown) TEST_ENTRY (fs_chown)
TEST_ENTRY (fs_utime) TEST_ENTRY (fs_utime)
TEST_ENTRY (fs_futime) TEST_ENTRY (fs_futime)
TEST_ENTRY (fs_readlink)
TEST_ENTRY (fs_symlink) TEST_ENTRY (fs_symlink)
TEST_ENTRY (fs_symlink_dir) TEST_ENTRY (fs_symlink_dir)
TEST_ENTRY (fs_stat_missing_path) TEST_ENTRY (fs_stat_missing_path)

33
deps/uv/test/test-ping-pong.c

@ -52,10 +52,7 @@ void pinger_try_read(pinger_t* pinger);
static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) { static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
uv_buf_t buf; return uv_buf_init(malloc(size), size);
buf.base = (char*)malloc(size);
buf.len = size;
return buf;
} }
@ -103,10 +100,7 @@ static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
ASSERT(uv_last_error(uv_default_loop()).code == UV_EOF); ASSERT(uv_last_error(uv_default_loop()).code == UV_EOF);
puts("got EOF"); puts("got EOF");
free(buf.base);
if (buf.base) {
free(buf.base);
}
uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close); uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);
@ -117,17 +111,22 @@ static void pinger_read_cb(uv_stream_t* stream, ssize_t nread, uv_buf_t buf) {
for (i = 0; i < nread; i++) { for (i = 0; i < nread; i++) {
ASSERT(buf.base[i] == PING[pinger->state]); ASSERT(buf.base[i] == PING[pinger->state]);
pinger->state = (pinger->state + 1) % (sizeof(PING) - 1); pinger->state = (pinger->state + 1) % (sizeof(PING) - 1);
if (pinger->state == 0) {
printf("PONG %d\n", pinger->pongs); if (pinger->state != 0)
pinger->pongs++; continue;
if (pinger->pongs < NUM_PINGS) {
pinger_write_ping(pinger); printf("PONG %d\n", pinger->pongs);
} else { pinger->pongs++;
uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);
return; if (pinger->pongs < NUM_PINGS) {
} pinger_write_ping(pinger);
} else {
uv_close((uv_handle_t*)(&pinger->stream.tcp), pinger_on_close);
break;
} }
} }
free(buf.base);
} }

37
deps/uv/test/test-ref.c

@ -36,6 +36,21 @@ static int req_cb_called;
static int connect_cb_called; static int connect_cb_called;
static int write_cb_called; static int write_cb_called;
static int shutdown_cb_called; static int shutdown_cb_called;
static int close_cb_called;
static void close_cb(uv_handle_t* handle) {
close_cb_called++;
}
static void do_close(void* handle) {
close_cb_called = 0;
uv_close((uv_handle_t*)handle, close_cb);
ASSERT(close_cb_called == 0);
uv_run(uv_default_loop());
ASSERT(close_cb_called == 1);
}
static void fail_cb(void) { static void fail_cb(void) {
@ -91,6 +106,7 @@ TEST_IMPL(idle_ref) {
uv_idle_start(&h, NULL); uv_idle_start(&h, NULL);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -100,6 +116,7 @@ TEST_IMPL(async_ref) {
uv_async_init(uv_default_loop(), &h, NULL); uv_async_init(uv_default_loop(), &h, NULL);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -110,6 +127,7 @@ TEST_IMPL(prepare_ref) {
uv_prepare_start(&h, NULL); uv_prepare_start(&h, NULL);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -120,6 +138,7 @@ TEST_IMPL(check_ref) {
uv_check_start(&h, NULL); uv_check_start(&h, NULL);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -136,6 +155,7 @@ TEST_IMPL(unref_in_prepare_cb) {
uv_prepare_init(uv_default_loop(), &h); uv_prepare_init(uv_default_loop(), &h);
uv_prepare_start(&h, prepare_cb); uv_prepare_start(&h, prepare_cb);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -145,6 +165,7 @@ TEST_IMPL(timer_ref) {
uv_timer_init(uv_default_loop(), &h); uv_timer_init(uv_default_loop(), &h);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -155,6 +176,7 @@ TEST_IMPL(timer_ref2) {
uv_timer_start(&h, (uv_timer_cb)fail_cb, 42, 42); uv_timer_start(&h, (uv_timer_cb)fail_cb, 42, 42);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -164,6 +186,7 @@ TEST_IMPL(fs_event_ref) {
uv_fs_event_init(uv_default_loop(), &h, ".", (uv_fs_event_cb)fail_cb, 0); uv_fs_event_init(uv_default_loop(), &h, ".", (uv_fs_event_cb)fail_cb, 0);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -174,6 +197,7 @@ TEST_IMPL(fs_poll_ref) {
uv_fs_poll_start(&h, NULL, ".", 999); uv_fs_poll_start(&h, NULL, ".", 999);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -183,6 +207,7 @@ TEST_IMPL(tcp_ref) {
uv_tcp_init(uv_default_loop(), &h); uv_tcp_init(uv_default_loop(), &h);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -193,6 +218,7 @@ TEST_IMPL(tcp_ref2) {
uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb); uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -206,6 +232,7 @@ TEST_IMPL(tcp_ref3) {
uv_run(uv_default_loop()); uv_run(uv_default_loop());
ASSERT(connect_cb_called == 1); ASSERT(connect_cb_called == 1);
ASSERT(shutdown_cb_called == 1); ASSERT(shutdown_cb_called == 1);
do_close(&h);
return 0; return 0;
} }
@ -220,6 +247,7 @@ TEST_IMPL(tcp_ref4) {
ASSERT(connect_cb_called == 1); ASSERT(connect_cb_called == 1);
ASSERT(write_cb_called == 1); ASSERT(write_cb_called == 1);
ASSERT(shutdown_cb_called == 1); ASSERT(shutdown_cb_called == 1);
do_close(&h);
return 0; return 0;
} }
@ -229,6 +257,7 @@ TEST_IMPL(udp_ref) {
uv_udp_init(uv_default_loop(), &h); uv_udp_init(uv_default_loop(), &h);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -241,6 +270,7 @@ TEST_IMPL(udp_ref2) {
uv_udp_recv_start(&h, (uv_alloc_cb)fail_cb, (uv_udp_recv_cb)fail_cb); uv_udp_recv_start(&h, (uv_alloc_cb)fail_cb, (uv_udp_recv_cb)fail_cb);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -256,6 +286,7 @@ TEST_IMPL(udp_ref3) {
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
ASSERT(req_cb_called == 1); ASSERT(req_cb_called == 1);
do_close(&h);
return 0; return 0;
} }
@ -266,6 +297,7 @@ TEST_IMPL(pipe_ref) {
uv_pipe_init(uv_default_loop(), &h, 0); uv_pipe_init(uv_default_loop(), &h, 0);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -276,6 +308,7 @@ TEST_IMPL(pipe_ref2) {
uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb); uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb);
uv_unref((uv_handle_t*)&h); uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop()); uv_run(uv_default_loop());
do_close(&h);
return 0; return 0;
} }
@ -288,6 +321,7 @@ TEST_IMPL(pipe_ref3) {
uv_run(uv_default_loop()); uv_run(uv_default_loop());
ASSERT(connect_cb_called == 1); ASSERT(connect_cb_called == 1);
ASSERT(shutdown_cb_called == 1); ASSERT(shutdown_cb_called == 1);
do_close(&h);
return 0; return 0;
} }
@ -301,6 +335,7 @@ TEST_IMPL(pipe_ref4) {
ASSERT(connect_cb_called == 1); ASSERT(connect_cb_called == 1);
ASSERT(write_cb_called == 1); ASSERT(write_cb_called == 1);
ASSERT(shutdown_cb_called == 1); ASSERT(shutdown_cb_called == 1);
do_close(&h);
return 0; return 0;
} }
@ -334,5 +369,7 @@ TEST_IMPL(process_ref) {
r = uv_process_kill(&h, /* SIGTERM */ 15); r = uv_process_kill(&h, /* SIGTERM */ 15);
ASSERT(r == 0); ASSERT(r == 0);
do_close(&h);
return 0; return 0;
} }

2
deps/uv/test/test-tcp-writealot.c

@ -145,7 +145,7 @@ TEST_IMPL(tcp_writealot) {
uv_tcp_t client; uv_tcp_t client;
int r; int r;
send_buffer = malloc(TOTAL_BYTES); send_buffer = calloc(1, TOTAL_BYTES);
ASSERT(send_buffer != NULL); ASSERT(send_buffer != NULL);
r = uv_tcp_init(uv_default_loop(), &client); r = uv_tcp_init(uv_default_loop(), &client);

24
deps/uv/uv.gyp

@ -6,7 +6,6 @@
'_LARGEFILE_SOURCE', '_LARGEFILE_SOURCE',
'_FILE_OFFSET_BITS=64', '_FILE_OFFSET_BITS=64',
'_GNU_SOURCE', '_GNU_SOURCE',
'EIO_STACKSIZE=262144'
], ],
'conditions': [ 'conditions': [
['OS=="solaris"', { ['OS=="solaris"', {
@ -53,7 +52,6 @@
[ 'OS=="win"', { [ 'OS=="win"', {
'defines': [ 'defines': [
'_WIN32_WINNT=0x0600', '_WIN32_WINNT=0x0600',
'EIO_STACKSIZE=262144',
'_GNU_SOURCE', '_GNU_SOURCE',
], ],
'sources': [ 'sources': [
@ -108,7 +106,6 @@
'-Wno-unused-parameter' '-Wno-unused-parameter'
], ],
'sources': [ 'sources': [
'include/uv-private/eio.h',
'include/uv-private/ev.h', 'include/uv-private/ev.h',
'include/uv-private/uv-unix.h', 'include/uv-private/uv-unix.h',
'include/uv-private/uv-linux.h', 'include/uv-private/uv-linux.h',
@ -118,15 +115,13 @@
'src/unix/async.c', 'src/unix/async.c',
'src/unix/core.c', 'src/unix/core.c',
'src/unix/dl.c', 'src/unix/dl.c',
'src/unix/eio/ecb.h',
'src/unix/eio/eio.c',
'src/unix/eio/xthread.h',
'src/unix/error.c', 'src/unix/error.c',
'src/unix/ev/ev.c', 'src/unix/ev/ev.c',
'src/unix/ev/ev_vars.h', 'src/unix/ev/ev_vars.h',
'src/unix/ev/ev_wrap.h', 'src/unix/ev/ev_wrap.h',
'src/unix/ev/event.h', 'src/unix/ev/event.h',
'src/unix/fs.c', 'src/unix/fs.c',
'src/unix/getaddrinfo.c',
'src/unix/internal.h', 'src/unix/internal.h',
'src/unix/loop.c', 'src/unix/loop.c',
'src/unix/loop-watcher.c', 'src/unix/loop-watcher.c',
@ -137,11 +132,10 @@
'src/unix/stream.c', 'src/unix/stream.c',
'src/unix/tcp.c', 'src/unix/tcp.c',
'src/unix/thread.c', 'src/unix/thread.c',
'src/unix/threadpool.c',
'src/unix/timer.c', 'src/unix/timer.c',
'src/unix/tty.c', 'src/unix/tty.c',
'src/unix/udp.c', 'src/unix/udp.c',
'src/unix/uv-eio.c',
'src/unix/uv-eio.h',
], ],
'include_dirs': [ 'src/unix/ev', ], 'include_dirs': [ 'src/unix/ev', ],
'libraries': [ '-lm' ] 'libraries': [ '-lm' ]
@ -156,7 +150,6 @@
'defines': [ 'defines': [
'_DARWIN_USE_64_BIT_INODE=1', '_DARWIN_USE_64_BIT_INODE=1',
'EV_CONFIG_H="config_darwin.h"', 'EV_CONFIG_H="config_darwin.h"',
'EIO_CONFIG_H="config_darwin.h"',
] ]
}], }],
[ 'OS=="linux"', { [ 'OS=="linux"', {
@ -168,7 +161,6 @@
], ],
'defines': [ 'defines': [
'EV_CONFIG_H="config_linux.h"', 'EV_CONFIG_H="config_linux.h"',
'EIO_CONFIG_H="config_linux.h"',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'libraries': [ '-lrt' ], 'libraries': [ '-lrt' ],
@ -180,13 +172,13 @@
'__EXTENSIONS__', '__EXTENSIONS__',
'_XOPEN_SOURCE=500', '_XOPEN_SOURCE=500',
'EV_CONFIG_H="config_sunos.h"', 'EV_CONFIG_H="config_sunos.h"',
'EIO_CONFIG_H="config_sunos.h"',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'libraries': [ 'libraries': [
'-lkstat', '-lkstat',
'-lsocket',
'-lnsl', '-lnsl',
'-lsendfile',
'-lsocket',
], ],
}, },
}], }],
@ -197,7 +189,6 @@
'_ALL_SOURCE', '_ALL_SOURCE',
'_XOPEN_SOURCE=500', '_XOPEN_SOURCE=500',
'EV_CONFIG_H="config_aix.h"', 'EV_CONFIG_H="config_aix.h"',
'EIO_CONFIG_H="config_aix.h"',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'libraries': [ 'libraries': [
@ -209,7 +200,6 @@
'sources': [ 'src/unix/freebsd.c' ], 'sources': [ 'src/unix/freebsd.c' ],
'defines': [ 'defines': [
'EV_CONFIG_H="config_freebsd.h"', 'EV_CONFIG_H="config_freebsd.h"',
'EIO_CONFIG_H="config_freebsd.h"',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'libraries': [ 'libraries': [
@ -221,14 +211,12 @@
'sources': [ 'src/unix/openbsd.c' ], 'sources': [ 'src/unix/openbsd.c' ],
'defines': [ 'defines': [
'EV_CONFIG_H="config_openbsd.h"', 'EV_CONFIG_H="config_openbsd.h"',
'EIO_CONFIG_H="config_openbsd.h"',
], ],
}], }],
[ 'OS=="netbsd"', { [ 'OS=="netbsd"', {
'sources': [ 'src/unix/netbsd.c' ], 'sources': [ 'src/unix/netbsd.c' ],
'defines': [ 'defines': [
'EV_CONFIG_H="config_netbsd.h"', 'EV_CONFIG_H="config_netbsd.h"',
'EIO_CONFIG_H="config_netbsd.h"',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'libraries': [ 'libraries': [
@ -239,6 +227,9 @@
[ 'OS=="mac" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', { [ 'OS=="mac" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
'sources': [ 'src/unix/kqueue.c' ], 'sources': [ 'src/unix/kqueue.c' ],
}], }],
['library=="shared_library"', {
'defines': [ 'BUILDING_UV_SHARED=1' ]
}]
] ]
}, },
@ -314,6 +305,7 @@
'test/test-mutexes.c', 'test/test-mutexes.c',
'test/test-signal.c', 'test/test-signal.c',
'test/test-thread.c', 'test/test-thread.c',
'test/test-condvar.c',
'test/test-timer-again.c', 'test/test-timer-again.c',
'test/test-timer.c', 'test/test-timer.c',
'test/test-tty.c', 'test/test-tty.c',

47
deps/uv/vcbuild.bat

@ -17,6 +17,10 @@ set target=Build
set noprojgen= set noprojgen=
set nobuild= set nobuild=
set run= set run=
set target_arch=ia32
set vs_toolset=x86
set platform=WIN32
set library=static_library
:next-arg :next-arg
if "%1"=="" goto args-done if "%1"=="" goto args-done
@ -27,11 +31,36 @@ if /i "%1"=="bench" set run=run-benchmarks.exe&goto arg-ok
if /i "%1"=="clean" set target=Clean&goto arg-ok if /i "%1"=="clean" set target=Clean&goto arg-ok
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
if /i "%1"=="x86" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
if /i "%1"=="ia32" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
if /i "%1"=="x64" set target_arch=x64&set platform=amd64&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 :arg-ok
shift shift
goto next-arg goto next-arg
:args-done :args-done
@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
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%
echo Warning: building with Visual Studio 2008 is currently not supported.
set GYP_MSVS_VERSION=2008
goto select-target
:vc-set-notfound
echo Warning: Visual Studio not found
:select-target
if not "%config%"=="" goto project-gen if not "%config%"=="" goto project-gen
if "%run%"=="run-tests.exe" set config=Debug& 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 if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen
@ -42,7 +71,6 @@ set config=Debug
if defined noprojgen goto msbuild if defined noprojgen goto msbuild
@rem Generate the VS project. @rem Generate the VS project.
if exist build\gyp goto have_gyp if exist build\gyp goto have_gyp
echo svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp echo svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp
svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp
@ -50,12 +78,12 @@ if errorlevel 1 goto gyp_install_failed
goto have_gyp goto have_gyp
:gyp_install_failed :gyp_install_failed
echo Failed to download gyp. Make sure you have subversion installed, or echo Failed to download gyp. Make sure you have subversion installed, or
echo manually install gyp into %~dp0build\gyp. echo manually install gyp into %~dp0build\gyp.
goto exit goto exit
:have_gyp :have_gyp
python gyp_uv python gyp_uv -Dtarget_arch=%target_arch% -Dlibrary=%library%
if errorlevel 1 goto create-msvs-files-failed if errorlevel 1 goto create-msvs-files-failed
if not exist uv.sln goto create-msvs-files-failed if not exist uv.sln goto create-msvs-files-failed
echo Project files generated. echo Project files generated.
@ -64,12 +92,7 @@ echo Project files generated.
@rem Skip project generation if requested. @rem Skip project generation if requested.
if defined nobuild goto run if defined nobuild goto run
@rem If not running in the VS build env, try to start it. If that fails, bail @rem Check if VS build env is available
@rem out.
if defined VCINSTALLDIR goto msbuild-found
if not defined VS100COMNTOOLS goto msbuild-not-found
if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found
call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat"
if not defined VCINSTALLDIR goto msbuild-not-found if not defined VCINSTALLDIR goto msbuild-not-found
goto msbuild-found goto msbuild-found
@ -79,7 +102,7 @@ goto run
@rem Build the sln with msbuild. @rem Build the sln with msbuild.
:msbuild-found :msbuild-found
msbuild uv.sln /t:%target% /p:Configuration=%config% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto exit if errorlevel 1 goto exit
:run :run
@ -91,11 +114,11 @@ echo running '%config%\%run%'
goto exit goto exit
:create-msvs-files-failed :create-msvs-files-failed
echo Failed to create vc project files. echo Failed to create vc project files.
goto exit goto exit
:help :help
echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared]
echo Examples: echo Examples:
echo vcbuild.bat : builds debug build echo vcbuild.bat : builds debug build
echo vcbuild.bat test : builds debug build and runs tests echo vcbuild.bat test : builds debug build and runs tests

Loading…
Cancel
Save