Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
deps: upgrade libuv to 3c41597
  • Loading branch information
bnoordhuis committed Apr 10, 2012
1 parent 06ada03 commit 0db4dc0
Show file tree
Hide file tree
Showing 41 changed files with 1,250 additions and 795 deletions.
22 changes: 14 additions & 8 deletions deps/uv/config-unix.mk
Expand Up @@ -27,18 +27,24 @@ LINKFLAGS=-lm
CPPFLAGS += -D_LARGEFILE_SOURCE
CPPFLAGS += -D_FILE_OFFSET_BITS=64

OBJS += src/unix/async.o
OBJS += src/unix/cares.o
OBJS += src/unix/check.o
OBJS += src/unix/core.o
OBJS += src/unix/dl.o
OBJS += src/unix/fs.o
OBJS += src/unix/cares.o
OBJS += src/unix/udp.o
OBJS += src/unix/error.o
OBJS += src/unix/thread.o
OBJS += src/unix/fs.o
OBJS += src/unix/idle.o
OBJS += src/unix/loop.o
OBJS += src/unix/pipe.o
OBJS += src/unix/prepare.o
OBJS += src/unix/process.o
OBJS += src/unix/stream.o
OBJS += src/unix/tcp.o
OBJS += src/unix/pipe.o
OBJS += src/unix/thread.o
OBJS += src/unix/timer.o
OBJS += src/unix/tty.o
OBJS += src/unix/stream.o
OBJS += src/unix/udp.o

ifeq (SunOS,$(uname_S))
EV_CONFIG=config_sunos.h
Expand All @@ -51,7 +57,7 @@ endif
ifeq (Darwin,$(uname_S))
EV_CONFIG=config_darwin.h
EIO_CONFIG=config_darwin.h
CPPFLAGS += -Isrc/ares/config_darwin
CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 -Isrc/ares/config_darwin
LINKFLAGS+=-framework CoreServices
OBJS += src/unix/darwin.o
OBJS += src/unix/kqueue.o
Expand All @@ -63,7 +69,7 @@ EIO_CONFIG=config_linux.h
CSTDFLAG += -D_GNU_SOURCE
CPPFLAGS += -Isrc/ares/config_linux
LINKFLAGS+=-ldl -lrt
OBJS += src/unix/linux/core.o src/unix/linux/inotify.o
OBJS += src/unix/linux/core.o src/unix/linux/inotify.o src/unix/linux/syscalls.o
endif

ifeq (FreeBSD,$(uname_S))
Expand Down
14 changes: 8 additions & 6 deletions deps/uv/include/uv-private/tree.h
Expand Up @@ -26,10 +26,12 @@
#ifndef UV_TREE_H_
#define UV_TREE_H_

#if __GNUC__
# define __unused __attribute__((unused))
#else
# define __unused
#ifndef UV__UNUSED
# if __GNUC__
# define UV__UNUSED __attribute__((unused))
# else
# define UV__UNUSED
# endif
#endif

/*
Expand Down Expand Up @@ -381,7 +383,7 @@ struct { \
#define RB_PROTOTYPE(name, type, field, cmp) \
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static)
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, UV__UNUSED static)
#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \
attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \
attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
Expand All @@ -400,7 +402,7 @@ attr struct type *name##_RB_MINMAX(struct name *, int); \
#define RB_GENERATE(name, type, field, cmp) \
RB_GENERATE_INTERNAL(name, type, field, cmp,)
#define RB_GENERATE_STATIC(name, type, field, cmp) \
RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static)
RB_GENERATE_INTERNAL(name, type, field, cmp, UV__UNUSED static)
#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \
attr void \
name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
Expand Down
15 changes: 7 additions & 8 deletions deps/uv/include/uv-private/uv-unix.h
Expand Up @@ -55,6 +55,9 @@ typedef pthread_rwlock_t uv_rwlock_t;
typedef void* uv_lib_t;
#define UV_DYNAMIC /* empty */

#define UV_HANDLE_TYPE_PRIVATE /* empty */
#define UV_REQ_TYPE_PRIVATE /* empty */

#if __linux__
# define UV_LOOP_PRIVATE_PLATFORM_FIELDS \
/* RB_HEAD(uv__inotify_watchers, uv_fs_event_s) */ \
Expand All @@ -74,14 +77,15 @@ typedef void* uv_lib_t;
* sure that we're always calling ares_process. See the warning above the \
* definition of ares_timeout(). \
*/ \
ev_timer timer; \
uv_timer_t timer; \
/* Poll result queue */ \
eio_channel uv_eio_channel; \
struct ev_loop* ev; \
/* Various thing for libeio. */ \
uv_async_t uv_eio_want_poll_notifier; \
uv_async_t uv_eio_done_poll_notifier; \
uv_idle_t uv_eio_poller; \
uv_handle_t* endgame_handles; \
UV_LOOP_PRIVATE_PLATFORM_FIELDS

#define UV_REQ_BUFSML_SIZE (4)
Expand Down Expand Up @@ -118,7 +122,7 @@ typedef void* uv_lib_t;
#define UV_HANDLE_PRIVATE_FIELDS \
int fd; \
int flags; \
ev_idle next_watcher;
uv_handle_t* endgame_next; /* that's what uv-win calls it */ \


#define UV_STREAM_PRIVATE_FIELDS \
Expand Down Expand Up @@ -182,11 +186,6 @@ typedef void* uv_lib_t;
ev_timer timer_watcher; \
uv_timer_cb timer_cb;

#define UV_ARES_TASK_PRIVATE_FIELDS \
int sock; \
ev_io read_watcher; \
ev_io write_watcher;

#define UV_GETADDRINFO_PRIVATE_FIELDS \
uv_getaddrinfo_cb cb; \
struct addrinfo* hints; \
Expand Down Expand Up @@ -223,7 +222,7 @@ typedef void* uv_lib_t;
ev_io read_watcher; \
uv_fs_event_cb cb;

#elif (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) \
#elif defined(__APPLE__) \
|| defined(__FreeBSD__) \
|| defined(__OpenBSD__) \
|| defined(__NetBSD__)
Expand Down
15 changes: 7 additions & 8 deletions deps/uv/include/uv-private/uv-win.h
Expand Up @@ -206,15 +206,21 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
/* Counter to keep track of active udp streams */ \
unsigned int active_udp_streams;

#define UV_HANDLE_TYPE_PRIVATE \
UV_ARES_EVENT,

#define UV_REQ_TYPE_PRIVATE \
/* TODO: remove the req suffix */ \
UV_ACCEPT, \
UV_ARES_EVENT_REQ, \
UV_ARES_CLEANUP_REQ, \
UV_FS_EVENT_REQ, \
UV_GETADDRINFO_REQ, \
UV_PROCESS_EXIT, \
UV_PROCESS_CLOSE, \
UV_READ, \
UV_UDP_RECV, \
UV_FS_EVENT_REQ
UV_WAKEUP,

#define UV_REQ_PRIVATE_FIELDS \
union { \
Expand Down Expand Up @@ -390,13 +396,6 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
uv_handle_t* endgame_next; \
unsigned int flags;

#define UV_ARES_TASK_PRIVATE_FIELDS \
struct uv_req_s ares_req; \
SOCKET sock; \
HANDLE h_wait; \
WSAEVENT h_event; \
HANDLE h_close_event;

#define UV_GETADDRINFO_PRIVATE_FIELDS \
struct uv_req_s getadddrinfo_req; \
uv_getaddrinfo_cb getaddrinfo_cb; \
Expand Down
78 changes: 55 additions & 23 deletions deps/uv/include/uv.h
Expand Up @@ -132,37 +132,46 @@ typedef enum {
} uv_err_code;
#undef UV_ERRNO_GEN

#define UV_HANDLE_TYPE_MAP(XX) \
XX(ARES_TASK, ares_task) \
XX(ASYNC, async) \
XX(CHECK, check) \
XX(FS_EVENT, fs_event) \
XX(IDLE, idle) \
XX(NAMED_PIPE, pipe) \
XX(PREPARE, prepare) \
XX(PROCESS, process) \
XX(TCP, tcp) \
XX(TIMER, timer) \
XX(TTY, tty) \
XX(UDP, udp) \

#define UV_REQ_TYPE_MAP(XX) \
XX(CONNECT, connect) \
XX(WRITE, write) \
XX(SHUTDOWN, shutdown) \
XX(UDP_SEND, udp_send) \
XX(FS, fs) \
XX(WORK, work) \
XX(GETADDRINFO, getaddrinfo) \

typedef enum {
UV_UNKNOWN_HANDLE = 0,
UV_TCP,
UV_UDP,
UV_NAMED_PIPE,
UV_TTY,
#define XX(uc, lc) UV_##uc,
UV_HANDLE_TYPE_MAP(XX)
#undef XX
UV_FILE,
UV_TIMER,
UV_PREPARE,
UV_CHECK,
UV_IDLE,
UV_ASYNC,
UV_ARES_TASK,
UV_ARES_EVENT,
UV_PROCESS,
UV_FS_EVENT
UV_HANDLE_TYPE_PRIVATE
UV_HANDLE_TYPE_MAX
} uv_handle_type;

typedef enum {
UV_UNKNOWN_REQ = 0,
UV_CONNECT,
UV_ACCEPT,
UV_READ,
UV_WRITE,
UV_SHUTDOWN,
UV_WAKEUP,
UV_UDP_SEND,
UV_FS,
UV_WORK,
UV_GETADDRINFO,
#define XX(uc, lc) UV_##uc,
UV_REQ_TYPE_MAP(XX)
#undef XX
UV_REQ_TYPE_PRIVATE
UV_REQ_TYPE_MAX
} uv_req_type;


Expand Down Expand Up @@ -373,6 +382,18 @@ struct uv_handle_s {
UV_HANDLE_FIELDS
};

/*
* Returns size of various handle types, useful for FFI
* bindings to allocate correct memory without copying struct
* definitions
*/
UV_EXTERN size_t uv_handle_size(uv_handle_type type);

/*
* Returns size of request types, useful for dynamic lookup with FFI
*/
UV_EXTERN size_t uv_req_size(uv_req_type type);

/*
* Returns 1 if the prepare/check/idle/timer handle has been started, 0
* otherwise. For other handle types this always returns 1.
Expand Down Expand Up @@ -522,6 +543,16 @@ UV_EXTERN int uv_is_readable(uv_stream_t* handle);
UV_EXTERN int uv_is_writable(uv_stream_t* handle);


/*
* Used to determine whether a stream is closing or closed.
*
* N.B. is only valid between the initialization of the handle
* and the arrival of the close callback, and cannot be used
* to validate the handle.
*/
UV_EXTERN int uv_is_closing(uv_handle_t* handle);


/*
* uv_tcp_t is a subclass of uv_stream_t
*
Expand Down Expand Up @@ -1501,6 +1532,7 @@ struct uv_loop_s {


/* Don't export the private CPP symbols. */
#undef UV_HANDLE_TYPE_PRIVATE
#undef UV_REQ_TYPE_PRIVATE
#undef UV_REQ_PRIVATE_FIELDS
#undef UV_STREAM_PRIVATE_FIELDS
Expand Down
58 changes: 58 additions & 0 deletions deps/uv/src/unix/async.c
@@ -0,0 +1,58 @@
/* 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 "internal.h"


static void uv__async(EV_P_ ev_async* w, int revents) {
uv_async_t* async = container_of(w, uv_async_t, async_watcher);

if (async->async_cb) {
async->async_cb(async, 0);
}
}


int uv_async_init(uv_loop_t* loop, uv_async_t* async, uv_async_cb async_cb) {
uv__handle_init(loop, (uv_handle_t*)async, UV_ASYNC);
loop->counters.async_init++;

ev_async_init(&async->async_watcher, uv__async);
async->async_cb = async_cb;

/* Note: This does not have symmetry with the other libev wrappers. */
ev_async_start(loop->ev, &async->async_watcher);
ev_unref(loop->ev);

return 0;
}


int uv_async_send(uv_async_t* async) {
ev_async_send(async->loop->ev, &async->async_watcher);
return 0;
}


void uv__async_close(uv_async_t* handle) {
ev_async_stop(handle->loop->ev, &handle->async_watcher);
ev_ref(handle->loop->ev);
}

3 comments on commit 0db4dc0

@isaacs
Copy link

@isaacs isaacs commented on 0db4dc0 Apr 11, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something in this commit caused 86 tests to fail with Abort trap: 6 on OS X. (Up from 0 failures.)

Here's the output: https://gist.github.com/2358108

@isaacs
Copy link

@isaacs isaacs commented on 0db4dc0 Apr 11, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it broke on joyent/libuv@ed395e0

ed395e0619ab50d86c960e839525a0a5e8259b66 is the first bad commit
commit ed395e0619ab50d86c960e839525a0a5e8259b66
Author: Ben Noordhuis <info@bnoordhuis.nl>
Date:   Wed Apr 4 05:03:15 2012 -0700

    unix: replace handle->next_watcher

    Remove the next_watcher and replace it with a linked list. Said list is named
    endgame_handles (because the uv-win calls it that) and contains all the handles
    that are in the UV_CLOSING state.

    The goal of this commit is two-fold:

    a) remove a dependency on libev, and
    b) share more code with uv-win in the future

    A nice side effect is that it shaves a few bytes off a uv_handle_t.

:040000 040000 aee7aade26cb7f3ec59aeb677a6d99ab737cb2c3 64a6685aa9d17519f502f892d21e9dcb5b390006 M  include
:040000 040000 c61b5d658e7092e17c2aac45ab1981f4d5fbe227 a8bb8f4b21785f516926847c7a90d4e9b53967ce M  src
:040000 040000 1f73502b47f184652f332031c06bfd0dd91bc361 3e20b51c0c35d212014446442e43ce9900e79e84 M  test

@bnoordhuis
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted in e9dcfd4.

Please sign in to comment.