https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87892
--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> --- Hints from Jakub: <jakub> marxin: just look at libgomp sources, I have all kinds of stuff there <marxin> jakub: ok, then let me fix that <jakub> marxin: sysconf(_SC_NPROCESSORS_ONLN) is a good fallback if the affinity doesn't work <jakub> note even the version they wrote is of course incorrect <jakub> it will not work on machines where the cpuset is very large <marxin> jakub: due to buffer(4096); ? <jakub> marxin: cpu_set_t is fixed size <jakub> marxin: newer glibcs provide APIs where one specifies the size <marxin> jakub: ok <jakub> marxin: if they don't want to use sysconf because it allocates memory, then can read /proc/cpuinfo themselves <marxin> jakub: they read /sys/devices/system/cpu instead <jakub> marxin: they do that on android only; /sys is newer than /proc though <jakub> marxin: in any case, CPU_COUNT, if missing, can be easily written using __builtin_popcountl in a loop, see libgomp/config/linux/proc.c (gomp_cpuset_popcount) <jakub> but that assumption that sched_getaffinity will succeed is bogus, it might fail because it isn't implemented, or may fail because the cpu_set_t is too small <jakub> marxin: then you can of course allocate using their allocators something bigger and retry <jakub> marxin: see also gomp_init_num_threads in the same file; while you might avoid the sysconf if they don't want to call it at start, start with cpu_set_t size <marxin> thanks for hints <jakub> just note that libgomp is GPL and libsanitizer is not, so copy'n'paste is not allowed