summaryrefslogtreecommitdiff
path: root/deps/uv
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2011-12-20 20:55:14 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2011-12-21 16:59:53 +0100
commitb24c515dbf227114bf215aac7930ecce386cc131 (patch)
treed735a405e8c7aec202673805a469cc60e71885b3 /deps/uv
parent18b92201be7e654ac9997b947d38aaf46adee06d (diff)
downloadnode-new-b24c515dbf227114bf215aac7930ecce386cc131.tar.gz
uv: upgrade to 10de090
Diffstat (limited to 'deps/uv')
-rw-r--r--deps/uv/AUTHORS1
-rw-r--r--deps/uv/include/uv-private/ngx-queue.h4
-rw-r--r--deps/uv/include/uv-private/uv-unix.h3
-rw-r--r--deps/uv/include/uv-private/uv-win.h10
-rw-r--r--deps/uv/include/uv.h7
-rw-r--r--deps/uv/src/unix/core.c43
-rw-r--r--deps/uv/src/unix/darwin.c25
-rw-r--r--deps/uv/src/unix/thread.c9
-rw-r--r--deps/uv/src/win/internal.h18
-rw-r--r--deps/uv/test/test-list.h2
-rw-r--r--deps/uv/test/test-thread.c7
11 files changed, 96 insertions, 33 deletions
diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS
index 6a95ce31f8..dd40b7af19 100644
--- a/deps/uv/AUTHORS
+++ b/deps/uv/AUTHORS
@@ -38,3 +38,4 @@ Ryan Emery <seebees@gmail.com>
Bruce Mitchener <bruce.mitchener@gmail.com>
Maciej MaƂecki <maciej.malecki@notimplemented.org>
Yasuhiro Matsumoto <mattn.jp@gmail.com>
+Daisuke Murase <typester@cpan.org>
diff --git a/deps/uv/include/uv-private/ngx-queue.h b/deps/uv/include/uv-private/ngx-queue.h
index f8576d67dc..8c5e461762 100644
--- a/deps/uv/include/uv-private/ngx-queue.h
+++ b/deps/uv/include/uv-private/ngx-queue.h
@@ -99,4 +99,8 @@ struct ngx_queue_s {
(type *) ((unsigned char *) q - offsetof(type, link))
+#define ngx_queue_foreach(q, h) \
+ for ((q) = ngx_queue_head(h); (q) != (h); (q) = ngx_queue_next(q))
+
+
#endif /* _NGX_QUEUE_H_INCLUDED_ */
diff --git a/deps/uv/include/uv-private/uv-unix.h b/deps/uv/include/uv-private/uv-unix.h
index 34246a8f7e..99537347f7 100644
--- a/deps/uv/include/uv-private/uv-unix.h
+++ b/deps/uv/include/uv-private/uv-unix.h
@@ -44,6 +44,9 @@ typedef struct {
typedef int uv_file;
+#define UV_ONCE_INIT PTHREAD_ONCE_INIT
+
+typedef pthread_once_t uv_once_t;
typedef pthread_t uv_thread_t;
typedef pthread_mutex_t uv_mutex_t;
typedef pthread_rwlock_t uv_rwlock_t;
diff --git a/deps/uv/include/uv-private/uv-win.h b/deps/uv/include/uv-private/uv-win.h
index a87ede7319..b4b89096d0 100644
--- a/deps/uv/include/uv-private/uv-win.h
+++ b/deps/uv/include/uv-private/uv-win.h
@@ -152,6 +152,16 @@ typedef union {
} fallback_;
} uv_rwlock_t;
+#define UV_ONCE_INIT { 0, NULL, NULL }
+
+typedef struct uv_once_s {
+ unsigned char ran;
+ /* The actual event handle must be aligned to sizeof(HANDLE), so in */
+ /* practice it might overlap padding a little. */
+ HANDLE event;
+ HANDLE padding;
+} uv_once_t;
+
/* Platform-specific definitions for uv_dlopen support. */
typedef HMODULE uv_lib_t;
#define UV_DYNAMIC FAR WINAPI
diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h
index ef1c6916b6..7e089ef724 100644
--- a/deps/uv/include/uv.h
+++ b/deps/uv/include/uv.h
@@ -1339,9 +1339,16 @@ UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock);
UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock);
UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock);
+/* 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).
+ * The guard should be initialized statically with the UV_ONCE_INIT macro.
+ */
+UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void));
+
UV_EXTERN int uv_thread_create(uv_thread_t *tid,
void (*entry)(void *arg), void *arg);
UV_EXTERN int uv_thread_join(uv_thread_t *tid);
+UV_EXTERN uv_thread_t uv_thread_self(void);
/* the presence of these unions force similar struct layout */
union uv_any_handle {
diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c
index 933c9bd73a..a024f12b86 100644
--- a/deps/uv/src/unix/core.c
+++ b/deps/uv/src/unix/core.c
@@ -158,10 +158,30 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
}
-uv_loop_t* uv_loop_new(void) {
- uv_loop_t* loop = calloc(1, sizeof(uv_loop_t));
- loop->ev = ev_loop_new(0);
+static int uv__loop_init(uv_loop_t* loop,
+ struct ev_loop *(ev_loop_new)(unsigned int flags)) {
+ memset(loop, 0, sizeof(*loop));
+#if HAVE_KQUEUE
+ loop->ev = ev_loop_new(EVBACKEND_KQUEUE);
+#else
+ loop->ev = ev_loop_new(EVFLAG_AUTO);
+#endif
ev_set_userdata(loop->ev, loop);
+ return 0;
+}
+
+
+uv_loop_t* uv_loop_new(void) {
+ uv_loop_t* loop;
+
+ if ((loop = malloc(sizeof(*loop))) == NULL)
+ return NULL;
+
+ if (uv__loop_init(loop, ev_loop_new)) {
+ free(loop);
+ return NULL;
+ }
+
return loop;
}
@@ -182,16 +202,13 @@ void uv_loop_delete(uv_loop_t* loop) {
uv_loop_t* uv_default_loop(void) {
- if (!default_loop_ptr) {
- default_loop_ptr = &default_loop_struct;
-#if HAVE_KQUEUE
- default_loop_struct.ev = ev_default_loop(EVBACKEND_KQUEUE);
-#else
- default_loop_struct.ev = ev_default_loop(EVFLAG_AUTO);
-#endif
- ev_set_userdata(default_loop_struct.ev, default_loop_ptr);
- }
- assert(default_loop_ptr->ev == EV_DEFAULT_UC);
+ if (default_loop_ptr)
+ return default_loop_ptr;
+
+ if (uv__loop_init(&default_loop_struct, ev_default_loop))
+ return NULL;
+
+ default_loop_ptr = &default_loop_struct;
return default_loop_ptr;
}
diff --git a/deps/uv/src/unix/darwin.c b/deps/uv/src/unix/darwin.c
index 47104be89b..e6deb3017b 100644
--- a/deps/uv/src/unix/darwin.c
+++ b/deps/uv/src/unix/darwin.c
@@ -28,7 +28,12 @@
#include <ifaddrs.h>
#include <net/if.h>
+#include <TargetConditionals.h>
+
+#if !TARGET_OS_IPHONE
#include <CoreServices/CoreServices.h>
+#endif
+
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
@@ -36,10 +41,26 @@
#include <sys/sysctl.h>
#include <unistd.h> /* sysconf */
-
static char *process_title;
+#if TARGET_OS_IPHONE
+/* see: http://developer.apple.com/library/mac/#qa/qa1398/_index.html */
+uint64_t uv_hrtime() {
+ uint64_t time;
+ uint64_t enano;
+ static mach_timebase_info_data_t sTimebaseInfo;
+
+ time = mach_absolute_time();
+ if (0 == sTimebaseInfo.denom) {
+ (void)mach_timebase_info(&sTimebaseInfo);
+ }
+
+ enano = time * sTimebaseInfo.numer / sTimebaseInfo.denom;
+
+ return enano;
+}
+#else
uint64_t uv_hrtime() {
uint64_t time;
Nanoseconds enano;
@@ -47,7 +68,7 @@ uint64_t uv_hrtime() {
enano = AbsoluteToNanoseconds(*(AbsoluteTime *)&time);
return (*(uint64_t *)&enano);
}
-
+#endif
int uv_exepath(char* buffer, size_t* size) {
uint32_t usize;
diff --git a/deps/uv/src/unix/thread.c b/deps/uv/src/unix/thread.c
index 76d44ea3dd..9a6b3d1b82 100644
--- a/deps/uv/src/unix/thread.c
+++ b/deps/uv/src/unix/thread.c
@@ -47,6 +47,10 @@ int uv_thread_join(uv_thread_t *tid) {
return 0;
}
+uv_thread_t uv_thread_self(void) {
+ return pthread_self();
+}
+
int uv_mutex_init(uv_mutex_t* mutex) {
if (pthread_mutex_init(mutex, NULL))
@@ -147,3 +151,8 @@ int uv_rwlock_trywrlock(uv_rwlock_t* rwlock) {
void uv_rwlock_wrunlock(uv_rwlock_t* rwlock) {
CHECK(pthread_rwlock_unlock(rwlock));
}
+
+
+void uv_once(uv_once_t* guard, void (*callback)(void)) {
+ CHECK(pthread_once(guard, callback));
+}
diff --git a/deps/uv/src/win/internal.h b/deps/uv/src/win/internal.h
index deb8972c5a..e7d6c974bf 100644
--- a/deps/uv/src/win/internal.h
+++ b/deps/uv/src/win/internal.h
@@ -343,22 +343,4 @@ extern int uv_allow_ipv6;
extern struct sockaddr_in uv_addr_ip4_any_;
extern struct sockaddr_in6 uv_addr_ip6_any_;
-
-/*
- * Threads and synchronization
- */
-typedef struct uv_once_s {
- unsigned char ran;
- /* The actual event handle must be aligned to sizeof(HANDLE), so in */
- /* practice it might overlap padding a little. */
- HANDLE event;
- HANDLE padding;
-} uv_once_t;
-
-#define UV_ONCE_INIT \
- { 0, NULL, NULL }
-
-void uv_once(uv_once_t* guard, void (*callback)(void));
-
-
#endif /* UV_WIN_INTERNAL_H_ */
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index d031eb27c6..51b847291e 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -122,6 +122,7 @@ TEST_DECLARE (threadpool_queue_work_simple)
TEST_DECLARE (thread_mutex)
TEST_DECLARE (thread_rwlock)
TEST_DECLARE (thread_create)
+TEST_DECLARE (thread_self)
TEST_DECLARE (strlcpy)
TEST_DECLARE (strlcat)
TEST_DECLARE (counters_init)
@@ -287,6 +288,7 @@ TASK_LIST_START
TEST_ENTRY (thread_mutex)
TEST_ENTRY (thread_rwlock)
TEST_ENTRY (thread_create)
+ TEST_ENTRY (thread_self)
TEST_ENTRY (strlcpy)
TEST_ENTRY (strlcat)
TEST_ENTRY (counters_init)
diff --git a/deps/uv/test/test-thread.c b/deps/uv/test/test-thread.c
index 61aa55a217..48b31b172e 100644
--- a/deps/uv/test/test-thread.c
+++ b/deps/uv/test/test-thread.c
@@ -49,3 +49,10 @@ TEST_IMPL(thread_create) {
return 0;
}
+
+
+TEST_IMPL(thread_self) {
+ uv_thread_t tid;
+ tid = uv_thread_self();
+ return 0;
+}