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,FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,19b0bf5b6906d2e7 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news2.google.com!proxad.net!usenet-fr.net!news.enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Duncan Sands Newsgroups: comp.lang.ada Subject: Re: Using GNAT.Sockets with Streams and Byte Swapping Date: Thu, 26 May 2005 12:01:47 +0200 Organization: Cuivre, Argent, Or Message-ID: References: <1117014486.871500.288200@g44g2000cwa.googlegroups.com> <1117099711.738704.120930@g47g2000cwa.googlegroups.com> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: melchior.cuivre.fr.eu.org 1117101992 10700 212.85.156.195 (26 May 2005 10:06:32 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Thu, 26 May 2005 10:06:32 +0000 (UTC) Cc: comp.lang.ada@ada-france.org To: markp Return-Path: In-Reply-To: <1117099711.738704.120930@g47g2000cwa.googlegroups.com> X-Mailer: Evolution 2.2.1.1 X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:11162 Date: 2005-05-26T12:01:47+02:00 On Thu, 2005-05-26 at 02:28 -0700, markp wrote: > Thanks for your reply. I have one question. In order to write my own > 'Write and 'Read subprograms, would I have to change GNAT.Sockets and > rebuild the runtime? Or, is there an easier way? The usual answer is that you should write your own 'Read and 'Write routines. However recent versions of GNAT support the machine independent XDR representation, which may be what you want. The GNAT reference manual says: 13.13.2(17): Stream Oriented Attributes If a stream element is the same size as a storage element, then the normal in-memory representation should be used by Read and Write for scalar objects. Otherwise, Read and Write should use the smallest number of stream elements needed to represent all values in the base range of the scalar type. Followed. By default, GNAT uses the interpretation suggested by AI-195, which specifies using the size of the first subtype. However, such an implementation is based on direct binary representations and is therefore target- and endianness-dependent. To address this issue, GNAT also supplies an alternate implementation of the stream attributes Read and Write, which uses the target-independent XDR standard representation for scalar types. The XDR implementation is provided as an alternative body of the System.Stream_Attributes package, in the file `s-strxdr.adb' in the GNAT library. There is no `s-strxdr.ads' file. In order to install the XDR implementation, do the following: 1. Replace the default implementation of the System.Stream_Attributes package with the XDR implementation. For example on a Unix platform issue the commands: $ mv s-stratt.adb s-strold.adb $ mv s-strxdr.adb s-stratt.adb 2. Rebuild the GNAT run-time library as documented in the GNAT User's Guide