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

Commit

Permalink
unix: rename UV__IO_* constants
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Nov 16, 2012
1 parent 1282d64 commit 65bb6f0
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion src/unix/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int uv__async_init(uv_loop_t* loop) {
return -1;

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

return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions src/unix/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ static void uv__run_pending(uv_loop_t* loop) {
ngx_queue_init(q);

w = ngx_queue_data(q, uv__io_t, pending_queue);
w->cb(loop, w, UV__IO_WRITE);
w->cb(loop, w, UV__POLLOUT);
}
}

Expand Down Expand Up @@ -595,7 +595,7 @@ void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) {


void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
assert(0 == (events & ~(UV__IO_READ | UV__IO_WRITE)));
assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT)));
assert(0 != events);
assert(w->fd >= 0);
assert(w->fd < INT_MAX);
Expand All @@ -614,7 +614,7 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {


void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
assert(0 == (events & ~(UV__IO_READ | UV__IO_WRITE)));
assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT)));
assert(0 != events);

if (w->fd == -1)
Expand Down Expand Up @@ -655,7 +655,7 @@ void uv__io_feed(uv_loop_t* loop, uv__io_t* w) {


int uv__io_active(const uv__io_t* w, unsigned int events) {
assert(0 == (events & ~(UV__IO_READ | UV__IO_WRITE)));
assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT)));
assert(0 != events);
return 0 != (w->pevents & events);
}
32 changes: 16 additions & 16 deletions src/unix/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,33 @@
while (0)

#if defined(__linux__)
# define UV__IO_READ UV__EPOLLIN
# define UV__IO_WRITE UV__EPOLLOUT
# define UV__IO_ERROR UV__EPOLLERR
# define UV__IO_HUP UV__EPOLLHUP
# define UV__POLLIN UV__EPOLLIN
# define UV__POLLOUT UV__EPOLLOUT
# define UV__POLLERR UV__EPOLLERR
# define UV__POLLHUP UV__EPOLLHUP
#endif

#if defined(__sun)
# define UV__IO_READ POLLIN
# define UV__IO_WRITE POLLOUT
# define UV__IO_ERROR POLLERR
# define UV__IO_HUP POLLHUP
# define UV__POLLIN POLLIN
# define UV__POLLOUT POLLOUT
# define UV__POLLERR POLLERR
# define UV__POLLHUP POLLHUP
#endif

#ifndef UV__IO_READ
# define UV__IO_READ 1
#ifndef UV__POLLIN
# define UV__POLLIN 1
#endif

#ifndef UV__IO_WRITE
# define UV__IO_WRITE 2
#ifndef UV__POLLOUT
# define UV__POLLOUT 2
#endif

#ifndef UV__IO_ERROR
# define UV__IO_ERROR 4
#ifndef UV__POLLERR
# define UV__POLLERR 4
#endif

#ifndef UV__IO_HUP
# define UV__IO_HUP 8
#ifndef UV__POLLHUP
# define UV__POLLHUP 8
#endif

/* handle flags */
Expand Down
24 changes: 12 additions & 12 deletions src/unix/kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
if (w->events == w->pevents)
continue;

if ((w->events & UV__IO_READ) == 0 && (w->pevents & UV__IO_READ) != 0) {
if ((w->events & UV__POLLIN) == 0 && (w->pevents & UV__POLLIN) != 0) {
filter = EVFILT_READ;
fflags = 0;
op = EV_ADD;
Expand All @@ -111,7 +111,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}
}

if ((w->events & UV__IO_WRITE) == 0 && (w->pevents & UV__IO_WRITE) != 0) {
if ((w->events & UV__POLLOUT) == 0 && (w->pevents & UV__POLLOUT) != 0) {
EV_SET(events + nevents, w->fd, EVFILT_WRITE, EV_ADD, 0, 0, 0);

if (++nevents == ARRAY_SIZE(events)) {
Expand Down Expand Up @@ -181,8 +181,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}

if (ev->filter == EVFILT_VNODE) {
assert(w->events == UV__IO_READ);
assert(w->pevents == UV__IO_READ);
assert(w->events == UV__POLLIN);
assert(w->pevents == UV__POLLIN);
w->cb(loop, w, ev->fflags); /* XXX always uv__fs_event() */
nevents++;
continue;
Expand All @@ -191,8 +191,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
revents = 0;

if (ev->filter == EVFILT_READ) {
if (w->events & UV__IO_READ)
revents |= UV__IO_READ;
if (w->events & UV__POLLIN)
revents |= UV__POLLIN;
else {
/* TODO batch up */
struct kevent events[1];
Expand All @@ -202,8 +202,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}

if (ev->filter == EVFILT_WRITE) {
if (w->events & UV__IO_WRITE)
revents |= UV__IO_WRITE;
if (w->events & UV__POLLOUT)
revents |= UV__POLLOUT;
else {
/* TODO batch up */
struct kevent events[1];
Expand All @@ -213,7 +213,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}

if (ev->flags & EV_ERROR)
revents |= UV__IO_ERROR;
revents |= UV__POLLERR;

if (revents == 0)
continue;
Expand Down Expand Up @@ -320,7 +320,7 @@ int uv_fs_event_init(uv_loop_t* loop,
fallback:
#endif /* defined(__APPLE__) */

uv__io_start(loop, &handle->event_watcher, UV__IO_READ);
uv__io_start(loop, &handle->event_watcher, UV__POLLIN);

return 0;
}
Expand All @@ -329,9 +329,9 @@ int uv_fs_event_init(uv_loop_t* loop,
void uv__fs_event_close(uv_fs_event_t* handle) {
#if defined(__APPLE__)
if (uv__fsevents_close(handle))
uv__io_stop(handle->loop, &handle->event_watcher, UV__IO_READ);
uv__io_stop(handle->loop, &handle->event_watcher, UV__POLLIN);
#else
uv__io_stop(handle->loop, &handle->event_watcher, UV__IO_READ);
uv__io_stop(handle->loop, &handle->event_watcher, UV__POLLIN);
#endif /* defined(__APPLE__) */

uv__handle_stop(handle);
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux/inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static int init_inotify(uv_loop_t* loop) {
}

uv__io_init(&loop->inotify_read_watcher, uv__inotify_read, loop->inotify_fd);
uv__io_start(loop, &loop->inotify_read_watcher, UV__IO_READ);
uv__io_start(loop, &loop->inotify_read_watcher, UV__POLLIN);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/unix/linux/linux-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {

void uv__platform_loop_delete(uv_loop_t* loop) {
if (loop->inotify_fd == -1) return;
uv__io_stop(loop, &loop->inotify_read_watcher, UV__IO_READ);
uv__io_stop(loop, &loop->inotify_read_watcher, UV__POLLIN);
close(loop->inotify_fd);
loop->inotify_fd = -1;
}
Expand Down
6 changes: 3 additions & 3 deletions src/unix/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
} else {
handle->connection_cb = cb;
handle->io_watcher.cb = uv__pipe_accept;
uv__io_start(handle->loop, &handle->io_watcher, UV__IO_READ);
uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN);
}

out:
Expand Down Expand Up @@ -200,7 +200,7 @@ void uv_pipe_connect(uv_connect_t* req,
UV_STREAM_READABLE | UV_STREAM_WRITABLE))
goto out;

uv__io_start(handle->loop, &handle->io_watcher, UV__IO_READ|UV__IO_WRITE);
uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN | UV__POLLOUT);
err = 0;

out:
Expand Down Expand Up @@ -244,7 +244,7 @@ static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
pipe->connection_cb((uv_stream_t*)pipe, 0);
if (pipe->accepted_fd == sockfd) {
/* The user hasn't called uv_accept() yet */
uv__io_stop(pipe->loop, &pipe->io_watcher, UV__IO_READ);
uv__io_stop(pipe->loop, &pipe->io_watcher, UV__POLLIN);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/unix/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {

handle = container_of(w, uv_poll_t, io_watcher);

if (events & UV__IO_ERROR) {
uv__io_stop(loop, w, UV__IO_READ | UV__IO_WRITE);
if (events & UV__POLLERR) {
uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT);
uv__handle_stop(handle);
uv__set_sys_error(handle->loop, EBADF);
handle->poll_cb(handle, -1, 0);
return;
}

pevents = 0;
if (events & UV__IO_READ)
if (events & UV__POLLIN)
pevents |= UV_READABLE;
if (events & UV__IO_WRITE)
if (events & UV__POLLOUT)
pevents |= UV_WRITABLE;

handle->poll_cb(handle, 0, pevents);
Expand All @@ -66,7 +66,7 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,


static void uv__poll_stop(uv_poll_t* handle) {
uv__io_stop(handle->loop, &handle->io_watcher, UV__IO_READ | UV__IO_WRITE);
uv__io_stop(handle->loop, &handle->io_watcher, UV__POLLIN | UV__POLLOUT);
uv__handle_stop(handle);
}

Expand All @@ -91,9 +91,9 @@ int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) {

events = 0;
if (pevents & UV_READABLE)
events |= UV__IO_READ;
events |= UV__POLLIN;
if (pevents & UV_WRITABLE)
events |= UV__IO_WRITE;
events |= UV__POLLOUT;

uv__io_start(handle->loop, &handle->io_watcher, events);
uv__handle_start(handle);
Expand Down
2 changes: 1 addition & 1 deletion src/unix/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static int uv__signal_loop_once_init(uv_loop_t* loop) {
uv__io_init(&loop->signal_io_watcher,
uv__signal_event,
loop->signal_pipefd[0]);
uv__io_start(loop, &loop->signal_io_watcher, UV__IO_READ);
uv__io_start(loop, &loop->signal_io_watcher, UV__POLLIN);

return 0;
}
Expand Down
Loading

0 comments on commit 65bb6f0

Please sign in to comment.