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>
### 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
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
+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:
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 \
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
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
— An 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)
+ * [Tests and benchmarks](https://github.com/libuv/libuv/tree/master/test)
— API specification and usage examples.
* [libuv-dox](https://github.com/thlorenz/libuv-dox)
— Documenting types and methods of libuv, mostly by reading uv.h.
+ * [learnuv](https://github.com/thlorenz/learnuv)
+ — Learn uv for fun and profit, a self guided workshop to libuv.
## Build Instructions
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
$ ./gyp_uv.py -f make
$ make -C out
+Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries.
+
### OS X
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
[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
'cflags': [ '-m32' ],
'ldflags': [ '-m32' ],
}],
+ [ 'target_arch=="x32"', {
+ 'cflags': [ '-mx32' ],
+ 'ldflags': [ '-mx32' ],
+ }],
[ 'OS=="linux"', {
'cflags': [ '-ansi' ],
}],
# 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])
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"], [
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()``.
`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.
--------
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
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
.. 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).
`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.
^^^^^^^
.. 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
^^^^^^^^^^^^^^^^^^^^
#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 */
* 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
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,
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;
# Ignore libtoolize-generated files.
*.m4
!as_case.m4
-!dtrace.m4
-!libuv-check-flags.m4
\ No newline at end of file
+!libuv-check-flags.m4
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);
}
r = uv__loop_alive(loop);
- UV_TICK_STOP(loop, mode);
if (mode & (UV_RUN_ONCE | UV_RUN_NOWAIT))
break;
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_ */
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)
#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);
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))
}
-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;
(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;
(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;
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. */
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;
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,
do {
DWORD incremental_bytes;
- /* WriteFile() does not advance overlapped as ReadFile() does. */
if (offset != -1) {
offset_.QuadPart = offset + bytes;
overlapped.Offset = offset_.LowPart;
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))
}
+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;
/* 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.
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_ */
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;
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));
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)
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)
--- /dev/null
+/* 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;
+}
{
- '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)'
- ],
- }
- ]
- }],
- ]
- },
-
]
}