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,1ea59bb198e88f9f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!feed.cgocable.net!read1.cgocable.net.POSTED!53ab2750!not-for-mail From: "Warren W. Gay VE3WWG" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: GNAT Ada.Streams Bug? References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 25 Nov 2004 23:11:04 -0500 NNTP-Posting-Host: 24.150.168.167 X-Complaints-To: abuse@cogeco.ca X-Trace: read1.cgocable.net 1101442207 24.150.168.167 (Thu, 25 Nov 2004 23:10:07 EST) NNTP-Posting-Date: Thu, 25 Nov 2004 23:10:07 EST Organization: Cogeco Cable Xref: g2news1.google.com comp.lang.ada:6494 Date: 2004-11-25T23:11:04-05:00 List-Id: Jeff C r e e.m wrote: > "Warren W. Gay VE3WWG" wrote in message > news:fOopd.59177$Le1.1221311@news20.bellglobal.com... > >>This is on gnat-3.14p on debian (debian's package library doesn't >>seem to provide 3.15p), so this may be fixed by now: >> >>I am running into a Ada.Streams problem with 24 bit values (3 bytes). >>For example, if you use Ada.Streams to read in a partition table, >>defined as follows, with 3.14p, you'll read more bytes than needed >>(thus messing things up): > > These might be helpful > > http://groups.google.com/groups?hl=en&lr=&threadm=t3f6rg54jlkfee%40corp.supernews.com&rnum=2&prev=/groups%3Fq%3Dstreams%2Bcreem%2Bsize%26hl%3Den%26lr%3D%26selm%3Dt3f6rg54jlkfee%2540corp.supernews.com%26rnum%3D2 > > http://groups.google.com/groups?q=streams+creem+size&hl=en&lr=&selm=t739enmlcvuo2d%40corp.supernews.com&rnum=1 > > http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00270.TXT?rev=1.6 Interesting. So the bug is in the RM ;-) > In any case, you can "work around" this and get more efficient code to boot > by writing your own 'read and 'write for your record to read the whole > "hunk" of data in at once (based on the 'size of the record in terms of > stream elements). I am not concerned at all about the efficiency of this case, as you read the partition 4 times at boot time (less if you have fewer disks). I know however, that you were stating the more general case. It is disappointing to learn that basically Ada95 is "portability busted" when it comes to Ada.Streams. As Randy (I think) mentioned in the AI link, it is very difficult to adapt a stream to external formats - more impossible to be compiler independent at the same time. Since I am trying to interface a stream to the boot sector, this becomes a real problem that I'll have to "work around". This is real disappointing for someone doing O/S work. C code bypasses any difficulty here, because you just give read(2) a pointer (essentially Var'Address) and tell it how many bytes to deposit there. Type is not checked, lengths not checked etc. Dangerous, and of course you could resort to this same technique in Ada as well. In Ada95 however, you don't want a custom Read routine for every O/S type you create (else you have to resign yourself to a small set of unsigned types and dispense with one of advantages of strong typing). You also don't want to do "conversions" all over the place. Finally, generic adapters would be too many and Unchecked_Conversion is not efficient or pleasant. So what to do? STREAMS lets you do your I/O in a safe, but strongly typed way. It seems like the right thing to do. It seems that for GNAT and Intel, you can work around it if you are careful. For some platforms however, where the base types for all types are 32 bits, this sounds impossible. Based upon the links you provided, THERE IS HOPE in Ada200Y for Streams. I welcome those changes. The point about efficiency is also a good one to raise. For example, if you String'Read(Stream,Var), GNAT calls the 'Read routine for each and every Character of the string. One pines for something more efficient than this, and I hope for the day when this improves in GNAT. (hint) Thanks for the links. wwg. -- Warren W. Gay VE3WWG http://home.cogeco.ca/~ve3wwg