]> granicus.if.org Git - xz/commit
tuklib_cpucores: Add support for sched_getaffinity().
authorLasse Collin <lasse.collin@tukaani.org>
Mon, 24 Oct 2016 15:51:36 +0000 (18:51 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Mon, 24 Oct 2016 15:51:36 +0000 (18:51 +0300)
commitdf8f446e3ad47e5148b8c8d8b6e519d3ce29cb9d
treeaf7d6b7d6aa3f05f83375de0ca79142ce8a50b99
parent446e4318fa79788e09299d5953b5dd428953d14b
tuklib_cpucores: Add support for sched_getaffinity().

It's available in glibc (GNU/Linux, GNU/kFreeBSD). It's better
than sysconf(_SC_NPROCESSORS_ONLN) because sched_getaffinity()
gives the number of cores available to the process instead of
the total number of cores online.

As a side effect, this commit fixes a bug on GNU/kFreeBSD where
configure would detect the FreeBSD-specific cpuset_getaffinity()
but it wouldn't actually work because on GNU/kFreeBSD it requires
using -lfreebsd-glue when linking. Now the glibc-specific function
will be used instead.

Thanks to Sebastian Andrzej Siewior for the original patch
and testing.
m4/tuklib_cpucores.m4
src/common/tuklib_cpucores.c