From: Rainer Orth Date: Mon, 23 Sep 2019 09:13:21 +0000 (+0000) Subject: Provide Task_Info.Number_Of_Processors on Solaris X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e25427723608118c1441aac4c4808e2360eb0b6c;p=gcc.git Provide Task_Info.Number_Of_Processors on Solaris gcc/ada: * libgnarl/s-osinte__solaris.ads (sysconf): Declare. (SC_NPROCESSORS_ONLN): Define. * libgnarl/s-tasinf__solaris.ads (Number_Of_Processors): Declare. * libgnarl/s-tasinf__solaris.adb (N_CPU): New variable. (Number_Of_Processors): New function. gcc/testsuite: * gnat.dg/system_info1.adb: Sort dg-do target list. Add *-*-solaris2.*. From-SVN: r276049 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c0bc883c20a..08244e89afb 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2019-09-23 Rainer Orth + + * libgnarl/s-osinte__solaris.ads (sysconf): Declare. + (SC_NPROCESSORS_ONLN): Define. + * libgnarl/s-tasinf__solaris.ads (Number_Of_Processors): Declare. + * libgnarl/s-tasinf__solaris.adb (N_CPU): New variable. + (Number_Of_Processors): New function. + 2019-09-23 Eric Botcazou * gcc-interface/trans.c (Regular_Loop_to_gnu): Do not rotate the loop diff --git a/gcc/ada/libgnarl/s-osinte__solaris.ads b/gcc/ada/libgnarl/s-osinte__solaris.ads index 25432255df7..be242baaf58 100644 --- a/gcc/ada/libgnarl/s-osinte__solaris.ads +++ b/gcc/ada/libgnarl/s-osinte__solaris.ads @@ -259,6 +259,11 @@ package System.OS_Interface is function To_Timespec (D : Duration) return timespec; pragma Inline (To_Timespec); + function sysconf (name : int) return long; + pragma Import (C, sysconf); + + SC_NPROCESSORS_ONLN : constant := 15; + ------------- -- Process -- ------------- diff --git a/gcc/ada/libgnarl/s-tasinf__solaris.adb b/gcc/ada/libgnarl/s-tasinf__solaris.adb index 9744d010d35..44a91159531 100644 --- a/gcc/ada/libgnarl/s-tasinf__solaris.adb +++ b/gcc/ada/libgnarl/s-tasinf__solaris.adb @@ -84,4 +84,23 @@ package body System.Task_Info is return (False, False); end Unbound_Thread_Attributes; + N_CPU : Natural := 0; + pragma Atomic (N_CPU); + -- Cache CPU number. Use pragma Atomic to avoid a race condition when + -- setting N_CPU in Number_Of_Processors below. + + -------------------------- + -- Number_Of_Processors -- + -------------------------- + + function Number_Of_Processors return Positive is + begin + if N_CPU = 0 then + N_CPU := Natural + (OS_Interface.sysconf (OS_Interface.SC_NPROCESSORS_ONLN)); + end if; + + return N_CPU; + end Number_Of_Processors; + end System.Task_Info; diff --git a/gcc/ada/libgnarl/s-tasinf__solaris.ads b/gcc/ada/libgnarl/s-tasinf__solaris.ads index c3dc0f1e316..0d2cbfdca54 100644 --- a/gcc/ada/libgnarl/s-tasinf__solaris.ads +++ b/gcc/ada/libgnarl/s-tasinf__solaris.ads @@ -139,4 +139,7 @@ package System.Task_Info is Unspecified_Task_Info : constant Task_Info_Type := null; + function Number_Of_Processors return Positive; + -- Returns the number of processors on the running host + end System.Task_Info; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 02462fc5229..815aee0ad52 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-09-23 Rainer Orth + + * gnat.dg/system_info1.adb: Sort dg-do target list. + Add *-*-solaris2.*. + 2019-09-23 Eric Botcazou * gnat.dg/specs/compile_time1.ads: New test. diff --git a/gcc/testsuite/gnat.dg/system_info1.adb b/gcc/testsuite/gnat.dg/system_info1.adb index e299bc4481e..fedcc228f29 100644 --- a/gcc/testsuite/gnat.dg/system_info1.adb +++ b/gcc/testsuite/gnat.dg/system_info1.adb @@ -3,7 +3,7 @@ -- both 32bit and 64bit Windows. Additional configurations where the -- feature was verified to work can opt-in. --- { dg-do run { target *-*-mingw* *-*-linux* } } +-- { dg-do run { target *-*-linux* *-*-mingw* *-*-solaris2.* } } with System.Multiprocessors; with System.Task_Info;