summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/freebsd.c
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-11-20 20:11:08 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2012-11-20 22:44:23 +0100
commit8ba1bec47d1a3f16db25af4efc29fab2ad2ffd3c (patch)
tree1cd4b46b764070cbf66ab4a7f5c616570c8cc81a /deps/uv/src/unix/freebsd.c
parent6f9ed28fac9db8ca34169059962118209826b28a (diff)
downloadandroid-node-v8-8ba1bec47d1a3f16db25af4efc29fab2ad2ffd3c.tar.gz
android-node-v8-8ba1bec47d1a3f16db25af4efc29fab2ad2ffd3c.tar.bz2
android-node-v8-8ba1bec47d1a3f16db25af4efc29fab2ad2ffd3c.zip
deps: upgrade libuv to fc5984f
Diffstat (limited to 'deps/uv/src/unix/freebsd.c')
-rw-r--r--deps/uv/src/unix/freebsd.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/deps/uv/src/unix/freebsd.c b/deps/uv/src/unix/freebsd.c
index 6619893b9b..4a32f6ee56 100644
--- a/deps/uv/src/unix/freebsd.c
+++ b/deps/uv/src/unix/freebsd.c
@@ -235,12 +235,26 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
multiplier = ((uint64_t)1000L / ticks), cpuspeed, maxcpus,
cur = 0;
uv_cpu_info_t* cpu_info;
+ const char* maxcpus_key;
+ const char* cptimes_key;
char model[512];
long* cp_times;
int numcpus;
size_t size;
int i;
+#if defined(__DragonFly__)
+ /* This is not quite correct but DragonFlyBSD doesn't seem to have anything
+ * comparable to kern.smp.maxcpus or kern.cp_times (kern.cp_time is a total,
+ * not per CPU). At least this stops uv_cpu_info() from failing completely.
+ */
+ maxcpus_key = "hw.ncpu";
+ cptimes_key = "kern.cp_time";
+#else
+ maxcpus_key = "kern.smp.maxcpus";
+ cptimes_key = "kern.cp_times";
+#endif
+
size = sizeof(model);
if (sysctlbyname("hw.model", &model, &size, NULL, 0) < 0) {
return uv__new_sys_error(errno);
@@ -262,19 +276,13 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
free(*cpu_infos);
return uv__new_sys_error(errno);
}
+
/* kern.cp_times on FreeBSD i386 gives an array up to maxcpus instead of ncpu */
size = sizeof(maxcpus);
-#ifdef __DragonFly__
- if (sysctlbyname("hw.ncpu", &maxcpus, &size, NULL, 0) < 0) {
+ if (sysctlbyname(maxcpus_key, &maxcpus, &size, NULL, 0) < 0) {
free(*cpu_infos);
return uv__new_sys_error(errno);
}
-#else
- if (sysctlbyname("kern.smp.maxcpus", &maxcpus, &size, NULL, 0) < 0) {
- free(*cpu_infos);
- return uv__new_sys_error(errno);
- }
-#endif
size = maxcpus * CPUSTATES * sizeof(long);
@@ -284,7 +292,7 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
return uv__new_sys_error(ENOMEM);
}
- if (sysctlbyname("kern.cp_times", cp_times, &size, NULL, 0) < 0) {
+ if (sysctlbyname(cptimes_key, cp_times, &size, NULL, 0) < 0) {
free(cp_times);
free(*cpu_infos);
return uv__new_sys_error(errno);