From: Maciej W. Rozycki Date: Fri, 20 Nov 2020 21:11:22 +0000 (+0000) Subject: libada: Check for the presence of _SC_NPROCESSORS_ONLN X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9e071b6e5ed5a07a4ce621382904c084431f9d47;p=gcc.git libada: Check for the presence of _SC_NPROCESSORS_ONLN Check for the presence of _SC_NPROCESSORS_ONLN rather than using a list of OS-specific macros to decide whether to use `sysconf' like elsewhere across GCC sources, fixing a compilation error: adaint.c: In function '__gnat_number_of_cpus': adaint.c:2398:26: error: '_SC_NPROCESSORS_ONLN' undeclared (first use in this function) 2398 | cores = (int) sysconf (_SC_NPROCESSORS_ONLN); | ^~~~~~~~~~~~~~~~~~~~ adaint.c:2398:26: note: each undeclared identifier is reported only once for each function it appears in at least with with VAX/NetBSD 1.6.2. gcc/ada/ * adaint.c (__gnat_number_of_cpus): Check for the presence of _SC_NPROCESSORS_ONLN rather than a list of OS-specific macros to decide whether to use `sysconf'. --- diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index f5432626ee6..554123c905b 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -2483,9 +2483,7 @@ __gnat_number_of_cpus (void) { int cores = 1; -#if defined (__linux__) || defined (__sun__) || defined (_AIX) \ - || defined (__APPLE__) || defined (__FreeBSD__) || defined (__OpenBSD__) \ - || defined (__DragonFly__) || defined (__NetBSD__) +#ifdef _SC_NPROCESSORS_ONLN cores = (int) sysconf (_SC_NPROCESSORS_ONLN); #elif defined (__QNX__)