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

Commit

Permalink
Upgrade libuv to cbbb254
Browse files Browse the repository at this point in the history
Fixes #1506
  • Loading branch information
ry committed Aug 29, 2011
1 parent ff7f7ae commit 59fa16f
Show file tree
Hide file tree
Showing 20 changed files with 1,958 additions and 54 deletions.
7 changes: 5 additions & 2 deletions deps/uv/README
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ To build via Makefile simply execute:

make

To build with Visual Studio run the create-msvs-files.bat file which will
checkout the GYP code into build/gyp and generate the build/all.sln and
To build with Visual Studio run the vcbuilds.bat file which will
checkout the GYP code into build/gyp and generate the uv.sln and
related files.

Windows users can also build from cmd-line using msbuild. This is
done by running vcbuild.bat from Visual Studio command prompt.

To have GYP generate build script for another system you will need to
checkout GYP into the project tree manually:

Expand Down
11 changes: 7 additions & 4 deletions deps/uv/config-unix.mk
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,18 @@ endif
RUNNER_LIBS=
RUNNER_SRC=test/runner-unix.c

uv.a: src/uv-unix.o src/uv-common.o src/uv-platform.o src/ev/ev.o src/uv-eio.o src/eio/eio.o $(CARES_OBJS)
$(AR) rcs uv.a src/uv-unix.o src/uv-platform.o src/uv-common.o src/uv-eio.o src/ev/ev.o \
uv.a: src/uv-unix.o src/unix/fs.o src/uv-common.o src/uv-platform.o src/ev/ev.o src/uv-eio.o src/eio/eio.o $(CARES_OBJS)
$(AR) rcs uv.a src/uv-unix.o src/unix/fs.o src/uv-platform.o src/uv-common.o src/uv-eio.o src/ev/ev.o \
src/eio/eio.o $(CARES_OBJS)

src/uv-platform.o: src/$(UV_OS_FILE) include/uv.h include/uv-unix.h
$(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c src/$(UV_OS_FILE) -o src/uv-platform.o

src/uv-unix.o: src/uv-unix.c include/uv.h include/uv-unix.h
$(CC) $(CSTDFLAG) $(CPPFLAGS) -Ieio $(CFLAGS) -c src/uv-unix.c -o src/uv-unix.o
src/uv-unix.o: src/uv-unix.c include/uv.h include/uv-unix.h src/unix/internal.h
$(CC) $(CSTDFLAG) $(CPPFLAGS) -Isrc $(CFLAGS) -c src/uv-unix.c -o src/uv-unix.o

src/unix/fs.o: src/unix/fs.c include/uv.h include/uv-unix.h src/unix/internal.h
$(CC) $(CSTDFLAG) $(CPPFLAGS) -Isrc/ $(CFLAGS) -c src/unix/fs.c -o src/unix/fs.o

src/uv-common.o: src/uv-common.c include/uv.h include/uv-unix.h
$(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c src/uv-common.c -o src/uv-common.o
Expand Down
21 changes: 0 additions & 21 deletions deps/uv/create-msvs-files.bat

This file was deleted.

8 changes: 8 additions & 0 deletions deps/uv/include/uv-unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ngx-queue.h"

#include "ev.h"
#include "eio.h"

#include <sys/types.h>
#include <sys/socket.h>
Expand All @@ -39,6 +40,8 @@ typedef struct {
size_t len;
} uv_buf_t;

typedef int uv_file;

#define UV_REQ_BUFSML_SIZE (4)

#define UV_REQ_PRIVATE_FIELDS /* empty */
Expand Down Expand Up @@ -155,4 +158,9 @@ typedef struct {
#define UV_PROCESS_PRIVATE_FIELDS \
ev_child child_watcher;

#define UV_FS_PRIVATE_FIELDS \
eio_req* eio;

#define UV_WORK_PRIVATE_FIELDS

#endif /* UV_UNIX_H */
19 changes: 19 additions & 0 deletions deps/uv/include/uv-win.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ typedef struct uv_buf_t {
char* base;
} uv_buf_t;

typedef int uv_file;

#define UV_REQ_TYPE_PRIVATE \
/* TODO: remove the req suffix */ \
UV_ARES_EVENT_REQ, \
Expand Down Expand Up @@ -208,5 +210,22 @@ typedef struct uv_buf_t {
HANDLE process_handle; \
HANDLE close_handle;

#define UV_FS_PRIVATE_FIELDS \
int flags; \
void* arg0; \
union { \
struct { \
void* arg1; \
void* arg2; \
void* arg3; \
}; \
struct { \
ssize_t arg4; \
ssize_t arg5; \
}; \
};

#define UV_WORK_PRIVATE_FIELDS \

int uv_utf16_to_utf8(const wchar_t* utf16Buffer, size_t utf16Size, char* utf8Buffer, size_t utf8Size);
int uv_utf8_to_utf16(const char* utf8Buffer, wchar_t* utf16Buffer, size_t utf16Size);
96 changes: 96 additions & 0 deletions deps/uv/include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ typedef struct uv_shutdown_s uv_shutdown_t;
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;
typedef struct uv_work_s uv_work_t;

#if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)
# include "uv-unix.h"
Expand Down Expand Up @@ -123,6 +125,9 @@ typedef void (*uv_check_cb)(uv_check_t* handle, int status);
typedef void (*uv_idle_cb)(uv_idle_t* handle, int status);
typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* handle, int status, struct addrinfo* res);
typedef void (*uv_exit_cb)(uv_process_t*, int exit_status, int term_signal);
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);


/* Expand this list if necessary. */
Expand Down Expand Up @@ -199,6 +204,8 @@ typedef enum {
UV_SHUTDOWN,
UV_WAKEUP,
UV_UDP_SEND,
UV_FS,
UV_WORK,
UV_REQ_TYPE_PRIVATE
} uv_req_type;

Expand Down Expand Up @@ -801,6 +808,91 @@ int uv_spawn(uv_process_t*, uv_process_options_t options);
int uv_process_kill(uv_process_t*, int signum);


/*
* uv_work_t is a subclass of uv_req_t
*/
struct uv_work_s {
UV_REQ_FIELDS
uv_work_cb work_cb;
uv_after_work_cb after_work_cb;
UV_WORK_PRIVATE_FIELDS
};

/* Queues a work request to execute asynchronously on the thread pool. */
int uv_queue_work(uv_work_t* req, uv_work_cb work_cb, uv_after_work_cb after_work_cb);


typedef enum {
UV_FS_UNKNOWN = -1,
UV_FS_CUSTOM,
UV_FS_OPEN,
UV_FS_CLOSE,
UV_FS_READ,
UV_FS_WRITE,
UV_FS_SENDFILE,
UV_FS_STAT,
UV_FS_LSTAT,
UV_FS_FSTAT,
UV_FS_FTRUNCATE,
UV_FS_UTIME,
UV_FS_FUTIME,
UV_FS_CHMOD,
UV_FS_FCHMOD,
UV_FS_FSYNC,
UV_FS_FDATASYNC,
UV_FS_UNLINK,
UV_FS_RMDIR,
UV_FS_MKDIR,
UV_FS_RENAME,
UV_FS_READDIR,
UV_FS_LINK,
UV_FS_SYMLINK,
UV_FS_READLINK,
UV_FS_CHOWN,
UV_FS_FCHOWN
} uv_fs_type;

/*
* uv_fs_t is a subclass of uv_req_t
*/
struct uv_fs_s {
UV_REQ_FIELDS
uv_fs_type fs_type;
uv_fs_cb cb;
ssize_t result;
void* ptr;
int errorno;
UV_FS_PRIVATE_FIELDS
};

void uv_fs_req_cleanup(uv_fs_t* req);
int uv_fs_close(uv_fs_t* req, uv_file file, uv_fs_cb cb);
int uv_fs_open(uv_fs_t* req, const char* path, int flags, int mode, uv_fs_cb cb);
int uv_fs_read(uv_fs_t* req, uv_file file, void* buf, size_t length, off_t offset, uv_fs_cb cb);
int uv_fs_unlink(uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_write(uv_fs_t* req, uv_file file, void* buf, size_t length, off_t offset, uv_fs_cb cb);
int uv_fs_mkdir(uv_fs_t* req, const char* path, int mode, uv_fs_cb cb);
int uv_fs_rmdir(uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_readdir(uv_fs_t* req, const char* path, int flags, uv_fs_cb cb);
int uv_fs_stat(uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_fstat(uv_fs_t* req, uv_file file, uv_fs_cb cb);
int uv_fs_rename(uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb);
int uv_fs_fsync(uv_fs_t* req, uv_file file, uv_fs_cb cb);
int uv_fs_fdatasync(uv_fs_t* req, uv_file file, uv_fs_cb cb);
int uv_fs_ftruncate(uv_fs_t* req, uv_file file, off_t offset, uv_fs_cb cb);
int uv_fs_sendfile(uv_fs_t* req, uv_file out_fd, uv_file in_fd, off_t in_offset, size_t length, uv_fs_cb cb);
int uv_fs_chmod(uv_fs_t* req, const char* path, int mode, uv_fs_cb cb);
int uv_fs_utime(uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb);
int uv_fs_futime(uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb);
int uv_fs_lstat(uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_link(uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb);
int uv_fs_symlink(uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb);
int uv_fs_readlink(uv_fs_t* req, const char* path, uv_fs_cb cb);
int uv_fs_fchmod(uv_fs_t* req, uv_file file, int mode, uv_fs_cb cb);
int uv_fs_chown(uv_fs_t* req, const char* path, int uid, int gid, uv_fs_cb cb);
int uv_fs_fchown(uv_fs_t* req, uv_file file, int uid, int gid, uv_fs_cb cb);


/* Utility */

/* Convert string ip addresses to binary structures */
Expand Down Expand Up @@ -843,6 +935,8 @@ union uv_any_req {
uv_write_t write;
uv_connect_t connect;
uv_shutdown_t shutdown;
uv_fs_t fs_req;
uv_work_t work_req;
};


Expand Down Expand Up @@ -876,6 +970,8 @@ uv_counters_t* uv_counters();
#undef UV_ASYNC_PRIVATE_FIELDS
#undef UV_TIMER_PRIVATE_FIELDS
#undef UV_GETADDRINFO_PRIVATE_FIELDS
#undef UV_FS_REQ_PRIVATE_FIELDS
#undef UV_WORK_PRIVATE_FIELDS

#ifdef __cplusplus
}
Expand Down
29 changes: 25 additions & 4 deletions deps/uv/src/eio/eio.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ static void eio_destroy (eio_req *req);
static int
symlink (const char *old, const char *neu)
{
#if 0 && WINVER >= 0x0600
if (CreateSymbolicLink (neu, old, SYMBOLIC_LINK_FLAG_DIRECTORY))
#if WINVER >= 0x0600
if (CreateSymbolicLink (neu, old, 1))
return 0;

if (CreateSymbolicLink (neu, old, 0))
Expand Down Expand Up @@ -401,6 +401,16 @@ static xmutex_t reslock;
static xmutex_t reqlock;
static xcond_t reqwait;

/* Fix for test-fs-sir-writes-alot */
/* Apple's OSX can't safely write() concurrently from 2 threads */
/* for more info see the thread "fs.write Data Munging" in the nodejs google group */
/* http://groups.google.com/group/nodejs/browse_thread/thread/c11f8b683f37cef/b18ad9e0a15314c5 */
/* And the thread "write()s and pwrite()s from multiple threads in OSX" in libev@lists.schmorp.de */
/* http://lists.schmorp.de/pipermail/libev/2010q4/001185.html */
#if defined (__APPLE__)
static xmutex_t apple_bug_writelock = X_MUTEX_INIT;
#endif

#if !HAVE_PREADWRITE
/*
* make our pread/pwrite emulation safe against themselves, but not against
Expand Down Expand Up @@ -2153,9 +2163,20 @@ eio_execute (etp_worker *self, eio_req *req)
req->result = req->offs >= 0
? pread (req->int1, req->ptr2, req->size, req->offs)
: read (req->int1, req->ptr2, req->size); break;
case EIO_WRITE: req->result = req->offs >= 0

case EIO_WRITE:
#if defined (__APPLE__)
pthread_mutex_lock (&apple_bug_writelock);
#endif

req->result = req->offs >= 0
? pwrite (req->int1, req->ptr2, req->size, req->offs)
: write (req->int1, req->ptr2, req->size); break;
: write (req->int1, req->ptr2, req->size);

#if defined (__APPLE__)
pthread_mutex_unlock (&apple_bug_writelock);
#endif
break;

case EIO_READAHEAD: req->result = readahead (req->int1, req->offs, req->size); break;
case EIO_SENDFILE: req->result = eio__sendfile (req->int1, req->int2, req->offs, req->size); break;
Expand Down
Loading

0 comments on commit 59fa16f

Please sign in to comment.