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!news.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: Allocators design flaw Date: Fri, 20 Oct 2017 20:42:45 -0500 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Sat, 21 Oct 2017 01:42:45 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="27474"; 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: news.eternal-september.org comp.lang.ada:48538 Date: 2017-10-20T20:42:45-05:00 List-Id: "Victor Porton" wrote in message news:ort609$1i31$2@gioia.aioe.org... > Dmitry A. Kazakov wrote: > >> On 2017-10-14 04:53, Victor Porton wrote: >>> It is impossible to properly implement an allocator through a C function >>> (such as raptor_alloc_memory() from Raptor C library) which allocates a >>> struct and returns the pointer to the allocated struct. >>> >>> It is because RM13.11(21.5/3) "The Alignment parameter is a nonzero >>> integral multiple of D'Alignment..." >>> >>> (If it were "The Alignment parameter is equal to D'Alignment", then we >>> would be able just to check (in Allocate procedure implementation) that >>> >>> pragma Assert(Dummy_Record'Alignment mod Alignment = 0); >>> -- where Dummy_Record is an arbitrary C-convention record >>> -- (as all C records have the same alignment reqs) >>> >>> So Alignment parameter may be arbitrarily big and the C function >>> alignment may not conform to it. >> >> Usually allocators return addresses already rounded and there is nothing >> to worry about. >> >>> Let us think how to work around (in Ada 202x) of this design flaw. >> >> If any it is _alloc_memory() flaw, not Ada's. > > It is an Ada flaw, because Ada must be able to interact with legacy C > libraries. Ada can interact just fine with C libraries. But there was never any intention that allocators and storage pools would be part of that interaction. It seems to be the case here that you are trying to fit a square peg into a round hole. Keep in mind that all C interfacing is by definition implementation-defined, since it depends heavily on the C compiler. There's only so much portability that can be achieved in such interfacing; it can never be 100%. Randy.