From 3368d6c1a222d81c1cf45800e1537cd048fc9cdd Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 22 Sep 2011 23:41:25 +0200 Subject: [PATCH] unix: stub file watcher implementation The file watcher API has not been implemented on all Unices yet. Provide stubs on those platforms so libuv at least compiles. --- include/uv-private/uv-unix.h | 5 +++++ src/unix/cygwin.c | 16 ++++++++++++++++ src/unix/darwin.c | 17 +++++++++++++++++ src/unix/freebsd.c | 19 ++++++++++++++++++- src/unix/netbsd.c | 19 ++++++++++++++++++- src/unix/sunos.c | 19 ++++++++++++++++++- 6 files changed, 92 insertions(+), 3 deletions(-) diff --git a/include/uv-private/uv-unix.h b/include/uv-private/uv-unix.h index 1c6c046ac4..5fa132872d 100644 --- a/include/uv-private/uv-unix.h +++ b/include/uv-private/uv-unix.h @@ -46,6 +46,11 @@ typedef struct { typedef int uv_file; +/* Stub. Remove it once all platforms support the file watcher API. */ +#ifndef UV_FS_EVENT_PRIVATE_FIELDS +#define UV_FS_EVENT_PRIVATE_FIELDS /* empty */ +#endif + #define UV_LOOP_PRIVATE_FIELDS \ ares_channel channel; \ /* \ diff --git a/src/unix/cygwin.c b/src/unix/cygwin.c index d56a8e839b..6702eb9234 100644 --- a/src/unix/cygwin.c +++ b/src/unix/cygwin.c @@ -20,8 +20,10 @@ #include "uv.h" +#include #include #include +#include #include #undef NANOSEC @@ -50,3 +52,17 @@ int uv_exepath(char* buffer, size_t* size) { buffer[*size] = '\0'; return 0; } + + +int uv_fs_event_init(uv_loop_t* loop, + uv_fs_event_t* handle, + const char* filename, + uv_fs_event_cb cb) { + uv_err_new(loop, ENOSYS); + return -1; +} + + +void uv__fs_event_destroy(uv_fs_event_t* handle) { + assert(0 && "implement me"); +} diff --git a/src/unix/darwin.c b/src/unix/darwin.c index bfa06eedef..6bc122cc61 100644 --- a/src/unix/darwin.c +++ b/src/unix/darwin.c @@ -20,7 +20,10 @@ #include "uv.h" +#include #include +#include + #include #include #include @@ -63,3 +66,17 @@ int uv_exepath(char* buffer, size_t* size) { *size = strlen(buffer); return 0; } + + +int uv_fs_event_init(uv_loop_t* loop, + uv_fs_event_t* handle, + const char* filename, + uv_fs_event_cb cb) { + uv_err_new(loop, ENOSYS); + return -1; +} + + +void uv__fs_event_destroy(uv_fs_event_t* handle) { + assert(0 && "implement me"); +} diff --git a/src/unix/freebsd.c b/src/unix/freebsd.c index 6766538f03..449aad4c21 100644 --- a/src/unix/freebsd.c +++ b/src/unix/freebsd.c @@ -20,15 +20,18 @@ #include "uv.h" +#include #include -#include +#include #include #include +#include #undef NANOSEC #define NANOSEC 1000000000 + uint64_t uv_hrtime(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); @@ -63,3 +66,17 @@ int uv_exepath(char* buffer, size_t* size) { return 0; } + + +int uv_fs_event_init(uv_loop_t* loop, + uv_fs_event_t* handle, + const char* filename, + uv_fs_event_cb cb) { + uv_err_new(loop, ENOSYS); + return -1; +} + + +void uv__fs_event_destroy(uv_fs_event_t* handle) { + assert(0 && "implement me"); +} diff --git a/src/unix/netbsd.c b/src/unix/netbsd.c index 91a286feed..0ba7999754 100644 --- a/src/unix/netbsd.c +++ b/src/unix/netbsd.c @@ -20,17 +20,20 @@ #include "uv.h" +#include #include -#include +#include #include #include #include +#include #undef NANOSEC #define NANOSEC 1000000000 + uint64_t uv_hrtime(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); @@ -66,3 +69,17 @@ int uv_exepath(char* buffer, size_t* size) { return 0; } + + +int uv_fs_event_init(uv_loop_t* loop, + uv_fs_event_t* handle, + const char* filename, + uv_fs_event_cb cb) { + uv_err_new(loop, ENOSYS); + return -1; +} + + +void uv__fs_event_destroy(uv_fs_event_t* handle) { + assert(0 && "implement me"); +} diff --git a/src/unix/sunos.c b/src/unix/sunos.c index 9ee6a31034..0b5c03b5a6 100644 --- a/src/unix/sunos.c +++ b/src/unix/sunos.c @@ -22,8 +22,11 @@ #include #include -#include +#include +#include + #include +#include uint64_t uv_hrtime() { @@ -58,3 +61,17 @@ int uv_exepath(char* buffer, size_t* size) { *size = res; return (0); } + + +int uv_fs_event_init(uv_loop_t* loop, + uv_fs_event_t* handle, + const char* filename, + uv_fs_event_cb cb) { + uv_err_new(loop, ENOSYS); + return -1; +} + + +void uv__fs_event_destroy(uv_fs_event_t* handle) { + assert(0 && "implement me"); +}