* Re: fixed point types over an interface
1997-02-07 0:00 ` Robert Dewar
@ 1997-02-10 0:00 ` Mats Weber
1997-02-10 0:00 ` Robert Dewar
1997-02-12 0:00 ` Laurent Pautet
` (3 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Mats Weber @ 1997-02-10 0:00 UTC (permalink / raw)
> Two processors are communicating over an interface. The
> applications for each processor are written/compiled
> using compilers from two different vendors.
> To pin this down, you need to use a Small clause and a Size clause,
> then you should be pretty safe relying on the result, although one
> can imagine compilers doing weird things.
You may also run into big endian/little endian problems. If performance
is not a problem, passing the data in text representation will always
work and be portable.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fixed point types over an interface
1997-02-10 0:00 ` Mats Weber
@ 1997-02-10 0:00 ` Robert Dewar
1997-02-11 0:00 ` nassera
0 siblings, 1 reply; 15+ messages in thread
From: Robert Dewar @ 1997-02-10 0:00 UTC (permalink / raw)
Mats said
<<You may also run into big endian/little endian problems. If performance
is not a problem, passing the data in text representation will always
work and be portable.>>
Another possibility is to use a target independent implementation of
Stream_IO, such as is provided with GLADE (the GNAT implementation of
the distributed annex PCS). GLADE uses XDR for stream representation,
which avoids any endian (or other target dependent) problems.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fixed point types over an interface
1997-02-10 0:00 ` Robert Dewar
@ 1997-02-11 0:00 ` nassera
1997-02-12 0:00 ` Samuel Tardieu
0 siblings, 1 reply; 15+ messages in thread
From: nassera @ 1997-02-11 0:00 UTC (permalink / raw)
In article <dewar.855629889@merv>, dewar@merv.cs.nyu.edu says...
>
>Mats said
>
><<You may also run into big endian/little endian problems. If performance
>is not a problem, passing the data in text representation will always
>work and be portable.>>
>
>Another possibility is to use a target independent implementation of
>Stream_IO, such as is provided with GLADE (the GNAT implementation of
>the distributed annex PCS). GLADE uses XDR for stream representation,
>which avoids any endian (or other target dependent) problems.
>
good choice. I just wanted to also add that Sun NFS and Sun RPC
also uses XDR.
man xdr: (on solaris 2.5)
DESCRIPTION
XDR routines allow C programmers to describe arbitrary data
structures in a machine-independent fashion. Data for
remote procedure calls (RPC) are transmitted using these
routines.
by the way, I wonder why the man output above mentions only "C programmers".
Nasser
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fixed point types over an interface
1997-02-07 0:00 ` Robert Dewar
1997-02-10 0:00 ` Mats Weber
@ 1997-02-12 0:00 ` Laurent Pautet
1997-02-12 0:00 ` Robert Dewar
1997-02-17 0:00 ` Jacob Sparre Andersen
1997-02-12 0:00 ` Jon S Anthony
` (2 subsequent siblings)
4 siblings, 2 replies; 15+ messages in thread
From: Laurent Pautet @ 1997-02-12 0:00 UTC (permalink / raw)
>> Another possibility is to use a target independent
>> implementation of Stream_IO, such as is provided with GLADE
>> (the GNAT implementation of the distributed annex PCS). GLADE
>> uses XDR for stream representation, which avoids any endian (or
>> other target dependent) problems.
nassera> good choice. I just wanted to also add that Sun NFS and
nassera> Sun RPC also uses XDR.
nassera> man xdr: (on solaris 2.5)
nassera> DESCRIPTION XDR routines allow C programmers to describe
nassera> arbitrary data structures in a machine-independent
nassera> fashion. Data for remote procedure calls (RPC) are
nassera> transmitted using these routines.
nassera> by the way, I wonder why the man output above mentions
nassera> only "C programmers".
Because it doesn't apply to Ada :-) For instance:
XDR says :
The representation of all items requires a multiple of four bytes (or
32 bits) of data.
LRM says :
For composite types, the Write or Read attribute for each component is
called in a canonical order ... Read and Write should use the smallest
number of stream elements needed to represent all values in the base
range of the scalar type.
So a string of 7 characters is stored on 8 bytes with XDR and 7 with Ada.
GLADE is only 95% XDR in order to follow LRM requirements. The 5%
comes from the XDR 4 bytes rule (basically strings).
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fixed point types over an interface
1997-02-12 0:00 ` Laurent Pautet
@ 1997-02-12 0:00 ` Robert Dewar
1997-02-12 0:00 ` Mats Weber
1997-02-17 0:00 ` Jacob Sparre Andersen
1 sibling, 1 reply; 15+ messages in thread
From: Robert Dewar @ 1997-02-12 0:00 UTC (permalink / raw)
Laurent Pautet said
<<GLADE is only 95% XDR in order to follow LRM requirements. The 5%
comes from the XDR 4 bytes rule (basically strings).>>
This is confusing and misleading. It is true that a string is not output
in XDR format, but that is because strings are not output in streams
ever. Instead the semantics of Ada is that a string is output as a series
of characters. These characters are indeed output in the format required
by XDR.
Yes, you might expect that a string in Ada would be output in a format
corresponding to a string as described in the XDR standard, but really
there is no reason to expect such a correspondence. Clearly a string
in Ada is a rather different beast, because for one thing it typically
includes bounds.
So, here is the exact statement of what is going on:
When the default stream attribtutes are used, the operates are first broken
down into a series of operations on primitive data values. The rules for
this breakdown are part of the Ada rules, and hence streams in Ada have
no requirement for dealing with composite values, since they are defined
to be a sequence of primitive values.
These primitive values are written in accordance with the rules in the XDR
standard, which are followed 100% accurately.
If you want to intercommunicate with another language, that other language
must understand the sequence of items that is written into the stream.
For example if we use 'Output on a four character string with bounds 1..4,
then six elements are written:
lower bound
upper bound
first character
second character
third character
fourth character
each of these six elements is represented using the XDR standard. The
"other language" code must read these six elements and assemble them into
whatever makes best sense for representing this particular aggregate data
item.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fixed point types over an interface
1997-02-12 0:00 ` Robert Dewar
@ 1997-02-12 0:00 ` Mats Weber
0 siblings, 0 replies; 15+ messages in thread
From: Mats Weber @ 1997-02-12 0:00 UTC (permalink / raw)
Robert Dewar wrote:
>
> Laurent Pautet said
>
> <<GLADE is only 95% XDR in order to follow LRM requirements. The 5%
> comes from the XDR 4 bytes rule (basically strings).>>
> These primitive values are written in accordance with the rules in the XDR
> standard, which are followed 100% accurately.
>
> If you want to intercommunicate with another language, that other language
> must understand the sequence of items that is written into the stream.
> For example if we use 'Output on a four character string with bounds 1..4,
> then six elements are written:
>
> lower bound
> upper bound
> first character
> second character
> third character
> fourth character
>
> each of these six elements is represented using the XDR standard. The
> "other language" code must read these six elements and assemble them into
> whatever makes best sense for representing this particular aggregate data
> item.
Does each of these six elements occupy 4 bytes in the message ?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fixed point types over an interface
1997-02-12 0:00 ` Laurent Pautet
1997-02-12 0:00 ` Robert Dewar
@ 1997-02-17 0:00 ` Jacob Sparre Andersen
1997-02-18 0:00 ` Robert Dewar
1 sibling, 1 reply; 15+ messages in thread
From: Jacob Sparre Andersen @ 1997-02-17 0:00 UTC (permalink / raw)
Laurent Pautet (pautet@inf.enst.fr) wrote:
|^^^^^^^^^^
| Because it doesn't apply to Ada :-) For instance:
|
| XDR says :
|
| The representation of all items requires a multiple of four bytes (or
| 32 bits) of data.
|
| LRM says :
|
| For composite types, the Write or Read attribute for each component is
| called in a canonical order ... Read and Write should use the smallest
| number of stream elements needed to represent all values in the base
| range of the scalar type.
^^^^^^^^^^
Is there anything that prevents the "stream elements" to fill 32 bits?
If I read 13.13.1 in the LRM correctly, then there's absolutely nothing that
prevents type Stream_Element from being declared as "mod 32".
Greetings,
Jacob
--
Jacob Sparre Andersen http://www.nbi.dk/%7Esparre/
Center for Chaos and Turbulence Studies Phone: (+45) 39 65 53 51
The Niels Bohr Institute (+45) 35 32 53 05
--
"In the long run we are all dead", John Maynard Keynes (1923)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fixed point types over an interface
1997-02-17 0:00 ` Jacob Sparre Andersen
@ 1997-02-18 0:00 ` Robert Dewar
0 siblings, 0 replies; 15+ messages in thread
From: Robert Dewar @ 1997-02-18 0:00 UTC (permalink / raw)
Jacob says
<<| For composite types, the Write or Read attribute for each component is
| called in a canonical order ... Read and Write should use the smallest
| number of stream elements needed to represent all values in the base
| range of the scalar type.
^^^^^^^^^^
Is there anything that prevents the "stream elements" to fill 32 bits?
If I read 13.13.1 in the LRM correctly, then there's absolutely nothing that
prevents type Stream_Element from being declared as "mod 32".>>
Right, that would be perfectly valid, but in any case, the part of yoru
quote after the ... is only implementation advice, and this means that
it should be followed unless there is good reason not to follow it, and
in any case whether you follow it or not has nothing to do with
conformance.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fixed point types over an interface
1997-02-07 0:00 ` Robert Dewar
1997-02-10 0:00 ` Mats Weber
1997-02-12 0:00 ` Laurent Pautet
@ 1997-02-12 0:00 ` Jon S Anthony
1997-02-12 0:00 ` Laurent Pautet
1997-02-13 0:00 ` Jon S Anthony
4 siblings, 0 replies; 15+ messages in thread
From: Jon S Anthony @ 1997-02-12 0:00 UTC (permalink / raw)
In article <dewar.855629889@merv> dewar@merv.cs.nyu.edu (Robert Dewar) writes:
> <<You may also run into big endian/little endian problems. If performance
> is not a problem, passing the data in text representation will always
> work and be portable.>>
>
> Another possibility is to use a target independent implementation of
> Stream_IO, such as is provided with GLADE (the GNAT implementation of
Or an ORB, which handles this stuff (among other various similar sorts
of things) as well. And works between pieces written in C, Ada, C++,
and ST (and Java, though that is not yet official...)
/Jon
--
Jon Anthony
Organon Motives, Inc.
Belmont, MA 02178
617.484.3383
jsa@organon.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fixed point types over an interface
1997-02-07 0:00 ` Robert Dewar
` (2 preceding siblings ...)
1997-02-12 0:00 ` Jon S Anthony
@ 1997-02-12 0:00 ` Laurent Pautet
1997-02-13 0:00 ` Jon S Anthony
4 siblings, 0 replies; 15+ messages in thread
From: Laurent Pautet @ 1997-02-12 0:00 UTC (permalink / raw)
(Robert Dewar) writes:
>> <<You may also run into big endian/little endian problems. If
>> performance is not a problem, passing the data in text
>> representation will always work and be portable.>>
>>
>> Another possibility is to use a target independent
>> implementation of Stream_IO, such as is provided with GLADE
>> (the GNAT implementation of
Jon> Or an ORB, which handles this stuff (among other various
Jon> similar sorts of things) as well. And works between pieces
Jon> written in C, Ada, C++, and ST (and Java, though that is not
Jon> yet official...)
Except that some Ada stream requirements will be violated.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: fixed point types over an interface
1997-02-07 0:00 ` Robert Dewar
` (3 preceding siblings ...)
1997-02-12 0:00 ` Laurent Pautet
@ 1997-02-13 0:00 ` Jon S Anthony
4 siblings, 0 replies; 15+ messages in thread
From: Jon S Anthony @ 1997-02-13 0:00 UTC (permalink / raw)
In article <rcaybcudtnk.fsf@quasimodo.enst.fr> Laurent Pautet <pautet@inf.enst.fr> writes:
> >> Another possibility is to use a target independent
> >> implementation of Stream_IO, such as is provided with GLADE
> >> (the GNAT implementation of
>
> Jon> Or an ORB, which handles this stuff (among other various
> Jon> similar sorts of things) as well. And works between pieces
> Jon> written in C, Ada, C++, and ST (and Java, though that is not
> Jon> yet official...)
>
> Except that some Ada stream requirements will be violated.
What's that have to do with it? You want to move the information from
once place to another in such a way that it behaves the same after
that is done. That's what an ORB does. Works fine.
Given this context the specific ins and outs of Ada streams per se are
irrelevant.
/Jon
--
Jon Anthony
Organon Motives, Inc.
Belmont, MA 02178
617.484.3383
jsa@organon.com
^ permalink raw reply [flat|nested] 15+ messages in thread