deps: upgrade libuv to 7e59f9b
This commit is contained in:
parent
4b20f3440d
commit
7707acd6ef
31
deps/uv/src/unix/linux-core.c
vendored
31
deps/uv/src/unix/linux-core.c
vendored
@ -57,9 +57,9 @@
|
|||||||
# define CLOCK_BOOTTIME 7
|
# define CLOCK_BOOTTIME 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void read_models(unsigned int numcpus, uv_cpu_info_t* ci);
|
static int read_models(unsigned int numcpus, uv_cpu_info_t* ci);
|
||||||
|
static int read_times(unsigned int numcpus, uv_cpu_info_t* ci);
|
||||||
static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci);
|
static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci);
|
||||||
static void read_times(unsigned int numcpus, uv_cpu_info_t* ci);
|
|
||||||
static unsigned long read_cpufreq(unsigned int cpunum);
|
static unsigned long read_cpufreq(unsigned int cpunum);
|
||||||
|
|
||||||
|
|
||||||
@ -420,10 +420,19 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
|
|||||||
if (ci == NULL)
|
if (ci == NULL)
|
||||||
return uv__new_sys_error(ENOMEM);
|
return uv__new_sys_error(ENOMEM);
|
||||||
|
|
||||||
read_models(numcpus, ci);
|
if (read_models(numcpus, ci)) {
|
||||||
read_times(numcpus, ci);
|
SAVE_ERRNO(free(ci));
|
||||||
|
return uv__new_sys_error(errno);
|
||||||
|
}
|
||||||
|
|
||||||
/* read_models() on x86 also reads the CPU speed from /proc/cpuinfo */
|
if (read_times(numcpus, ci)) {
|
||||||
|
SAVE_ERRNO(free(ci));
|
||||||
|
return uv__new_sys_error(errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read_models() on x86 also reads the CPU speed from /proc/cpuinfo.
|
||||||
|
* We don't check for errors here. Worst case, the field is left zero.
|
||||||
|
*/
|
||||||
if (ci[0].speed == 0)
|
if (ci[0].speed == 0)
|
||||||
read_speeds(numcpus, ci);
|
read_speeds(numcpus, ci);
|
||||||
|
|
||||||
@ -445,7 +454,7 @@ static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci) {
|
|||||||
/* Also reads the CPU frequency on x86. The other architectures only have
|
/* Also reads the CPU frequency on x86. The other architectures only have
|
||||||
* a BogoMIPS field, which may not be very accurate.
|
* a BogoMIPS field, which may not be very accurate.
|
||||||
*/
|
*/
|
||||||
static void read_models(unsigned int numcpus, uv_cpu_info_t* ci) {
|
static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) {
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
static const char model_marker[] = "model name\t: ";
|
static const char model_marker[] = "model name\t: ";
|
||||||
static const char speed_marker[] = "cpu MHz\t\t: ";
|
static const char speed_marker[] = "cpu MHz\t\t: ";
|
||||||
@ -470,7 +479,7 @@ static void read_models(unsigned int numcpus, uv_cpu_info_t* ci) {
|
|||||||
|
|
||||||
fp = fopen("/proc/cpuinfo", "r");
|
fp = fopen("/proc/cpuinfo", "r");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return;
|
return -1;
|
||||||
|
|
||||||
model_idx = 0;
|
model_idx = 0;
|
||||||
speed_idx = 0;
|
speed_idx = 0;
|
||||||
@ -515,10 +524,12 @@ static void read_models(unsigned int numcpus, uv_cpu_info_t* ci) {
|
|||||||
ci[model_idx].model = strndup(inferred_model, strlen(inferred_model));
|
ci[model_idx].model = strndup(inferred_model, strlen(inferred_model));
|
||||||
model_idx++;
|
model_idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void read_times(unsigned int numcpus, uv_cpu_info_t* ci) {
|
static int read_times(unsigned int numcpus, uv_cpu_info_t* ci) {
|
||||||
unsigned long clock_ticks;
|
unsigned long clock_ticks;
|
||||||
struct uv_cpu_times_s ts;
|
struct uv_cpu_times_s ts;
|
||||||
unsigned long user;
|
unsigned long user;
|
||||||
@ -538,7 +549,7 @@ static void read_times(unsigned int numcpus, uv_cpu_info_t* ci) {
|
|||||||
|
|
||||||
fp = fopen("/proc/stat", "r");
|
fp = fopen("/proc/stat", "r");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return;
|
return -1;
|
||||||
|
|
||||||
if (!fgets(buf, sizeof(buf), fp))
|
if (!fgets(buf, sizeof(buf), fp))
|
||||||
abort();
|
abort();
|
||||||
@ -583,6 +594,8 @@ static void read_times(unsigned int numcpus, uv_cpu_info_t* ci) {
|
|||||||
ci[num++].cpu_times = ts;
|
ci[num++].cpu_times = ts;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user