btreplay: use sysconf to get the number of configured cpus
[blktrace.git] / btreplay / btreplay.c
index 6f0ba634024d9f75b54bde8b54e44234a1174a63..fe6cd80050c76368717bf196cc8f46ea5b9182e5 100644 (file)
@@ -502,6 +502,9 @@ static inline void start_iter(void)
  */
 static void get_ncpus(void)
 {
+#ifdef _SC_NPROCESSORS_CONF
+       ncpus = sysconf(_SC_NPROCESSORS_CONF);
+#else
        long last_cpu;
        cpu_set_t cpus;
 
@@ -515,6 +518,7 @@ static void get_ncpus(void)
                if (CPU_ISSET( last_cpu, &cpus) ) 
                        ncpus = last_cpu;
        ncpus++;
+#endif
        if (ncpus == 0) {
                fatal(NULL, ERR_SYSCALL, "Insufficient number of CPUs\n");
                /*NOTREACHED*/