Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

upgrade libuv

  • Loading branch information...
ry committed Sep 23, 2011
1 parent 74c0206 commit 8d37b6c92b61d9ab66b48ca67fd3e42751f5cf43
@@ -22,7 +22,7 @@ CC = $(PREFIX)gcc
AR = $(PREFIX)ar
E=
CSTDFLAG=--std=c89 -pedantic -Wall -Wextra -Wno-unused-parameter
CFLAGS=-g
CFLAGS += -g
CPPFLAGS += -Isrc/unix/ev
LINKFLAGS=-lm

@@ -0,0 +1,29 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

#ifndef UV_LINUX_H
#define UV_LINUX_H

#define UV_FS_EVENT_PRIVATE_FIELDS \
ev_io read_watcher; \
uv_fs_event_cb cb; \

#endif /* UV_LINUX_H */
@@ -27,6 +27,10 @@
#include "ev.h"
#include "eio.h"

#if defined(__linux__)
#include "uv-private/uv-linux.h"
#endif

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
@@ -42,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; \
/* \
@@ -86,7 +86,8 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
UV_GETADDRINFO_REQ, \
UV_PROCESS_EXIT, \
UV_PROCESS_CLOSE, \
UV_UDP_RECV
UV_UDP_RECV, \
UV_FS_EVENT_REQ

#define UV_REQ_PRIVATE_FIELDS \
union { \
@@ -261,6 +262,16 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);

#define UV_WORK_PRIVATE_FIELDS \

#define UV_FS_EVENT_PRIVATE_FIELDS \
struct uv_fs_event_req_s { \
UV_REQ_FIELDS \
} req; \
HANDLE dir_handle; \
int req_pending; \
uv_fs_event_cb cb; \
wchar_t* filew; \
int is_path_dir; \
char* buffer;

#define UV_TTY_PRIVATE_FIELDS /* empty */

@@ -65,6 +65,8 @@ typedef struct uv_write_s uv_write_t;
typedef struct uv_connect_s uv_connect_t;
typedef struct uv_udp_send_s uv_udp_send_t;
typedef struct uv_fs_s uv_fs_t;
/* uv_fs_event_t is a subclass of uv_handle_t. */
typedef struct uv_fs_event_s uv_fs_event_t;
typedef struct uv_work_s uv_work_t;

#if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)
@@ -137,6 +139,15 @@ typedef void (*uv_fs_cb)(uv_fs_t* req);
typedef void (*uv_work_cb)(uv_work_t* req);
typedef void (*uv_after_work_cb)(uv_work_t* req);

/*
* This will be called repeatedly after the uv_fs_event_t is initialized.
* If uv_fs_event_t was initialized with a directory the filename parameter
* will be a relative path to a file contained in the directory.
* The events paramenter is an ORed mask of enum uv_fs_event elements.
*/
typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename,
int events, int status);


/* Expand this list if necessary. */
typedef enum {
@@ -201,7 +212,8 @@ typedef enum {
UV_ASYNC,
UV_ARES_TASK,
UV_ARES_EVENT,
UV_PROCESS
UV_PROCESS,
UV_FS_EVENT
} uv_handle_type;

typedef enum {
@@ -612,6 +624,17 @@ int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd);
*/
int uv_tty_set_mode(uv_tty_t*, int mode);

/*
* Gets the current Window size. On success zero is returned.
*/
int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);

/*
* Used to detect what type of stream should be used with a given file
* descriptor. Usually this will be used during initialization to guess the
* type of the stdio streams.
*/
uv_handle_type uv_guess_handle(uv_file file);

/*
* uv_pipe_t is a subclass of uv_stream_t
@@ -1002,6 +1025,27 @@ int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid,
int gid, uv_fs_cb cb);


enum uv_fs_event {
UV_RENAME = 1,
UV_CHANGE = 2
};


struct uv_fs_event_s {
UV_HANDLE_FIELDS
char* filename;
UV_FS_EVENT_PRIVATE_FIELDS
};


/*
* If filename is a directory then we will watch for all events in that
* directory. If filename is a file - we will only get events from that
* file. Subdirectories are not watched.
*/
int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
const char* filename, uv_fs_event_cb cb);

/* Utility */

/* Convert string ip addresses to binary structures */
@@ -1037,6 +1081,7 @@ union uv_any_handle {
uv_async_t async;
uv_timer_t timer;
uv_getaddrinfo_t getaddrinfo;
uv_fs_event_t fs_event;
};

union uv_any_req {
@@ -1064,6 +1109,7 @@ struct uv_counters_s {
uint64_t async_init;
uint64_t timer_init;
uint64_t process_init;
uint64_t fs_event_init;
};


@@ -1097,6 +1143,7 @@ struct uv_loop_s {
#undef UV_GETADDRINFO_PRIVATE_FIELDS
#undef UV_FS_REQ_PRIVATE_FIELDS
#undef UV_WORK_PRIVATE_FIELDS
#undef UV_FS_EVENT_PRIVATE_FIELDS

#ifdef __cplusplus
}
@@ -137,6 +137,10 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
ev_child_stop(process->loop->ev, &process->child_watcher);
break;

case UV_FS_EVENT:
uv__fs_event_destroy((uv_fs_event_t*)handle);
break;

default:
assert(0);
}
@@ -250,6 +254,9 @@ void uv__finish_close(uv_handle_t* handle) {
assert(!ev_is_active(&((uv_process_t*)handle)->child_watcher));
break;

case UV_FS_EVENT:
break;

default:
assert(0);
break;
@@ -20,8 +20,10 @@

#include "uv.h"

#include <assert.h>
#include <stdint.h>
#include <stddef.h>
#include <errno.h>
#include <time.h>

#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");
}
@@ -20,7 +20,10 @@

#include "uv.h"

#include <assert.h>
#include <stdint.h>
#include <errno.h>

#include <CoreServices/CoreServices.h>
#include <mach/mach.h>
#include <mach/mach_time.h>
@@ -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");
}
@@ -20,15 +20,18 @@

#include "uv.h"

#include <assert.h>
#include <string.h>
#include <time.h>
#include <errno.h>

#include <sys/types.h>
#include <sys/sysctl.h>
#include <time.h>

#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");
}
@@ -25,6 +25,8 @@
#include "uv-common.h"
#include "uv-eio.h"

#include <stddef.h> /* offsetof */

#if defined(__linux__)

#include <linux/version.h>
@@ -59,6 +61,17 @@
# define HAVE_FUTIMES
#endif

#define container_of(ptr, type, member) \
((type *) ((char *) (ptr) - offsetof(type, member)))

#define SAVE_ERRNO(block) \
do { \
int _saved_errno = errno; \
do { block; } while (0); \
errno = _saved_errno; \
} \
while (0);

/* flags */
enum {
UV_CLOSING = 0x00000001, /* uv_close() called but not finished. */
@@ -110,4 +123,7 @@ int uv_pipe_cleanup(uv_pipe_t* handle);
void uv__udp_destroy(uv_udp_t* handle);
void uv__udp_watcher_stop(uv_udp_t* handle, ev_io* w);

/* fs */
void uv__fs_event_destroy(uv_fs_event_t* handle);

#endif /* UV_UNIX_INTERNAL_H_ */

0 comments on commit 8d37b6c

Please sign in to comment.
You can’t perform that action at this time.