Merge branch 'v0.10'

This commit is contained in:
Bert Belder 2013-04-10 17:53:10 +02:00
commit db1a8b85d2
10 changed files with 95 additions and 96 deletions

View File

@ -80,6 +80,8 @@ endif
ifeq (darwin,$(PLATFORM))
HAVE_DTRACE=1
# dtrace(1) probes contain dollar signs.
CFLAGS += -Wno-dollar-in-identifier-extension
CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
LDFLAGS += -framework Foundation \
-framework CoreServices \

View File

@ -54,14 +54,14 @@ uv_err_t uv_inet_ntop(int af, const void* src, char* dst, size_t size) {
static uv_err_t inet_ntop4(const unsigned char *src, char *dst, size_t size) {
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
size_t l;
int l;
#ifndef _WIN32
l = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
#else
l = _snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);
#endif
if (l <= 0 || l >= size) {
if (l <= 0 || (size_t) l >= size) {
return uv_enospc_;
}
strncpy(dst, tmp, size);

View File

@ -62,7 +62,6 @@ uint64_t uv__hrtime(void) {
int uv_exepath(char* buffer, size_t* size) {
ssize_t res;
char pp[64], cwdl[PATH_MAX];
size_t cwdl_len;
struct psinfo ps;
int fd;
@ -79,7 +78,6 @@ int uv_exepath(char* buffer, size_t* size) {
return res;
cwdl[res] = '\0';
cwdl_len = res;
(void) snprintf(pp, sizeof(pp), "/proc/%lu/psinfo", (unsigned long) getpid());
fd = open(pp, O_RDONLY);

View File

@ -56,9 +56,6 @@ void uv_loadavg(double avg[3]) {
int uv_exepath(char* buffer, size_t* size) {
uint32_t usize;
int result;
char* path;
char* fullpath;
if (!buffer || !size) {
return -1;

View File

@ -185,7 +185,6 @@ int uv_backend_timeout(const uv_loop_t* loop) {
static void uv_poll(uv_loop_t* loop, int block) {
BOOL success;
DWORD bytes, timeout;
ULONG_PTR key;
OVERLAPPED* overlapped;
@ -197,11 +196,11 @@ static void uv_poll(uv_loop_t* loop, int block) {
timeout = 0;
}
success = GetQueuedCompletionStatus(loop->iocp,
&bytes,
&key,
&overlapped,
timeout);
GetQueuedCompletionStatus(loop->iocp,
&bytes,
&key,
&overlapped,
timeout);
if (overlapped) {
/* Package was dequeued */

View File

@ -311,7 +311,7 @@ static SOCKET uv__fast_poll_get_peer_socket(uv_loop_t* loop,
static DWORD WINAPI uv__slow_poll_thread_proc(void* arg) {
uv_req_t* req = (uv_req_t*) arg;
uv_poll_t* handle = (uv_poll_t*) req->data;
unsigned char events, reported_events;
unsigned char reported_events;
int r;
uv_single_fd_set_t rfds, wfds, efds;
struct timeval timeout;
@ -319,14 +319,6 @@ static DWORD WINAPI uv__slow_poll_thread_proc(void* arg) {
assert(handle->type == UV_POLL);
assert(req->type == UV_POLL_REQ);
if (req == &handle->poll_req_1) {
events = handle->submitted_events_1;
} else if (req == &handle->poll_req_2) {
events = handle->submitted_events_2;
} else {
assert(0);
}
if (handle->events & UV_READABLE) {
rfds.fd_count = 1;
rfds.fd_array[0] = handle->socket;

View File

@ -182,7 +182,7 @@ static int uv__bind(uv_udp_t* handle,
int addrsize,
unsigned int flags) {
int r;
DWORD no = 0, yes = 1;
DWORD no = 0;
if ((flags & UV_UDP_IPV6ONLY) && family != AF_INET6) {
/* UV_UDP_IPV6ONLY is supported only for IPV6 sockets */
@ -658,7 +658,6 @@ int uv_udp_set_broadcast(uv_udp_t* handle, int value) {
int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) {
WSAPROTOCOL_INFOW protocol_info;
int opt_len;
DWORD yes = 1;
/* Detect the address family of the socket. */
opt_len = (int) sizeof protocol_info;

View File

@ -579,47 +579,50 @@ uv_err_t uv_uptime(double* uptime) {
}
uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) {
uv_cpu_info_t* cpu_infos;
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* sppi;
DWORD sppi_size;
SYSTEM_INFO system_info;
DWORD cpu_count, i, r;
DWORD cpu_count, r, i;
NTSTATUS status;
ULONG result_size;
size_t size;
uv_err_t err;
uv_cpu_info_t* cpu_info;
*cpu_infos = NULL;
*count = 0;
cpu_infos = NULL;
cpu_count = 0;
sppi = NULL;
uv__once_init();
GetSystemInfo(&system_info);
cpu_count = system_info.dwNumberOfProcessors;
size = cpu_count * sizeof(uv_cpu_info_t);
*cpu_infos = (uv_cpu_info_t*) malloc(size);
if (*cpu_infos == NULL) {
cpu_infos = calloc(cpu_count, sizeof *cpu_infos);
if (cpu_infos == NULL) {
err = uv__new_artificial_error(UV_ENOMEM);
goto out;
}
memset(*cpu_infos, 0, size);
sppi_size = sizeof(*sppi) * cpu_count;
sppi = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*) malloc(sppi_size);
if (!sppi) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
goto error;
}
r = pNtQuerySystemInformation(SystemProcessorPerformanceInformation,
sppi,
sppi_size,
&result_size);
if (r != ERROR_SUCCESS || result_size != sppi_size) {
err = uv__new_sys_error(GetLastError());
goto out;
sppi_size = cpu_count * sizeof(*sppi);
sppi = malloc(sppi_size);
if (sppi == NULL) {
err = uv__new_artificial_error(UV_ENOMEM);
goto error;
}
status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation,
sppi,
sppi_size,
&result_size);
if (!NT_SUCCESS(status)) {
err = uv__new_sys_error(pRtlNtStatusToDosError(status));
goto error;
}
assert(result_size == sppi_size);
for (i = 0; i < cpu_count; i++) {
WCHAR key_name[128];
HKEY processor_key;
@ -627,11 +630,14 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
DWORD cpu_speed_size = sizeof(cpu_speed);
WCHAR cpu_brand[256];
DWORD cpu_brand_size = sizeof(cpu_brand);
int len;
_snwprintf(key_name,
ARRAY_SIZE(key_name),
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d",
i);
len = _snwprintf(key_name,
ARRAY_SIZE(key_name),
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d",
i);
assert(len > 0 && len < ARRAY_SIZE(key_name));
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
key_name,
@ -640,32 +646,34 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
&processor_key);
if (r != ERROR_SUCCESS) {
err = uv__new_sys_error(GetLastError());
goto out;
goto error;
}
if (RegQueryValueExW(processor_key,
L"~MHz",
NULL, NULL,
NULL,
NULL,
(BYTE*) &cpu_speed,
&cpu_speed_size) != ERROR_SUCCESS) {
err = uv__new_sys_error(GetLastError());
RegCloseKey(processor_key);
goto out;
goto error;
}
if (RegQueryValueExW(processor_key,
L"ProcessorNameString",
NULL, NULL,
NULL,
NULL,
(BYTE*) &cpu_brand,
&cpu_brand_size) != ERROR_SUCCESS) {
err = uv__new_sys_error(GetLastError());
RegCloseKey(processor_key);
goto out;
goto error;
}
RegCloseKey(processor_key);
cpu_info = &(*cpu_infos)[i];
cpu_info = &cpu_infos[i];
cpu_info->speed = cpu_speed;
cpu_info->cpu_times.user = sppi[i].UserTime.QuadPart / 10000;
cpu_info->cpu_times.sys = (sppi[i].KernelTime.QuadPart -
@ -674,57 +682,59 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
cpu_info->cpu_times.irq = sppi[i].InterruptTime.QuadPart / 10000;
cpu_info->cpu_times.nice = 0;
size = uv_utf16_to_utf8(cpu_brand,
cpu_brand_size / sizeof(WCHAR),
NULL,
0);
if (size == 0) {
len = WideCharToMultiByte(CP_UTF8,
0,
cpu_brand,
cpu_brand_size / sizeof(WCHAR),
NULL,
0,
NULL,
NULL);
if (len == 0) {
err = uv__new_sys_error(GetLastError());
goto out;
goto error;
}
assert(len > 0);
/* Allocate 1 extra byte for the null terminator. */
cpu_info->model = (char*) malloc(size + 1);
cpu_info->model = malloc(len + 1);
if (cpu_info->model == NULL) {
err = uv__new_artificial_error(UV_ENOMEM);
goto out;
goto error;
}
if (uv_utf16_to_utf8(cpu_brand,
cpu_brand_size / sizeof(WCHAR),
cpu_info->model,
size) == 0) {
if (WideCharToMultiByte(CP_UTF8,
0,
cpu_brand,
cpu_brand_size / sizeof(WCHAR),
cpu_info->model,
len,
NULL,
NULL) == 0) {
err = uv__new_sys_error(GetLastError());
goto out;
goto error;
}
/* Ensure that cpu_info->model is null terminated. */
cpu_info->model[size] = '\0';
(*count)++;
cpu_info->model[len] = '\0';
}
err = uv_ok_;
free(sppi);
out:
if (sppi) {
free(sppi);
}
*cpu_count_ptr = cpu_count;
*cpu_infos_ptr = cpu_infos;
if (err.code != UV_OK &&
*cpu_infos != NULL) {
int i;
return uv_ok_;
for (i = 0; i < *count; i++) {
/* This is safe because the cpu_infos memory area is zeroed out */
/* immediately after allocating it. */
free((*cpu_infos)[i].model);
}
free(*cpu_infos);
error:
/* This is safe because the cpu_infos array is zeroed on allocation. */
for (i = 0; i < cpu_count; i++)
free(cpu_infos[i].model);
*cpu_infos = NULL;
*count = 0;
}
free(cpu_infos);
free(sppi);
return err;
}

View File

@ -79,12 +79,6 @@ static int error_means_no_support(DWORD error) {
void uv_winsock_init() {
const GUID wsaid_connectex = WSAID_CONNECTEX;
const GUID wsaid_acceptex = WSAID_ACCEPTEX;
const GUID wsaid_getacceptexsockaddrs = WSAID_GETACCEPTEXSOCKADDRS;
const GUID wsaid_disconnectex = WSAID_DISCONNECTEX;
const GUID wsaid_transmitfile = WSAID_TRANSMITFILE;
WSADATA wsa_data;
int errorno;
SOCKET dummy;

View File

@ -41,6 +41,14 @@ shift
goto next-arg
:args-done
@rem Look for Visual Studio 2012
if not defined VS110COMNTOOLS goto vc-set-2010
if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010
call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
set GYP_MSVS_VERSION=2012
goto select-target
:vc-set-2010
@rem Look for Visual Studio 2010
if not defined VS100COMNTOOLS goto vc-set-2008
if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008