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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.182.162 with SMTP id ef2mr17736799pac.35.1442850840338; Mon, 21 Sep 2015 08:54:00 -0700 (PDT) X-Received: by 10.182.52.132 with SMTP id t4mr85741obo.25.1442850840298; Mon, 21 Sep 2015 08:54:00 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!kq10no7069067igb.0!news-out.google.com!n2ni7658igy.0!nntp.google.com!kq10no7069058igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 21 Sep 2015 08:54:00 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=194.138.39.55; posting-account=IcHmbgoAAABVfpbjrkJyy4Yb3hmce3tn NNTP-Posting-Host: 194.138.39.55 References: <26b4bb33-0ebc-4181-bea6-07f1e36ca288@googlegroups.com> <871tds56jw.fsf@adaheads.sparre-andersen.dk> <2c064071-2e40-4267-81f6-3196d7ae35ab@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <324198e3-3117-48fa-a3d3-aabf54567944@googlegroups.com> Subject: Re: Addressing in Object Ada v/s GNAT (2013) showing Vast Differences From: Lucas Redding Injection-Date: Mon, 21 Sep 2015 15:54:00 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:27804 Date: 2015-09-21T08:54:00-07:00 List-Id: On Monday, September 21, 2015 at 2:52:10 PM UTC+1, Georg Bauhaus wrote: > On 21.09.15 15:22, Lucas Redding wrote: > > On Monday, September 21, 2015 at 12:57:09 PM UTC+1, Jacob Sparre Andersen wrote: > >> Lucas Redding wrote: > >> > >> Your examples don't compile. Please show us the actual code. > >> > >> Greetings, > >> > >> Jacob > >> -- > >> "Very small. Go to sleep" - monster (not drooling) > > > > Hi Jacob > > > > thanks for that. I am avoiding having to flood this with tons of code. So here is a compiled example. > > > > package interface_p > > is > (...) > > end INTERFACE_P ; > > > > Is this happening only when you read from the shared location? > I see the output > local a: 1, local b: 2 > from the following program, compiled using GNAT GPL 2014 on a Mac: > > With Ada.Text_IO; > with INTERFACE_P; use INTERFACE_P; > procedure Test_Interface_P > is > It : local_rec; > begin > It := READ_RECORD; > > declare > use Ada; > package Xintio is new Text_IO.Integer_IO (sixteen_bits); > begin > Text_Io.Put ("local a:"); Xintio.Put (It.a); > Text_Io.Put (", local b:"); Xintio.Put (It.b); > Text_Io.New_Line; > end; > > end Test_Interface_P; Totally agree. Both you and Jacob are correct. There must be something subtle in my definitions that I am missing. Note the new code below which reflects the real code except the array of bytes is much larger. I hall keep digging and report back. Thank you very much. with SYSTEM ; package mapping is type thirty_two_bits is range 0..(2**31)-1; for thirty_two_bits'size use 32 ; for thirty_two_bits'Alignment use 1 ; type byte_t is range 0..255 ; for byte_t'size use 8 ; for byte_t'alignment use 1 ; type byte_stream is array (0..3) of byte_t ; for byte_stream'Component_Size use 8 ; for byte_stream'Alignment use 1; MAPPED_ARRAY : byte_stream := ( 16#01#, 16#80#,16#0#, 16#0# ) ; MAPPED_ITEM : thirty_two_bits ; for MAPPED_ITEM use at MAPPED_ARRAY'Address ; MAPPED_ITEM_ADDRESS : System.Address := MAPPED_ITEM'Address ; end mapping ; with mapping ; package interface_p is type thirty_two_bits is range 0..(2**31)-1; for thirty_two_bits'size use 32 ; for thirty_two_bits'Alignment use 1 ; type sixteen_bits is range 0..(2**16)-1 ; type fourteen_bits is range 0..(2**14)-1; type ten_bits is range 0..(2**10)-1; type padding_bits is range 0..(2**8)-1 ; type rec is record a: fourteen_bits ; b: ten_bits ; padding : padding_bits ; end record ; for rec use record a at 0 range 0..13 ; b at 0 range 14..23 ; padding at 0 range 24..31; end record ; for rec'size use 32; for rec'alignment use 1; subtype local_fourteen_bits is sixteen_bits range 0 .. (2 ** 14)-1; subtype local_ten_bits is sixteen_bits range 0 .. (2 ** 10)-1; type local_rec is record a : local_fourteen_bits ; b : local_ten_bits ; end record; for local_rec use record a at 0 range 0 .. 13 ; b at 2 range 0 .. 9 ; end record; for local_rec'size use 32 ; for local_rec'Alignment use 1 ; MAPPED_ITEM : thirty_two_bits ; for MAPPED_ITEM'Address use mapping.MAPPED_ITEM_ADDRESS ; VAR_REC : rec ; for VAR_REC use at MAPPED_ITEM'Address ; -- I explicitly assign here but in actual application it maps onto a 32 bit -- record in memory. I have deliberately changed in order to avoid adding -- tons of irrelevant code. function READ_RECORD return local_rec ; end interface_p ; In the system, the mapping is to an array of bytes populated in memory and then mapped.