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

Commit

Permalink
uv: upgrade to d808cf9
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Dec 16, 2011
1 parent c744e92 commit 666aa0a
Show file tree
Hide file tree
Showing 22 changed files with 427 additions and 39 deletions.
2 changes: 2 additions & 0 deletions deps/uv/.gitignore
Expand Up @@ -7,6 +7,8 @@
*.orig
*.sdf
*.suo
core
vgcore.*
/out/
/build/gyp

Expand Down
9 changes: 9 additions & 0 deletions deps/uv/.travis.yml
@@ -0,0 +1,9 @@
language: node_js

script:
- "make test"

notifications:
email: false
irc:
- "irc.freenode.net#libuv"
1 change: 1 addition & 0 deletions deps/uv/AUTHORS
Expand Up @@ -36,3 +36,4 @@ Tj Holowaychuk <tj@vision-media.ca>
Shimon Doodkin <helpmepro1@gmail.com>
Ryan Emery <seebees@gmail.com>
Bruce Mitchener <bruce.mitchener@gmail.com>
Maciej Małecki <maciej.malecki@notimplemented.org>
2 changes: 1 addition & 1 deletion deps/uv/README.md
@@ -1,4 +1,4 @@
# libuv
# 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
Expand Down
10 changes: 5 additions & 5 deletions deps/uv/src/unix/core.c
Expand Up @@ -317,8 +317,8 @@ int64_t uv_now(uv_loop_t* loop) {
}


void uv__req_init(uv_req_t* req) {
/* loop->counters.req_init++; */
void uv__req_init(uv_loop_t* loop, uv_req_t* req) {
loop->counters.req_init++;
req->type = UV_UNKNOWN_REQ;
}

Expand Down Expand Up @@ -658,7 +658,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
return -1;
}

uv__req_init((uv_req_t*)handle);
uv__req_init(loop, (uv_req_t*)handle);
handle->type = UV_GETADDRINFO;
handle->loop = loop;
handle->cb = cb;
Expand Down Expand Up @@ -735,8 +735,8 @@ int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
assert(sockfd >= 0);

while (1) {
#if HAVE_ACCEPT4
peerfd = accept4(sockfd, saddr, &slen, SOCK_NONBLOCK | SOCK_CLOEXEC);
#if HAVE_SYS_ACCEPT4
peerfd = sys_accept4(sockfd, saddr, &slen, SOCK_NONBLOCK | SOCK_CLOEXEC);

if (peerfd != -1)
break;
Expand Down
1 change: 1 addition & 0 deletions deps/uv/src/unix/cygwin.c
Expand Up @@ -72,6 +72,7 @@ int uv_fs_event_init(uv_loop_t* loop,
const char* filename,
uv_fs_event_cb cb,
int flags) {
loop->counters.fs_event_init++;
uv__set_sys_error(loop, ENOSYS);
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions deps/uv/src/unix/fs.c
Expand Up @@ -66,7 +66,7 @@ static void uv_fs_req_init(uv_loop_t* loop, uv_fs_t* req, uv_fs_type fs_type,
/* Make sure the thread pool is initialized. */
uv_eio_init(loop);

uv__req_init((uv_req_t*) req);
uv__req_init(loop, (uv_req_t*)req);
req->type = UV_FS;
req->loop = loop;
req->fs_type = fs_type;
Expand Down Expand Up @@ -685,7 +685,7 @@ int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb,

uv_eio_init(loop);

uv__req_init((uv_req_t*) req);
uv__req_init(loop, (uv_req_t*)req);
uv_ref(loop);
req->loop = loop;
req->data = data;
Expand Down
75 changes: 58 additions & 17 deletions deps/uv/src/unix/internal.h
Expand Up @@ -32,30 +32,69 @@
#endif

#undef HAVE_FUTIMES
#undef HAVE_PIPE2
#undef HAVE_ACCEPT4
#undef HAVE_KQUEUE
#undef HAVE_PORTS_FS

#if defined(__linux__)

#include <linux/version.h>
#include <features.h>
# undef HAVE_SYS_UTIMESAT
# undef HAVE_SYS_PIPE2
# undef HAVE_SYS_ACCEPT4

/* futimes() requires linux >= 2.6.22 and glib >= 2.6 */
#if LINUX_VERSION_CODE >= 0x20616 && __GLIBC_PREREQ(2, 6)
#define HAVE_FUTIMES 1
#endif
# undef _GNU_SOURCE
# define _GNU_SOURCE

/* pipe2() requires linux >= 2.6.27 and glibc >= 2.9 */
#if LINUX_VERSION_CODE >= 0x2061B && __GLIBC_PREREQ(2, 9)
#define HAVE_PIPE2 1
#endif
# include <linux/version.h>
# include <sys/syscall.h>
# include <features.h>
# include <unistd.h>

/* accept4() requires linux >= 2.6.28 and glib >= 2.10 */
#if LINUX_VERSION_CODE >= 0x2061C && __GLIBC_PREREQ(2, 10)
#define HAVE_ACCEPT4 1
#endif
# if __NR_utimensat
# define HAVE_SYS_UTIMESAT 1
# endif
# if __NR_pipe2
# define HAVE_SYS_PIPE2 1
# endif
# if __NR_accept4
# define HAVE_SYS_ACCEPT4 1
# endif

# if HAVE_SYS_UTIMESAT
inline static int sys_utimesat(int dirfd,
const char* path,
const struct timespec times[2],
int flags)
{
return syscall(__NR_utimensat, dirfd, path, times, flags);
}
inline static int sys_futimes(int fd, const struct timeval times[2])
{
struct timespec ts[2];
ts[0].tv_sec = times[0].tv_sec, ts[0].tv_nsec = times[0].tv_usec * 1000;
ts[1].tv_sec = times[1].tv_sec, ts[1].tv_nsec = times[1].tv_usec * 1000;
return sys_utimesat(fd, NULL, ts, 0);
}
# undef HAVE_FUTIMES
# define HAVE_FUTIMES 1
# define futimes(fd, times) sys_futimes(fd, times)
# endif /* HAVE_SYS_FUTIMESAT */

# if HAVE_SYS_PIPE2
inline static int sys_pipe2(int pipefd[2], int flags)
{
return syscall(__NR_pipe2, pipefd, flags);
}
# endif /* HAVE_SYS_PIPE2 */

# if HAVE_SYS_ACCEPT4
inline static int sys_accept4(int fd,
struct sockaddr* addr,
socklen_t* addrlen,
int flags)
{
return syscall(__NR_accept4, fd, addr, addrlen, flags);
}
# endif /* HAVE_SYS_ACCEPT4 */

#endif /* __linux__ */

Expand Down Expand Up @@ -106,7 +145,6 @@ enum {
size_t uv__strlcpy(char* dst, const char* src, size_t size);

int uv__close(int fd);
void uv__req_init(uv_req_t*);
void uv__handle_init(uv_loop_t* loop, uv_handle_t* handle, uv_handle_type type);


Expand All @@ -118,6 +156,9 @@ int uv__socket(int domain, int type, int protocol);
uv_err_code uv_translate_sys_error(int sys_errno);
void uv_fatal_error(const int errorno, const char* syscall);

/* requests */
void uv__req_init(uv_loop_t* loop, uv_req_t*);

/* stream */
void uv__stream_init(uv_loop_t* loop, uv_stream_t* stream,
uv_handle_type type);
Expand Down
3 changes: 3 additions & 0 deletions deps/uv/src/unix/kqueue.c
Expand Up @@ -90,6 +90,8 @@ int uv_fs_event_init(uv_loop_t* loop,
int flags) {
int fd;

loop->counters.fs_event_init++;

/* We don't support any flags yet. */
assert(!flags);

Expand Down Expand Up @@ -129,6 +131,7 @@ int uv_fs_event_init(uv_loop_t* loop,
const char* filename,
uv_fs_event_cb cb,
int flags) {
loop->counters.fs_event_init++;
uv__set_sys_error(loop, ENOSYS);
return -1;
}
Expand Down
114 changes: 111 additions & 3 deletions deps/uv/src/unix/linux.c
Expand Up @@ -27,14 +27,98 @@
#include <assert.h>
#include <errno.h>

#include <sys/inotify.h>
#include <sys/sysinfo.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>

#undef NANOSEC
#define NANOSEC 1000000000

#undef HAVE_INOTIFY_INIT
#undef HAVE_INOTIFY_INIT1
#undef HAVE_INOTIFY_ADD_WATCH
#undef HAVE_INOTIFY_RM_WATCH

#if __NR_inotify_init
# define HAVE_INOTIFY_INIT 1
#endif
#if __NR_inotify_init1
# define HAVE_INOTIFY_INIT1 1
#endif
#if __NR_inotify_add_watch
# define HAVE_INOTIFY_ADD_WATCH 1
#endif
#if __NR_inotify_rm_watch
# define HAVE_INOTIFY_RM_WATCH 1
#endif

#if HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1
# undef IN_ACCESS
# undef IN_MODIFY
# undef IN_ATTRIB
# undef IN_CLOSE_WRITE
# undef IN_CLOSE_NOWRITE
# undef IN_OPEN
# undef IN_MOVED_FROM
# undef IN_MOVED_TO
# undef IN_CREATE
# undef IN_DELETE
# undef IN_DELETE_SELF
# undef IN_MOVE_SELF
# define IN_ACCESS 0x001
# define IN_MODIFY 0x002
# define IN_ATTRIB 0x004
# define IN_CLOSE_WRITE 0x008
# define IN_CLOSE_NOWRITE 0x010
# define IN_OPEN 0x020
# define IN_MOVED_FROM 0x040
# define IN_MOVED_TO 0x080
# define IN_CREATE 0x100
# define IN_DELETE 0x200
# define IN_DELETE_SELF 0x400
# define IN_MOVE_SELF 0x800
struct inotify_event {
int32_t wd;
uint32_t mask;
uint32_t cookie;
uint32_t len;
/* char name[0]; */
};
#endif /* HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 */

#undef IN_CLOEXEC
#undef IN_NONBLOCK

#if HAVE_INOTIFY_INIT1
# define IN_CLOEXEC O_CLOEXEC
# define IN_NONBLOCK O_NONBLOCK
#endif /* HAVE_INOTIFY_INIT1 */

#if HAVE_INOTIFY_INIT
inline static int inotify_init(void) {
return syscall(__NR_inotify_init);
}
#endif /* HAVE_INOTIFY_INIT */

#if HAVE_INOTIFY_INIT1
inline static int inotify_init1(int flags) {
return syscall(__NR_inotify_init1, flags);
}
#endif /* HAVE_INOTIFY_INIT1 */

#if HAVE_INOTIFY_ADD_WATCH
inline static int inotify_add_watch(int fd, const char* path, uint32_t mask) {
return syscall(__NR_inotify_add_watch, fd, path, mask);
}
#endif /* HAVE_INOTIFY_ADD_WATCH */

#if HAVE_INOTIFY_RM_WATCH
inline static int inotify_rm_watch(int fd, uint32_t wd) {
return syscall(__NR_inotify_rm_watch, fd, wd);
}
#endif /* HAVE_INOTIFY_RM_WATCH */


/* Don't look aghast, this is exactly how glibc's basename() works. */
static char* basename_r(const char* path) {
Expand Down Expand Up @@ -83,8 +167,10 @@ uint64_t uv_get_total_memory(void) {
return (uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES);
}

#if HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1

static int new_inotify_fd(void) {
#if defined(IN_NONBLOCK) && defined(IN_CLOEXEC)
#if HAVE_INOTIFY_INIT1
return inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
#else
int fd;
Expand Down Expand Up @@ -141,7 +227,7 @@ static void uv__inotify_read(EV_P_ ev_io* w, int revents) {
* for modifications. Repurpose the filename for API compatibility.
* I'm not convinced this is a good thing, maybe it should go.
*/
filename = e->len ? e->name : basename_r(handle->filename);
filename = e->len ? (const char*) (e + 1) : basename_r(handle->filename);

handle->cb(handle, filename, events, 0);

Expand All @@ -161,6 +247,8 @@ int uv_fs_event_init(uv_loop_t* loop,
int events;
int fd;

loop->counters.fs_event_init++;

/* We don't support any flags yet. */
assert(!flags);

Expand Down Expand Up @@ -207,3 +295,23 @@ void uv__fs_event_destroy(uv_fs_event_t* handle) {
free(handle->filename);
handle->filename = NULL;
}

#else /* !HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 */

int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb,
int flags) {
loop->counters.fs_event_init++;
uv__set_sys_error(loop, ENOSYS);
return -1;
}


void uv__fs_event_destroy(uv_fs_event_t* handle) {
assert(0 && "unreachable");
abort();
}

#endif /* HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 */
1 change: 0 additions & 1 deletion deps/uv/src/unix/pipe.c
Expand Up @@ -274,5 +274,4 @@ void uv__pipe_accept(EV_P_ ev_io* watcher, int revents) {


void uv_pipe_pending_instances(uv_pipe_t* handle, int count) {
return 0;
}
4 changes: 2 additions & 2 deletions deps/uv/src/unix/process.c
Expand Up @@ -104,15 +104,15 @@ static int uv__make_socketpair(int fds[2], int flags) {


static int uv__make_pipe(int fds[2], int flags) {
#if HAVE_PIPE2
#if HAVE_SYS_PIPE2
int fl;

fl = O_CLOEXEC;

if (flags & UV__F_NONBLOCK)
fl |= O_NONBLOCK;

if (pipe2(fds, fl) == 0)
if (sys_pipe2(fds, fl) == 0)
return 0;

if (errno != ENOSYS)
Expand Down

0 comments on commit 666aa0a

Please sign in to comment.