summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac3
-rw-r--r--lib/common/writer/init.c14
2 files changed, 10 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index bc7db61..29e28c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -287,10 +287,9 @@ AS_IF([test "x$have_compressor" != "xyes"],
##### additional checks #####
AC_CHECK_HEADERS([sys/xattr.h], [], [])
-AC_CHECK_HEADERS([sys/sysinfo.h], [], [])
AC_CHECK_HEADERS([alloca.h], [], [])
-AC_CHECK_FUNCS([strndup getopt getopt_long getsubopt fnmatch strchrnul])
+AC_CHECK_FUNCS([strndup getopt getopt_long getsubopt fnmatch strchrnul sched_getaffinity])
##### generate output #####
diff --git a/lib/common/writer/init.c b/lib/common/writer/init.c
index 06726ce..7940c3f 100644
--- a/lib/common/writer/init.c
+++ b/lib/common/writer/init.c
@@ -10,16 +10,20 @@
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
-#ifdef HAVE_SYS_SYSINFO_H
-#include <sys/sysinfo.h>
+#ifdef HAVE_SCHED_GETAFFINITY
+#include <sched.h>
static size_t os_get_num_jobs(void)
{
- int nprocs;
+ cpu_set_t cpu_set;
+ CPU_ZERO(&cpu_set);
- nprocs = get_nprocs_conf();
- return nprocs < 1 ? 1 : nprocs;
+ if (sched_getaffinity(0, sizeof cpu_set, &cpu_set) == -1)
+ return 1;
+ else
+ return CPU_COUNT(&cpu_set);
}
#else
static size_t os_get_num_jobs(void)