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,d778a4f52acd9d43 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.75.170 with SMTP id d10mr20773742pbw.6.1325030951125; Tue, 27 Dec 2011 16:09:11 -0800 (PST) MIME-Version: 1.0 Path: lh20ni71771pbb.0!nntp.google.com!news1.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Representation clauses for base-64 encoding Date: Tue, 27 Dec 2011 18:09:07 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <9lgi3jFhaU1@mid.individual.net> <9lqpq5Ft05U1@mid.individual.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1325030949 16102 69.95.181.76 (28 Dec 2011 00:09:09 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 28 Dec 2011 00:09:09 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2011-12-27T18:09:07-06:00 List-Id: "Niklas Holsti" wrote in message news:9lqpq5Ft05U1@mid.individual.net... > On 11-12-23 03:30 , Randy Brukardt wrote: >> "Niklas Holsti" wrote in message >> news:9lgi3jFhaU1@mid.individual.net... >>> On 11-12-22 11:41 , Natasha Kerensikova wrote: >> ... >>>> type Octet_Block is array (1 .. 3) of Octet; >>>> pragma Pack (Octet_Block); >>> >>> I would add the following, to check that packing is effective: >>> >>> for Octet_Block'Size use 24; >> >> I think it would probably be better to forget Pack and actually say what >> you >> mean here: >> >> type Octet_Block is array (1 .. 3) of Octet; >> for Octet_Block'Component_Size use 8; >> >> "Pack" should be reserved for cases where you don't care about the exact >> layout, you just want to save space. Here you do care about the exact >> layout, so use a Component_Size. > > Fine adjustment: when Component_Size is not a factor or multiple of the > word size, RM 13.3(73) says that the array may also have to be packed in > order to eliminate gaps between components. > > Of course, a Component_Size of 8 bits is usually a factor of the word > size. But perhaps not always. You're right of course, although I would hope that no compiler was silly enough to ignore a direct component-size command by putting gaps into it. I'd much rather the compiler rejected such a clause (surely Janus/Ada would). If you want gaps, you should say so. For instance, on the U2200 (a 36-bit machine with 9-bit divisions), you'd have to say type Octet_Block is array (1 .. 3) of Octet; for Octet_Block'Component_Size use 9; if you wanted gaps. (And 8 might have been rejected, I don't remember anymore whether the Unisys code generator could handle that.) That's why Janus/Ada uses a constant Host.Stor_Unit_Size in all of its representation clauses. (As you might guess, package Host contains a bunch of constants and subprograms defining the host environment for the compiler. You'd probably also guess that there is a similar package Target, and if you did, you'd be right.) Randy.