comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Packing Record Structures in Ada
Date: 1998/01/13
Date: 1998-01-13T00:00:00+00:00	[thread overview]
Message-ID: <dewar.884732893@merv> (raw)
In-Reply-To: m267no4ccx.fsf@wf-rch.cirr.com


Corey asks

<<From my reading of the ARM, it is not extremely clear to me that
streaming between different compilers is 100% compatible.  It may be
(I haven't read the AARM and I'm no language expert) and I would
expect it would be in general (assuming endian-ness conversion is
done, of course).

I have done tests of streaming vs direct layout and copying using
GNAT.  Streaming is rather slow, on the order of 20 times slower than
direct copying.  I would expect this is due to a polymorphic call on
every data item (every array element, etc.), so I wouldn't expect any
other compilers to be any better.  With a representation clause,
layouts are guaranteed except for endianness, and you can directly
copy the data structure.

If you were able to do a "for T'Bit_Order use ..." would that solve
the endianness problem?  I realize that compilers do not have to allow
this, but if they did...
>>

No, of course there is no requirement that different compilers represent
data in the same way. For example two compilers on the same machine with
32-bit type Integer, are free to represent it in different manners (it's
unlikely that they will, but there is nothing in the RM to suggest that
this kind of interoperability is guaranteed, and streams have nothing
to say about that.

The factor of 20 will differ a lot, you can get cases with much higher
costs (e.g. when exceptions are involved), or much lower costs, it very
much depends on the case.





  reply	other threads:[~1998-01-13  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-12  0:00 Packing Record Structures in Ada Randall_Rathbun
1998-01-12  0:00 ` Matthew Heaney
1998-01-13  0:00 ` Robert Dewar
1998-01-13  0:00   ` Corey Minyard
1998-01-13  0:00     ` Robert Dewar [this message]
1998-01-15  0:00     ` Michael F Brenner
1998-01-15  0:00       ` Robert Dewar
1998-01-19  0:00 ` Anonymous
replies disabled

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