Merge pull request #21943 from vrabaud:3.4_proc
authorVincent Rabaud <vrabaud@users.noreply.github.com>
Thu, 5 May 2022 07:59:29 +0000 (09:59 +0200)
committerGitHub <noreply@github.com>
Thu, 5 May 2022 07:59:29 +0000 (07:59 +0000)
* Fix compilation with non glibc.

_SC_NPROCESSORS_ONLN is non standard as defined on https://man7.org/linux/man-pages/man3/sysconf.3.html
It seems to only be on glibc, cf https://www.gnu.org/software/libc/manual/html_node/Processor-Resources.html

* Fix to defined(_SC_NPROCESSORS_ONLN)

modules/core/src/parallel.cpp

index 95df545..a4a7baf 100644 (file)
@@ -942,7 +942,7 @@ int getNumberOfCPUs_()
 
 #endif
 
-#if !defined(_WIN32) && !defined(__APPLE__)
+#if !defined(_WIN32) && !defined(__APPLE__) && defined(_SC_NPROCESSORS_ONLN)
 
     static unsigned cpu_count_sysconf = (unsigned)sysconf( _SC_NPROCESSORS_ONLN );
     ncpus = minNonZero(ncpus, cpu_count_sysconf);