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,2808111f01d47bd3 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Counting Elements figured out. Date: 02 Dec 2005 18:09:58 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1133564998 6638 192.74.137.71 (2 Dec 2005 23:09:58 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 2 Dec 2005 23:09:58 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:6725 Date: 2005-12-02T18:09:58-05:00 List-Id: Freejack writes: > Aha. I gotcha. I suppose I should take that into account when mapping the > storage space into my process. I just tested it out. It works when the > compiler does it's malloc() allocations, but segfaults on an mmaped() > region. So the length of the region I map should be > Size_In_Storage_Elements + 1, yes? And then use the " - 1 " on allocations > from that region? I don't really understand the above, but it doesn't look right. Anyway, mmap requires page-alignment, right? That is, you can't mmap 100 bytes; you have to round it up to 2**12 or 2**13 bytes or some such. > I suppose I should have two Region types. One where Storage blocks are > exact multiples of Storage_Unit, and one that handles truncated Sizes. I don't think that makes sense. Allocation is always done in integer numbers of storage units (storage elements). A storage pool type never has to deal with fractional storage elements. That is, on a normaly 8-bit-byte-addressable machine, Allocate will never be asked to allocate 3 bits, or 67 bits -- it doesn't get sizes in bits at all. You have to deal with different alignments, though. The required alignment is passed in to Allocate. It should make sure that the address returned is aligned to that boundary, or else it should raise an exception for unsupported alignments. Alignment is also in terms of storage units/elements, not bits. The simplest thing is to always align to the most stringent natural alignment required by the hardware, which is usually Long_Float'Alignment, which is usually 4 or 8. >... Oh > gawd, about two dozen possible schemes just jumped into my head all at > once. > > Heh. The wonderful world of memory managment. - Bob