This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

deps: upgrade libuv to 1f9bd99

  • Loading branch information...
1 parent 2c97da8 commit dd1b9477063e39c5d916ebb602947340442d4d50 @bnoordhuis bnoordhuis committed Sep 13, 2012
View
@@ -77,6 +77,9 @@ Macintosh users run
./gyp_uv -f xcode
xcodebuild -project uv.xcodeproj -configuration Release -target All
+Note for Linux users: compile your project with `-D_GNU_SOURCE` when you
+include `uv.h`. GYP builds take care of that automatically. If you use
+autotools, add a `AC_GNU_SOURCE` declaration to your `configure.ac`.
## Supported Platforms
View
@@ -60,6 +60,7 @@ CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
LINKFLAGS+=-framework CoreServices
OBJS += src/unix/darwin.o
OBJS += src/unix/kqueue.o
+OBJS += src/unix/fsevents.o
endif
ifeq (Linux,$(uname_S))
@@ -91,7 +92,7 @@ endif
ifeq (NetBSD,$(uname_S))
EV_CONFIG=config_netbsd.h
EIO_CONFIG=config_netbsd.h
-LINKFLAGS+=
+LINKFLAGS+=-lkvm
OBJS += src/unix/netbsd.o
OBJS += src/unix/kqueue.o
endif
View
@@ -60,9 +60,11 @@ if __name__ == '__main__':
# There's a bug with windows which doesn't allow this feature.
if sys.platform != 'win32':
- args.extend(['--generator-output', output_dir])
- args.extend(['-Goutput_dir=' + output_dir])
- args.extend('-f make'.split())
+ if '-f' not in args:
+ args.extend('-f make'.split())
+ if 'ninja' not in args:
+ args.extend(['-Goutput_dir=' + output_dir])
+ args.extend(['--generator-output', output_dir])
(major, minor), is_clang = compiler_version()
args.append('-Dgcc_version=%d' % (10 * major + minor))
args.append('-Dclang=%d' % int(is_clang))
@@ -29,10 +29,23 @@
# define UV_PLATFORM_SEM_T semaphore_t
#endif
+#define UV_PLATFORM_LOOP_FIELDS \
+ uv_thread_t cf_thread; \
+ void* cf_cb; \
+ void* cf_loop; \
+ uv_mutex_t cf_mutex; \
+ uv_sem_t cf_sem; \
+ ngx_queue_t cf_signals; \
+
#define UV_PLATFORM_FS_EVENT_FIELDS \
ev_io event_watcher; \
int fflags; \
int fd; \
+ void* cf_eventstream; \
+ uv_async_t* cf_cb; \
+ ngx_queue_t cf_events; \
+ uv_sem_t cf_sem; \
+ uv_mutex_t cf_mutex; \
#define UV_STREAM_PRIVATE_PLATFORM_FIELDS \
void* select; \
@@ -137,6 +137,7 @@ typedef struct {
uint64_t time; \
void* signal_ctx; \
uv_signal_t child_watcher; \
+ int emfile_fd; \
UV_PLATFORM_LOOP_FIELDS \
#define UV_REQ_TYPE_PRIVATE /* empty */
View
@@ -1789,6 +1789,7 @@ 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 unsigned long uv_thread_self(void);
UV_EXTERN int uv_thread_join(uv_thread_t *tid);
/* the presence of these unions force similar struct layout */
View
@@ -31,7 +31,7 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* handle, int events);
__attribute__((always_inline))
-inline static int uv__async_make_pending(volatile sig_atomic_t* ptr) {
+static int uv__async_make_pending(volatile sig_atomic_t* ptr) {
/* Do a cheap read first. */
if (*ptr)
return 1;
View
@@ -463,7 +463,7 @@ int uv__accept(int sockfd) {
while (1) {
#if __linux__
- static __read_mostly int no_accept4;
+ static int no_accept4;
if (no_accept4)
goto skip;
View
@@ -43,13 +43,137 @@
static char *process_title;
+/* Forward declarations */
+void uv__cf_loop_runner(void* arg);
+void uv__cf_loop_cb(void* arg);
+
+typedef struct uv__cf_loop_signal_s uv__cf_loop_signal_t;
+struct uv__cf_loop_signal_s {
+ void* arg;
+ cf_loop_signal_cb cb;
+ ngx_queue_t member;
+};
+
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
+ CFRunLoopSourceContext ctx;
+ int r;
+
+ loop->cf_loop = NULL;
+ if ((r = uv_mutex_init(&loop->cf_mutex)))
+ return r;
+ if ((r = uv_sem_init(&loop->cf_sem, 0)))
+ return r;
+ ngx_queue_init(&loop->cf_signals);
+
+ memset(&ctx, 0, sizeof(ctx));
+ ctx.info = loop;
+ ctx.perform = uv__cf_loop_cb;
+ loop->cf_cb = CFRunLoopSourceCreate(NULL, 0, &ctx);
+
+ if ((r = uv_thread_create(&loop->cf_thread, uv__cf_loop_runner, loop)))
+ return r;
+
+ /* Synchronize threads */
+ uv_sem_wait(&loop->cf_sem);
+ assert(((volatile CFRunLoopRef) loop->cf_loop) != NULL);
+
return 0;
}
void uv__platform_loop_delete(uv_loop_t* loop) {
+ ngx_queue_t* item;
+ uv__cf_loop_signal_t* s;
+
+ assert(loop->cf_loop != NULL);
+ CFRunLoopStop(loop->cf_loop);
+ uv_thread_join(&loop->cf_thread);
+ loop->cf_loop = NULL;
+
+ uv_sem_destroy(&loop->cf_sem);
+ uv_mutex_destroy(&loop->cf_mutex);
+
+ /* Free any remaining data */
+ while (!ngx_queue_empty(&loop->cf_signals)) {
+ item = ngx_queue_head(&loop->cf_signals);
+
+ s = ngx_queue_data(item, uv__cf_loop_signal_t, member);
+
+ ngx_queue_remove(item);
+ free(s);
+ }
+}
+
+
+void uv__cf_loop_runner(void* arg) {
+ uv_loop_t* loop;
+
+ loop = arg;
+
+ /* Get thread's loop */
+ *((volatile CFRunLoopRef*)&loop->cf_loop) = CFRunLoopGetCurrent();
+
+ CFRunLoopAddSource(loop->cf_loop,
+ loop->cf_cb,
+ kCFRunLoopDefaultMode);
+
+ uv_sem_post(&loop->cf_sem);
+
+ CFRunLoopRun();
+
+ CFRunLoopRemoveSource(loop->cf_loop,
+ loop->cf_cb,
+ kCFRunLoopDefaultMode);
+}
+
+
+void uv__cf_loop_cb(void* arg) {
+ uv_loop_t* loop;
+ ngx_queue_t* item;
+ ngx_queue_t split_head;
+ uv__cf_loop_signal_t* s;
+
+ loop = arg;
+
+ uv_mutex_lock(&loop->cf_mutex);
+ ngx_queue_init(&split_head);
+ if (!ngx_queue_empty(&loop->cf_signals)) {
+ ngx_queue_t* split_pos = ngx_queue_next(&loop->cf_signals);
+ ngx_queue_split(&loop->cf_signals, split_pos, &split_head);
+ }
+ uv_mutex_unlock(&loop->cf_mutex);
+
+ while (!ngx_queue_empty(&split_head)) {
+ item = ngx_queue_head(&split_head);
+
+ s = ngx_queue_data(item, uv__cf_loop_signal_t, member);
+ s->cb(s->arg);
+
+ ngx_queue_remove(item);
+ free(s);
+ }
+}
+
+
+void uv__cf_loop_signal(uv_loop_t* loop, cf_loop_signal_cb cb, void* arg) {
+ uv__cf_loop_signal_t* item;
+
+ item = malloc(sizeof(*item));
+ /* XXX: Fail */
+ if (item == NULL)
+ abort();
+
+ item->arg = arg;
+ item->cb = cb;
+
+ uv_mutex_lock(&loop->cf_mutex);
+ ngx_queue_insert_tail(&loop->cf_signals, &item->member);
+ uv_mutex_unlock(&loop->cf_mutex);
+
+ assert(loop->cf_loop != NULL);
+ CFRunLoopSourceSignal(loop->cf_cb);
+ CFRunLoopWakeUp(loop->cf_loop);
}
Oops, something went wrong.

0 comments on commit dd1b947

Please sign in to comment.