@@ -273,7 +273,9 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
return -errno;
}

/* kern.cp_times on FreeBSD i386 gives an array up to maxcpus instead of ncpu */
/* kern.cp_times on FreeBSD i386 gives an array up to maxcpus instead of
* ncpu.
*/
size = sizeof(maxcpus);
if (sysctlbyname(maxcpus_key, &maxcpus, &size, NULL, 0)) {
SAVE_ERRNO(free(*cpu_infos));
@@ -335,7 +335,9 @@ int uv_signal_start(uv_signal_t* handle, uv_signal_cb signal_cb, int signum) {
}


static void uv__signal_event(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
static void uv__signal_event(uv_loop_t* loop,
uv__io_t* w,
unsigned int events) {
uv__signal_msg_t* msg;
uv_signal_t* handle;
char buf[sizeof(uv__signal_msg_t) * 32];
@@ -256,7 +256,7 @@ int uv_exepath(char* buffer, size_t* size) {
if (buffer == NULL || size == NULL)
return -EINVAL;

(void) snprintf(buf, sizeof(buf), "/proc/%lu/path/a.out", (unsigned long) getpid());
snprintf(buf, sizeof(buf), "/proc/%lu/path/a.out", (unsigned long) getpid());
res = readlink(buf, buffer, *size - 1);
if (res == -1)
return -errno;
@@ -389,7 +389,9 @@ int uv_fs_event_init(uv_loop_t* loop,

void uv__fs_event_close(uv_fs_event_t* handle) {
if (handle->fd == PORT_FIRED || handle->fd == PORT_LOADED) {
port_dissociate(handle->loop->fs_fd, PORT_SOURCE_FILE, (uintptr_t)&handle->fo);
port_dissociate(handle->loop->fs_fd,
PORT_SOURCE_FILE,
(uintptr_t) &handle->fo);
}
handle->fd = PORT_DELETED;
free(handle->filename);
@@ -511,13 +513,13 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
cpu_info->speed = 0;
cpu_info->model = NULL;
} else {
knp = (kstat_named_t*) kstat_data_lookup(ksp, (char*) "clock_MHz");
knp = kstat_data_lookup(ksp, (char*) "clock_MHz");
assert(knp->data_type == KSTAT_DATA_INT32 ||
knp->data_type == KSTAT_DATA_INT64);
cpu_info->speed = (knp->data_type == KSTAT_DATA_INT32) ? knp->value.i32
: knp->value.i64;

knp = (kstat_named_t*) kstat_data_lookup(ksp, (char*) "brand");
knp = kstat_data_lookup(ksp, (char*) "brand");
assert(knp->data_type == KSTAT_DATA_STRING);
cpu_info->model = strdup(KSTAT_NAMED_STR_PTR(knp));
}
@@ -528,7 +530,11 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {

cpu_info = *cpu_infos;
lookup_instance = 0;
while ((ksp = kstat_lookup(kc, (char*) "cpu", lookup_instance, (char*) "sys"))){
for (;;) {
ksp = kstat_lookup(kc, (char*) "cpu", lookup_instance, (char*) "sys");

if (ksp == NULL)
break;

if (kstat_read(kc, ksp, NULL) == -1) {
cpu_info->cpu_times.user = 0;
@@ -537,19 +543,19 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
cpu_info->cpu_times.idle = 0;
cpu_info->cpu_times.irq = 0;
} else {
knp = (kstat_named_t*) kstat_data_lookup(ksp, (char*) "cpu_ticks_user");
knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_user");
assert(knp->data_type == KSTAT_DATA_UINT64);
cpu_info->cpu_times.user = knp->value.ui64;

knp = (kstat_named_t*) kstat_data_lookup(ksp, (char*) "cpu_ticks_kernel");
knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_kernel");
assert(knp->data_type == KSTAT_DATA_UINT64);
cpu_info->cpu_times.sys = knp->value.ui64;

knp = (kstat_named_t*) kstat_data_lookup(ksp, (char*) "cpu_ticks_idle");
knp = kstat_data_lookup(ksp, (char*) "cpu_ticks_idle");
assert(knp->data_type == KSTAT_DATA_UINT64);
cpu_info->cpu_times.idle = knp->value.ui64;

knp = (kstat_named_t*) kstat_data_lookup(ksp, (char*) "intr");
knp = kstat_data_lookup(ksp, (char*) "intr");
assert(knp->data_type == KSTAT_DATA_UINT64);
cpu_info->cpu_times.irq = knp->value.ui64;
cpu_info->cpu_times.nice = 0;
@@ -86,7 +86,9 @@ static int test_async(int nthreads) {
ctx->loop = uv_loop_new();
ASSERT(ctx->loop != NULL);
ASSERT(0 == uv_async_init(ctx->loop, &ctx->worker_async, worker_async_cb));
ASSERT(0 == uv_async_init(uv_default_loop(), &ctx->main_async, main_async_cb));
ASSERT(0 == uv_async_init(uv_default_loop(),
&ctx->main_async,
main_async_cb));
ASSERT(0 == uv_thread_create(&ctx->thread, worker, ctx));
}

@@ -148,7 +148,9 @@ static void pinger_read_cb(uv_stream_t* tcp,
if (pinger->state == 0) {
pinger->pongs++;
if (uv_now(loop) - start_time > TIME) {
uv_shutdown(&pinger->shutdown_req, (uv_stream_t*) tcp, pinger_shutdown_cb);
uv_shutdown(&pinger->shutdown_req,
(uv_stream_t*) tcp,
pinger_shutdown_cb);
break;
} else {
pinger_write_ping(pinger);
@@ -229,7 +229,10 @@ static void pipe_make_connect(conn_rec* p) {
r = uv_pipe_init(loop, (uv_pipe_t*)&p->stream, 0);
ASSERT(r == 0);

uv_pipe_connect(&((pipe_conn_rec*)p)->conn_req, (uv_pipe_t*)&p->stream, TEST_PIPENAME, connect_cb);
uv_pipe_connect(&((pipe_conn_rec*) p)->conn_req,
(uv_pipe_t*) &p->stream,
TEST_PIPENAME,
connect_cb);

#if DEBUG
printf("make connect %d\n", p->i);
@@ -308,20 +311,40 @@ static int pound_it(int concurrency,


BENCHMARK_IMPL(tcp4_pound_100) {
return pound_it(100, "tcp", tcp_do_setup, tcp_do_connect, tcp_make_connect, NULL);
return pound_it(100,
"tcp",
tcp_do_setup,
tcp_do_connect,
tcp_make_connect,
NULL);
}


BENCHMARK_IMPL(tcp4_pound_1000) {
return pound_it(1000, "tcp", tcp_do_setup, tcp_do_connect, tcp_make_connect, NULL);
return pound_it(1000,
"tcp",
tcp_do_setup,
tcp_do_connect,
tcp_make_connect,
NULL);
}


BENCHMARK_IMPL(pipe_pound_100) {
return pound_it(100, "pipe", pipe_do_setup, pipe_do_connect, pipe_make_connect, NULL);
return pound_it(100,
"pipe",
pipe_do_setup,
pipe_do_connect,
pipe_make_connect,
NULL);
}


BENCHMARK_IMPL(pipe_pound_1000) {
return pound_it(1000, "pipe", pipe_do_setup, pipe_do_connect, pipe_make_connect, NULL);
return pound_it(1000,
"pipe",
pipe_do_setup,
pipe_do_connect,
pipe_make_connect,
NULL);
}
@@ -101,11 +101,16 @@ static void show_stats(uv_timer_t* handle, int status) {
uv_update_time(loop);
diff = uv_now(loop) - start_time;

LOGF("%s_pump%d_client: %.1f gbit/s\n", type == TCP ? "tcp" : "pipe", write_sockets,
gbit(nsent_total, diff));
LOGF("%s_pump%d_client: %.1f gbit/s\n",
type == TCP ? "tcp" : "pipe",
write_sockets,
gbit(nsent_total, diff));

for (i = 0; i < write_sockets; i++) {
uv_close(type == TCP ? (uv_handle_t*)&tcp_write_handles[i] : (uv_handle_t*)&pipe_write_handles[i], NULL);
if (type == TCP)
uv_close((uv_handle_t*) &tcp_write_handles[i], NULL);
else
uv_close((uv_handle_t*) &pipe_write_handles[i], NULL);
}

exit(0);
@@ -123,8 +128,10 @@ static void read_show_stats(void) {
uv_update_time(loop);
diff = uv_now(loop) - start_time;

LOGF("%s_pump%d_server: %.1f gbit/s\n", type == TCP ? "tcp" : "pipe", max_read_sockets,
gbit(nrecv_total, diff));
LOGF("%s_pump%d_server: %.1f gbit/s\n",
type == TCP ? "tcp" : "pipe",
max_read_sockets,
gbit(nrecv_total, diff));
}


@@ -219,7 +226,10 @@ static void connect_cb(uv_connect_t* req, int status) {

/* Yay! start writing */
for (i = 0; i < write_sockets; i++) {
do_write(type == TCP ? (uv_stream_t*)&tcp_write_handles[i] : (uv_stream_t*)&pipe_write_handles[i]);
if (type == TCP)
do_write((uv_stream_t*) &tcp_write_handles[i]);
else
do_write((uv_stream_t*) &pipe_write_handles[i]);
}
}
}
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>

#define EXPECTED "RANG TANG DING DONG I AM THE JAPANESE SANDMAN" /* "Take eight!" */
#define EXPECTED "RANG TANG DING DONG I AM THE JAPANESE SANDMAN"

#define TEST_DURATION 5000 /* ms */

@@ -159,12 +159,16 @@ static void process_req(uv_stream_t* handle,
/* process len and id */
if (readbuf_remaining < hdrbuf_remaining) {
/* too little to get request header. save for next buffer */
memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining], dnsreq, readbuf_remaining);
memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining],
dnsreq,
readbuf_remaining);
hdrbuf_remaining = DNSREC_LEN - readbuf_remaining;
break;
} else {
/* save header */
memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining], dnsreq, hdrbuf_remaining);
memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining],
dnsreq,
hdrbuf_remaining);
dnsreq += hdrbuf_remaining;
readbuf_remaining -= hdrbuf_remaining;
hdrbuf_remaining = 0;
@@ -192,7 +196,9 @@ static void process_req(uv_stream_t* handle,
}
}

/* if we had to use bytes from prev buffer, start processing the current one */
/* If we had to use bytes from prev buffer, start processing the current
* one.
*/
if (usingprev == 1) {
/* free previous buffer */
free(dns->state.prevbuf_ptr);
@@ -110,7 +110,9 @@ int process_start(char *name, char *part, process_info_t *p, int is_helper) {
if (!SetHandleInformation(nul, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
goto error;

result = GetModuleFileNameW(NULL, (WCHAR*)&image, sizeof(image) / sizeof(WCHAR));
result = GetModuleFileNameW(NULL,
(WCHAR*) &image,
sizeof(image) / sizeof(WCHAR));
if (result == 0 || result == sizeof(image))
goto error;

@@ -214,8 +216,12 @@ int process_copy_output(process_info_t *p, int fd) {
char buf[1024];
char *line, *start;

if (SetFilePointer(p->stdio_out, 0, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
if (SetFilePointer(p->stdio_out,
0,
0,
FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
return -1;
}

if (tap_output)
write(fd, "#", 1);
@@ -337,8 +343,13 @@ static int clear_line() {
if (!SetConsoleCursorPosition(handle, coord))
return -1;

if (!FillConsoleOutputCharacterW(handle, 0x20, info.dwSize.X, coord, &written))
if (!FillConsoleOutputCharacterW(handle,
0x20,
info.dwSize.X,
coord,
&written)) {
return -1;
}

return 0;
}
@@ -410,7 +410,8 @@ static int compare_task(const void* va, const void* vb) {
}


static int find_helpers(const task_entry_t* task, const task_entry_t** helpers) {
static int find_helpers(const task_entry_t* task,
const task_entry_t** helpers) {
const task_entry_t* helper;
int n_helpers;

@@ -1333,7 +1333,12 @@ TEST_IMPL(fs_symlink) {

close(link);

r = uv_fs_symlink(loop, &req, "test_file_symlink", "test_file_symlink_symlink", 0, NULL);
r = uv_fs_symlink(loop,
&req,
"test_file_symlink",
"test_file_symlink_symlink",
0,
NULL);
ASSERT(r == 0);
uv_fs_req_cleanup(&req);

@@ -1343,7 +1348,12 @@ TEST_IMPL(fs_symlink) {
uv_fs_req_cleanup(&req);

/* async link */
r = uv_fs_symlink(loop, &req, "test_file", "test_file_symlink2", 0, symlink_cb);
r = uv_fs_symlink(loop,
&req,
"test_file",
"test_file_symlink2",
0,
symlink_cb);
ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT);
ASSERT(symlink_cb_count == 1);
@@ -1362,7 +1372,12 @@ TEST_IMPL(fs_symlink) {

close(link);

r = uv_fs_symlink(loop, &req, "test_file_symlink2", "test_file_symlink2_symlink", 0, NULL);
r = uv_fs_symlink(loop,
&req,
"test_file_symlink2",
"test_file_symlink2_symlink",
0,
NULL);
ASSERT(r == 0);
uv_fs_req_cleanup(&req);

@@ -47,7 +47,9 @@ TEST_IMPL(get_currentexe) {
}

match = strstr(buffer, path);
/* Verify that the path returned from uv_exepath is a subdirectory of executable_path */
/* Verify that the path returned from uv_exepath is a subdirectory of
* executable_path.
*/
ASSERT(match && !strcmp(match, path));
ASSERT(size == strlen(buffer));

@@ -78,7 +78,11 @@ static void pinger_write_ping(pinger_t* pinger) {
buf = uv_buf_init(PING, sizeof(PING) - 1);

req = malloc(sizeof(*req));
if (uv_write(req, (uv_stream_t*)&pinger->stream.tcp, &buf, 1, pinger_after_write)) {
if (uv_write(req,
(uv_stream_t*) &pinger->stream.tcp,
&buf,
1,
pinger_after_write)) {
FATAL("uv_write failed");
}