Skip to content

Commit

Permalink
Upgrade libuv to f5ff8694
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jul 14, 2011
1 parent b722aaa commit 7a78216
Show file tree
Hide file tree
Showing 47 changed files with 2,269 additions and 1,441 deletions.
12 changes: 9 additions & 3 deletions deps/uv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,23 @@ test/echo.o: test/echo.c test/echo.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c test/echo.c -o test/echo.o


.PHONY: clean clean-platform distclean distclean-platform test benchmark
.PHONY: clean clean-platform distclean distclean-platform test bench


test: test/run-tests$(E)
test/run-tests

#test-%: test/run-tests$(E)
# test/run-tests $(@:test-%=%)

bench: test/run-benchmarks$(E)
test/run-benchmarks

#bench-%: test/run-benchmarks$(E)
# test/run-benchmarks $(@:bench-%=%)

clean: clean-platform
$(RM) -f *.o *.a test/run-tests$(E) test/run-benchmarks$(E)
$(RM) -f src/*.o *.a test/run-tests$(E) test/run-benchmarks$(E)

distclean: distclean-platform
$(RM) -f *.o *.a test/run-tests$(E) test/run-benchmarks$(E)
$(RM) -f src/*.o *.a test/run-tests$(E) test/run-benchmarks$(E)
4 changes: 2 additions & 2 deletions deps/uv/config-mingw.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

# Use make -f Makefile.gcc PREFIX=i686-w64-mingw32-
# for cross compilation
CC ?= $(PREFIX)gcc
AR ?= $(PREFIX)ar
CC = $(PREFIX)gcc
AR = $(PREFIX)ar
E=.exe

CFLAGS=$(CPPFLAGS) -g --std=gnu89 -D_WIN32_WINNT=0x0501 -Isrc/ares/config_win32
Expand Down
16 changes: 9 additions & 7 deletions deps/uv/config-unix.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

CC ?= $(PREFIX)gcc
AR ?= $(PREFIX)ar
CC = $(PREFIX)gcc
AR = $(PREFIX)ar
E=
CFLAGS=--std=gnu89 -g
CSTDFLAG=--std=c89 -pedantic
CFLAGS=-g
CPPFLAGS += -Isrc/ev
LINKFLAGS=-lm

Expand All @@ -47,6 +48,7 @@ endif
ifeq (Linux,$(uname_S))
EV_CONFIG=config_linux.h
EIO_CONFIG=config_linux.h
CSTDFLAG += -D_XOPEN_SOURCE=600
CPPFLAGS += -Isrc/ares/config_linux
LINKFLAGS+=-lrt
UV_OS_FILE=uv-linux.c
Expand Down Expand Up @@ -80,13 +82,13 @@ uv.a: src/uv-unix.o src/uv-common.o src/uv-platform.o src/ev/ev.o src/uv-eio.o s
src/eio/eio.o $(CARES_OBJS)

src/uv-platform.o: src/$(UV_OS_FILE) include/uv.h include/uv-unix.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c src/$(UV_OS_FILE) -o src/uv-platform.o
$(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) $(CPPFLAGS) -Ieio $(CFLAGS) -c src/uv-unix.c -o src/uv-unix.o
$(CC) $(CSTDFLAG) $(CPPFLAGS) -Ieio $(CFLAGS) -c src/uv-unix.c -o src/uv-unix.o

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

src/ev/ev.o: src/ev/ev.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c src/ev/ev.c -o src/ev/ev.o -DEV_CONFIG_H=\"$(EV_CONFIG)\"
Expand All @@ -101,7 +103,7 @@ src/eio/eio.o: src/eio/eio.c
$(CC) $(EIO_CPPFLAGS) $(CFLAGS) -c src/eio/eio.c -o src/eio/eio.o

src/uv-eio.o: src/uv-eio.c
$(CC) $(CPPFLAGS) -Isrc/eio/ $(CFLAGS) -c src/uv-eio.c -o src/uv-eio.o
$(CC) $(CPPFLAGS) -Isrc/eio/ $(CSTDFLAG) $(CFLAGS) -c src/uv-eio.c -o src/uv-eio.o


clean-platform:
Expand Down
1 change: 1 addition & 0 deletions deps/uv/include/ares.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

#else /* Not Windows */

# include <sys/time.h>
# include <sys/types.h>
# include <sys/socket.h>
#endif
Expand Down
4 changes: 2 additions & 2 deletions deps/uv/include/eio.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ enum
enum
{
EIO_MCL_CURRENT = 1,
EIO_MCL_FUTURE = 2,
EIO_MCL_FUTURE = 2
};

/* request priorities */

enum {
EIO_PRI_MIN = -4,
EIO_PRI_MAX = 4,
EIO_PRI_DEFAULT = 0,
EIO_PRI_DEFAULT = 0
};

/* eio request structure */
Expand Down
4 changes: 2 additions & 2 deletions deps/uv/src/ev/ev.h → deps/uv/include/ev.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ struct ev_loop;

/* eventmask, revents, events... */
enum {
EV_UNDEF = 0xFFFFFFFF, /* guaranteed to be invalid */
EV_UNDEF = -1, /* guaranteed to be invalid */
EV_NONE = 0x00, /* no events */
EV_READ = 0x01, /* ev_io detected read will not block */
EV_WRITE = 0x02, /* ev_io detected write will not block */
Expand All @@ -219,7 +219,7 @@ enum {
EV_CLEANUP = 0x00040000, /* event loop resumed in child */
EV_ASYNC = 0x00080000, /* async intra-loop signal */
EV_CUSTOM = 0x01000000, /* for use by user code */
EV_ERROR = 0x80000000 /* sent when an error occurs */
EV_ERROR = (-2147483647 - 1) /* sent when an error occurs */
};

/* can be used to add custom fields to all watchers, while losing binary compatibility */
Expand Down
5 changes: 5 additions & 0 deletions deps/uv/include/uv-unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ typedef struct {
ev_io write_watcher; \
ngx_queue_t write_queue; \
ngx_queue_t write_completed_queue;


/* UV_NAMED_PIPE */
#define UV_PIPE_PRIVATE_TYPEDEF
#define UV_PIPE_PRIVATE_FIELDS


/* UV_PREPARE */ \
Expand Down
60 changes: 47 additions & 13 deletions deps/uv/include/uv-win.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#include "tree.h"

#define MAX_PIPENAME_LEN 256

/**
* It should be possible to cast uv_buf_t[] to WSABUF[]
* see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
Expand All @@ -40,6 +42,22 @@ typedef struct uv_buf_t {
char* base;
} uv_buf_t;

/*
* Private uv_pipe_instance state.
*/
typedef enum {
UV_PIPEINSTANCE_CONNECTED = 0,
UV_PIPEINSTANCE_DISCONNECTED,
UV_PIPEINSTANCE_ACTIVE
} uv_pipeinstance_state;

/* Used to store active pipe instances inside a linked list. */
typedef struct uv_pipe_instance_s {
HANDLE handle;
uv_pipeinstance_state state;
struct uv_pipe_instance_s* next;
} uv_pipe_instance_t;

#define UV_REQ_PRIVATE_FIELDS \
union { \
/* Used by I/O operations */ \
Expand All @@ -52,30 +70,46 @@ typedef struct uv_buf_t {
uv_err_t error; \
struct uv_req_s* next_req;

#define uv_stream_connection_fields \
unsigned int write_reqs_pending; \
uv_req_t* shutdown_req;

#define uv_stream_server_fields \
uv_connection_cb connection_cb;

#define UV_STREAM_PRIVATE_FIELDS \
unsigned int reqs_pending; \
uv_alloc_cb alloc_cb; \
uv_read_cb read_cb; \
struct uv_req_s read_req; \

#define uv_tcp_connection_fields \
unsigned int write_reqs_pending; \
uv_req_t* shutdown_req;

#define uv_tcp_server_fields \
uv_connection_cb connection_cb; \
SOCKET accept_socket; \
struct uv_req_s accept_req; \
char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32];
union { \
struct { uv_stream_connection_fields }; \
struct { uv_stream_server_fields }; \
};

#define UV_TCP_PRIVATE_FIELDS \
unsigned int reqs_pending; \
union { \
SOCKET socket; \
HANDLE handle; \
}; \
SOCKET accept_socket; \
char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \
struct uv_req_s accept_req;

#define uv_pipe_server_fields \
char* name; \
uv_pipe_instance_t* connections; \
struct uv_req_s accept_reqs[4];

#define uv_pipe_connection_fields \
uv_pipe_t* server; \
uv_pipe_instance_t* connection; \
uv_pipe_instance_t clientConnection;

#define UV_PIPE_PRIVATE_FIELDS \
union { \
struct { uv_tcp_connection_fields }; \
struct { uv_tcp_server_fields }; \
struct { uv_pipe_server_fields }; \
struct { uv_pipe_connection_fields }; \
};

#define UV_TIMER_PRIVATE_FIELDS \
Expand Down
55 changes: 48 additions & 7 deletions deps/uv/include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typedef struct uv_err_s uv_err_t;
typedef struct uv_handle_s uv_handle_t;
typedef struct uv_stream_s uv_stream_t;
typedef struct uv_tcp_s uv_tcp_t;
typedef struct uv_pipe_s uv_pipe_t;
typedef struct uv_timer_s uv_timer_t;
typedef struct uv_prepare_s uv_prepare_t;
typedef struct uv_check_s uv_check_t;
Expand Down Expand Up @@ -124,7 +125,8 @@ typedef enum {
UV_EAIFAMNOSUPPORT,
UV_EAINONAME,
UV_EAISERVICE,
UV_EAISOCKTYPE
UV_EAISOCKTYPE,
UV_ESHUTDOWN
} uv_err_code;

typedef enum {
Expand All @@ -138,8 +140,8 @@ typedef enum {
UV_CHECK,
UV_IDLE,
UV_ASYNC,
UV_ARES,
UV_ARES_TASK,
UV_ARES_EVENT,
UV_GETADDRINFO
} uv_handle_type;

Expand All @@ -150,7 +152,11 @@ typedef enum {
UV_READ,
UV_WRITE,
UV_SHUTDOWN,
UV_WAKEUP
UV_WAKEUP,
/* TODO: remove the req suffix */
UV_ARES_EVENT_REQ,
UV_ARES_CLEANUP_REQ,
UV_GETADDRINFO_REQ
} uv_req_type;


Expand All @@ -167,7 +173,7 @@ struct uv_req_s {
uv_req_type type;
/* public */
uv_handle_t* handle;
void* cb;
void *(*cb)(void *);
void* data;
/* private */
UV_REQ_PRIVATE_FIELDS
Expand All @@ -176,7 +182,7 @@ struct uv_req_s {
/*
* Initialize a request for use with uv_write, uv_shutdown, or uv_connect.
*/
void uv_req_init(uv_req_t* req, uv_handle_t* handle, void* cb);
void uv_req_init(uv_req_t* req, uv_handle_t* handle, void *(*cb)(void *));

int uv_shutdown(uv_req_t* req);

Expand All @@ -188,7 +194,7 @@ int uv_shutdown(uv_req_t* req);
uv_close_cb close_cb; \
void* data; \
/* private */ \
UV_HANDLE_PRIVATE_FIELDS \
UV_HANDLE_PRIVATE_FIELDS

/* The abstract base class of all handles. */
struct uv_handle_s {
Expand All @@ -212,7 +218,7 @@ int uv_close(uv_handle_t* handle, uv_close_cb close_cb);
/* number of bytes queued for writing */ \
size_t write_queue_size; \
/* private */ \
UV_STREAM_PRIVATE_FIELDS \
UV_STREAM_PRIVATE_FIELDS

/* The abstract base class for all streams. */
struct uv_stream_s {
Expand Down Expand Up @@ -286,6 +292,26 @@ int uv_tcp_connect6(uv_req_t* req, struct sockaddr_in6);

int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb);

int uv_getsockname(uv_tcp_t* handle, struct sockaddr* name, int* namelen);


/*
* A subclass of uv_stream_t representing a pipe stream or pipe server.
*/
struct uv_pipe_s {
UV_HANDLE_FIELDS
UV_STREAM_FIELDS
UV_PIPE_PRIVATE_FIELDS
};

int uv_pipe_init(uv_pipe_t* handle);

int uv_pipe_bind(uv_pipe_t* handle, const char* name);

int uv_pipe_listen(uv_pipe_t* handle, uv_connection_cb cb);

int uv_pipe_connect(uv_req_t* req, const char* name);


/*
* Subclass of uv_handle_t. libev wrapper. Every active prepare handle gets
Expand Down Expand Up @@ -466,6 +492,7 @@ extern uint64_t uv_hrtime(void);
/* the presence of this union forces similar struct layout */
union uv_any_handle {
uv_tcp_t tcp;
uv_pipe_t pipe;
uv_prepare_t prepare;
uv_check_t check;
uv_idle_t idle;
Expand All @@ -478,7 +505,9 @@ union uv_any_handle {
typedef struct {
uint64_t req_init;
uint64_t handle_init;
uint64_t stream_init;
uint64_t tcp_init;
uint64_t pipe_init;
uint64_t prepare_init;
uint64_t check_init;
uint64_t idle_init;
Expand All @@ -488,6 +517,18 @@ typedef struct {

uv_counters_t* uv_counters();


/* Don't export the private CPP symbols. */
#undef UV_REQ_PRIVATE_FIELDS
#undef UV_STREAM_PRIVATE_FIELDS
#undef UV_TCP_PRIVATE_FIELDS
#undef UV_PREPARE_PRIVATE_FIELDS
#undef UV_CHECK_PRIVATE_FIELDS
#undef UV_IDLE_PRIVATE_FIELDS
#undef UV_ASYNC_PRIVATE_FIELDS
#undef UV_TIMER_PRIVATE_FIELDS
#undef UV_GETADDRINFO_PRIVATE_FIELDS

#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit 7a78216

Please sign in to comment.