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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: AI12-0218: What is the portable representation clause for processing IETF packets on little-endian machines? Date: Thu, 10 May 2018 17:40:45 -0500 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Thu, 10 May 2018 22:40:48 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="14863"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:52222 Date: 2018-05-10T17:40:45-05:00 List-Id: "Simon Wright" wrote in message news:ly4ljfgvim.fsf@pushface.org... > "Dan'l Miller" writes: > >> so the ..representation clause.. in AI12-0218 (on only GNAT for now) >> is the only game in Adatown > > I don't have a reference, but there was a cunning plan once involving > the fact that Boolean'Pos (False) is 0, and Boolean'Pos (True) is 1. So > you could write expressions involving > > BE : constant := > Boolean'Pos (System.Default_Bit_Order = System.High_Order_First); > > & likewise for LE, and you could then write representation components as > > (le-value * LE + be-value * BE) > > (something like that, anyway). Ugh. That's an Ada 83 approch. With Ada 2012, you could be more direct: (if BE then be-value else le-value) > But you still have to byte-swap. Right. The problem with AI12-0218-1 (besides the fact that no one other than the author understands it, and the author has not volunteered to help), is that it makes it way too easy to put very expensive byte-swapping code into data structures that occur everywhere. It's also very expensive to implement, since every compiler back-end has to be aware of it. (If you just implement it in the front-end using code equivalent to unchecked_conversions, you're forcing all of the operations into memory and don't allow any hardware support to get used.) Ada-specific back-ends definitely don't support byte-swapping (it never appears anywhere in existing Ada, the rules are designed to prevent it). A change to the back-end can be much more expensive than changes to front-ends, simply because there are many more of them and every individual target has to be tested carefully. (Front-ends only need to be tested carefully once; other testing only can surface latent back-end bugs.) Randy.