X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=contrib%2Fbin%2Fmemaslap%2Fms_setting.c;h=7cbdb53d30261a931315facef9e97ae5136ed0a8;hb=01c5e0ed8d3d9c72ea192792d1c49a50e756d635;hp=38a5cbbcb62697e25a3f76c491f577c8ee281dcb;hpb=808f81dba2553a1e552e8f3cea3ee376ad7d3558;p=awesomized%2Flibmemcached diff --git a/contrib/bin/memaslap/ms_setting.c b/contrib/bin/memaslap/ms_setting.c index 38a5cbbc..7cbdb53d 100644 --- a/contrib/bin/memaslap/ms_setting.c +++ b/contrib/bin/memaslap/ms_setting.c @@ -183,32 +183,28 @@ static void ms_get_serverlist(char *str) { /** * used to get the CPU count of the current system * - * @return return the cpu count if get, else return EXIT_FAILURE + * @return return the cpu count if possible, else return 1 */ static uint32_t ms_get_cpu_count() { -#ifdef HAVE__SC_NPROCESSORS_ONLN - return sysconf(_SC_NPROCESSORS_CONF); - -#else -# ifdef HAVE_CPU_SET_T - int cpu_count = 0; +#ifdef HAVE_CPU_SET_T + unsigned cpu_count = 0; cpu_set_t cpu_set; sched_getaffinity(0, sizeof(cpu_set_t), &cpu_set); - for (int i = 0; i < (sizeof(cpu_set_t) * 8); i++) { + for (unsigned i = 0; i < (sizeof(cpu_set_t) * 8); i++) { if (CPU_ISSET(i, &cpu_set)) { cpu_count++; } } return cpu_count; - -# endif +#elif defined HAVE__SC_NPROCESSORS_ONLN + return sysconf(_SC_NPROCESSORS_CONF); #endif /* the system with one cpu at least */ - return EXIT_FAILURE; + return 1; } /* ms_get_cpu_count */ /**