From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9f3d09bde7b33b5d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-13 03:28:28 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!adsl-213-200-246-247.cybernet.CH!not-for-mail From: Vinzent 'Gadget' Hoefler Newsgroups: comp.lang.ada Subject: Re: Pass by reference Date: Tue, 13 Apr 2004 12:26:57 +0200 Organization: JeLlyFish software Message-ID: <4hen70p62fq82m89cc52t6kutg44k757tf@jellix.jlfencey.com> References: <19b0e504.0404080652.4eab9f80@posting.google.com> <5QAdc.7896$Jf6.4030@newssvr23.news.prodigy.com> NNTP-Posting-Host: adsl-213-200-246-247.cybernet.ch (213.200.246.247) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de 1081852107 1414693 I 213.200.246.247 ([175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:7040 Date: 2004-04-13T12:26:57+02:00 List-Id: Simon Wright wrote: >Vinzent 'Gadget' Hoefler writes: > >> Pat Rogers wrote: >>=20 >> >If you made the type volatile that would also force by-reference. > >C.6(18): If a type is atomic or volatile and it is not a by-copy type, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Yes, but if I understand that part correctly, this is the point. The register-type is just a simple Integer-type: |package Registers is | | type Reg_8 is mod 2**8; | type Reg_8_Access is access Reg_8; | [...] | |private | | pragma Volatile (Reg_8); | [...] |end Registers; So although it is declared Volatile it is a by-copy type. Too bad. >> Are you sure? I'm just looking at the assembly ouput of GNAT for a >> procedure that takes a volatile type (memory mapped register) and it >> does't seem so. Even worse, it optimizes the sequence of assignment >> which I need for this register. If you have any idea how can I avoid >> using access types to make it right, I'd be glad to hear it. > >I think you need to use inline assembler to be sure. You must be kidding me, I'm just getting away from using assembler. :) The old system was a 16-bit-CPU programmed entirely in assembly language, now I am having MaRTE and Ada and you say, I should use inline assembler instead? ;-) Well, there is no general problem in here for me, but even with inline assembler the fact remains that the procedure would need the _address_ of the register, and *not* its contents. So using inline assembler wouldn't help in avoiding access types and if it doesn't, I won't need it, because in that case the compiler generated code is just fine. >And to be really sure you may need to use Volatile =3D> True on the >call, I had to (this was GNAT/PowerPC, by the way). I'm not sure if I understand... can I actually apply that pragma to a call? Or am I missing something else? Vinzent.