From: "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca>
Subject: Re: Endianness independance
Date: Wed, 05 Mar 2003 16:54:43 -0500
Date: 2003-03-05T16:54:43-05:00 [thread overview]
Message-ID: <3E667223.5020904@cogeco.ca> (raw)
In-Reply-To: x7vllztfu3k.fsf@smaug.pushface.org
Simon Wright wrote:
> "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca> 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
next prev parent reply other threads:[~2003-03-05 21:54 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <BB06F6B19AC7D51181D10050DA725A10138C75@eoleclb.clb.tcfr.thales>
2003-03-04 12:46 ` Endianness independance 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 [this message]
2003-03-05 17:49 David C. Hoos
2003-03-05 20:16 ` Simon Wright
2003-03-05 21:58 ` Warren W. Gay VE3WWG
-- strict thread matches above, loose matches on Subject: below --
2003-03-04 11:34 Lionel.DRAGHI
[not found] <BB06F6B19AC7D51181D10050DA725A10138C71@eoleclb.clb.tcfr.thales>
2003-03-03 18:38 ` David C. Hoos
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