comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
To: "comp.lang.ada mail to news gateway" <comp.lang.ada@ada.eu.org>
Subject: Re: Endianness independance
Date: Mon, 3 Mar 2003 12:38:07 -0600
Date: 2003-03-03T12:38:07-06:00	[thread overview]
Message-ID: <mailman.21.1046716707.1343.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: BB06F6B19AC7D51181D10050DA725A10138C71@eoleclb.clb.tcfr.thales


----- Original Message -----
From: <Lionel.DRAGHI@fr.thalesgroup.com>
To: <comp.lang.ada@ada.eu.org>
Sent: Monday, March 03, 2003 11:52 AM
Subject: RE: Endianness independance


> | -----Message d'origine-----
> | De: Stephen Leake [mailto:Stephen.A.Leake@nasa.gov]
> ...
> | It is not possible to get compatible stream representations via
> | representation clauses.
> |
> | You must override 'Write and 'Read to get that.
> |
> | The reason is that representation clauses can't swap bytes within
> | scalars (integers and floats), as is required by endian-independant
> | stream representations.
> |
> This is what i called the "easy" part of the job.
> But, obviously i suppose the compiler will do the job. If i must override
> Stream attributes, i won't consider it so easy :-)
>
> I can't believe it's impossible, after all, this is actually done by
Glade,
> isn't it?
Yes, Glade does it, but the only thing Glade has to worry about is that
the stream representation is independent of hardware platform and OS.

Glade does this by providing a replacement body for the
System.Stream_Attributes package.

However, I have done a lot of endianess-independent work where a
specific network representation is required -- i.e., where an Ada
program has to communicate with a program writen in a language
not necessarily known to me.

My personal preference has been to care not at all about memory
representation of records, but to override the 'Write and 'Read
attributes of record components as required to produce/interpret the
required network representation.

In the case of memory-mapped IO interfaces, I read/write the raw data
from/to a "memory stream," using my overriding stream attributes.

Overriding stream attibutes is not all that difficult -- since it is done at
the record component level.  It is only necessary that the components
for which the default stream attributes are overridden begin and end
on octet boundaries.

When this is not the case, I define a record type to aggregate the
components that do not both begin and end on octet boundaries into
a type that does, and then use that type as the component of the main
record.

The actual implementation of the stream attributes frequently makes
use of a combination of unchecked conversion and instantiations of
generic procedures that manipulate arrays of bits.

>
> Lionel Draghi.
>
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
>




       reply	other threads:[~2003-03-03 18:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BB06F6B19AC7D51181D10050DA725A10138C71@eoleclb.clb.tcfr.thales>
2003-03-03 18:38 ` David C. Hoos [this message]
2003-03-05 17:49 Endianness independance David C. Hoos
2003-03-05 20:16 ` Simon Wright
2003-03-05 21:58   ` Warren W. Gay VE3WWG
     [not found] <BB06F6B19AC7D51181D10050DA725A10138C75@eoleclb.clb.tcfr.thales>
2003-03-04 12:46 ` David C. Hoos, Sr.
2003-03-04 16:38   ` John Harbaugh
2003-03-04 21:25   ` Simon Wright
2003-03-05 17:28     ` Warren W. Gay VE3WWG
2003-03-05 20:15       ` Simon Wright
2003-03-05 21:54         ` Warren W. Gay VE3WWG
  -- strict thread matches above, loose matches on Subject: below --
2003-03-04 11:34 Lionel.DRAGHI
2003-03-03 17:52 Lionel.DRAGHI
2003-03-03 20:29 ` Pascal Obry
2003-03-03 13:33 Lionel.DRAGHI
2003-03-03 16:11 ` Stephen Leake
2003-02-28 17:21 Lionel.DRAGHI
2003-02-28 20:37 ` Randy Brukardt
2003-02-28 15:11 Lionel.DRAGHI
2003-02-28 16:10 ` Stephen Leake
2003-02-28 18:26 ` Marin David Condic
2003-03-01 10:48   ` Amir Yantimirov
2003-03-01 12:00     ` Simon Wright
2003-03-01 12:53       ` Jeffrey Creem
2003-03-01 17:26         ` Simon Wright
2003-03-01 12:47     ` Marin David Condic
2003-03-02  9:49       ` Amir Yantimirov
2003-03-03 13:29         ` Marin David Condic
2003-03-03 16:05       ` Stephen Leake
2003-03-03 17:50         ` Marin David Condic
2003-03-04  2:33         ` Jeffrey Carter
2003-03-04 17:50           ` Stephen Leake
2003-03-05  2:15             ` Jeffrey Carter
2003-03-05 17:37               ` Stephen Leake
replies disabled

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