From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
To: Arnaud Charlet <charlet@adacore.com>
Cc: Olivier Hainque <hainque@adacore.com>,
Iain Sandoe <idsandoe@googlemail.com>,
Pierre-Marie de Rodat <derodat@adacore.com>,
gcc-patches@gcc.gnu.org
Subject: Re: [Ada] Fix 32/64bit mistake on SYSTEM_INFO component in s-win32
Date: Mon, 23 Sep 2019 10:12:00 -0000 [thread overview]
Message-ID: <ydd8sqfmid5.fsf@CeBiTec.Uni-Bielefeld.DE> (raw)
In-Reply-To: <20190920141229.GA22024@adacore.com> (Arnaud Charlet's message of "Fri, 20 Sep 2019 16:12:29 +0200")
[-- Attachment #1: Type: text/plain, Size: 1294 bytes --]
Hi Arnaud,
>> I'd keep the target list alphabetical. Can do so when the Solaris patch
>> goes in.
>>
>> Here's what I've successfully tested last night on both
>> i386-pc-solaris2.11 and sparc-sun-solaris2.11, shamelessly stolen from
>> the Linux counterparts. If it is acceptable, I'd add *-*-solaris2.* to
>> the target list when merging.
>
> The change is OK.
>
>> 2019-09-19 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
>>
>> * 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.
Thanks. Here's what I've installed.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2019-09-19 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
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.*.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-libgnat-n_o_p.patch --]
[-- Type: text/x-patch, Size: 2414 bytes --]
# HG changeset patch
# Parent 0d13bfaa0b34084a84b2b12d906b7252383366d4
Provide Task_Info.Number_Of_Processors on Solaris
diff --git a/gcc/ada/libgnarl/s-osinte__solaris.ads b/gcc/ada/libgnarl/s-osinte__solaris.ads
--- 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
--- 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
--- 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/gnat.dg/system_info1.adb b/gcc/testsuite/gnat.dg/system_info1.adb
--- 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;
next prev parent reply other threads:[~2019-09-23 10:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-18 8:40 Pierre-Marie de Rodat
2019-09-19 14:41 ` Iain Sandoe
2019-09-19 14:56 ` Rainer Orth
2019-09-19 15:02 ` Iain Sandoe
2019-09-19 16:40 ` Olivier Hainque
2019-09-20 12:21 ` Olivier Hainque
2019-09-20 13:02 ` Rainer Orth
2019-09-20 14:12 ` Arnaud Charlet
2019-09-23 10:12 ` Rainer Orth [this message]
2019-09-20 12:57 ` Rainer Orth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ydd8sqfmid5.fsf@CeBiTec.Uni-Bielefeld.DE \
--to=ro@cebitec.uni-bielefeld.de \
--cc=charlet@adacore.com \
--cc=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hainque@adacore.com \
--cc=idsandoe@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).