From fe4b7420a3e1d31d92f1c2fc03d89682bba0091b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 30 Aug 2011 13:09:47 +0200 Subject: [PATCH] uv: upgrade to 0ba44cf --- deps/uv/src/ev/config_linux.h | 41 ++++++++++++++++++++++++++--------------- deps/uv/src/unix/fs.c | 8 +++++--- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/deps/uv/src/ev/config_linux.h b/deps/uv/src/ev/config_linux.h index b147b59..a13b179 100644 --- a/deps/uv/src/ev/config_linux.h +++ b/deps/uv/src/ev/config_linux.h @@ -2,12 +2,7 @@ /* config.h.in. Generated from configure.ac by autoheader. */ #include - -#define LINUX_VERSION_CODE_FOR(major, minor, patch) \ - (((major & 255) << 16) | ((minor & 255) << 8) | (patch & 255)) - -#define LINUX_VERSION_AT_LEAST(major, minor, patch) \ - (LINUX_VERSION_CODE >= LINUX_VERSION_CODE_FOR(major, minor, patch)) +#include /* Define to 1 if you have the `clock_gettime' function. */ /* #undef HAVE_CLOCK_GETTIME */ @@ -18,14 +13,26 @@ /* Define to 1 if you have the header file. */ #define HAVE_DLFCN_H 1 -/* Define to 1 if you have the `epoll_ctl' function. */ +/* epoll_ctl(2) is available if kernel >= 2.6.9 and glibc >= 2.4 */ +#if LINUX_VERSION_CODE >= 0x020609 && __GLIBC_PREREQ(2, 4) #define HAVE_EPOLL_CTL 1 - -/* Define to 1 if you have the `eventfd' function. */ -#define HAVE_EVENTFD LINUX_VERSION_AT_LEAST(2, 6, 22) - -/* Define to 1 if you have the `inotify_init' function. */ -#define HAVE_INOTIFY_INIT LINUX_VERSION_AT_LEAST(2, 6, 13) +#else +#define HAVE_EPOLL_CTL 0 +#endif + +/* eventfd(2) is available if kernel >= 2.6.22 and glibc >= 2.8 */ +#if LINUX_VERSION_CODE >= 0x020616 && __GLIBC_PREREQ(2, 8) +#define HAVE_EVENTFD 1 +#else +#define HAVE_EVENTFD 0 +#endif + +/* inotify_init(2) is available if kernel >= 2.6.13 and glibc >= 2.4 */ +#if LINUX_VERSION_CODE >= 0x02060d && __GLIBC_PREREQ(2, 4) +#define HAVE_INOTIFY_INIT 1 +#else +#define HAVE_INOTIFY_INIT 0 +#endif /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 @@ -60,8 +67,12 @@ /* Define to 1 if you have the `select' function. */ #define HAVE_SELECT 1 -/* Define to 1 if you have the `signalfd' function. */ -#define HAVE_SIGNALFD LINUX_VERSION_AT_LEAST(2, 6, 22) +/* signalfd(2) is available if kernel >= 2.6.22 and glibc >= 2.8 */ +#if LINUX_VERSION_CODE >= 0x020616 && __GLIBC_PREREQ(2, 8) +#define HAVE_SIGNALFD 1 +#else +#define HAVE_SIGNALFD 0 +#endif /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index b6fb16f..4d26935 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -304,6 +304,7 @@ int uv_fs_readdir(uv_fs_t* req, const char* path, int flags, uv_fs_cb cb) { int r; struct dirent* entry; size_t size = 0; + size_t d_namlen = 0; uv_fs_req_init(req, UV_FS_READDIR, cb); @@ -325,11 +326,12 @@ int uv_fs_readdir(uv_fs_t* req, const char* path, int flags, uv_fs_cb cb) { } while ((entry = readdir(dir))) { - req->ptr = realloc(req->ptr, size + entry->d_namlen + 1); + d_namlen = strlen(entry->d_name); + req->ptr = realloc(req->ptr, size + d_namlen + 1); /* TODO check ENOMEM */ /* TODO skip . and .. */ - memcpy((char*)req->ptr + size, entry->d_name, entry->d_namlen); - size += entry->d_namlen; + memcpy((char*)req->ptr + size, entry->d_name, d_namlen); + size += d_namlen; ((char*)req->ptr)[size] = '\0'; size++; } -- 2.7.4