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,6353697ffeb79d16 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!postnews.google.com!p11g2000vbn.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Encapsulating Ada.Direct_IO Date: Thu, 18 Nov 2010 08:36:56 -0800 (PST) Organization: http://groups.google.com Message-ID: <2edbda42-28e8-462c-9005-eda66538274b@p11g2000vbn.googlegroups.com> References: <5ba4147a-6099-4a05-b548-09544f58247a@j18g2000yqd.googlegroups.com> <162dnSHurcNcEHnRRVn_vwA@giganews.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1290098216 19236 127.0.0.1 (18 Nov 2010 16:36:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 18 Nov 2010 16:36:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p11g2000vbn.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:15588 Date: 2010-11-18T08:36:56-08:00 List-Id: On Nov 17, 6:21=A0pm, "Peter C. Chapin" wrote: > On 2010-11-17 20:16, Randy Brukardt wrote: > > > Surely not. Not all machines have 8-bits as any sort of native type. Fo= r > > instance, the Unisys U2200 (a 36-bit machine, with 9-bit bytes) used > > Character'Size =3D 9. (It was great fun for the cross-compiler.) > > So in that case if you absolutely wanted to read 8 bit units from a file > (because the file is in some externally defined binary format that uses > 8 bit units) it would be necessary to do something like: > > type My_Byte is mod 2**8; > for My_Byte'Size use 8; =A0 -- This is important. > > package My_Byte_IO is new Ada.Sequential_IO(My_Byte); > > ... and then convert from My_Byte to Character only as appropriate > during the file decoding process. > > True? I have a longish rant that touches on this, but the short answer is that I don't think there's an Ada answer to your question. If you had a file defined as using 8-bit units, and that file got put onto a system that uses 36-bit words, you'd need to know just what the OS is going to do with it, and how the particular Ada implementation will deal with files on that OS. It may be that the native "read from file" service on that OS will put each byte into a 9-bit byte and zero the high bit. I don't see how to avoid implementation-dependent code in a case like this. -- Adam