Skip to content

Commit

Permalink
win: fix style nits [NFC] (#3474)
Browse files Browse the repository at this point in the history
Internal functions usually have a uv__ prefix.
  • Loading branch information
vtjnash authored Feb 15, 2022
1 parent d41a9a0 commit d54c92e
Show file tree
Hide file tree
Showing 25 changed files with 498 additions and 500 deletions.
2 changes: 1 addition & 1 deletion src/fs-poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#ifdef _WIN32
#include "win/internal.h"
#include "win/handle-inl.h"
#define uv__make_close_pending(h) uv_want_endgame((h)->loop, (h))
#define uv__make_close_pending(h) uv__want_endgame((h)->loop, (h))
#else
#include "unix/internal.h"
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/unix/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ int uv__dup2_cloexec(int oldfd, int newfd);
int uv__open_cloexec(const char* path, int flags);

/* tcp */
int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb);
int uv__tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb);
int uv__tcp_nodelay(int fd, int on);
int uv__tcp_keepalive(int fd, int on, unsigned int delay);

/* pipe */
int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb);
int uv__pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb);

/* signal */
void uv__signal_close(uv_signal_t* handle);
Expand Down
2 changes: 1 addition & 1 deletion src/unix/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
}


int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
int uv__pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
if (uv__stream_fd(handle) == -1)
return UV_EINVAL;

Expand Down
4 changes: 2 additions & 2 deletions src/unix/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,11 @@ int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) {

switch (stream->type) {
case UV_TCP:
err = uv_tcp_listen((uv_tcp_t*)stream, backlog, cb);
err = uv__tcp_listen((uv_tcp_t*)stream, backlog, cb);
break;

case UV_NAMED_PIPE:
err = uv_pipe_listen((uv_pipe_t*)stream, backlog, cb);
err = uv__pipe_listen((uv_pipe_t*)stream, backlog, cb);
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion src/unix/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb) {
}


int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
int uv__tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
static int single_accept_cached = -1;
unsigned long flags;
int single_accept;
Expand Down
10 changes: 5 additions & 5 deletions src/win/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "req-inl.h"


void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle) {
void uv__async_endgame(uv_loop_t* loop, uv_async_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING &&
!handle->async_sent) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
Expand All @@ -54,9 +54,9 @@ int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) {
}


void uv_async_close(uv_loop_t* loop, uv_async_t* handle) {
void uv__async_close(uv_loop_t* loop, uv_async_t* handle) {
if (!((uv_async_t*)handle)->async_sent) {
uv_want_endgame(loop, (uv_handle_t*) handle);
uv__want_endgame(loop, (uv_handle_t*) handle);
}

uv__handle_closing(handle);
Expand All @@ -83,15 +83,15 @@ int uv_async_send(uv_async_t* handle) {
}


void uv_process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle,
void uv__process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle,
uv_req_t* req) {
assert(handle->type == UV_ASYNC);
assert(req->type == UV_WAKEUP);

handle->async_sent = 0;

if (handle->flags & UV_HANDLE_CLOSING) {
uv_want_endgame(loop, (uv_handle_t*)handle);
uv__want_endgame(loop, (uv_handle_t*)handle);
} else if (handle->async_cb != NULL) {
handle->async_cb(handle);
}
Expand Down
35 changes: 19 additions & 16 deletions src/win/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ static int uv__loops_capacity;
#define UV__LOOPS_CHUNK_SIZE 8
static uv_mutex_t uv__loops_lock;


static void uv__loops_init(void) {
uv_mutex_init(&uv__loops_lock);
}


static int uv__loops_add(uv_loop_t* loop) {
uv_loop_t** new_loops;
int new_capacity, i;
Expand Down Expand Up @@ -115,6 +117,7 @@ static int uv__loops_add(uv_loop_t* loop) {
return ERROR_OUTOFMEMORY;
}


static void uv__loops_remove(uv_loop_t* loop) {
int loop_index;
int smaller_capacity;
Expand Down Expand Up @@ -173,7 +176,7 @@ void uv__wake_all_loops(void) {
uv_mutex_unlock(&uv__loops_lock);
}

static void uv_init(void) {
static void uv__init(void) {
/* Tell Windows that we will handle critical errors. */
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX);
Expand All @@ -199,19 +202,19 @@ static void uv_init(void) {
/* Fetch winapi function pointers. This must be done first because other
* initialization code might need these function pointers to be loaded.
*/
uv_winapi_init();
uv__winapi_init();

/* Initialize winsock */
uv_winsock_init();
uv__winsock_init();

/* Initialize FS */
uv_fs_init();
uv__fs_init();

/* Initialize signal stuff */
uv_signals_init();
uv__signals_init();

/* Initialize console */
uv_console_init();
uv__console_init();

/* Initialize utilities */
uv__util_init();
Expand Down Expand Up @@ -327,7 +330,7 @@ void uv_update_time(uv_loop_t* loop) {


void uv__once_init(void) {
uv_once(&uv_init_guard_, uv_init);
uv_once(&uv_init_guard_, uv__init);
}


Expand Down Expand Up @@ -467,8 +470,8 @@ static void uv__poll_wine(uv_loop_t* loop, DWORD timeout) {

if (overlapped) {
/* Package was dequeued */
req = uv_overlapped_to_req(overlapped);
uv_insert_pending_req(loop, req);
req = uv__overlapped_to_req(overlapped);
uv__insert_pending_req(loop, req);

/* Some time might have passed waiting for I/O,
* so update the loop time here.
Expand Down Expand Up @@ -552,8 +555,8 @@ static void uv__poll(uv_loop_t* loop, DWORD timeout) {
* meant only to wake us up.
*/
if (overlappeds[i].lpOverlapped) {
req = uv_overlapped_to_req(overlappeds[i].lpOverlapped);
uv_insert_pending_req(loop, req);
req = uv__overlapped_to_req(overlappeds[i].lpOverlapped);
uv__insert_pending_req(loop, req);
}
}

Expand Down Expand Up @@ -599,9 +602,9 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
uv_update_time(loop);
uv__run_timers(loop);

ran_pending = uv_process_reqs(loop);
uv_idle_invoke(loop);
uv_prepare_invoke(loop);
ran_pending = uv__process_reqs(loop);
uv__idle_invoke(loop);
uv__prepare_invoke(loop);

timeout = 0;
if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT)
Expand All @@ -619,8 +622,8 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
*/
uv__metrics_update_idle_time(loop);

uv_check_invoke(loop);
uv_process_endgames(loop);
uv__check_invoke(loop);
uv__process_endgames(loop);

if (mode == UV_RUN_ONCE) {
/* UV_RUN_ONCE implies forward progress: at least one callback must have
Expand Down
36 changes: 18 additions & 18 deletions src/win/fs-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
const unsigned int uv_directory_watcher_buffer_size = 4096;


static void uv_fs_event_queue_readdirchanges(uv_loop_t* loop,
static void uv__fs_event_queue_readdirchanges(uv_loop_t* loop,
uv_fs_event_t* handle) {
assert(handle->dir_handle != INVALID_HANDLE_VALUE);
assert(!handle->req_pending);
Expand All @@ -57,15 +57,15 @@ static void uv_fs_event_queue_readdirchanges(uv_loop_t* loop,
NULL)) {
/* Make this req pending reporting an error. */
SET_REQ_ERROR(&handle->req, GetLastError());
uv_insert_pending_req(loop, (uv_req_t*)&handle->req);
uv__insert_pending_req(loop, (uv_req_t*)&handle->req);
}

handle->req_pending = 1;
}

static void uv_relative_path(const WCHAR* filename,
const WCHAR* dir,
WCHAR** relpath) {
static void uv__relative_path(const WCHAR* filename,
const WCHAR* dir,
WCHAR** relpath) {
size_t relpathlen;
size_t filenamelen = wcslen(filename);
size_t dirlen = wcslen(dir);
Expand All @@ -80,7 +80,7 @@ static void uv_relative_path(const WCHAR* filename,
(*relpath)[relpathlen] = L'\0';
}

static int uv_split_path(const WCHAR* filename, WCHAR** dir,
static int uv__split_path(const WCHAR* filename, WCHAR** dir,
WCHAR** file) {
size_t len, i;
DWORD dir_len;
Expand Down Expand Up @@ -255,12 +255,12 @@ int uv_fs_event_start(uv_fs_event_t* handle,
short_path_done:
short_path = short_path_buffer;

if (uv_split_path(pathw, &dir, &handle->filew) != 0) {
if (uv__split_path(pathw, &dir, &handle->filew) != 0) {
last_error = GetLastError();
goto error;
}

if (uv_split_path(short_path, NULL, &handle->short_filew) != 0) {
if (uv__split_path(short_path, NULL, &handle->short_filew) != 0) {
last_error = GetLastError();
goto error;
}
Expand Down Expand Up @@ -423,7 +423,7 @@ static int file_info_cmp(WCHAR* str, WCHAR* file_name, size_t file_name_len) {
}


void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
void uv__process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
uv_fs_event_t* handle) {
FILE_NOTIFY_INFORMATION* file_info;
int err, sizew, size;
Expand All @@ -442,7 +442,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
*/
if (!uv__is_active(handle)) {
if (handle->flags & UV_HANDLE_CLOSING) {
uv_want_endgame(loop, (uv_handle_t*) handle);
uv__want_endgame(loop, (uv_handle_t*) handle);
}
return;
}
Expand Down Expand Up @@ -515,9 +515,9 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,

if (long_filenamew) {
/* Get the file name out of the long path. */
uv_relative_path(long_filenamew,
handle->dirw,
&filenamew);
uv__relative_path(long_filenamew,
handle->dirw,
&filenamew);
uv__free(long_filenamew);
long_filenamew = filenamew;
sizew = -1;
Expand Down Expand Up @@ -575,26 +575,26 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
}

if (handle->flags & UV_HANDLE_CLOSING) {
uv_want_endgame(loop, (uv_handle_t*)handle);
uv__want_endgame(loop, (uv_handle_t*)handle);
} else if (uv__is_active(handle)) {
uv_fs_event_queue_readdirchanges(loop, handle);
uv__fs_event_queue_readdirchanges(loop, handle);
}
}


void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) {
void uv__fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) {
uv_fs_event_stop(handle);

uv__handle_closing(handle);

if (!handle->req_pending) {
uv_want_endgame(loop, (uv_handle_t*)handle);
uv__want_endgame(loop, (uv_handle_t*)handle);
}

}


void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) {
void uv__fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) {
if ((handle->flags & UV_HANDLE_CLOSING) && !handle->req_pending) {
assert(!(handle->flags & UV_HANDLE_CLOSED));

Expand Down
6 changes: 3 additions & 3 deletions src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
do { \
if (req == NULL) \
return UV_EINVAL; \
uv_fs_req_init(loop, req, subtype, cb); \
uv__fs_req_init(loop, req, subtype, cb); \
} \
while (0)

Expand Down Expand Up @@ -132,7 +132,7 @@ static int uv__file_symlink_usermode_flag = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGE
static DWORD uv__allocation_granularity;


void uv_fs_init(void) {
void uv__fs_init(void) {
SYSTEM_INFO system_info;

GetSystemInfo(&system_info);
Expand Down Expand Up @@ -241,7 +241,7 @@ 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,
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) {
uv__once_init();
UV_REQ_INIT(req, UV_FS);
Expand Down
Loading

0 comments on commit d54c92e

Please sign in to comment.