diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/unix/aix.c | 6 | ||||
-rw-r--r-- | src/unix/bsd-ifaddrs.c | 7 | ||||
-rw-r--r-- | src/unix/ibmi.c | 5 | ||||
-rw-r--r-- | src/unix/linux.c | 7 | ||||
-rw-r--r-- | src/unix/sunos.c | 5 | ||||
-rw-r--r-- | src/uv-common.c | 8 | ||||
-rw-r--r-- | src/win/core.c | 107 | ||||
-rw-r--r-- | src/win/fs-fd-hash-inl.h | 8 | ||||
-rw-r--r-- | src/win/fs.c | 72 | ||||
-rw-r--r-- | src/win/req-inl.h | 107 | ||||
-rw-r--r-- | src/win/util.c | 6 |
11 files changed, 158 insertions, 180 deletions
diff --git a/src/unix/aix.c b/src/unix/aix.c index 48da0c9c..8343bc5c 100644 --- a/src/unix/aix.c +++ b/src/unix/aix.c @@ -1288,12 +1288,6 @@ cleanup: } -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - uv__free(addresses); -} - - void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { struct pollfd* events; uintptr_t i; diff --git a/src/unix/bsd-ifaddrs.c b/src/unix/bsd-ifaddrs.c index 8d9ebd25..6829e2a8 100644 --- a/src/unix/bsd-ifaddrs.c +++ b/src/unix/bsd-ifaddrs.c @@ -155,10 +155,3 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { return 0; } - - -/* TODO(bnoordhuis) share with linux.c */ -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - uv__free(addresses); -} diff --git a/src/unix/ibmi.c b/src/unix/ibmi.c index 9d94d2af..fe270f8c 100644 --- a/src/unix/ibmi.c +++ b/src/unix/ibmi.c @@ -505,11 +505,6 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { } -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - uv__free(addresses); -} - char** uv_setup_args(int argc, char** argv) { char exepath[UV__PATH_MAX]; char* s; diff --git a/src/unix/linux.c b/src/unix/linux.c index 77d079b7..1a62d78d 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -2045,13 +2045,6 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { } -/* TODO(bnoordhuis) share with bsd-ifaddrs.c */ -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - uv__free(addresses); -} - - void uv__set_process_title(const char* title) { #if defined(PR_SET_NAME) prctl(PR_SET_NAME, title); /* Only copies first 16 characters. */ diff --git a/src/unix/sunos.c b/src/unix/sunos.c index 6c38c31a..62584d72 100644 --- a/src/unix/sunos.c +++ b/src/unix/sunos.c @@ -898,11 +898,6 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { } #endif /* SUNOS_NO_IFADDRS */ -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - uv__free(addresses); -} - #if !defined(_POSIX_VERSION) || _POSIX_VERSION < 200809L size_t strnlen(const char* s, size_t maxlen) { diff --git a/src/uv-common.c b/src/uv-common.c index bff9d9ee..e5a76329 100644 --- a/src/uv-common.c +++ b/src/uv-common.c @@ -1054,3 +1054,11 @@ uint64_t uv_metrics_idle_time(uv_loop_t* loop) { idle_time += uv_hrtime() - entry_time; return idle_time; } + +/* OS390 needs a different implementation, already provided in os390.c. */ +#ifndef __MVS__ +void uv_free_interface_addresses(uv_interface_address_t* addresses, + int count) { + uv__free(addresses); +} +#endif /* !__MVS__ */ diff --git a/src/win/core.c b/src/win/core.c index 5f41c87a..ec50ec47 100644 --- a/src/win/core.c +++ b/src/win/core.c @@ -428,6 +428,7 @@ static void uv__poll(uv_loop_t* loop, DWORD timeout) { BOOL success; uv_req_t* req; OVERLAPPED_ENTRY overlappeds[128]; + OVERLAPPED* overlapped; ULONG count; ULONG i; int repeat; @@ -491,7 +492,8 @@ static void uv__poll(uv_loop_t* loop, DWORD timeout) { if (actual_timeout == 0) uv__metrics_inc_events_waiting(loop, 1); - req = uv__overlapped_to_req(overlappeds[i].lpOverlapped); + overlapped = overlappeds[i].lpOverlapped; + req = container_of(overlapped, uv_req_t, u.io.overlapped); uv__insert_pending_req(loop, req); } } @@ -525,6 +527,109 @@ static void uv__poll(uv_loop_t* loop, DWORD timeout) { } +#define DELEGATE_STREAM_REQ(loop, req, method, handle_at) \ + do { \ + switch (((uv_handle_t*) (req)->handle_at)->type) { \ + case UV_TCP: \ + uv__process_tcp_##method##_req(loop, \ + (uv_tcp_t*) ((req)->handle_at), \ + req); \ + break; \ + \ + case UV_NAMED_PIPE: \ + uv__process_pipe_##method##_req(loop, \ + (uv_pipe_t*) ((req)->handle_at), \ + req); \ + break; \ + \ + case UV_TTY: \ + uv__process_tty_##method##_req(loop, \ + (uv_tty_t*) ((req)->handle_at), \ + req); \ + break; \ + \ + default: \ + assert(0); \ + } \ + } while (0) + + +static void uv__process_reqs(uv_loop_t* loop) { + uv_req_t* req; + uv_req_t* first; + uv_req_t* next; + + if (loop->pending_reqs_tail == NULL) + return; + + first = loop->pending_reqs_tail->next_req; + next = first; + loop->pending_reqs_tail = NULL; + + while (next != NULL) { + req = next; + next = req->next_req != first ? req->next_req : NULL; + + switch (req->type) { + case UV_READ: + DELEGATE_STREAM_REQ(loop, req, read, data); + break; + + case UV_WRITE: + DELEGATE_STREAM_REQ(loop, (uv_write_t*) req, write, handle); + break; + + case UV_ACCEPT: + DELEGATE_STREAM_REQ(loop, req, accept, data); + break; + + case UV_CONNECT: + DELEGATE_STREAM_REQ(loop, (uv_connect_t*) req, connect, handle); + break; + + case UV_SHUTDOWN: + DELEGATE_STREAM_REQ(loop, (uv_shutdown_t*) req, shutdown, handle); + break; + + case UV_UDP_RECV: + uv__process_udp_recv_req(loop, (uv_udp_t*) req->data, req); + break; + + case UV_UDP_SEND: + uv__process_udp_send_req(loop, + ((uv_udp_send_t*) req)->handle, + (uv_udp_send_t*) req); + break; + + case UV_WAKEUP: + uv__process_async_wakeup_req(loop, (uv_async_t*) req->data, req); + break; + + case UV_SIGNAL_REQ: + uv__process_signal_req(loop, (uv_signal_t*) req->data, req); + break; + + case UV_POLL_REQ: + uv__process_poll_req(loop, (uv_poll_t*) req->data, req); + break; + + case UV_PROCESS_EXIT: + uv__process_proc_exit(loop, (uv_process_t*) req->data); + break; + + case UV_FS_EVENT_REQ: + uv__process_fs_event_req(loop, req, (uv_fs_event_t*) req->data); + break; + + default: + assert(0); + } + } +} + +#undef DELEGATE_STREAM_REQ + + int uv_run(uv_loop_t *loop, uv_run_mode mode) { DWORD timeout; int r; diff --git a/src/win/fs-fd-hash-inl.h b/src/win/fs-fd-hash-inl.h index 0b532af1..fd875d28 100644 --- a/src/win/fs-fd-hash-inl.h +++ b/src/win/fs-fd-hash-inl.h @@ -73,7 +73,7 @@ static struct uv__fd_hash_entry_group_s static struct uv__fd_hash_bucket_s uv__fd_hash[UV__FD_HASH_SIZE]; -INLINE static void uv__fd_hash_init(void) { +static void uv__fd_hash_init(void) { size_t i; int err; @@ -119,7 +119,7 @@ INLINE static void uv__fd_hash_init(void) { FIND_IN_GROUP_PTR(UV__FD_HASH_GROUP_SIZE); \ } while (0) -INLINE static int uv__fd_hash_get(int fd, struct uv__fd_info_s* info) { +static int uv__fd_hash_get(int fd, struct uv__fd_info_s* info) { FIND_COMMON_VARIABLES uv_mutex_lock(&uv__fd_hash_mutex); @@ -134,7 +134,7 @@ INLINE static int uv__fd_hash_get(int fd, struct uv__fd_info_s* info) { return entry_ptr != NULL; } -INLINE static void uv__fd_hash_add(int fd, struct uv__fd_info_s* info) { +static void uv__fd_hash_add(int fd, struct uv__fd_info_s* info) { FIND_COMMON_VARIABLES uv_mutex_lock(&uv__fd_hash_mutex); @@ -164,7 +164,7 @@ INLINE static void uv__fd_hash_add(int fd, struct uv__fd_info_s* info) { uv_mutex_unlock(&uv__fd_hash_mutex); } -INLINE static int uv__fd_hash_remove(int fd, struct uv__fd_info_s* info) { +static int uv__fd_hash_remove(int fd, struct uv__fd_info_s* info) { FIND_COMMON_VARIABLES uv_mutex_lock(&uv__fd_hash_mutex); diff --git a/src/win/fs.c b/src/win/fs.c index fb1a5844..4e156930 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -167,9 +167,10 @@ typedef enum { FS__STAT_PATH_TRY_SLOW } fs__stat_path_return_t; -INLINE static void fs__stat_assign_statbuf_null(uv_stat_t* statbuf); -INLINE static void fs__stat_assign_statbuf(uv_stat_t* statbuf, - FILE_STAT_BASIC_INFORMATION stat_info, int do_lstat); +static void fs__stat_assign_statbuf_null(uv_stat_t* statbuf); +static void fs__stat_assign_statbuf(uv_stat_t* statbuf, + FILE_STAT_BASIC_INFORMATION stat_info, + int do_lstat); void uv__fs_init(void) { @@ -182,9 +183,9 @@ void uv__fs_init(void) { } -INLINE static int fs__readlink_handle(HANDLE handle, - char** target_ptr, - size_t* target_len_ptr) { +static int fs__readlink_handle(HANDLE handle, + char** target_ptr, + size_t* target_len_ptr) { char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; REPARSE_DATA_BUFFER* reparse_data = (REPARSE_DATA_BUFFER*) buffer; WCHAR* w_target; @@ -319,8 +320,10 @@ INLINE static int fs__readlink_handle(HANDLE handle, } -INLINE static int fs__capture_path(uv_fs_t* req, const char* path, - const char* new_path, const int copy_path) { +static int fs__capture_path(uv_fs_t* req, + const char* path, + const char* new_path, + const int copy_path) { WCHAR* buf; WCHAR* pos; size_t buf_sz = 0; @@ -394,8 +397,10 @@ INLINE static int fs__capture_path(uv_fs_t* req, const char* path, } -INLINE static void uv__fs_req_init(uv_loop_t* loop, uv_fs_t* req, - uv_fs_type fs_type, const uv_fs_cb cb) { +static void uv__fs_req_init(uv_loop_t* loop, + uv_fs_t* req, + uv_fs_type fs_type, + const uv_fs_cb cb) { uv__once_init(); UV_REQ_INIT(req, UV_FS); req->loop = loop; @@ -1698,8 +1703,9 @@ void fs__closedir(uv_fs_t* req) { SET_REQ_RESULT(req, 0); } -INLINE static fs__stat_path_return_t fs__stat_path(WCHAR* path, - uv_stat_t* statbuf, int do_lstat) { +static fs__stat_path_return_t fs__stat_path(WCHAR* path, + uv_stat_t* statbuf, + int do_lstat) { FILE_STAT_BASIC_INFORMATION stat_info; /* Check if the new fast API is available. */ @@ -1735,8 +1741,7 @@ INLINE static fs__stat_path_return_t fs__stat_path(WCHAR* path, return FS__STAT_PATH_SUCCESS; } -INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf, - int do_lstat) { +static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf, int do_lstat) { size_t target_length = 0; FILE_FS_DEVICE_INFORMATION device_info; FILE_ALL_INFORMATION file_info; @@ -1827,7 +1832,7 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf, return 0; } -INLINE static void fs__stat_assign_statbuf_null(uv_stat_t* statbuf) { +static void fs__stat_assign_statbuf_null(uv_stat_t* statbuf) { memset(statbuf, 0, sizeof(uv_stat_t)); statbuf->st_mode = _S_IFCHR; statbuf->st_mode |= (_S_IREAD | _S_IWRITE) | ((_S_IREAD | _S_IWRITE) >> 3) | @@ -1837,8 +1842,9 @@ INLINE static void fs__stat_assign_statbuf_null(uv_stat_t* statbuf) { statbuf->st_rdev = FILE_DEVICE_NULL << 16; } -INLINE static void fs__stat_assign_statbuf(uv_stat_t* statbuf, - FILE_STAT_BASIC_INFORMATION stat_info, int do_lstat) { +static void fs__stat_assign_statbuf(uv_stat_t* statbuf, + FILE_STAT_BASIC_INFORMATION stat_info, + int do_lstat) { statbuf->st_dev = stat_info.VolumeSerialNumber.LowPart; /* Todo: st_mode should probably always be 0666 for everyone. We might also @@ -1943,7 +1949,7 @@ INLINE static void fs__stat_assign_statbuf(uv_stat_t* statbuf, } -INLINE static void fs__stat_prepare_path(WCHAR* pathw) { +static void fs__stat_prepare_path(WCHAR* pathw) { size_t len = wcslen(pathw); if (len > 1 && pathw[len - 2] != L':' && @@ -1952,8 +1958,10 @@ INLINE static void fs__stat_prepare_path(WCHAR* pathw) { } } -INLINE static DWORD fs__stat_directory(WCHAR* path, uv_stat_t* statbuf, - int do_lstat, DWORD ret_error) { +static DWORD fs__stat_directory(WCHAR* path, + uv_stat_t* statbuf, + int do_lstat, + DWORD ret_error) { HANDLE handle = INVALID_HANDLE_VALUE; FILE_STAT_BASIC_INFORMATION stat_info; FILE_ID_FULL_DIR_INFORMATION dir_info; @@ -2126,9 +2134,9 @@ cleanup: return ret_error; } -INLINE static DWORD fs__stat_impl_from_path(WCHAR* path, - int do_lstat, - uv_stat_t* statbuf) { +static DWORD fs__stat_impl_from_path(WCHAR* path, + int do_lstat, + uv_stat_t* statbuf) { HANDLE handle; DWORD flags; DWORD ret; @@ -2173,7 +2181,7 @@ INLINE static DWORD fs__stat_impl_from_path(WCHAR* path, } -INLINE static void fs__stat_impl(uv_fs_t* req, int do_lstat) { +static void fs__stat_impl(uv_fs_t* req, int do_lstat) { DWORD error; error = fs__stat_impl_from_path(req->file.pathw, do_lstat, &req->statbuf); @@ -2196,7 +2204,7 @@ INLINE static void fs__stat_impl(uv_fs_t* req, int do_lstat) { } -INLINE static int fs__fstat_handle(int fd, HANDLE handle, uv_stat_t* statbuf) { +static int fs__fstat_handle(int fd, HANDLE handle, uv_stat_t* statbuf) { DWORD file_type; /* Each file type is processed differently. */ @@ -2272,7 +2280,7 @@ static void fs__rename(uv_fs_t* req) { } -INLINE static void fs__sync_impl(uv_fs_t* req) { +static void fs__sync_impl(uv_fs_t* req) { int fd = req->file.fd; int result; @@ -2578,7 +2586,7 @@ fchmod_cleanup: } -INLINE static int fs__utime_handle(HANDLE handle, double atime, double mtime) { +static int fs__utime_handle(HANDLE handle, double atime, double mtime) { FILETIME filetime_as, *filetime_a = &filetime_as; FILETIME filetime_ms, *filetime_m = &filetime_ms; FILETIME now; @@ -2606,10 +2614,10 @@ INLINE static int fs__utime_handle(HANDLE handle, double atime, double mtime) { return 0; } -INLINE static DWORD fs__utime_impl_from_path(WCHAR* path, - double atime, - double mtime, - int do_lutime) { +static DWORD fs__utime_impl_from_path(WCHAR* path, + double atime, + double mtime, + int do_lutime) { HANDLE handle; DWORD flags; DWORD ret; @@ -2639,7 +2647,7 @@ INLINE static DWORD fs__utime_impl_from_path(WCHAR* path, return ret; } -INLINE static void fs__utime_impl(uv_fs_t* req, int do_lutime) { +static void fs__utime_impl(uv_fs_t* req, int do_lutime) { DWORD error; error = fs__utime_impl_from_path(req->file.pathw, diff --git a/src/win/req-inl.h b/src/win/req-inl.h index cf16e8ba..c1ca8ea4 100644 --- a/src/win/req-inl.h +++ b/src/win/req-inl.h @@ -81,12 +81,6 @@ uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); \ } - -INLINE static uv_req_t* uv__overlapped_to_req(OVERLAPPED* overlapped) { - return container_of(overlapped, uv_req_t, u.io.overlapped); -} - - INLINE static void uv__insert_pending_req(uv_loop_t* loop, uv_req_t* req) { req->next_req = NULL; if (loop->pending_reqs_tail) { @@ -110,105 +104,4 @@ INLINE static void uv__insert_pending_req(uv_loop_t* loop, uv_req_t* req) { } } - -#define DELEGATE_STREAM_REQ(loop, req, method, handle_at) \ - do { \ - switch (((uv_handle_t*) (req)->handle_at)->type) { \ - case UV_TCP: \ - uv__process_tcp_##method##_req(loop, \ - (uv_tcp_t*) ((req)->handle_at), \ - req); \ - break; \ - \ - case UV_NAMED_PIPE: \ - uv__process_pipe_##method##_req(loop, \ - (uv_pipe_t*) ((req)->handle_at), \ - req); \ - break; \ - \ - case UV_TTY: \ - uv__process_tty_##method##_req(loop, \ - (uv_tty_t*) ((req)->handle_at), \ - req); \ - break; \ - \ - default: \ - assert(0); \ - } \ - } while (0) - - -INLINE static void uv__process_reqs(uv_loop_t* loop) { - uv_req_t* req; - uv_req_t* first; - uv_req_t* next; - - if (loop->pending_reqs_tail == NULL) - return; - - first = loop->pending_reqs_tail->next_req; - next = first; - loop->pending_reqs_tail = NULL; - - while (next != NULL) { - req = next; - next = req->next_req != first ? req->next_req : NULL; - - switch (req->type) { - case UV_READ: - DELEGATE_STREAM_REQ(loop, req, read, data); - break; - - case UV_WRITE: - DELEGATE_STREAM_REQ(loop, (uv_write_t*) req, write, handle); - break; - - case UV_ACCEPT: - DELEGATE_STREAM_REQ(loop, req, accept, data); - break; - - case UV_CONNECT: - DELEGATE_STREAM_REQ(loop, (uv_connect_t*) req, connect, handle); - break; - - case UV_SHUTDOWN: - DELEGATE_STREAM_REQ(loop, (uv_shutdown_t*) req, shutdown, handle); - break; - - case UV_UDP_RECV: - uv__process_udp_recv_req(loop, (uv_udp_t*) req->data, req); - break; - - case UV_UDP_SEND: - uv__process_udp_send_req(loop, - ((uv_udp_send_t*) req)->handle, - (uv_udp_send_t*) req); - break; - - case UV_WAKEUP: - uv__process_async_wakeup_req(loop, (uv_async_t*) req->data, req); - break; - - case UV_SIGNAL_REQ: - uv__process_signal_req(loop, (uv_signal_t*) req->data, req); - break; - - case UV_POLL_REQ: - uv__process_poll_req(loop, (uv_poll_t*) req->data, req); - break; - - case UV_PROCESS_EXIT: - uv__process_proc_exit(loop, (uv_process_t*) req->data); - break; - - case UV_FS_EVENT_REQ: - uv__process_fs_event_req(loop, req, (uv_fs_event_t*) req->data); - break; - - default: - assert(0); - } - } -} - #endif /* UV_WIN_REQ_INL_H_ */ diff --git a/src/win/util.c b/src/win/util.c index cebc2b3e..8c2681fe 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -872,12 +872,6 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, } -void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count) { - uv__free(addresses); -} - - int uv_getrusage(uv_rusage_t *uv_rusage) { FILETIME create_time, exit_time, kernel_time, user_time; SYSTEMTIME kernel_system_time, user_system_time; |