deps: update libuv to 1.0.1
authorSaúl Ibarra Corretgé <saghul@gmail.com>
Fri, 21 Nov 2014 14:43:12 +0000 (15:43 +0100)
committerBert Belder <bertbelder@gmail.com>
Tue, 9 Dec 2014 16:57:06 +0000 (17:57 +0100)
PR-URL: https://github.com/joyent/node/pull/8785
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
30 files changed:
deps/uv/AUTHORS
deps/uv/CONTRIBUTING.md
deps/uv/ChangeLog
deps/uv/Makefile.am
deps/uv/README.md
deps/uv/common.gypi
deps/uv/configure.ac
deps/uv/docs/src/fs.rst
deps/uv/docs/src/handle.rst
deps/uv/docs/src/index.rst
deps/uv/docs/src/misc.rst
deps/uv/docs/src/request.rst
deps/uv/docs/src/threading.rst
deps/uv/include/uv-version.h
deps/uv/include/uv.h
deps/uv/m4/.gitignore
deps/uv/src/unix/core.c
deps/uv/src/unix/internal.h
deps/uv/src/unix/process.c
deps/uv/src/unix/thread.c
deps/uv/src/unix/tty.c
deps/uv/src/uv-common.c
deps/uv/src/win/fs.c
deps/uv/src/win/thread.c
deps/uv/src/win/util.c
deps/uv/src/win/winsock.h
deps/uv/test/test-fs.c
deps/uv/test/test-list.h
deps/uv/test/test-thread-equal.c [new file with mode: 0644]
deps/uv/uv.gyp

index 6dae58e..72fa470 100644 (file)
@@ -166,3 +166,10 @@ Jeff Widman <jeff@jeffwidman.com>
 cjihrig <cjihrig@gmail.com>
 Tomasz Kołodziejski <tkolodziejski@mozilla.com>
 Unknown W. Brackets <checkins@unknownbrackets.org>
+Emmanuel Odeke <odeke@ualberta.ca>
+Mikhail Mukovnikov <yndi@me.com>
+Thorsten Lorenz <thlorenz@gmx.de>
+Yuri D'Elia <yuri.delia@eurac.edu>
+Manos Nikolaidis <manos@shadowrobot.com>
+Elijah Andrews <elijah@busbud.com>
+Michael Ira Krufky <m.krufky@samsung.com>
index ea4be39..332ed11 100644 (file)
@@ -6,13 +6,13 @@ through the process.
 
 ### FORK
 
-Fork the project [on GitHub](https://github.com/joyent/libuv) and check out
+Fork the project [on GitHub](https://github.com/libuv/libuv) and check out
 your copy.
 
 ```
 $ git clone https://github.com/username/libuv.git
 $ cd libuv
-$ git remote add upstream https://github.com/joyent/libuv.git
+$ git remote add upstream https://github.com/libuv/libuv.git
 ```
 
 Now decide if you want your feature or bug fix to go into the master branch
@@ -160,7 +160,7 @@ feature branch.  Post a comment in the pull request afterwards; GitHub does
 not send out notifications when you add commits.
 
 
-[issue tracker]: https://github.com/joyent/libuv/issues
+[issue tracker]: https://github.com/libuv/libuv/issues
 [libuv mailing list]: http://groups.google.com/group/libuv
 [IRC]: http://webchat.freelibuv.net/?channels=libuv
 [Google C/C++ style guide]: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
index c06c782..78600b7 100644 (file)
@@ -1,3 +1,50 @@
+2014.11.27, Version 1.0.1 (Stable), 0a8e81374e861d425b56c45c8599595d848911d2
+
+Changes since version 1.0.0:
+
+* readme: remove Rust from users (Elijah Andrews)
+
+* doc,build,include: update project links (Ben Noordhuis)
+
+* doc: fix typo: Strcutures -> Structures (Michael Ira Krufky)
+
+* unix: fix processing process handles queue (Saúl Ibarra Corretgé)
+
+* win: replace non-ansi characters in source file (Bert Belder)
+
+
+2014.11.21, Version 1.0.0 (Stable), feb2a9e6947d892f449b2770c4090f7d8c88381b
+
+Changes since version 1.0.0-rc2:
+
+* doc: fix git/svn url for gyp repo in README (Emmanuel Odeke)
+
+* windows: fix fs_read with nbufs > 1 and offset (Unknown W. Brackets)
+
+* win: add missing IP_ADAPTER_UNICAST_ADDRESS_LH definition for MinGW
+  (huxingyi)
+
+* doc: mention homebrew in README (Mikhail Mukovnikov)
+
+* doc: add learnuv workshop to README (Thorsten Lorenz)
+
+* doc: fix parameter name in uv_fs_access (Saúl Ibarra Corretgé)
+
+* unix: use cfmakeraw() for setting raw TTY mode (Yuri D'Elia)
+
+* win: fix uv_thread_self() (Alexis Campailla)
+
+* build: add x32 support to gyp build (Ben Noordhuis)
+
+* build: remove dtrace probes (Ben Noordhuis)
+
+* doc: fix link in misc.rst (Manos Nikolaidis)
+
+* mailmap: remove duplicated entries (Saúl Ibarra Corretgé)
+
+* gyp: fix comment regarding version info location (Saúl Ibarra Corretgé)
+
+
 2014.10.21, Version 1.0.0-rc2 (Pre-release)
 
 Changes since version 1.0.0-rc1:
index 3c6fcb5..371df71 100644 (file)
@@ -206,6 +206,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \
                          test/test-tcp-writealot.c \
                          test/test-tcp-try-write.c \
                          test/test-tcp-write-queue-order.c \
+                         test/test-thread-equal.c \
                          test/test-thread.c \
                          test/test-threadpool-cancel.c \
                          test/test-threadpool.c \
@@ -306,46 +307,7 @@ libuv_la_CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500
 libuv_la_SOURCES += src/unix/sunos.c
 endif
 
-if HAVE_DTRACE
-BUILT_SOURCES = include/uv-dtrace.h
-CLEANFILES += include/uv-dtrace.h
-if FREEBSD
-libuv_la_LDFLAGS += -lelf
-endif
-endif
-
-if DTRACE_NEEDS_OBJECTS
-libuv_la_SOURCES += src/unix/uv-dtrace.d
-libuv_la_DEPENDENCIES = src/unix/uv-dtrace.o
-libuv_la_LIBADD = uv-dtrace.lo
-CLEANFILES += src/unix/uv-dtrace.o src/unix/uv-dtrace.lo
-endif
-
 if HAVE_PKG_CONFIG
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = @PACKAGE_NAME@.pc
 endif
-
-if HAVE_DTRACE
-include/uv-dtrace.h: src/unix/uv-dtrace.d
-       $(AM_V_GEN)$(DTRACE) $(DTRACEFLAGS) -h -xnolibs -s $< -o $(top_srcdir)/$@
-endif
-
-if DTRACE_NEEDS_OBJECTS
-SUFFIXES = .d
-
-src/unix/uv-dtrace.o: src/unix/uv-dtrace.d ${libuv_la_OBJECTS}
-
-# It's ok to specify the output here, because we have 1 .d file, and we process
-# every created .o, most projects don't need to include more than one .d
-.d.o:
-       $(AM_V_GEN)$(DTRACE) $(DTRACEFLAGS) -G -o $(top_builddir)/uv-dtrace.o -s $< \
-               `find ${top_builddir}/src -name "*.o"`
-       $(AM_V_GEN)printf %s\\n \
-               '# ${top_builddir}/uv-dtrace.lo - a libtool object file' \
-               '# Generated by libtool (GNU libtool) 2.4' \
-               '# libtool wants a .lo not a .o' \
-               "pic_object='uv-dtrace.o'" \
-               "non_pic_object='uv-dtrace.o'" \
-       > ${top_builddir}/uv-dtrace.lo
-endif
index 53c1b46..7fc7cfb 100644 (file)
@@ -4,9 +4,8 @@
 
 libuv is a multi-platform support library with a focus on asynchronous I/O. It
 was primarily developed for use by [Node.js](http://nodejs.org), but it's also
-used by Mozilla's [Rust language](http://www.rust-lang.org/),
-[Luvit](http://luvit.io/), [Julia](http://julialang.org/),
-[pyuv](https://github.com/saghul/pyuv), and [others](https://github.com/joyent/libuv/wiki/Projects-that-use-libuv).
+used by [Luvit](http://luvit.io/), [Julia](http://julialang.org/),
+[pyuv](https://github.com/saghul/pyuv), and [others](https://github.com/libuv/libuv/wiki/Projects-that-use-libuv).
 
 ## Feature highlights
 
@@ -78,10 +77,12 @@ Documentation can be browsed online [here](http://docs.libuv.org).
    &mdash; An overview of libuv with tutorials.
  * [LXJS 2012 talk](http://www.youtube.com/watch?v=nGn60vDSxQ4)
    &mdash; High-level introductory talk about libuv.
- * [Tests and benchmarks](https://github.com/joyent/libuv/tree/master/test)
+ * [Tests and benchmarks](https://github.com/libuv/libuv/tree/master/test)
    &mdash; API specification and usage examples.
  * [libuv-dox](https://github.com/thlorenz/libuv-dox)
    &mdash; Documenting types and methods of libuv, mostly by reading uv.h.
+ * [learnuv](https://github.com/thlorenz/learnuv)
+   &mdash; Learn uv for fun and profit, a self guided workshop to libuv.
 
 ## Build Instructions
 
@@ -110,8 +111,9 @@ generate uv.sln as well as related project files.
 To have GYP generate build script for another system, checkout GYP into the
 project tree manually:
 
-    $ mkdir -p build
-    $ git clone https://git.chromium.org/external/gyp.git build/gyp
+    $ git clone https://chromium.googlesource.com/external/gyp.git build/gyp
+    OR
+    $ svn co http://gyp.googlecode.com/svn/trunk build/gyp
 
 ### Unix
 
@@ -120,6 +122,8 @@ Run:
     $ ./gyp_uv.py -f make
     $ make -C out
 
+Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries.
+
 ### OS X
 
 Run:
@@ -128,6 +132,10 @@ Run:
     $ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \
          -configuration Release -target All
 
+Using Homebrew:
+
+    $ brew install --HEAD libuv
+
 Note to OS X users:
 
 Make sure that you specify the architecture you wish to build for in the
@@ -173,5 +181,5 @@ See the [guidelines for contributing][].
 [GYP]: http://code.google.com/p/gyp/
 [Python]: https://www.python.org/downloads/
 [Visual Studio Express 2010]: http://www.microsoft.com/visualstudio/eng/products/visual-studio-2010-express
-[guidelines for contributing]: https://github.com/joyent/libuv/blob/master/CONTRIBUTING.md
-[libuv_banner]: https://raw.githubusercontent.com/joyent/libuv/master/img/banner.png
+[guidelines for contributing]: https://github.com/libuv/libuv/blob/master/CONTRIBUTING.md
+[libuv_banner]: https://raw.githubusercontent.com/libuv/libuv/master/img/banner.png
index a0e0eea..a8e2ef4 100644 (file)
             'cflags': [ '-m32' ],
             'ldflags': [ '-m32' ],
           }],
+          [ 'target_arch=="x32"', {
+            'cflags': [ '-mx32' ],
+            'ldflags': [ '-mx32' ],
+          }],
           [ 'OS=="linux"', {
             'cflags': [ '-ansi' ],
           }],
index c6a30e1..247e42b 100644 (file)
@@ -13,7 +13,7 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 AC_PREREQ(2.57)
-AC_INIT([libuv], [1.0.0-rc2], [https://github.com/joyent/libuv/issues])
+AC_INIT([libuv], [1.0.1], [https://github.com/libuv/libuv/issues])
 AC_CONFIG_MACRO_DIR([m4])
 m4_include([m4/libuv-extra-automake-flags.m4])
 m4_include([m4/as_case.m4])
@@ -50,7 +50,6 @@ AM_CONDITIONAL([NETBSD],   [AS_CASE([$host_os],[netbsd*],       [true], [false])
 AM_CONDITIONAL([OPENBSD],  [AS_CASE([$host_os],[openbsd*],      [true], [false])])
 AM_CONDITIONAL([SUNOS],    [AS_CASE([$host_os],[solaris*],      [true], [false])])
 AM_CONDITIONAL([WINNT],    [AS_CASE([$host_os],[mingw*],        [true], [false])])
-PANDORA_ENABLE_DTRACE
 AC_CHECK_PROG(PKG_CONFIG, pkg-config, yes)
 AM_CONDITIONAL([HAVE_PKG_CONFIG], [test "x$PKG_CONFIG" != "x"])
 AS_IF([test "x$PKG_CONFIG" != "x"], [
index cc8f552..27d92d0 100644 (file)
@@ -229,7 +229,7 @@ API
 
     Limited equivalent to ``sendfile(2)``.
 
-.. c:function:: int uv_fs_access(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_cb cb)
+.. c:function:: int uv_fs_access(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb)
 
     Equivalent to ``access(2)`` on Unix. Windows uses ``GetFileAttributesW()``.
 
index 4dcfc3d..6ba597a 100644 (file)
@@ -6,7 +6,7 @@
 
 `uv_handle_t` is the base type for all libuv handle types.
 
-Strcutures are aligned so that any libuv handle can be cast to `uv_handle_t`.
+Structures are aligned so that any libuv handle can be cast to `uv_handle_t`.
 All API functions defined here work with any handle type.
 
 
index ce30cf9..9cdc494 100644 (file)
@@ -6,19 +6,18 @@ Overview
 --------
 
 libuv is a multi-platform support library with a focus on asynchronous I/O. It
-was primarily developed for use by `Node.js`_, but it's also used by Mozilla's
-`Rust language`_, `Luvit`_, `Julia`_, `pyuv`_, and `others`_.
+was primarily developed for use by `Node.js`_, but it's also used by `Luvit`_,
+`Julia`_, `pyuv`_, and `others`_.
 
 .. note::
     In case you find errors in this documentation you can help by sending
-    `pull requests <https://github.com/joyent/libuv>`_!
+    `pull requests <https://github.com/libuv/libuv>`_!
 
 .. _Node.js: http://nodejs.org
-.. _Rust language: http://www.rust-lang.org
 .. _Luvit: http://luvit.io
 .. _Julia: http://julialang.org
 .. _pyuv: https://github.com/saghul/pyuv
-.. _others: https://github.com/joyent/libuv/wiki/Projects-that-use-libuv
+.. _others: https://github.com/libuv/libuv/wiki/Projects-that-use-libuv
 
 
 Features
@@ -47,7 +46,7 @@ libuv can be downloaded from `here <http://dist.libuv.org/dist/>`_.
 Installation
 ------------
 
-Installation instructions can be found on `the README <https://github.com/joyent/libuv/blob/master/README.md>`_.
+Installation instructions can be found on `the README <https://github.com/libuv/libuv/blob/master/README.md>`_.
 
 
 Upgrading
index b313159..1e1125a 100644 (file)
@@ -171,7 +171,7 @@ API
 
 .. c:function:: void uv_loadavg(double avg[3])
 
-    Gets the load average. See: http://en.wikipedia.org/wiki/Load_(computing)
+    Gets the load average. See: `<http://en.wikipedia.org/wiki/Load_(computing)>`_
 
     .. note::
         Returns [0,0,0] on Windows (i.e., it's not implemented).
index 29c1277..2f58d46 100644 (file)
@@ -6,7 +6,7 @@
 
 `uv_req_t` is the base type for all libuv request types.
 
-Strcutures are aligned so that any libuv request can be cast to `uv_req_t`.
+Structures are aligned so that any libuv request can be cast to `uv_req_t`.
 All API functions defined here work with any request type.
 
 
index 38daf4e..aab13f8 100644 (file)
@@ -56,8 +56,9 @@ Threads
 ^^^^^^^
 
 .. c:function:: int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg)
-.. c:function:: unsigned long uv_thread_self(void)
+.. c:function:: uv_thread_t uv_thread_self(void)
 .. c:function:: int uv_thread_join(uv_thread_t *tid)
+.. c:function:: int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2)
 
 Thread-local storage
 ^^^^^^^^^^^^^^^^^^^^
index 2ae3ca7..889abff 100644 (file)
@@ -32,8 +32,8 @@
 
 #define UV_VERSION_MAJOR 1
 #define UV_VERSION_MINOR 0
-#define UV_VERSION_PATCH 0
+#define UV_VERSION_PATCH 1
 #define UV_VERSION_IS_RELEASE 1
-#define UV_VERSION_SUFFIX "rc2"
+#define UV_VERSION_SUFFIX ""
 
 #endif /* UV_VERSION_H */
index ad6bde9..7f4fa6d 100644 (file)
@@ -19,7 +19,7 @@
  * IN THE SOFTWARE.
  */
 
-/* See https://github.com/joyent/libuv#documentation for documentation. */
+/* See https://github.com/libuv/libuv#documentation for documentation. */
 
 #ifndef UV_H
 #define UV_H
@@ -1138,7 +1138,7 @@ UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop,
 UV_EXTERN int uv_fs_access(uv_loop_t* loop,
                            uv_fs_t* req,
                            const char* path,
-                           int flags,
+                           int mode,
                            uv_fs_cb cb);
 UV_EXTERN int uv_fs_chmod(uv_loop_t* loop,
                           uv_fs_t* req,
@@ -1369,8 +1369,9 @@ UV_EXTERN void uv_key_set(uv_key_t* key, void* value);
 typedef void (*uv_thread_cb)(void* arg);
 
 UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);
-UV_EXTERN unsigned long uv_thread_self(void);
+UV_EXTERN uv_thread_t uv_thread_self(void);
 UV_EXTERN int uv_thread_join(uv_thread_t *tid);
+UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2);
 
 /* The presence of these unions force similar struct layout. */
 #define XX(_, name) uv_ ## name ## _t name;
index 9d0f4af..c44e4c2 100644 (file)
@@ -1,5 +1,4 @@
 # Ignore libtoolize-generated files.
 *.m4
 !as_case.m4
-!dtrace.m4
-!libuv-check-flags.m4
\ No newline at end of file
+!libuv-check-flags.m4
index 7add085..e6a0768 100644 (file)
@@ -310,8 +310,6 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) {
     uv__update_time(loop);
 
   while (r != 0 && loop->stop_flag == 0) {
-    UV_TICK_START(loop, mode);
-
     uv__update_time(loop);
     uv__run_timers(loop);
     uv__run_pending(loop);
@@ -340,7 +338,6 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) {
     }
 
     r = uv__loop_alive(loop);
-    UV_TICK_STOP(loop, mode);
 
     if (mode & (UV_RUN_ONCE | UV_RUN_NOWAIT))
       break;
index d5bc310..b94508c 100644 (file)
@@ -306,12 +306,4 @@ UV_UNUSED(static char* uv__basename_r(const char* path)) {
   return s + 1;
 }
 
-
-#ifdef HAVE_DTRACE
-#include "uv-dtrace.h"
-#else
-#define UV_TICK_START(arg0, arg1)
-#define UV_TICK_STOP(arg0, arg1)
-#endif
-
 #endif /* UV_UNIX_INTERNAL_H_ */
index 0aff5fd..be283b4 100644 (file)
@@ -85,9 +85,14 @@ static void uv__chld(uv_signal_t* handle, int signum) {
     QUEUE_INSERT_TAIL(&pending, &process->queue);
   }
 
-  QUEUE_FOREACH(q, &pending) {
+  h = &pending;
+  q = QUEUE_HEAD(h);
+  while (q != h) {
     process = QUEUE_DATA(q, uv_process_t, queue);
-    QUEUE_REMOVE(q);
+    q = QUEUE_NEXT(q);
+
+    QUEUE_REMOVE(&process->queue);
+    QUEUE_INIT(&process->queue);
     uv__handle_stop(process);
 
     if (process->exit_cb == NULL)
index 522426f..7a55bd6 100644 (file)
 #undef NANOSEC
 #define NANOSEC ((uint64_t) 1e9)
 
+
+struct thread_ctx {
+  void (*entry)(void* arg);
+  void* arg;
+};
+
+
+static void* uv__thread_start(void *arg)
+{
+  struct thread_ctx *ctx_p;
+  struct thread_ctx ctx;
+
+  ctx_p = arg;
+  ctx = *ctx_p;
+  free(ctx_p);
+  ctx.entry(ctx.arg);
+
+  return 0;
+}
+
+
+int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
+  struct thread_ctx* ctx;
+  int err;
+
+  ctx = malloc(sizeof(*ctx));
+  if (ctx == NULL)
+    return UV_ENOMEM;
+
+  ctx->entry = entry;
+  ctx->arg = arg;
+
+  err = pthread_create(tid, NULL, uv__thread_start, ctx);
+
+  if (err)
+    free(ctx);
+
+  return err ? -1 : 0;
+}
+
+
+uv_thread_t uv_thread_self(void) {
+  return pthread_self();
+}
+
 int uv_thread_join(uv_thread_t *tid) {
   return -pthread_join(*tid, NULL);
 }
 
 
+int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) {
+  return pthread_equal(*t1, *t2);
+}
+
+
 int uv_mutex_init(uv_mutex_t* mutex) {
 #if defined(NDEBUG) || !defined(PTHREAD_MUTEX_ERRORCHECK)
   return -pthread_mutex_init(mutex, NULL);
index 7ae1990..82fa27c 100644 (file)
@@ -123,12 +123,7 @@ int uv_tty_set_mode(uv_tty_t* tty, int mode) {
     uv_spinlock_unlock(&termios_spinlock);
 
     raw = tty->orig_termios;
-    raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
-    raw.c_oflag |= (ONLCR);
-    raw.c_cflag |= (CS8);
-    raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
-    raw.c_cc[VMIN] = 1;
-    raw.c_cc[VTIME] = 0;
+    cfmakeraw(&raw);
 
     /* Put terminal in raw mode after draining */
     if (tcsetattr(fd, TCSADRAIN, &raw))
index 97727ba..5ba1ea4 100644 (file)
@@ -257,64 +257,6 @@ int uv_udp_recv_stop(uv_udp_t* handle) {
 }
 
 
-struct thread_ctx {
-  void (*entry)(void* arg);
-  void* arg;
-};
-
-
-#ifdef _WIN32
-static UINT __stdcall uv__thread_start(void* arg)
-#else
-static void* uv__thread_start(void *arg)
-#endif
-{
-  struct thread_ctx *ctx_p;
-  struct thread_ctx ctx;
-
-  ctx_p = arg;
-  ctx = *ctx_p;
-  free(ctx_p);
-  ctx.entry(ctx.arg);
-
-  return 0;
-}
-
-
-int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
-  struct thread_ctx* ctx;
-  int err;
-
-  ctx = malloc(sizeof(*ctx));
-  if (ctx == NULL)
-    return UV_ENOMEM;
-
-  ctx->entry = entry;
-  ctx->arg = arg;
-
-#ifdef _WIN32
-  *tid = (HANDLE) _beginthreadex(NULL, 0, uv__thread_start, ctx, 0, NULL);
-  err = *tid ? 0 : errno;
-#else
-  err = pthread_create(tid, NULL, uv__thread_start, ctx);
-#endif
-
-  if (err)
-    free(ctx);
-
-  return err ? -1 : 0;
-}
-
-
-unsigned long uv_thread_self(void) {
-#ifdef _WIN32
-  return (unsigned long) GetCurrentThreadId();
-#else
-  return (unsigned long) pthread_self();
-#endif
-}
-
-
 void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) {
   QUEUE* q;
   uv_handle_t* h;
index 11d20f2..7208a65 100644 (file)
@@ -283,7 +283,7 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
            (w_target[4] >= L'a' && w_target[4] <= L'z')) &&
           w_target[5] == L':' &&
           (w_target_len == 6 || w_target[6] == L'\\')) {
-        /* \??\«drive»:\ */
+        /* \??\<drive>:\ */
         w_target += 4;
         w_target_len -= 4;
 
@@ -292,8 +292,8 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
                  (w_target[5] == L'N' || w_target[5] == L'n') &&
                  (w_target[6] == L'C' || w_target[6] == L'c') &&
                  w_target[7] == L'\\') {
-        /* \??\UNC\«server»\«share»\ - make sure the final path looks like */
-        /* \\«server»\«share»\ */
+        /* \??\UNC\<server>\<share>\ - make sure the final path looks like */
+        /* \\<server>\<share>\ */
         w_target += 6;
         w_target[0] = L'\\';
         w_target_len -= 6;
@@ -308,8 +308,8 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
     w_target_len = reparse_data->MountPointReparseBuffer.SubstituteNameLength /
         sizeof(WCHAR);
 
-    /* Only treat junctions that look like \??\«drive»:\ as symlink. */
-    /* Junctions can also be used as mount points, like \??\Volume{«guid»}, */
+    /* Only treat junctions that look like \??\<drive>:\ as symlink. */
+    /* Junctions can also be used as mount points, like \??\Volume{<guid>}, */
     /* but that's confusing for programs since they wouldn't be able to */
     /* actually understand such a path when returned by uv_readlink(). */
     /* UNC paths are never valid for junctions so we don't care about them. */
@@ -557,11 +557,6 @@ void fs__read(uv_fs_t* req) {
 
   if (offset != -1) {
     memset(&overlapped, 0, sizeof overlapped);
-
-    offset_.QuadPart = offset;
-    overlapped.Offset = offset_.LowPart;
-    overlapped.OffsetHigh = offset_.HighPart;
-
     overlapped_ptr = &overlapped;
   } else {
     overlapped_ptr = NULL;
@@ -571,6 +566,13 @@ void fs__read(uv_fs_t* req) {
   bytes = 0;
   do {
     DWORD incremental_bytes;
+
+    if (offset != -1) {
+      offset_.QuadPart = offset + bytes;
+      overlapped.Offset = offset_.LowPart;
+      overlapped.OffsetHigh = offset_.HighPart;
+    }
+
     result = ReadFile(handle,
                       req->bufs[index].base,
                       req->bufs[index].len,
@@ -623,7 +625,6 @@ void fs__write(uv_fs_t* req) {
   do {
     DWORD incremental_bytes;
 
-    /* WriteFile() does not advance overlapped as ReadFile() does. */
     if (offset != -1) {
       offset_.QuadPart = offset + bytes;
       overlapped.Offset = offset_.LowPart;
index ccc5579..7143743 100644 (file)
@@ -117,6 +117,68 @@ void uv_once(uv_once_t* guard, void (*callback)(void)) {
   uv__once_inner(guard, callback);
 }
 
+static UV_THREAD_LOCAL uv_thread_t uv__current_thread = NULL;
+
+struct thread_ctx {
+  void (*entry)(void* arg);
+  void* arg;
+  uv_thread_t self;
+};
+
+
+static UINT __stdcall uv__thread_start(void* arg)
+{
+  struct thread_ctx *ctx_p;
+  struct thread_ctx ctx;
+
+  ctx_p = arg;
+  ctx = *ctx_p;
+  free(ctx_p);
+
+  uv__current_thread = ctx.self;
+  ctx.entry(ctx.arg);
+
+  return 0;
+}
+
+
+int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
+  struct thread_ctx* ctx;
+  int err;
+  HANDLE thread;
+
+  ctx = malloc(sizeof(*ctx));
+  if (ctx == NULL)
+    return UV_ENOMEM;
+
+  ctx->entry = entry;
+  ctx->arg = arg;
+
+  /* Create the thread in suspended state so we have a chance to pass
+   * its own creation handle to it */
+  thread = (HANDLE) _beginthreadex(NULL,
+                                   0,
+                                   uv__thread_start,
+                                   ctx,
+                                   CREATE_SUSPENDED,
+                                   NULL);
+  if (thread == NULL) {
+    err = errno;
+    free(ctx);
+  } else {
+    err = 0;
+    *tid = thread;
+    ctx->self = thread;
+    ResumeThread(thread);
+  }
+
+  return err;
+}
+
+
+uv_thread_t uv_thread_self(void) {
+  return uv__current_thread;
+}
 
 int uv_thread_join(uv_thread_t *tid) {
   if (WaitForSingleObject(*tid, INFINITE))
@@ -129,6 +191,11 @@ int uv_thread_join(uv_thread_t *tid) {
 }
 
 
+int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) {
+  return *t1 == *t2;
+}
+
+
 int uv_mutex_init(uv_mutex_t* mutex) {
   InitializeCriticalSection(mutex);
   return 0;
index b7dba7b..0bcb721 100644 (file)
@@ -1037,7 +1037,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
 
       /* XP has no OnLinkPrefixLength field. */
       if (is_vista_or_greater) {
-        prefix_len = unicast_address->OnLinkPrefixLength;
+        prefix_len =
+          ((IP_ADAPTER_UNICAST_ADDRESS_LH*) unicast_address)->OnLinkPrefixLength;
       } else {
         /* Prior to Windows Vista the FirstPrefix pointed to the list with
          * single prefix for each IP address assigned to the adapter.
index 957d08e..7c007ab 100644 (file)
@@ -166,6 +166,25 @@ typedef struct _IP_ADAPTER_UNICAST_ADDRESS_XP {
   ULONG LeaseLifetime;
 } IP_ADAPTER_UNICAST_ADDRESS_XP,*PIP_ADAPTER_UNICAST_ADDRESS_XP;
 
+typedef struct _IP_ADAPTER_UNICAST_ADDRESS_LH {
+  union {
+    ULONGLONG Alignment;
+    struct {
+      ULONG Length;
+      DWORD Flags;
+    };
+  };
+  struct _IP_ADAPTER_UNICAST_ADDRESS_LH *Next;
+  SOCKET_ADDRESS Address;
+  IP_PREFIX_ORIGIN PrefixOrigin;
+  IP_SUFFIX_ORIGIN SuffixOrigin;
+  IP_DAD_STATE DadState;
+  ULONG ValidLifetime;
+  ULONG PreferredLifetime;
+  ULONG LeaseLifetime;
+  UINT8 OnLinkPrefixLength;
+} IP_ADAPTER_UNICAST_ADDRESS_LH,*PIP_ADAPTER_UNICAST_ADDRESS_LH;
+
 #endif
 
 #endif /* UV_WIN_WINSOCK_H_ */
index 3e9dcb8..471860a 100644 (file)
@@ -109,6 +109,7 @@ static uv_fs_t utime_req;
 static uv_fs_t futime_req;
 
 static char buf[32];
+static char buf2[32];
 static char test_buf[] = "test-buffer\n";
 static char test_buf2[] = "second-buffer\n";
 static uv_buf_t iov;
@@ -2200,12 +2201,15 @@ TEST_IMPL(fs_write_multiple_bufs) {
   uv_fs_req_cleanup(&open_req1);
 
   memset(buf, 0, sizeof(buf));
-  iov = uv_buf_init(buf, sizeof(buf));
-  r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1, -1, NULL);
+  memset(buf2, 0, sizeof(buf2));
+  /* Read the strings back to separate buffers. */
+  iovs[0] = uv_buf_init(buf, sizeof(test_buf));
+  iovs[1] = uv_buf_init(buf2, sizeof(test_buf2));
+  r = uv_fs_read(loop, &read_req, open_req1.result, iovs, 2, 0, NULL);
   ASSERT(r >= 0);
   ASSERT(read_req.result >= 0);
-  ASSERT(memcmp(buf, test_buf, sizeof(test_buf)) == 0);
-  ASSERT(strcmp(buf + sizeof(test_buf), test_buf2) == 0);
+  ASSERT(strcmp(buf, test_buf) == 0);
+  ASSERT(strcmp(buf2, test_buf2) == 0);
   uv_fs_req_cleanup(&read_req);
 
   iov = uv_buf_init(buf, sizeof(buf));
index 08ba3f8..85ddac8 100644 (file)
@@ -259,6 +259,7 @@ TEST_DECLARE   (thread_local_storage)
 TEST_DECLARE   (thread_mutex)
 TEST_DECLARE   (thread_rwlock)
 TEST_DECLARE   (thread_create)
+TEST_DECLARE   (thread_equal)
 TEST_DECLARE   (dlerror)
 TEST_DECLARE   (poll_duplex)
 TEST_DECLARE   (poll_unidirectional)
@@ -632,6 +633,7 @@ TASK_LIST_START
   TEST_ENTRY  (thread_mutex)
   TEST_ENTRY  (thread_rwlock)
   TEST_ENTRY  (thread_create)
+  TEST_ENTRY  (thread_equal)
   TEST_ENTRY  (dlerror)
   TEST_ENTRY  (ip4_addr)
   TEST_ENTRY  (ip6_addr_link_local)
diff --git a/deps/uv/test/test-thread-equal.c b/deps/uv/test/test-thread-equal.c
new file mode 100644 (file)
index 0000000..27c07ee
--- /dev/null
@@ -0,0 +1,45 @@
+/* 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"
+
+uv_thread_t main_thread_id;
+uv_thread_t subthreads[2];
+
+static void check_thread(void* arg) {
+  uv_thread_t *thread_id = arg;
+  uv_thread_t self_id = uv_thread_self();
+  ASSERT(uv_thread_equal(&main_thread_id, &self_id) == 0);
+  *thread_id = uv_thread_self();
+}
+
+TEST_IMPL(thread_equal) {
+  uv_thread_t threads[2];
+  main_thread_id = uv_thread_self();
+  ASSERT(0 != uv_thread_equal(&main_thread_id, &main_thread_id));
+  ASSERT(0 == uv_thread_create(threads + 0, check_thread, subthreads + 0));
+  ASSERT(0 == uv_thread_create(threads + 1, check_thread, subthreads + 1));
+  ASSERT(0 == uv_thread_join(threads + 0));
+  ASSERT(0 == uv_thread_join(threads + 1));
+  ASSERT(0 == uv_thread_equal(subthreads + 0, subthreads + 1));
+  return 0;
+}
index 444182b..a5ba14c 100644 (file)
@@ -1,14 +1,4 @@
 {
-  'variables': {
-    'uv_use_dtrace%': 'false',
-    # uv_parent_path is the relative path to libuv in the parent project
-    # this is only relevant when dtrace is enabled and libuv is a child project
-    # as it's necessary to correctly locate the object files for post
-    # processing.
-    # XXX gyp is quite sensitive about paths with double / they don't normalize
-    'uv_parent_path': '/',
-  },
-
   'target_defaults': {
     'conditions': [
       ['OS != "win"', {
             ['uv_library=="shared_library" and OS!="mac"', {
               'link_settings': {
                 # Must correspond with UV_VERSION_MAJOR and UV_VERSION_MINOR
-                # in src/version.c
+                # in include/uv-version.h
                 'libraries': [ '-Wl,-soname,libuv.so.1.0' ],
               },
             }],
         ['uv_library=="shared_library"', {
           'defines': [ 'BUILDING_UV_SHARED=1' ]
         }],
-        # FIXME(bnoordhuis or tjfontaine) Unify this, it's extremely ugly.
-        ['uv_use_dtrace=="true"', {
-          'defines': [ 'HAVE_DTRACE=1' ],
-          'dependencies': [ 'uv_dtrace_header' ],
-          'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
-          'conditions': [
-            [ 'OS not in "mac linux"', {
-              'sources': [ 'src/unix/dtrace.c' ],
-            }],
-            [ 'OS=="linux"', {
-              'sources': [ '<(SHARED_INTERMEDIATE_DIR)/dtrace.o' ]
-            }],
-          ],
-        }],
       ]
     },
 
         'test/test-tcp-write-queue-order.c',
         'test/test-threadpool.c',
         'test/test-threadpool-cancel.c',
+        'test/test-thread-equal.c',
         'test/test-mutexes.c',
         'test/test-thread.c',
         'test/test-barrier.c',
         },
       },
     },
-
-    {
-      'target_name': 'uv_dtrace_header',
-      'type': 'none',
-      'conditions': [
-        [ 'uv_use_dtrace=="true"', {
-          'actions': [
-            {
-              'action_name': 'uv_dtrace_header',
-              'inputs': [ 'src/unix/uv-dtrace.d' ],
-              'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/uv-dtrace.h' ],
-              'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)',
-                '-o', '<@(_outputs)' ],
-            },
-          ],
-        }],
-      ],
-    },
-
-    # FIXME(bnoordhuis or tjfontaine) Unify this, it's extremely ugly.
-    {
-      'target_name': 'uv_dtrace_provider',
-      'type': 'none',
-      'conditions': [
-        [ 'uv_use_dtrace=="true" and OS not in "mac linux"', {
-          'actions': [
-            {
-              'action_name': 'uv_dtrace_o',
-              'inputs': [
-                'src/unix/uv-dtrace.d',
-                '<(PRODUCT_DIR)/obj.target/libuv<(uv_parent_path)src/unix/core.o',
-              ],
-              'outputs': [
-                '<(PRODUCT_DIR)/obj.target/libuv<(uv_parent_path)src/unix/dtrace.o',
-              ],
-              'action': [ 'dtrace', '-G', '-xnolibs', '-s', '<@(_inputs)',
-                '-o', '<@(_outputs)' ]
-            }
-          ]
-        }],
-        [ 'uv_use_dtrace=="true" and OS=="linux"', {
-          'actions': [
-            {
-              'action_name': 'uv_dtrace_o',
-              'inputs': [ 'src/unix/uv-dtrace.d' ],
-              'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/dtrace.o' ],
-              'action': [
-                'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)'
-              ],
-            }
-          ]
-        }],
-      ]
-    },
-
   ]
 }