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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,febd9e55846c9556 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-03 10:38:30 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!freenix!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Endianness independance Date: Mon, 3 Mar 2003 12:38:07 -0600 Organization: ENST, France Message-ID: References: Reply-To: "comp.lang.ada mail to news gateway" NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1046716708 25043 137.194.161.2 (3 Mar 2003 18:38:28 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 3 Mar 2003 18:38:28 +0000 (UTC) To: "comp.lang.ada mail to news gateway" Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:34834 Date: 2003-03-03T12:38:07-06:00 ----- Original Message ----- From: To: 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 >