tuklib_cpucores: Silence warnings from -Wsign-conversion.

This commit is contained in:
Lasse Collin 2019-06-23 22:27:45 +03:00
parent a502dd1d00
commit 7c65ae0f5f
1 changed files with 5 additions and 5 deletions

View File

@ -56,14 +56,14 @@ tuklib_cpucores(void)
#elif defined(TUKLIB_CPUCORES_SCHED_GETAFFINITY) #elif defined(TUKLIB_CPUCORES_SCHED_GETAFFINITY)
cpu_set_t cpu_mask; cpu_set_t cpu_mask;
if (sched_getaffinity(0, sizeof(cpu_mask), &cpu_mask) == 0) if (sched_getaffinity(0, sizeof(cpu_mask), &cpu_mask) == 0)
ret = CPU_COUNT(&cpu_mask); ret = (uint32_t)CPU_COUNT(&cpu_mask);
#elif defined(TUKLIB_CPUCORES_CPUSET) #elif defined(TUKLIB_CPUCORES_CPUSET)
cpuset_t set; cpuset_t set;
if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
sizeof(set), &set) == 0) { sizeof(set), &set) == 0) {
# ifdef CPU_COUNT # ifdef CPU_COUNT
ret = CPU_COUNT(&set); ret = (uint32_t)CPU_COUNT(&set);
# else # else
for (unsigned i = 0; i < CPU_SETSIZE; ++i) for (unsigned i = 0; i < CPU_SETSIZE; ++i)
if (CPU_ISSET(i, &set)) if (CPU_ISSET(i, &set))
@ -77,7 +77,7 @@ tuklib_cpucores(void)
size_t cpus_size = sizeof(cpus); size_t cpus_size = sizeof(cpus);
if (sysctl(name, 2, &cpus, &cpus_size, NULL, 0) != -1 if (sysctl(name, 2, &cpus, &cpus_size, NULL, 0) != -1
&& cpus_size == sizeof(cpus) && cpus > 0) && cpus_size == sizeof(cpus) && cpus > 0)
ret = cpus; ret = (uint32_t)cpus;
#elif defined(TUKLIB_CPUCORES_SYSCONF) #elif defined(TUKLIB_CPUCORES_SYSCONF)
# ifdef _SC_NPROCESSORS_ONLN # ifdef _SC_NPROCESSORS_ONLN
@ -88,12 +88,12 @@ tuklib_cpucores(void)
const long cpus = sysconf(_SC_NPROC_ONLN); const long cpus = sysconf(_SC_NPROC_ONLN);
# endif # endif
if (cpus > 0) if (cpus > 0)
ret = cpus; ret = (uint32_t)cpus;
#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC) #elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)
struct pst_dynamic pst; struct pst_dynamic pst;
if (pstat_getdynamic(&pst, sizeof(pst), 1, 0) != -1) if (pstat_getdynamic(&pst, sizeof(pst), 1, 0) != -1)
ret = pst.psd_proc_cnt; ret = (uint32_t)pst.psd_proc_cnt;
#endif #endif
return ret; return ret;