Skip to content

Commit

Permalink
uv: Upgrade to v0.11.8
Browse files Browse the repository at this point in the history
  • Loading branch information
tjfontaine committed Aug 21, 2013
1 parent 41f55dc commit a784aba
Show file tree
Hide file tree
Showing 28 changed files with 513 additions and 268 deletions.
53 changes: 52 additions & 1 deletion deps/uv/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,55 @@
2013.08.07, Version 0.11.7 (Unstable)
2013.08.22, Version 0.11.8 (Unstable)

Changes since version 0.11.7:

* unix: fix missing return value warning in stream.c (Ben Noordhuis)

* build: serial-tests was added in automake v1.12 (Ben Noordhuis)

* windows: fix uninitialized local variable warning (Ben Noordhuis)

* windows: fix missing return value warning (Ben Noordhuis)

* build: fix string comparisons in autogen.sh (Ben Noordhuis)

* windows: move INLINE macro, remove UNUSED (Ben Noordhuis)

* unix: clean up __attribute__((quux)) usage (Ben Noordhuis)

* sunos: remove futimes() macro (Ben Noordhuis)

* unix: fix uv__signal_unlock() prototype (Ben Noordhuis)

* unix, windows: allow NULL async callback (Ben Noordhuis)

* build: apply dtrace -G to all object files (Timothy J. Fontaine)

* darwin: fix indentation in uv__hrtime() (Ben Noordhuis)

* darwin: create fsevents thread on demand (Ben Noordhuis)

* darwin: reduce fsevents thread stack size (Ben Noordhuis)

* darwin: call pthread_setname_np() if available (Ben Noordhuis)

* build: fix automake serial-tests check again (Ben Noordhuis)

* unix: retry waitpid() on EINTR (Ben Noordhuis)

* darwin: fix ios build error (Ben Noordhuis)

* darwin: fix ios compiler warning (Ben Noordhuis)

* test: simplify test-ip6-addr.c (Ben Noordhuis)

* unix, windows: fix ipv6 link-local address parsing (Ben Noordhuis)

* fsevents: FSEvents is most likely not thread-safe (Fedor Indutny)

* windows: omit stdint.h, fix msvc 2008 build error (Ben Noordhuis)


2013.08.07, Version 0.11.7 (Unstable), 3cad361f8776f70941b39d65bd9426bcb1aa817b

Changes since version 0.11.6:

Expand Down
3 changes: 2 additions & 1 deletion deps/uv/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \
test/task.h \
test/test-active.c \
test/test-async.c \
test/test-async-null-cb.c \
test/test-barrier.c \
test/test-callback-order.c \
test/test-callback-stack.c \
Expand Down Expand Up @@ -215,7 +216,7 @@ src/unix/uv-dtrace.o: src/unix/uv-dtrace.d ${libuv_la_OBJECTS}
# 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 $< \
`grep '^pic_object' $$(find ${top_builddir} -name "*.lo") | cut -f 2 -d\'`
`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' \
Expand Down
31 changes: 26 additions & 5 deletions deps/uv/autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,33 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

if [ "$LIBTOOLIZE" == "" ] && [ "`uname`" == "Darwin" ]; then
cd `dirname "$0"`

if [ "$LIBTOOLIZE" = "" ] && [ "`uname`" = "Darwin" ]; then
LIBTOOLIZE=glibtoolize
fi

ACLOCAL=${ACLOCAL:-aclocal}
AUTOCONF=${AUTOCONF:-autoconf}
AUTOMAKE=${AUTOMAKE:-automake}
LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}

automake_version=`"$AUTOMAKE" --version | head -n 1 | sed 's/[^.0-9]//g'`
automake_version_major=`echo "$automake_version" | cut -d. -f1`
automake_version_minor=`echo "$automake_version" | cut -d. -f2`

UV_EXTRA_AUTOMAKE_FLAGS=
if test "$automake_version_major" -gt 1 || \
test "$automake_version_major" -eq 1 && \
test "$automake_version_minor" -gt 11; then
# serial-tests is available in v0.12 and newer.
UV_EXTRA_AUTOMAKE_FLAGS="$UV_EXTRA_AUTOMAKE_FLAGS serial-tests"
fi
echo "m4_define([UV_EXTRA_AUTOMAKE_FLAGS], [$UV_EXTRA_AUTOMAKE_FLAGS])" \
> m4/libuv-extra-automake-flags.m4

set -ex
${LIBTOOLIZE:-libtoolize}
${ACLOCAL:-aclocal -I m4}
${AUTOCONF:-autoconf}
${AUTOMAKE:-automake} --add-missing
"$LIBTOOLIZE"
"$ACLOCAL" -I m4
"$AUTOCONF"
"$AUTOMAKE" --add-missing --copy
7 changes: 2 additions & 5 deletions deps/uv/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@

AC_PREREQ(2.57)
AC_INIT([libuv], [0.11.5], [https://github.com/joyent/libuv/issues])
# Use AM_SILENT_RULES as an ad-hoc version check to find out if it's safe
# to use the serial-tests directive. Both were added in automake v0.11.
AM_INIT_AUTOMAKE(m4_ifdef([AM_SILENT_RULES],
[-Wall -Werror foreign subdir-objects serial-tests],
[-Wall -Werror foreign subdir-objects]))
AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/libuv-extra-automake-flags.m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects] UV_EXTRA_AUTOMAKE_FLAGS)
AC_CANONICAL_HOST
AC_ENABLE_SHARED
AC_ENABLE_STATIC
Expand Down
6 changes: 6 additions & 0 deletions deps/uv/include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,12 @@ struct uv_async_s {
UV_ASYNC_PRIVATE_FIELDS
};

/*
* Initialize the uv_async_t handle. A NULL callback is allowed.
*
* Note that uv_async_init(), unlike other libuv functions, immediately
* starts the handle. To stop the handle again, close it with uv_close().
*/
UV_EXTERN int uv_async_init(uv_loop_t*, uv_async_t* async,
uv_async_cb async_cb);

Expand Down
4 changes: 1 addition & 3 deletions deps/uv/src/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#ifndef QUEUE_H_
#define QUEUE_H_

#include <stdint.h>

typedef void *QUEUE[2];

/* Private macros. */
Expand All @@ -28,7 +26,7 @@ typedef void *QUEUE[2];

/* Public macros. */
#define QUEUE_DATA(ptr, type, field) \
((type *) ((char *) (ptr) - ((uintptr_t) &((type *) 0)->field)))
((type *) ((char *) (ptr) - ((char *) &((type *) 0)->field)))

#define QUEUE_FOREACH(q, h) \
for ((q) = (QUEUE *) (*(h))[0]; (q) != (h); (q) = (QUEUE *) (*(q))[0])
Expand Down
7 changes: 6 additions & 1 deletion deps/uv/src/unix/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@ static void uv__async_event(uv_loop_t* loop,

QUEUE_FOREACH(q, &loop->async_handles) {
h = QUEUE_DATA(q, uv_async_t, queue);
if (!h->pending) continue;

if (h->pending == 0)
continue;
h->pending = 0;

if (h->async_cb == NULL)
continue;
h->async_cb(h, 0);
}
}
Expand Down
29 changes: 28 additions & 1 deletion deps/uv/src/unix/darwin-proctitle.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
* IN THE SOFTWARE.
*/

#include <dlfcn.h>
#include <errno.h>
#include <stdlib.h>

#include <TargetConditionals.h>

#if !TARGET_OS_IPHONE
Expand All @@ -26,9 +30,30 @@
#endif


static int uv__pthread_setname_np(const char* name) {
int (*dynamic_pthread_setname_np)(const char* name);
char namebuf[64]; /* MAXTHREADNAMESIZE */
int err;

/* pthread_setname_np() first appeared in OS X 10.6 and iOS 3.2. */
dynamic_pthread_setname_np = dlsym(RTLD_DEFAULT, "pthread_setname_np");
if (dynamic_pthread_setname_np == NULL)
return -ENOSYS;

strncpy(namebuf, name, sizeof(namebuf) - 1);
namebuf[sizeof(namebuf) - 1] = '\0';

err = dynamic_pthread_setname_np(namebuf);
if (err)
return -err;

return 0;
}


int uv__set_process_title(const char* title) {
#if TARGET_OS_IPHONE
return -ENOSYS;
return uv__pthread_setname_np(title);
#else
typedef CFTypeRef (*LSGetCurrentApplicationASNType)(void);
typedef OSStatus (*LSSetApplicationInformationItemType)(int,
Expand Down Expand Up @@ -84,6 +109,8 @@ int uv__set_process_title(const char* title) {
if (err != noErr)
return -ENOENT;

uv__pthread_setname_np(title); /* Don't care if it fails. */

return 0;
#endif /* !TARGET_OS_IPHONE */
}
139 changes: 6 additions & 133 deletions deps/uv/src/unix/darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,163 +29,36 @@
#include <net/if.h>
#include <net/if_dl.h>

#include <CoreFoundation/CFRunLoop.h>

#include <mach/mach.h>
#include <mach/mach_time.h>
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <unistd.h> /* sysconf */

/* Forward declarations */
static void uv__cf_loop_runner(void* arg);
static 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;
QUEUE member;
};


int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
CFRunLoopSourceContext ctx;
int r;
loop->cf_loop = NULL;

if (uv__kqueue_init(loop))
return -errno;

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;
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(ACCESS_ONCE(CFRunLoopRef, loop->cf_loop) != NULL);

return 0;
}


void uv__platform_loop_delete(uv_loop_t* loop) {
QUEUE* item;
uv__cf_loop_signal_t* s;

assert(loop->cf_loop != NULL);
uv__cf_loop_signal(loop, NULL, NULL);
uv_thread_join(&loop->cf_thread);

uv_sem_destroy(&loop->cf_sem);
uv_mutex_destroy(&loop->cf_mutex);

/* Free any remaining data */
while (!QUEUE_EMPTY(&loop->cf_signals)) {
item = QUEUE_HEAD(&loop->cf_signals);

s = QUEUE_DATA(item, uv__cf_loop_signal_t, member);

QUEUE_REMOVE(item);
free(s);
}
}


static void uv__cf_loop_runner(void* arg) {
uv_loop_t* loop;

loop = arg;

/* Get thread's loop */
ACCESS_ONCE(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);
}


static void uv__cf_loop_cb(void* arg) {
uv_loop_t* loop;
QUEUE* item;
QUEUE split_head;
uv__cf_loop_signal_t* s;

loop = arg;

uv_mutex_lock(&loop->cf_mutex);
QUEUE_INIT(&split_head);
if (!QUEUE_EMPTY(&loop->cf_signals)) {
QUEUE* split_pos = QUEUE_HEAD(&loop->cf_signals);
QUEUE_SPLIT(&loop->cf_signals, split_pos, &split_head);
}
uv_mutex_unlock(&loop->cf_mutex);

while (!QUEUE_EMPTY(&split_head)) {
item = QUEUE_HEAD(&split_head);

s = QUEUE_DATA(item, uv__cf_loop_signal_t, member);

/* This was a termination signal */
if (s->cb == NULL)
CFRunLoopStop(loop->cf_loop);
else
s->cb(s->arg);

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);
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);
uv__fsevents_loop_delete(loop);
}


uint64_t uv__hrtime(void) {
mach_timebase_info_data_t info;
mach_timebase_info_data_t info;

if (mach_timebase_info(&info) != KERN_SUCCESS)
abort();
if (mach_timebase_info(&info) != KERN_SUCCESS)
abort();

return mach_absolute_time() * info.numer / info.denom;
return mach_absolute_time() * info.numer / info.denom;
}


Expand Down
Loading

0 comments on commit a784aba

Please sign in to comment.