From 865aa4ebdd71d39f8e8ae59b40d993edb4a62708 Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Thu, 7 May 2015 20:28:11 +0200 Subject: Restore build on non Linux systems This change broke the build on NetBSD, FreeBSD, and MacOS X: http://review.gluster.org/10526/ We restore the build with two fixes: - Use POSIX-compliant sysconf(_SC_NPROCESSORS_ONLN) to get the number of processors, instead of Linux specific get_nprocs(). That let us remove Linux-specific #include - Only define MAX() if it is not already defined. NetBSD defines it in which is already included BUG: 1129939 Change-Id: I62341c670598670e47ea2f69ab94864f96588b18 Signed-off-by: Emmanuel Dreyfus Reviewed-on: http://review.gluster.org/10652 Reviewed-by: Kaleb KEITHLEY Tested-by: Vijay Bellur --- xlators/cluster/dht/src/dht-shared.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'xlators/cluster/dht/src/dht-shared.c') diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c index 0ab81c37890..04e96127ec6 100644 --- a/xlators/cluster/dht/src/dht-shared.c +++ b/xlators/cluster/dht/src/dht-shared.c @@ -15,12 +15,13 @@ #endif /* TODO: add NS locking */ -#include #include "statedump.h" #include "dht-common.h" #include "dht-messages.h" +#ifndef MAX #define MAX(a, b) (((a) > (b))?(a):(b)) +#endif #define GF_DECIDE_DEFRAG_THROTTLE_COUNT(throttle_count, conf) { \ \ @@ -29,7 +30,8 @@ if (!strcasecmp (conf->dthrottle, "lazy")) \ conf->defrag->recon_thread_count = 1; \ \ - throttle_count = MAX ((get_nprocs() - 4), 4); \ + throttle_count = \ + MAX ((sysconf(_SC_NPROCESSORS_ONLN) - 4), 4); \ \ if (!strcasecmp (conf->dthrottle, "normal")) \ conf->defrag->recon_thread_count = \ -- cgit