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

Commit

Permalink
Browse files Browse the repository at this point in the history
upgrade libuv
  • Loading branch information
ry committed Sep 23, 2011
1 parent 74c0206 commit 8d37b6c
Show file tree
Hide file tree
Showing 23 changed files with 1,050 additions and 7 deletions.
2 changes: 1 addition & 1 deletion deps/uv/config-unix.mk
Expand Up @@ -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

Expand Down
29 changes: 29 additions & 0 deletions deps/uv/include/uv-private/uv-linux.h
@@ -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 */
9 changes: 9 additions & 0 deletions deps/uv/include/uv-private/uv-unix.h
Expand Up @@ -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>
Expand All @@ -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; \
/* \
Expand Down
13 changes: 12 additions & 1 deletion deps/uv/include/uv-private/uv-win.h
Expand Up @@ -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 { \
Expand Down Expand Up @@ -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 */

Expand Down
49 changes: 48 additions & 1 deletion deps/uv/include/uv.h
Expand Up @@ -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__)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
};


Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 7 additions & 0 deletions deps/uv/src/unix/core.c
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions deps/uv/src/unix/cygwin.c
Expand Up @@ -20,8 +20,10 @@

#include "uv.h"

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

#undef NANOSEC
Expand Down Expand Up @@ -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");
}
17 changes: 17 additions & 0 deletions deps/uv/src/unix/darwin.c
Expand Up @@ -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>
Expand Down Expand Up @@ -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");
}
19 changes: 18 additions & 1 deletion deps/uv/src/unix/freebsd.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
16 changes: 16 additions & 0 deletions deps/uv/src/unix/internal.h
Expand Up @@ -25,6 +25,8 @@
#include "uv-common.h"
#include "uv-eio.h"

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

#if defined(__linux__)

#include <linux/version.h>
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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.