comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@futureapps.invalid>
Subject: Re: Addressing in Object Ada v/s GNAT (2013) showing Vast Differences
Date: Thu, 10 Sep 2015 14:34:16 +0200
Date: 2015-09-10T14:34:16+02:00	[thread overview]
Message-ID: <msrt8o$fdm$1@dont-email.me> (raw)
In-Reply-To: <ca55984c-17ca-4295-a43d-46300bf255e4@googlegroups.com>

On 10.09.15 12:47, Lucas Redding wrote:
> I need to change the alignment of each underlying type mapped into memory. I am hoping the combination of explicit alignments and precise rep clauses (size etc.) should make the code portable between compilers.

You are certainly aware of mappings that can be effected
by just using a type conversion? This way, some of the less
portable representations can be stashed away.

package P is

    type T1 is range 1 .. 10;
    type T2 is range -1_000 .. +1_000;

    type Internal is record
       A : T1;
       B : T2;
    end record;

    type Mapped is new Internal;

    for Mapped'Size use 32;
    for Mapped'Alignment use 1;
    for Mapped use record
       A at 0 range 0 .. 7;
       B at 0 range 11 .. 30;
    end record;

end P;

with P;
procedure Test_P is
    Z : P.Mapped;
    pragma Volatile (Z);

    procedure Place (Value : P.Internal) is
    begin
       Z := P.Mapped (Value);
       pragma Inspection_Point (Z);
    end Place;

begin
    Place( P.Internal'(A => 3, B => 42) );
end Test_P;


  reply	other threads:[~2015-09-10 12:34 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-07 11:39 Addressing in Object Ada v/s GNAT (2013) showing Vast Differences Lucas Redding
2015-09-07 11:54 ` Lucas Redding
2015-09-07 14:04   ` G.B.
2015-09-07 16:02     ` Lucas Redding
2015-09-07 16:28       ` Anh Vo
2015-09-08  7:30         ` Lucas Redding
2015-09-08 15:11           ` Anh Vo
2015-09-08 17:20           ` Jeffrey R. Carter
2015-09-07 17:20   ` Pascal Obry
2015-09-07 17:21   ` Pascal Obry
2015-09-08  7:04     ` Lucas Redding
2015-09-07 21:02   ` Niklas Holsti
2015-09-08  8:00     ` Lucas Redding
2015-09-07 15:48 ` Jeffrey R. Carter
2015-09-08  7:27   ` Lucas Redding
2015-09-08  7:12 ` Markus Schöpflin
2015-09-08  8:05   ` Lucas Redding
2015-09-10 10:47 ` Lucas Redding
2015-09-10 12:34   ` G.B. [this message]
2015-09-21 11:12     ` Lucas Redding
2015-09-21 11:57       ` Jacob Sparre Andersen
2015-09-21 13:22         ` Lucas Redding
2015-09-21 13:47           ` Jacob Sparre Andersen
2015-09-21 13:52           ` Georg Bauhaus
2015-09-21 15:54             ` Lucas Redding
2015-09-22 17:49               ` Jacob Sparre Andersen
2015-09-22 18:45               ` Jacob Sparre Andersen
2015-10-01  6:50                 ` Lucas Redding
2015-09-21 16:48       ` Dmitry A. Kazakov
2015-10-01  7:25         ` Lucas Redding
2015-10-01 20:04           ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox