From 6bec5440ebced1bc2b91c1c9f3fbc7a361995331 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Mon, 20 Aug 2012 18:41:07 +0200 Subject: uv: upgrade to 8073a26 --- deps/uv/include/uv-private/eio.h | 2 +- deps/uv/include/uv-private/ngx-queue.h | 2 +- deps/uv/include/uv-private/uv-bsd.h | 30 ++ deps/uv/include/uv-private/uv-darwin.h | 37 +++ deps/uv/include/uv-private/uv-linux.h | 34 +++ deps/uv/include/uv-private/uv-sunos.h | 40 +++ deps/uv/include/uv-private/uv-unix.h | 293 ++++++++------------ deps/uv/include/uv-private/uv-win.h | 481 +++++++++++++++++---------------- deps/uv/include/uv.h | 294 ++++++++++++-------- 9 files changed, 697 insertions(+), 516 deletions(-) create mode 100644 deps/uv/include/uv-private/uv-bsd.h create mode 100644 deps/uv/include/uv-private/uv-darwin.h create mode 100644 deps/uv/include/uv-private/uv-linux.h create mode 100644 deps/uv/include/uv-private/uv-sunos.h (limited to 'deps/uv/include') diff --git a/deps/uv/include/uv-private/eio.h b/deps/uv/include/uv-private/eio.h index aab9988b81..975f7ef8a5 100644 --- a/deps/uv/include/uv-private/eio.h +++ b/deps/uv/include/uv-private/eio.h @@ -251,7 +251,7 @@ struct eio_req eio_channel *channel; /* data used to direct poll callbacks arising from this req */ -#if __i386 || __amd64 +#if defined(__i386) || defined(__amd64) unsigned char cancelled; #else sig_atomic_t cancelled; diff --git a/deps/uv/include/uv-private/ngx-queue.h b/deps/uv/include/uv-private/ngx-queue.h index 6fd0071ff0..201107edba 100644 --- a/deps/uv/include/uv-private/ngx-queue.h +++ b/deps/uv/include/uv-private/ngx-queue.h @@ -62,7 +62,7 @@ struct ngx_queue_s { (q)->prev -#if (NGX_DEBUG) +#if defined(NGX_DEBUG) #define ngx_queue_remove(x) \ (x)->next->prev = (x)->prev; \ diff --git a/deps/uv/include/uv-private/uv-bsd.h b/deps/uv/include/uv-private/uv-bsd.h new file mode 100644 index 0000000000..26830a6840 --- /dev/null +++ b/deps/uv/include/uv-private/uv-bsd.h @@ -0,0 +1,30 @@ +/* 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_BSD_H +#define UV_BSD_H + +#define UV_PLATFORM_FS_EVENT_FIELDS \ + uv__io_t event_watcher; \ + int fflags; \ + int fd; \ + +#endif /* UV_BSD_H */ diff --git a/deps/uv/include/uv-private/uv-darwin.h b/deps/uv/include/uv-private/uv-darwin.h new file mode 100644 index 0000000000..93f2ca4e78 --- /dev/null +++ b/deps/uv/include/uv-private/uv-darwin.h @@ -0,0 +1,37 @@ +/* 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_DARWIN_H +#define UV_DARWIN_H + +#if defined(__APPLE__) && defined(__MACH__) +# include +# include +# include +# define UV_PLATFORM_SEM_T semaphore_t +#endif + +#define UV_PLATFORM_FS_EVENT_FIELDS \ + ev_io event_watcher; \ + int fflags; \ + int fd; \ + +#endif /* UV_DARWIN_H */ diff --git a/deps/uv/include/uv-private/uv-linux.h b/deps/uv/include/uv-private/uv-linux.h new file mode 100644 index 0000000000..0d50123e38 --- /dev/null +++ b/deps/uv/include/uv-private/uv-linux.h @@ -0,0 +1,34 @@ +/* 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_PLATFORM_LOOP_FIELDS \ + uv__io_t inotify_read_watcher; \ + void* inotify_watchers; \ + int inotify_fd; \ + +#define UV_PLATFORM_FS_EVENT_FIELDS \ + ngx_queue_t watchers; \ + int wd; \ + +#endif /* UV_LINUX_H */ diff --git a/deps/uv/include/uv-private/uv-sunos.h b/deps/uv/include/uv-private/uv-sunos.h new file mode 100644 index 0000000000..9d55e23fde --- /dev/null +++ b/deps/uv/include/uv-private/uv-sunos.h @@ -0,0 +1,40 @@ +/* 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_SUNOS_H +#define UV_SUNOS_H + +#include +#include + +#if defined(PORT_SOURCE_FILE) + +# define UV_PLATFORM_LOOP_FIELDS \ + uv__io_t fs_event_watcher; \ + int fs_fd; \ + +# define UV_PLATFORM_FS_EVENT_FIELDS \ + file_obj_t fo; \ + int fd; \ + +#endif /* defined(PORT_SOURCE_FILE) */ + +#endif /* UV_SUNOS_H */ diff --git a/deps/uv/include/uv-private/uv-unix.h b/deps/uv/include/uv-private/uv-unix.h index a8dda72a29..560889e177 100644 --- a/deps/uv/include/uv-private/uv-unix.h +++ b/deps/uv/include/uv-private/uv-unix.h @@ -40,20 +40,43 @@ #include #include +#include #include #include -#if defined(__APPLE__) && defined(__MACH__) -# include -# include -# include -#else -# include +struct uv__io_s; +struct uv_loop_s; + +typedef struct uv__io_s uv__io_t; +typedef void (*uv__io_cb)(struct uv_loop_s* loop, uv__io_t* handle, int events); + +struct uv__io_s { + ev_io io_watcher; +}; + +#if defined(__linux__) +# include "uv-linux.h" +#elif defined(__sun) +# include "uv-sunos.h" +#elif defined(__APPLE__) +# include "uv-darwin.h" +#elif defined(__DragonFly__) || \ + defined(__FreeBSD__) || \ + defined(__OpenBSD__) || \ + defined(__NetBSD__) +# include "uv-bsd.h" +#endif + +#ifndef UV_PLATFORM_SEM_T +# define UV_PLATFORM_SEM_T sem_t +#endif + +#ifndef UV_PLATFORM_LOOP_FIELDS +# define UV_PLATFORM_LOOP_FIELDS /* empty */ #endif -#if __sun -# include -# include +#ifndef UV_PLATFORM_FS_EVENT_FIELDS +# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */ #endif /* Note: May be cast to struct iovec. See writev(2). */ @@ -63,9 +86,7 @@ typedef struct { } uv_buf_t; typedef int uv_file; - typedef int uv_os_sock_t; - typedef struct stat uv_statbuf_t; #define UV_ONCE_INIT PTHREAD_ONCE_INIT @@ -74,11 +95,7 @@ typedef pthread_once_t uv_once_t; typedef pthread_t uv_thread_t; typedef pthread_mutex_t uv_mutex_t; typedef pthread_rwlock_t uv_rwlock_t; -#if defined(__APPLE__) && defined(__MACH__) -typedef semaphore_t uv_sem_t; -#else -typedef sem_t uv_sem_t; -#endif +typedef UV_PLATFORM_SEM_T uv_sem_t; /* Platform-specific definitions for uv_spawn support. */ typedef gid_t uv_gid_t; @@ -86,37 +103,14 @@ typedef uid_t uv_uid_t; /* Platform-specific definitions for uv_dlopen support. */ #define UV_DYNAMIC /* empty */ + typedef struct { void* handle; char* errmsg; } uv_lib_t; -struct uv__io_s; -struct uv_loop_s; - -typedef struct uv__io_s uv__io_t; -typedef void (*uv__io_cb)(struct uv_loop_s* loop, uv__io_t* handle, int events); - -struct uv__io_s { - ev_io io_watcher; -}; - -#define UV_REQ_TYPE_PRIVATE /* empty */ - -#if __linux__ -# define UV_LOOP_PRIVATE_PLATFORM_FIELDS \ - uv__io_t inotify_read_watcher; \ - void* inotify_watchers; \ - int inotify_fd; -#elif defined(PORT_SOURCE_FILE) -# define UV_LOOP_PRIVATE_PLATFORM_FIELDS \ - uv__io_t fs_event_watcher; \ - int fs_fd; -#else -# define UV_LOOP_PRIVATE_PLATFORM_FIELDS -#endif - #define UV_LOOP_PRIVATE_FIELDS \ + unsigned long flags; \ /* Poll result queue */ \ eio_channel uv_eio_channel; \ struct ev_loop* ev; \ @@ -125,6 +119,7 @@ struct uv__io_s { uv_async_t uv_eio_done_poll_notifier; \ uv_idle_t uv_eio_poller; \ uv_handle_t* closing_handles; \ + ngx_queue_t process_handles[1]; \ ngx_queue_t prepare_handles; \ ngx_queue_t check_handles; \ ngx_queue_t idle_handles; \ @@ -132,111 +127,94 @@ struct uv__io_s { uv__io_t async_watcher; \ int async_pipefd[2]; \ /* RB_HEAD(uv__timers, uv_timer_s) */ \ - struct uv__timers { struct uv_timer_s* rbh_root; } timer_handles; \ + struct uv__timers { \ + struct uv_timer_s* rbh_root; \ + } timer_handles; \ uint64_t time; \ - UV_LOOP_PRIVATE_PLATFORM_FIELDS + void* signal_ctx; \ + uv_signal_t child_watcher; \ + UV_PLATFORM_LOOP_FIELDS \ -#define UV_REQ_BUFSML_SIZE (4) +#define UV_REQ_TYPE_PRIVATE /* empty */ #define UV_REQ_PRIVATE_FIELDS /* empty */ -#define UV_WRITE_PRIVATE_FIELDS \ - ngx_queue_t queue; \ - int write_index; \ - uv_buf_t* bufs; \ - int bufcnt; \ - int error; \ - uv_buf_t bufsml[UV_REQ_BUFSML_SIZE]; - -#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ - -#define UV_CONNECT_PRIVATE_FIELDS \ - ngx_queue_t queue; - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - ngx_queue_t queue; \ - struct sockaddr_in6 addr; \ - int bufcnt; \ - uv_buf_t* bufs; \ - ssize_t status; \ - uv_udp_send_cb send_cb; \ - uv_buf_t bufsml[UV_REQ_BUFSML_SIZE]; \ - #define UV_PRIVATE_REQ_TYPES /* empty */ +#define UV_WRITE_PRIVATE_FIELDS \ + ngx_queue_t queue; \ + int write_index; \ + uv_buf_t* bufs; \ + int bufcnt; \ + int error; \ + uv_buf_t bufsml[4]; \ -/* TODO: union or classes please! */ -#define UV_HANDLE_PRIVATE_FIELDS \ - int flags; \ - uv_handle_t* next_closing; \ - - -#define UV_STREAM_PRIVATE_FIELDS \ - uv_connect_t *connect_req; \ - uv_shutdown_t *shutdown_req; \ - uv__io_t read_watcher; \ - uv__io_t write_watcher; \ - ngx_queue_t write_queue; \ - ngx_queue_t write_completed_queue; \ - uv_connection_cb connection_cb; \ - int delayed_error; \ - int accepted_fd; \ - int fd; \ - - -/* UV_TCP, idle_handle is for UV_TCP_SINGLE_ACCEPT handles */ -#define UV_TCP_PRIVATE_FIELDS \ - uv_idle_t* idle_handle; \ - - -/* UV_UDP */ -#define UV_UDP_PRIVATE_FIELDS \ - int fd; \ - uv_alloc_cb alloc_cb; \ - uv_udp_recv_cb recv_cb; \ - uv__io_t read_watcher; \ - uv__io_t write_watcher; \ - ngx_queue_t write_queue; \ - ngx_queue_t write_completed_queue; \ +#define UV_CONNECT_PRIVATE_FIELDS \ + ngx_queue_t queue; \ +#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ -/* UV_NAMED_PIPE */ -#define UV_PIPE_PRIVATE_FIELDS \ +#define UV_UDP_SEND_PRIVATE_FIELDS \ + ngx_queue_t queue; \ + struct sockaddr_in6 addr; \ + int bufcnt; \ + uv_buf_t* bufs; \ + ssize_t status; \ + uv_udp_send_cb send_cb; \ + uv_buf_t bufsml[4]; \ + +#define UV_HANDLE_PRIVATE_FIELDS \ + int flags; \ + uv_handle_t* next_closing; \ + +#define UV_STREAM_PRIVATE_FIELDS \ + uv_connect_t *connect_req; \ + uv_shutdown_t *shutdown_req; \ + uv__io_t read_watcher; \ + uv__io_t write_watcher; \ + ngx_queue_t write_queue; \ + ngx_queue_t write_completed_queue; \ + uv_connection_cb connection_cb; \ + int delayed_error; \ + int accepted_fd; \ + int fd; \ + +#define UV_TCP_PRIVATE_FIELDS \ + uv_idle_t* idle_handle; /* for UV_TCP_SINGLE_ACCEPT handles */ \ + +#define UV_UDP_PRIVATE_FIELDS \ + int fd; \ + uv_alloc_cb alloc_cb; \ + uv_udp_recv_cb recv_cb; \ + uv__io_t read_watcher; \ + uv__io_t write_watcher; \ + ngx_queue_t write_queue; \ + ngx_queue_t write_completed_queue; \ + +#define UV_PIPE_PRIVATE_FIELDS \ const char* pipe_fname; /* strdup'ed */ - -/* UV_POLL */ -#define UV_POLL_PRIVATE_FIELDS \ - int fd; \ +#define UV_POLL_PRIVATE_FIELDS \ + int fd; \ uv__io_t io_watcher; - -/* UV_PREPARE */ -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_cb prepare_cb; \ +#define UV_PREPARE_PRIVATE_FIELDS \ + uv_prepare_cb prepare_cb; \ ngx_queue_t queue; - -/* UV_CHECK */ -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_cb check_cb; \ +#define UV_CHECK_PRIVATE_FIELDS \ + uv_check_cb check_cb; \ ngx_queue_t queue; - -/* UV_IDLE */ -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_cb idle_cb; \ +#define UV_IDLE_PRIVATE_FIELDS \ + uv_idle_cb idle_cb; \ ngx_queue_t queue; - -/* UV_ASYNC */ #define UV_ASYNC_PRIVATE_FIELDS \ volatile sig_atomic_t pending; \ uv_async_cb async_cb; \ ngx_queue_t queue; - -/* UV_TIMER */ #define UV_TIMER_PRIVATE_FIELDS \ /* RB_ENTRY(uv_timer_s) node; */ \ struct { \ @@ -249,66 +227,35 @@ struct uv__io_s { uint64_t timeout; \ uint64_t repeat; -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - uv_getaddrinfo_cb cb; \ - struct addrinfo* hints; \ - char* hostname; \ - char* service; \ - struct addrinfo* res; \ +#define UV_GETADDRINFO_PRIVATE_FIELDS \ + uv_getaddrinfo_cb cb; \ + struct addrinfo* hints; \ + char* hostname; \ + char* service; \ + struct addrinfo* res; \ int retcode; -#define UV_PROCESS_PRIVATE_FIELDS \ - ev_child child_watcher; +#define UV_PROCESS_PRIVATE_FIELDS \ + ngx_queue_t queue; \ + int errorno; \ -#define UV_FS_PRIVATE_FIELDS \ - struct stat statbuf; \ - eio_req* eio; +#define UV_FS_PRIVATE_FIELDS \ + struct stat statbuf; \ + uv_file file; \ + eio_req* eio; \ -#define UV_WORK_PRIVATE_FIELDS \ +#define UV_WORK_PRIVATE_FIELDS \ eio_req* eio; -#define UV_TTY_PRIVATE_FIELDS \ - struct termios orig_termios; \ +#define UV_TTY_PRIVATE_FIELDS \ + struct termios orig_termios; \ int mode; -/* UV_FS_EVENT_PRIVATE_FIELDS */ -#if defined(__linux__) - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - ngx_queue_t watchers; \ - uv_fs_event_cb cb; \ - int wd; \ - void* pad0; \ - void* pad1; \ - -#elif defined(__APPLE__) \ - || defined(__FreeBSD__) \ - || defined(__DragonFly__) \ - || defined(__OpenBSD__) \ - || defined(__NetBSD__) - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - ev_io event_watcher; \ - uv_fs_event_cb cb; \ - int fflags; \ - int fd; - -#elif defined(__sun) - -#ifdef PORT_SOURCE_FILE -# define UV_FS_EVENT_PRIVATE_FIELDS \ - uv_fs_event_cb cb; \ - file_obj_t fo; \ - int fd; -#else /* !PORT_SOURCE_FILE */ -# define UV_FS_EVENT_PRIVATE_FIELDS -#endif - -#else - -/* Stub for platforms where the file watcher isn't implemented yet. */ -#define UV_FS_EVENT_PRIVATE_FIELDS +#define UV_SIGNAL_PRIVATE_FIELDS \ + ngx_queue_t queue; -#endif +#define UV_FS_EVENT_PRIVATE_FIELDS \ + uv_fs_event_cb cb; \ + UV_PLATFORM_FS_EVENT_FIELDS \ #endif /* UV_UNIX_H */ diff --git a/deps/uv/include/uv-private/uv-win.h b/deps/uv/include/uv-private/uv-win.h index 5b0aba619f..dbbecedc9d 100644 --- a/deps/uv/include/uv-private/uv-win.h +++ b/deps/uv/include/uv-private/uv-win.h @@ -29,12 +29,14 @@ typedef intptr_t ssize_t; # define _SSIZE_T_DEFINED #endif -#include -#include #include #include #include #include + +#include +#include +#include #include #include "tree.h" @@ -43,32 +45,50 @@ typedef intptr_t ssize_t; #define MAX_PIPENAME_LEN 256 #ifndef S_IFLNK -# define S_IFLNK 0xA000 +# define S_IFLNK 0xA000 #endif +/* Additional signals supported by uv_signal and or uv_kill. The CRT defines + * the following signals already: + * + * #define SIGINT 2 + * #define SIGILL 4 + * #define SIGABRT_COMPAT 6 + * #define SIGFPE 8 + * #define SIGSEGV 11 + * #define SIGTERM 15 + * #define SIGBREAK 21 + * #define SIGABRT 22 + * + * The additional signals have values that are common on other Unix + * variants (Linux and Darwin) + */ +#define SIGHUP 1 +#define SIGKILL 9 + /* * Guids and typedefs for winsock extension functions * Mingw32 doesn't have these :-( */ #ifndef WSAID_ACCEPTEX -# define WSAID_ACCEPTEX \ - {0xb5367df1, 0xcbac, 0x11cf, \ +# define WSAID_ACCEPTEX \ + {0xb5367df1, 0xcbac, 0x11cf, \ {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} -# define WSAID_CONNECTEX \ - {0x25a207b9, 0xddf3, 0x4660, \ +# define WSAID_CONNECTEX \ + {0x25a207b9, 0xddf3, 0x4660, \ {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} -# define WSAID_GETACCEPTEXSOCKADDRS \ - {0xb5367df2, 0xcbac, 0x11cf, \ +# define WSAID_GETACCEPTEXSOCKADDRS \ + {0xb5367df2, 0xcbac, 0x11cf, \ {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} -# define WSAID_DISCONNECTEX \ - {0x7fda2e11, 0x8630, 0x436f, \ +# define WSAID_DISCONNECTEX \ + {0x7fda2e11, 0x8630, 0x436f, \ {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}} -# define WSAID_TRANSMITFILE \ - {0xb5367df0, 0xcbac, 0x11cf, \ +# define WSAID_TRANSMITFILE \ + {0xb5367df0, 0xcbac, 0x11cf, \ {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} typedef BOOL PASCAL (*LPFN_ACCEPTEX) @@ -246,272 +266,281 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); /* Counter to keep track of active udp streams */ \ unsigned int active_udp_streams; -#define UV_REQ_TYPE_PRIVATE \ - /* TODO: remove the req suffix */ \ - UV_ACCEPT, \ - UV_FS_EVENT_REQ, \ - UV_POLL_REQ, \ - UV_PROCESS_EXIT, \ - UV_PROCESS_CLOSE, \ - UV_READ, \ - UV_UDP_RECV, \ - UV_WAKEUP, - -#define UV_REQ_PRIVATE_FIELDS \ - union { \ - /* Used by I/O operations */ \ - struct { \ - OVERLAPPED overlapped; \ - size_t queued_bytes; \ - }; \ - }; \ +#define UV_REQ_TYPE_PRIVATE \ + /* TODO: remove the req suffix */ \ + UV_ACCEPT, \ + UV_FS_EVENT_REQ, \ + UV_POLL_REQ, \ + UV_PROCESS_EXIT, \ + UV_READ, \ + UV_UDP_RECV, \ + UV_WAKEUP, \ + UV_SIGNAL_REQ, + +#define UV_REQ_PRIVATE_FIELDS \ + union { \ + /* Used by I/O operations */ \ + struct { \ + OVERLAPPED overlapped; \ + size_t queued_bytes; \ + }; \ + }; \ struct uv_req_s* next_req; -#define UV_WRITE_PRIVATE_FIELDS \ - int ipc_header; \ - uv_buf_t write_buffer; \ - HANDLE event_handle; \ +#define UV_WRITE_PRIVATE_FIELDS \ + int ipc_header; \ + uv_buf_t write_buffer; \ + HANDLE event_handle; \ HANDLE wait_handle; -#define UV_CONNECT_PRIVATE_FIELDS \ +#define UV_CONNECT_PRIVATE_FIELDS \ /* empty */ -#define UV_SHUTDOWN_PRIVATE_FIELDS \ +#define UV_SHUTDOWN_PRIVATE_FIELDS \ /* empty */ -#define UV_UDP_SEND_PRIVATE_FIELDS \ +#define UV_UDP_SEND_PRIVATE_FIELDS \ /* empty */ -#define UV_PRIVATE_REQ_TYPES \ - typedef struct uv_pipe_accept_s { \ - UV_REQ_FIELDS \ - HANDLE pipeHandle; \ - struct uv_pipe_accept_s* next_pending; \ - } uv_pipe_accept_t; \ - \ - typedef struct uv_tcp_accept_s { \ - UV_REQ_FIELDS \ - SOCKET accept_socket; \ - char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - struct uv_tcp_accept_s* next_pending; \ - } uv_tcp_accept_t; \ - \ - typedef struct uv_read_s { \ - UV_REQ_FIELDS \ - HANDLE event_handle; \ - HANDLE wait_handle; \ +#define UV_PRIVATE_REQ_TYPES \ + typedef struct uv_pipe_accept_s { \ + UV_REQ_FIELDS \ + HANDLE pipeHandle; \ + struct uv_pipe_accept_s* next_pending; \ + } uv_pipe_accept_t; \ + \ + typedef struct uv_tcp_accept_s { \ + UV_REQ_FIELDS \ + SOCKET accept_socket; \ + char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \ + HANDLE event_handle; \ + HANDLE wait_handle; \ + struct uv_tcp_accept_s* next_pending; \ + } uv_tcp_accept_t; \ + \ + typedef struct uv_read_s { \ + UV_REQ_FIELDS \ + HANDLE event_handle; \ + HANDLE wait_handle; \ } uv_read_t; -#define uv_stream_connection_fields \ - unsigned int write_reqs_pending; \ +#define uv_stream_connection_fields \ + unsigned int write_reqs_pending; \ uv_shutdown_t* shutdown_req; -#define uv_stream_server_fields \ +#define uv_stream_server_fields \ uv_connection_cb connection_cb; -#define UV_STREAM_PRIVATE_FIELDS \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_read_t read_req; \ - union { \ - struct { uv_stream_connection_fields }; \ - struct { uv_stream_server_fields }; \ +#define UV_STREAM_PRIVATE_FIELDS \ + unsigned int reqs_pending; \ + int activecnt; \ + uv_read_t read_req; \ + union { \ + struct { uv_stream_connection_fields }; \ + struct { uv_stream_server_fields }; \ }; -#define uv_tcp_server_fields \ - uv_tcp_accept_t* accept_reqs; \ - unsigned int processed_accepts; \ - uv_tcp_accept_t* pending_accepts; \ +#define uv_tcp_server_fields \ + uv_tcp_accept_t* accept_reqs; \ + unsigned int processed_accepts; \ + uv_tcp_accept_t* pending_accepts; \ LPFN_ACCEPTEX func_acceptex; -#define uv_tcp_connection_fields \ - uv_buf_t read_buffer; \ +#define uv_tcp_connection_fields \ + uv_buf_t read_buffer; \ LPFN_CONNECTEX func_connectex; -#define UV_TCP_PRIVATE_FIELDS \ - SOCKET socket; \ - int bind_error; \ - union { \ - struct { uv_tcp_server_fields }; \ - struct { uv_tcp_connection_fields }; \ +#define UV_TCP_PRIVATE_FIELDS \ + SOCKET socket; \ + int bind_error; \ + union { \ + struct { uv_tcp_server_fields }; \ + struct { uv_tcp_connection_fields }; \ }; -#define UV_UDP_PRIVATE_FIELDS \ - SOCKET socket; \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_req_t recv_req; \ - uv_buf_t recv_buffer; \ - struct sockaddr_storage recv_from; \ - int recv_from_len; \ - uv_udp_recv_cb recv_cb; \ - uv_alloc_cb alloc_cb; \ - LPFN_WSARECV func_wsarecv; \ +#define UV_UDP_PRIVATE_FIELDS \ + SOCKET socket; \ + unsigned int reqs_pending; \ + int activecnt; \ + uv_req_t recv_req; \ + uv_buf_t recv_buffer; \ + struct sockaddr_storage recv_from; \ + int recv_from_len; \ + uv_udp_recv_cb recv_cb; \ + uv_alloc_cb alloc_cb; \ + LPFN_WSARECV func_wsarecv; \ LPFN_WSARECVFROM func_wsarecvfrom; -#define uv_pipe_server_fields \ - int pending_instances; \ - uv_pipe_accept_t* accept_reqs; \ +#define uv_pipe_server_fields \ + int pending_instances; \ + uv_pipe_accept_t* accept_reqs; \ uv_pipe_accept_t* pending_accepts; -#define uv_pipe_connection_fields \ - uv_timer_t* eof_timer; \ - uv_write_t ipc_header_write_req; \ - int ipc_pid; \ - uint64_t remaining_ipc_rawdata_bytes; \ - unsigned char reserved[sizeof(void*)]; \ - struct { \ - WSAPROTOCOL_INFOW* socket_info; \ - int tcp_connection; \ - } pending_ipc_info; \ +#define uv_pipe_connection_fields \ + uv_timer_t* eof_timer; \ + uv_write_t ipc_header_write_req; \ + int ipc_pid; \ + uint64_t remaining_ipc_rawdata_bytes; \ + unsigned char reserved[sizeof(void*)]; \ + struct { \ + WSAPROTOCOL_INFOW* socket_info; \ + int tcp_connection; \ + } pending_ipc_info; \ uv_write_t* non_overlapped_writes_tail; -#define UV_PIPE_PRIVATE_FIELDS \ - HANDLE handle; \ - wchar_t* name; \ - union { \ - struct { uv_pipe_server_fields }; \ - struct { uv_pipe_connection_fields }; \ +#define UV_PIPE_PRIVATE_FIELDS \ + HANDLE handle; \ + WCHAR* name; \ + union { \ + struct { uv_pipe_server_fields }; \ + struct { uv_pipe_connection_fields }; \ }; /* TODO: put the parser states in an union - TTY handles are always */ /* half-duplex so read-state can safely overlap write-state. */ -#define UV_TTY_PRIVATE_FIELDS \ - HANDLE handle; \ - HANDLE read_line_handle; \ - uv_buf_t read_line_buffer; \ - HANDLE read_raw_wait; \ - DWORD original_console_mode; \ - /* Fields used for translating win */ \ - /* keystrokes into vt100 characters */ \ - char last_key[8]; \ - unsigned char last_key_offset; \ - unsigned char last_key_len; \ - INPUT_RECORD last_input_record; \ - WCHAR last_utf16_high_surrogate; \ - /* utf8-to-utf16 conversion state */ \ - unsigned char utf8_bytes_left; \ - unsigned int utf8_codepoint; \ - /* eol conversion state */ \ - unsigned char previous_eol; \ - /* ansi parser state */ \ - unsigned char ansi_parser_state; \ - unsigned char ansi_csi_argc; \ - unsigned short ansi_csi_argv[4]; \ - COORD saved_position; \ - WORD saved_attributes; - -#define UV_POLL_PRIVATE_FIELDS \ - SOCKET socket; \ - /* Used in fast mode */ \ - SOCKET peer_socket; \ - AFD_POLL_INFO afd_poll_info_1; \ - AFD_POLL_INFO afd_poll_info_2; \ - /* Used in fast and slow mode. */ \ - uv_req_t poll_req_1; \ - uv_req_t poll_req_2; \ - unsigned char submitted_events_1; \ - unsigned char submitted_events_2; \ - unsigned char mask_events_1; \ - unsigned char mask_events_2; \ +#define UV_TTY_PRIVATE_FIELDS \ + HANDLE handle; \ + union { \ + struct { \ + /* Used for readable TTY handles */ \ + HANDLE read_line_handle; \ + uv_buf_t read_line_buffer; \ + HANDLE read_raw_wait; \ + DWORD original_console_mode; \ + /* Fields used for translating win keystrokes into vt100 characters */ \ + char last_key[8]; \ + unsigned char last_key_offset; \ + unsigned char last_key_len; \ + WCHAR last_utf16_high_surrogate; \ + INPUT_RECORD last_input_record; \ + }; \ + struct { \ + /* Used for writable TTY handles */ \ + /* utf8-to-utf16 conversion state */ \ + unsigned int utf8_codepoint; \ + unsigned char utf8_bytes_left; \ + /* eol conversion state */ \ + unsigned char previous_eol; \ + /* ansi parser state */ \ + unsigned char ansi_parser_state; \ + unsigned char ansi_csi_argc; \ + unsigned short ansi_csi_argv[4]; \ + COORD saved_position; \ + WORD saved_attributes; \ + }; \ + }; + +#define UV_POLL_PRIVATE_FIELDS \ + SOCKET socket; \ + /* Used in fast mode */ \ + SOCKET peer_socket; \ + AFD_POLL_INFO afd_poll_info_1; \ + AFD_POLL_INFO afd_poll_info_2; \ + /* Used in fast and slow mode. */ \ + uv_req_t poll_req_1; \ + uv_req_t poll_req_2; \ + unsigned char submitted_events_1; \ + unsigned char submitted_events_2; \ + unsigned char mask_events_1; \ + unsigned char mask_events_2; \ unsigned char events; -#define UV_TIMER_PRIVATE_FIELDS \ - RB_ENTRY(uv_timer_s) tree_entry; \ - int64_t due; \ - int64_t repeat; \ +#define UV_TIMER_PRIVATE_FIELDS \ + RB_ENTRY(uv_timer_s) tree_entry; \ + int64_t due; \ + int64_t repeat; \ uv_timer_cb timer_cb; -#define UV_ASYNC_PRIVATE_FIELDS \ - struct uv_req_s async_req; \ - uv_async_cb async_cb; \ - /* char to avoid alignment issues */ \ +#define UV_ASYNC_PRIVATE_FIELDS \ + struct uv_req_s async_req; \ + uv_async_cb async_cb; \ + /* char to avoid alignment issues */ \ char volatile async_sent; -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_t* prepare_prev; \ - uv_prepare_t* prepare_next; \ +#define UV_PREPARE_PRIVATE_FIELDS \ + uv_prepare_t* prepare_prev; \ + uv_prepare_t* prepare_next; \ uv_prepare_cb prepare_cb; -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_t* check_prev; \ - uv_check_t* check_next; \ +#define UV_CHECK_PRIVATE_FIELDS \ + uv_check_t* check_prev; \ + uv_check_t* check_next; \ uv_check_cb check_cb; -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_t* idle_prev; \ - uv_idle_t* idle_next; \ +#define UV_IDLE_PRIVATE_FIELDS \ + uv_idle_t* idle_prev; \ + uv_idle_t* idle_next; \ uv_idle_cb idle_cb; -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* endgame_next; \ +#define UV_HANDLE_PRIVATE_FIELDS \ + uv_handle_t* endgame_next; \ unsigned int flags; -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - uv_getaddrinfo_cb getaddrinfo_cb; \ - void* alloc; \ - wchar_t* node; \ - wchar_t* service; \ - struct addrinfoW* hints; \ - struct addrinfoW* res; \ +#define UV_GETADDRINFO_PRIVATE_FIELDS \ + uv_getaddrinfo_cb getaddrinfo_cb; \ + void* alloc; \ + WCHAR* node; \ + WCHAR* service; \ + struct addrinfoW* hints; \ + struct addrinfoW* res; \ int retcode; -#define UV_PROCESS_PRIVATE_FIELDS \ - struct uv_process_exit_s { \ - UV_REQ_FIELDS \ - } exit_req; \ - struct uv_process_close_s { \ - UV_REQ_FIELDS \ - } close_req; \ - BYTE* child_stdio_buffer; \ - int exit_signal; \ - DWORD spawn_errno; \ - HANDLE wait_handle; \ - HANDLE process_handle; \ - HANDLE close_handle; - -#define UV_FS_PRIVATE_FIELDS \ - int flags; \ - DWORD sys_errno_; \ - union { \ - /* TODO: remove me in 0.9. */ \ - WCHAR* pathw; \ - int fd; \ - }; \ - union { \ - struct { \ - int mode; \ - WCHAR* new_pathw; \ - int file_flags; \ - int fd_out; \ - void* buf; \ - size_t length; \ - int64_t offset; \ - }; \ - struct _stati64 stat; \ - struct { \ - double atime; \ - double mtime; \ - }; \ +#define UV_PROCESS_PRIVATE_FIELDS \ + struct uv_process_exit_s { \ + UV_REQ_FIELDS \ + } exit_req; \ + BYTE* child_stdio_buffer; \ + uv_err_t spawn_error; \ + int exit_signal; \ + HANDLE wait_handle; \ + HANDLE process_handle; \ + volatile char exit_cb_pending; + +#define UV_FS_PRIVATE_FIELDS \ + int flags; \ + DWORD sys_errno_; \ + union { \ + /* TODO: remove me in 0.9. */ \ + WCHAR* pathw; \ + int fd; \ + }; \ + union { \ + struct { \ + int mode; \ + WCHAR* new_pathw; \ + int file_flags; \ + int fd_out; \ + void* buf; \ + size_t length; \ + int64_t offset; \ + }; \ + struct _stati64 stat; \ + struct { \ + double atime; \ + double mtime; \ + }; \ }; -#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; \ - wchar_t* short_filew; \ - wchar_t* dirw; \ +#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* filew; \ + WCHAR* short_filew; \ + WCHAR* dirw; \ char* buffer; -int uv_utf16_to_utf8(const wchar_t* utf16Buffer, size_t utf16Size, +#define UV_SIGNAL_PRIVATE_FIELDS \ + RB_ENTRY(uv_signal_s) tree_entry; \ + struct uv_req_s signal_req; \ + unsigned long pending_signum; + +int uv_utf16_to_utf8(const WCHAR* utf16Buffer, size_t utf16Size, char* utf8Buffer, size_t utf8Size); -int uv_utf8_to_utf16(const char* utf8Buffer, wchar_t* utf16Buffer, +int uv_utf8_to_utf16(const char* utf8Buffer, WCHAR* utf16Buffer, size_t utf16Size); diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index 19fa6e0458..66ee41cb95 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -19,7 +19,7 @@ * IN THE SOFTWARE. */ -/* See uv_loop_new for an introduction. */ +/* See http://nikhilm.github.com/uvbook/ for an introduction. */ #ifndef UV_H #define UV_H @@ -53,6 +53,10 @@ extern "C" { #include /* int64_t */ #include /* size_t */ +#if defined(__SVR4) && !defined(__unix__) +# define __unix__ +#endif + #if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__) # include "uv-private/uv-unix.h" #else @@ -60,64 +64,64 @@ extern "C" { #endif /* Expand this list if necessary. */ -#define UV_ERRNO_MAP(XX) \ - XX( -1, UNKNOWN, "unknown error") \ - XX( 0, OK, "success") \ - XX( 1, EOF, "end of file") \ - XX( 2, EADDRINFO, "getaddrinfo error") \ - XX( 3, EACCES, "permission denied") \ - XX( 4, EAGAIN, "no more processes") \ - XX( 5, EADDRINUSE, "address already in use") \ - XX( 6, EADDRNOTAVAIL, "") \ - XX( 7, EAFNOSUPPORT, "") \ - XX( 8, EALREADY, "") \ - XX( 9, EBADF, "bad file descriptor") \ - XX( 10, EBUSY, "resource busy or locked") \ - XX( 11, ECONNABORTED, "software caused connection abort") \ - XX( 12, ECONNREFUSED, "connection refused") \ - XX( 13, ECONNRESET, "connection reset by peer") \ - XX( 14, EDESTADDRREQ, "destination address required") \ - XX( 15, EFAULT, "bad address in system call argument") \ - XX( 16, EHOSTUNREACH, "host is unreachable") \ - XX( 17, EINTR, "interrupted system call") \ - XX( 18, EINVAL, "invalid argument") \ - XX( 19, EISCONN, "socket is already connected") \ - XX( 20, EMFILE, "too many open files") \ - XX( 21, EMSGSIZE, "message too long") \ - XX( 22, ENETDOWN, "network is down") \ - XX( 23, ENETUNREACH, "network is unreachable") \ - XX( 24, ENFILE, "file table overflow") \ - XX( 25, ENOBUFS, "no buffer space available") \ - XX( 26, ENOMEM, "not enough memory") \ - XX( 27, ENOTDIR, "not a directory") \ - XX( 28, EISDIR, "illegal operation on a directory") \ - XX( 29, ENONET, "machine is not on the network") \ - XX( 31, ENOTCONN, "socket is not connected") \ - XX( 32, ENOTSOCK, "socket operation on non-socket") \ - XX( 33, ENOTSUP, "operation not supported on socket") \ - XX( 34, ENOENT, "no such file or directory") \ - XX( 35, ENOSYS, "function not implemented") \ - XX( 36, EPIPE, "broken pipe") \ - XX( 37, EPROTO, "protocol error") \ - XX( 38, EPROTONOSUPPORT, "protocol not supported") \ - XX( 39, EPROTOTYPE, "protocol wrong type for socket") \ - XX( 40, ETIMEDOUT, "connection timed out") \ - XX( 41, ECHARSET, "") \ - XX( 42, EAIFAMNOSUPPORT, "") \ - XX( 44, EAISERVICE, "") \ - XX( 45, EAISOCKTYPE, "") \ - XX( 46, ESHUTDOWN, "") \ - XX( 47, EEXIST, "file already exists") \ - XX( 48, ESRCH, "no such process") \ - XX( 49, ENAMETOOLONG, "name too long") \ - XX( 50, EPERM, "operation not permitted") \ - XX( 51, ELOOP, "too many symbolic links encountered") \ - XX( 52, EXDEV, "cross-device link not permitted") \ - XX( 53, ENOTEMPTY, "directory not empty") \ - XX( 54, ENOSPC, "no space left on device") \ - XX( 55, EIO, "i/o error") \ - XX( 56, EROFS, "read-only file system" ) \ - XX( 57, ENODEV, "no such device" ) \ +#define UV_ERRNO_MAP(XX) \ + XX( -1, UNKNOWN, "unknown error") \ + XX( 0, OK, "success") \ + XX( 1, EOF, "end of file") \ + XX( 2, EADDRINFO, "getaddrinfo error") \ + XX( 3, EACCES, "permission denied") \ + XX( 4, EAGAIN, "no more processes") \ + XX( 5, EADDRINUSE, "address already in use") \ + XX( 6, EADDRNOTAVAIL, "") \ + XX( 7, EAFNOSUPPORT, "") \ + XX( 8, EALREADY, "") \ + XX( 9, EBADF, "bad file descriptor") \ + XX( 10, EBUSY, "resource busy or locked") \ + XX( 11, ECONNABORTED, "software caused connection abort") \ + XX( 12, ECONNREFUSED, "connection refused") \ + XX( 13, ECONNRESET, "connection reset by peer") \ + XX( 14, EDESTADDRREQ, "destination address required") \ + XX( 15, EFAULT, "bad address in system call argument") \ + XX( 16, EHOSTUNREACH, "host is unreachable") \ + XX( 17, EINTR, "interrupted system call") \ + XX( 18, EINVAL, "invalid argument") \ + XX( 19, EISCONN, "socket is already connected") \ + XX( 20, EMFILE, "too many open files") \ + XX( 21, EMSGSIZE, "message too long") \ + XX( 22, ENETDOWN, "network is down") \ + XX( 23, ENETUNREACH, "network is unreachable") \ + XX( 24, ENFILE, "file table overflow") \ + XX( 25, ENOBUFS, "no buffer space available") \ + XX( 26, ENOMEM, "not enough memory") \ + XX( 27, ENOTDIR, "not a directory") \ + XX( 28, EISDIR, "illegal operation on a directory") \ + XX( 29, ENONET, "machine is not on the network") \ + XX( 31, ENOTCONN, "socket is not connected") \ + XX( 32, ENOTSOCK, "socket operation on non-socket") \ + XX( 33, ENOTSUP, "operation not supported on socket") \ + XX( 34, ENOENT, "no such file or directory") \ + XX( 35, ENOSYS, "function not implemented") \ + XX( 36, EPIPE, "broken pipe") \ + XX( 37, EPROTO, "protocol error") \ + XX( 38, EPROTONOSUPPORT, "protocol not supported") \ + XX( 39, EPROTOTYPE, "protocol wrong type for socket") \ + XX( 40, ETIMEDOUT, "connection timed out") \ + XX( 41, ECHARSET, "") \ + XX( 42, EAIFAMNOSUPPORT, "") \ + XX( 44, EAISERVICE, "") \ + XX( 45, EAISOCKTYPE, "") \ + XX( 46, ESHUTDOWN, "") \ + XX( 47, EEXIST, "file already exists") \ + XX( 48, ESRCH, "no such process") \ + XX( 49, ENAMETOOLONG, "name too long") \ + XX( 50, EPERM, "operation not permitted") \ + XX( 51, ELOOP, "too many symbolic links encountered") \ + XX( 52, EXDEV, "cross-device link not permitted") \ + XX( 53, ENOTEMPTY, "directory not empty") \ + XX( 54, ENOSPC, "no space left on device") \ + XX( 55, EIO, "i/o error") \ + XX( 56, EROFS, "read-only file system" ) \ + XX( 57, ENODEV, "no such device" ) \ XX( 58, ECANCELED, "operation canceled" ) @@ -128,29 +132,30 @@ typedef enum { } uv_err_code; #undef UV_ERRNO_GEN -#define UV_HANDLE_TYPE_MAP(XX) \ - XX(ASYNC, async) \ - XX(CHECK, check) \ - XX(FS_EVENT, fs_event) \ - XX(FS_POLL, fs_poll) \ - XX(IDLE, idle) \ - XX(NAMED_PIPE, pipe) \ - XX(POLL, poll) \ - XX(PREPARE, prepare) \ - XX(PROCESS, process) \ - XX(TCP, tcp) \ - XX(TIMER, timer) \ - XX(TTY, tty) \ - XX(UDP, udp) \ - -#define UV_REQ_TYPE_MAP(XX) \ - XX(CONNECT, connect) \ - XX(WRITE, write) \ - XX(SHUTDOWN, shutdown) \ - XX(UDP_SEND, udp_send) \ - XX(FS, fs) \ - XX(WORK, work) \ - XX(GETADDRINFO, getaddrinfo) \ +#define UV_HANDLE_TYPE_MAP(XX) \ + XX(ASYNC, async) \ + XX(CHECK, check) \ + XX(FS_EVENT, fs_event) \ + XX(FS_POLL, fs_poll) \ + XX(IDLE, idle) \ + XX(NAMED_PIPE, pipe) \ + XX(POLL, poll) \ + XX(PREPARE, prepare) \ + XX(PROCESS, process) \ + XX(TCP, tcp) \ + XX(TIMER, timer) \ + XX(TTY, tty) \ + XX(UDP, udp) \ + XX(SIGNAL, signal) \ + +#define UV_REQ_TYPE_MAP(XX) \ + XX(CONNECT, connect) \ + XX(WRITE, write) \ + XX(SHUTDOWN, shutdown) \ + XX(UDP_SEND, udp_send) \ + XX(FS, fs) \ + XX(WORK, work) \ + XX(GETADDRINFO, getaddrinfo) \ typedef enum { UV_UNKNOWN_HANDLE = 0, @@ -189,6 +194,7 @@ typedef struct uv_async_s uv_async_t; typedef struct uv_process_s uv_process_t; typedef struct uv_fs_event_s uv_fs_event_t; typedef struct uv_fs_poll_s uv_fs_poll_t; +typedef struct uv_signal_s uv_signal_t; /* Request types. */ typedef struct uv_req_s uv_req_t; @@ -312,6 +318,9 @@ typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, const uv_statbuf_t* prev, const uv_statbuf_t* curr); +typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); + + typedef enum { UV_LEAVE_GROUP = 0, UV_JOIN_GROUP @@ -336,14 +345,14 @@ UV_EXTERN const char* uv_strerror(uv_err_t err); UV_EXTERN const char* uv_err_name(uv_err_t err); -#define UV_REQ_FIELDS \ - /* public */ \ - void* data; \ - /* private */ \ - ngx_queue_t active_queue; \ - UV_REQ_PRIVATE_FIELDS \ - /* read-only */ \ - uv_req_type type; \ +#define UV_REQ_FIELDS \ + /* public */ \ + void* data; \ + /* private */ \ + ngx_queue_t active_queue; \ + UV_REQ_PRIVATE_FIELDS \ + /* read-only */ \ + uv_req_type type; \ /* Abstract base class of all requests. */ struct uv_req_s { @@ -454,13 +463,13 @@ UV_EXTERN size_t uv_strlcpy(char* dst, const char* src, size_t size); UV_EXTERN size_t uv_strlcat(char* dst, const char* src, size_t size); -#define UV_STREAM_FIELDS \ - /* number of bytes queued for writing */ \ - size_t write_queue_size; \ - uv_alloc_cb alloc_cb; \ - uv_read_cb read_cb; \ - uv_read2_cb read2_cb; \ - /* private */ \ +#define UV_STREAM_FIELDS \ + /* number of bytes queued for writing */ \ + size_t write_queue_size; \ + uv_alloc_cb alloc_cb; \ + uv_read_cb read_cb; \ + uv_read2_cb read2_cb; \ + /* private */ \ UV_STREAM_PRIVATE_FIELDS /* @@ -1098,8 +1107,7 @@ UV_EXTERN int uv_async_send(uv_async_t* async); /* * uv_timer_t is a subclass of uv_handle_t. * - * Wraps libev's ev_timer watcher. Used to get woken up at a specified time - * in the future. + * Used to get woken up at a specified time in the future. */ struct uv_timer_s { UV_HANDLE_FIELDS @@ -1108,8 +1116,22 @@ struct uv_timer_s { UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* timer); -UV_EXTERN int uv_timer_start(uv_timer_t* timer, uv_timer_cb cb, - int64_t timeout, int64_t repeat); +/* + * Start the timer. `timeout` and `repeat` are in milliseconds. + * + * If timeout is zero, the callback fires on the next tick of the event loop. + * + * If repeat is non-zero, the callback fires first after timeout milliseconds + * and then repeatedly after repeat milliseconds. + * + * timeout and repeat are signed integers but that will change in a future + * version of libuv. Don't pass in negative values, you'll get a nasty surprise + * when that change becomes effective. + */ +UV_EXTERN int uv_timer_start(uv_timer_t* timer, + uv_timer_cb cb, + int64_t timeout, + int64_t repeat); UV_EXTERN int uv_timer_stop(uv_timer_t* timer); @@ -1121,10 +1143,10 @@ UV_EXTERN int uv_timer_stop(uv_timer_t* timer); UV_EXTERN int uv_timer_again(uv_timer_t* timer); /* - * Set the repeat value. Note that if the repeat value is set from a timer - * callback it does not immediately take effect. If the timer was non-repeating - * before, it will have been stopped. If it was repeating, then the old repeat - * value will have been used to schedule the next timeout. + * Set the repeat value in milliseconds. Note that if the repeat value is set + * from a timer callback it does not immediately take effect. If the timer was + * non-repeating before, it will have been stopped. If it was repeating, then + * the old repeat value will have been used to schedule the next timeout. */ UV_EXTERN void uv_timer_set_repeat(uv_timer_t* timer, int64_t repeat); @@ -1529,14 +1551,17 @@ struct uv_fs_event_s { struct uv_fs_poll_s { UV_HANDLE_FIELDS /* Private, don't touch. */ - int busy_polling; /* TODO(bnoordhuis) Fold into flags field. */ - unsigned int interval; - uint64_t start_time; - char* path; - uv_fs_poll_cb poll_cb; - uv_timer_t timer_handle; - uv_fs_t* fs_req; - uv_statbuf_t statbuf; + void* poll_ctx; + /* v0.8 ABI compatibility */ + char padding[sizeof(int) + + sizeof(unsigned int) + + sizeof(uint64_t) + + sizeof(char*) + + sizeof(uv_fs_poll_cb) + + sizeof(uv_timer_t) + + sizeof(uv_fs_t*) + + sizeof(uv_statbuf_t) + - sizeof(void*)]; }; UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); @@ -1563,6 +1588,46 @@ UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); + +/* + * UNIX signal handling on a per-event loop basis. The implementation is not + * ultra efficient so don't go creating a million event loops with a million + * signal watchers. + * + * TODO(bnoordhuis) As of 2012-08-10 only the default event loop supports + * signals. That will be fixed. + * + * Some signal support is available on Windows: + * + * SIGINT is normally delivered when the user presses CTRL+C. However, like + * on Unix, it is not generated when terminal raw mode is enabled. + * + * SIGBREAK is delivered when the user pressed CTRL+BREAK. + * + * SIGHUP is generated when the user closes the console window. On SIGHUP the + * program is given approximately 10 seconds to perform cleanup. After that + * Windows will unconditionally terminate it. + * + * Watchers for other signals can be successfully created, but these signals + * are never generated. These signals are: SIGILL, SIGABRT, SIGFPE, SIGSEGV, + * SIGTERM and SIGKILL. + * + * Note that calls to raise() or abort() to programmatically raise a signal are + * not detected by libuv; these will not trigger a signal watcher. + */ +struct uv_signal_s { + UV_HANDLE_FIELDS + uv_signal_cb signal_cb; + UV_SIGNAL_PRIVATE_FIELDS + int signum; +}; + +/* These functions are no-ops on Windows. */ +int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); +int uv_signal_start(uv_signal_t* handle, uv_signal_cb signal_cb, int signum); +int uv_signal_stop(uv_signal_t* handle); + + /* * Gets load avg * See: http://en.wikipedia.org/wiki/Load_(computing) @@ -1772,8 +1837,6 @@ struct uv_counters_s { struct uv_loop_s { UV_LOOP_PRIVATE_FIELDS - /* Diagnostic counters */ - uv_counters_t counters; /* The last error */ uv_err_t last_err; /* Loop reference counting */ @@ -1800,6 +1863,7 @@ struct uv_loop_s { #undef UV_FS_REQ_PRIVATE_FIELDS #undef UV_WORK_PRIVATE_FIELDS #undef UV_FS_EVENT_PRIVATE_FIELDS +#undef UV_SIGNAL_PRIVATE_FIELDS #undef UV_LOOP_PRIVATE_FIELDS #undef UV_LOOP_PRIVATE_PLATFORM_FIELDS -- cgit v1.2.1