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-Thread: 103376,5ae752c88e0dde5e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!feeder.erje.net!news2.arglkargh.de!news.n-ix.net!news.belwue.de!LF.net!news.enyo.de!not-for-mail From: Florian Weimer Newsgroups: comp.lang.ada Subject: Re: Using representation clauses in networking software Date: Sun, 15 Aug 2010 17:32:02 +0200 Message-ID: <87tymvhoy5.fsf@mid.deneb.enyo.de> References: <8739ugqfeb.fsf@mid.deneb.enyo.de> <43fkp7an4c5m$.3db3n6adym42.dlg@40tude.net> <8739ugkka6.fsf@mid.deneb.enyo.de> <1pjh30gv98n9t$.lycfvhr1l9rz$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: idssi.enyo.de 1281886322 11144 172.17.135.6 (15 Aug 2010 15:32:02 GMT) X-Complaints-To: news@enyo.de Cancel-Lock: sha1:OMxDz04GYUPN4ZriUsxC3cQXoQI= Xref: g2news1.google.com comp.lang.ada:13342 Date: 2010-08-15T17:32:02+02:00 List-Id: * Dmitry A. Kazakov: > On Sun, 15 Aug 2010 16:44:33 +0200, Florian Weimer wrote: > >> * Dmitry A. Kazakov: >> >>> On Sun, 15 Aug 2010 15:44:34 +0200, Yannick Duch�ne (Hibou57) wrote: >>> >>> (I agree with what you wrote. I am programming a lot of communication >>> stuff, but never used representation clauses to handle endianness.) >> >> This is not surprising because the current representation clauses >> cannot handle it. > > What for, if there are better ways to handle it? Representation layout > clause was invented for handling something in place. It is no more actual, > because reading out/writing in with an appropriate recoding is cleaner and > possibly cheaper on modern hardware. It's quite difficult to come up with the best approach to deserialization for a particular architecture. There are some pretty common CPUs that handle unaligned loads quite well, so it's unclear that the load-a-byte-at-a-time-and-shift approach is a win. Same for serialization. >> I wonder if there has been any attempt to enhance representation >> clauses so that they are useful in this context. > > To handle all possible cases of mixed-endian? To handle non-2's complement > integers? IEEE, IBM, DEC float layouts? Layouts of Character like EBCDIC, > KOI-7/8 etc? It would be a mammoth task to accomplish. What is the gain? So why were representation clauses added to Ada in the first place? Would it make sense to deprecate them? (Endian issues arise even when controlling devices because most PCI devices you can plug into a big-endian box expect little endian memory-mapped I/O.)