Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: remove dependency on libev
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Nov 16, 2012
1 parent 59a2c63 commit 1282d64
Show file tree
Hide file tree
Showing 26 changed files with 988 additions and 401 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# libuv [![Build Status](https://secure.travis-ci.org/joyent/libuv.png)](http://travis-ci.org/joyent/libuv)

libuv is a new platform layer for Node. Its purpose is to abstract IOCP on
Windows and libev on Unix systems. We intend to eventually contain all
platform differences in this library.
Windows and epoll/kqueue/event ports/etc. on Unix systems. We intend to
eventually contain all platform differences in this library.

http://nodejs.org/

Expand Down
4 changes: 1 addition & 3 deletions include/uv-private/uv-bsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#define UV_BSD_H

#define UV_PLATFORM_FS_EVENT_FIELDS \
ev_io event_watcher; \
int fflags; \
int fd; \
uv__io_t event_watcher; \

#endif /* UV_BSD_H */
4 changes: 1 addition & 3 deletions include/uv-private/uv-darwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
ngx_queue_t cf_signals; \

#define UV_PLATFORM_FS_EVENT_FIELDS \
ev_io event_watcher; \
int fflags; \
int fd; \
uv__io_t event_watcher; \
char* realpath; \
int realpath_len; \
int cf_flags; \
Expand Down
29 changes: 17 additions & 12 deletions include/uv-private/uv-unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

#include "ngx-queue.h"

#include "ev.h"

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
Expand All @@ -46,11 +44,18 @@
struct uv__io_s;
struct uv_loop_s;

typedef void (*uv__io_cb)(struct uv_loop_s* loop,
struct uv__io_s* w,
unsigned int events);
typedef struct uv__io_s uv__io_t;
typedef void (*uv__io_cb)(struct uv_loop_s* loop, uv__io_t* handle, int events);

struct uv__io_s {
ev_io io_watcher;
uv__io_cb cb;
ngx_queue_t pending_queue;
ngx_queue_t watcher_queue;
unsigned int pevents; /* Pending event mask i.e. mask at next tick. */
unsigned int events; /* Current event mask. */
int fd;
};

struct uv__work {
Expand Down Expand Up @@ -135,7 +140,12 @@ typedef struct {

#define UV_LOOP_PRIVATE_FIELDS \
unsigned long flags; \
struct ev_loop* ev; \
int backend_fd; \
ngx_queue_t pending_queue; \
ngx_queue_t watcher_queue; \
uv__io_t** watchers; \
unsigned int nwatchers; \
unsigned int nfds; \
ngx_queue_t wq; \
uv_mutex_t wq_mutex; \
uv_async_t wq_async; \
Expand Down Expand Up @@ -193,31 +203,26 @@ typedef struct {
#define UV_STREAM_PRIVATE_FIELDS \
uv_connect_t *connect_req; \
uv_shutdown_t *shutdown_req; \
uv__io_t read_watcher; \
uv__io_t write_watcher; \
uv__io_t io_watcher; \
ngx_queue_t write_queue; \
ngx_queue_t write_completed_queue; \
uv_connection_cb connection_cb; \
int delayed_error; \
int accepted_fd; \
int fd; \

#define UV_TCP_PRIVATE_FIELDS /* empty */

#define UV_UDP_PRIVATE_FIELDS \
int fd; \
uv_alloc_cb alloc_cb; \
uv_udp_recv_cb recv_cb; \
uv__io_t read_watcher; \
uv__io_t write_watcher; \
uv__io_t io_watcher; \
ngx_queue_t write_queue; \
ngx_queue_t write_completed_queue; \

#define UV_PIPE_PRIVATE_FIELDS \
const char* pipe_fname; /* strdup'ed */

#define UV_POLL_PRIVATE_FIELDS \
int fd; \
uv__io_t io_watcher;

#define UV_PREPARE_PRIVATE_FIELDS \
Expand Down
28 changes: 13 additions & 15 deletions include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1044,9 +1044,8 @@ UV_EXTERN int uv_poll_stop(uv_poll_t* handle);
/*
* uv_prepare_t is a subclass of uv_handle_t.
*
* libev wrapper. Every active prepare handle gets its callback called
* exactly once per loop iteration, just before the system blocks to wait
* for completed i/o.
* Every active prepare handle gets its callback called exactly once per loop
* iteration, just before the system blocks to wait for completed i/o.
*/
struct uv_prepare_s {
UV_HANDLE_FIELDS
Expand All @@ -1063,8 +1062,8 @@ UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare);
/*
* uv_check_t is a subclass of uv_handle_t.
*
* libev wrapper. Every active check handle gets its callback called exactly
* once per loop iteration, just after the system returns from blocking.
* Every active check handle gets its callback called exactly once per loop
* iteration, just after the system returns from blocking.
*/
struct uv_check_s {
UV_HANDLE_FIELDS
Expand All @@ -1081,10 +1080,10 @@ UV_EXTERN int uv_check_stop(uv_check_t* check);
/*
* uv_idle_t is a subclass of uv_handle_t.
*
* libev wrapper. Every active idle handle gets its callback called
* repeatedly until it is stopped. This happens after all other types of
* callbacks are processed. When there are multiple "idle" handles active,
* their callbacks are called in turn.
* Every active idle handle gets its callback called repeatedly until it is
* stopped. This happens after all other types of callbacks are processed.
* When there are multiple "idle" handles active, their callbacks are called
* in turn.
*/
struct uv_idle_s {
UV_HANDLE_FIELDS
Expand All @@ -1101,12 +1100,11 @@ UV_EXTERN int uv_idle_stop(uv_idle_t* idle);
/*
* uv_async_t is a subclass of uv_handle_t.
*
* libev wrapper. uv_async_send wakes up the event
* loop and calls the async handle's callback There is no guarantee that
* every uv_async_send call leads to exactly one invocation of the callback;
* The only guarantee is that the callback function is called at least once
* after the call to async_send. Unlike all other libuv functions,
* uv_async_send can be called from another thread.
* uv_async_send wakes up the event loop and calls the async handle's callback.
* There is no guarantee that every uv_async_send call leads to exactly one
* invocation of the callback; the only guarantee is that the callback function
* is called at least once after the call to async_send. Unlike all other
* libuv functions, uv_async_send can be called from another thread.
*/
struct uv_async_s {
UV_HANDLE_FIELDS
Expand Down
11 changes: 4 additions & 7 deletions src/unix/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <unistd.h>

static int uv__async_init(uv_loop_t* loop);
static void uv__async_io(uv_loop_t* loop, uv__io_t* handle, int events);
static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events);


static int uv__async_make_pending(volatile sig_atomic_t* ptr) {
Expand Down Expand Up @@ -104,17 +104,14 @@ static int uv__async_init(uv_loop_t* loop) {
if (uv__make_pipe(loop->async_pipefd, UV__F_NONBLOCK))
return -1;

uv__io_init(&loop->async_watcher,
uv__async_io,
loop->async_pipefd[0],
UV__IO_READ);
uv__io_start(loop, &loop->async_watcher);
uv__io_init(&loop->async_watcher, uv__async_io, loop->async_pipefd[0]);
uv__io_start(loop, &loop->async_watcher, UV__IO_READ);

return 0;
}


static void uv__async_io(uv_loop_t* loop, uv__io_t* handle, int events) {
static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
char buf[1024];
ngx_queue_t* q;
uv_async_t* h;
Expand Down
Loading

0 comments on commit 1282d64

Please sign in to comment.