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 autolearn=ham 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-05 13:57:32 PST Message-ID: <3E667223.5020904@cogeco.ca> From: "Warren W. Gay VE3WWG" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Endianness independance References: <3E6633C7.8000503@cogeco.ca> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 05 Mar 2003 16:54:43 -0500 NNTP-Posting-Host: 198.96.47.195 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1046901283 198.96.47.195 (Wed, 05 Mar 2003 16:54:43 EST) NNTP-Posting-Date: Wed, 05 Mar 2003 16:54:43 EST Organization: Bell Sympatico Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!torn!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail Xref: archiver1.google.com comp.lang.ada:34939 Date: 2003-03-05T16:54:43-05:00 List-Id: Simon Wright wrote: > "Warren W. Gay VE3WWG" writes: >>If you look carefully at GLADE, you will notice that all that is >>being done there is "byte swapping". There is more to independent >>network formats than that (it just happens to work with _most_ >>modern platforms at the moment). > > I don't know what version of GLADE you are looking at, but the code > for 3.15p does a lot more than this. I am no expert as to whether it > achieves the purpose or not on eg a VAX (but I don't believe that GNAT > supports VAXes anyway). > > This is reading a single-length Float from the net: > > function I_F (Stream : access RST) return Float is > I : constant Precision := Single; > E_Size : Integer renames Fields (I).E_Size; > E_Bias : Integer renames Fields (I).E_Bias; > E_Last : Integer renames Fields (I).E_Last; > F_Size : Integer renames Fields (I).F_Size; > F_Mask : SE renames Fields (I).F_Mask; > E_Bytes : SEO renames Fields (I).E_Bytes; > F_Bytes : SEO renames Fields (I).F_Bytes; > > E : Unsigned; > P : Boolean; > X : Float; > S : SEA (1 .. F_L); > L : SEO; > > begin > Ada.Streams.Read (Stream.all, S, L); > > if L /= S'Last then > raise Data_Error; > end if; > > -- Extract Fraction, Exponent and Sign. > X := Float (S (F_L + 1 - F_Bytes) and F_Mask); > for N in F_L + 2 - F_Bytes .. F_L loop > X := X * FB + Float (S (N)); > end loop; > X := Scaling (X, -F_Size); -- Float ... > end I_F; Well Simon, I have to admit this sure looks a lot different than the code I remember looking at. I havn't reviewed this in great detail, but obviously there is more than byte swapping here. I am sure that the last time I looked was pre 3.15p. I am actually rather happy to see this level of support. It would be best if the format supported was XDR, but without more investigation, I cannot say here and now if this is it (XDR support would make Ada more easily able to speak on equal network terms with existing RPC C code). However, simply guaranteeing that the format is compatible between two GLADE sessions is good enough for most purposes that I would personally have in mind. Thanks for pointing this out. Warren. -- Warren W. Gay VE3WWG http://home.cogeco.ca/~ve3wwg