Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

A triangle which has an angle of 135 degrees is called an obscene triangle.


devel / comp.lang.ada / Custom Storage Pool questions

SubjectAuthor
* Custom Storage Pool questionsJere
+* Re: Custom Storage Pool questionsRandy Brukardt
|+* Re: Custom Storage Pool questionsJere
||`- Re: Custom Storage Pool questionsRandy Brukardt
|+- Re: Custom Storage Pool questionsSimon Wright
|`* Re: Custom Storage Pool questionsJere
| `* Re: Custom Storage Pool questionsNiklas Holsti
|  `* Re: Custom Storage Pool questionsEmmanuel Briot
|   +- Re: Custom Storage Pool questionsDmitry A. Kazakov
|   +- Re: Custom Storage Pool questionsShark8
|   `* Re: Custom Storage Pool questionsRandy Brukardt
|    `* Re: Custom Storage Pool questionsJere
|     `* Re: Custom Storage Pool questionsRandy Brukardt
|      `* Re: Custom Storage Pool questionsJere
|       `* Re: Custom Storage Pool questionsDmitry A. Kazakov
|        `- Re: Custom Storage Pool questionsRandy Brukardt
+* Re: Custom Storage Pool questionsJ-P. Rosen
|`* Re: Custom Storage Pool questionsJere
| +* Re: Custom Storage Pool questionsJ-P. Rosen
| |`* Re: Custom Storage Pool questionsJere
| | `* Re: Custom Storage Pool questionsSimon Wright
| |  `* Re: Custom Storage Pool questionsJere
| |   `* Re: Custom Storage Pool questionsRandy Brukardt
| |    `- Re: Custom Storage Pool questionsJere
| +* Re: Custom Storage Pool questionsDmitry A. Kazakov
| |+* Re: Custom Storage Pool questionsJ-P. Rosen
| ||+- Re: Custom Storage Pool questionsDmitry A. Kazakov
| ||`- Re: Custom Storage Pool questionsRandy Brukardt
| |+* Re: Custom Storage Pool questionsJere
| ||`- Re: Custom Storage Pool questionsDmitry A. Kazakov
| |`- Re: Custom Storage Pool questionsRandy Brukardt
| `* Re: Custom Storage Pool questionsEgil H H
|  `- Re: Custom Storage Pool questionsJere
`* Re: Custom Storage Pool questionsSimon Wright
 +- Re: Custom Storage Pool questionsSimon Wright
 `* Re: Custom Storage Pool questionsDmitry A. Kazakov
  `* Re: Custom Storage Pool questionsSimon Wright
   +* Re: Custom Storage Pool questionsEmmanuel Briot
   |`* Re: Custom Storage Pool questionsJere
   | +- Re: Custom Storage Pool questionsEmmanuel Briot
   | +- Re: Custom Storage Pool questionsSimon Wright
   | `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |  `* Re: Custom Storage Pool questionsSimon Wright
   |   `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    +* Re: Custom Storage Pool questionsNiklas Holsti
   |    |`* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | +* Re: Custom Storage Pool questionsNiklas Holsti
   |    | |`* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | | +* Re: Custom Storage Pool questionsNiklas Holsti
   |    | | |`* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | | | `* Re: Custom Storage Pool questionsNiklas Holsti
   |    | | |  `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | | |   +* Re: Custom Storage Pool questionsNiklas Holsti
   |    | | |   |`* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | | |   | `* Re: Custom Storage Pool questionsNiklas Holsti
   |    | | |   |  +* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | | |   |  |`- Re: Custom Storage Pool questionsRandy Brukardt
   |    | | |   |  `- Re: Custom Storage Pool questionsRandy Brukardt
   |    | | |   +- Re: Custom Storage Pool questionsRandy Brukardt
   |    | | |   `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | | |    `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | | |     `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | | |      `- Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | | `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | |  `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |   `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | |    `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |     `* Re: Custom Storage Pool questionsSimon Wright
   |    | |      `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |       `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | |        `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |         `* Re: Custom Storage Pool questionsShark8
   |    | |          `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |           `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | |            `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |             `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | |              `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |               `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | |                `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |                 `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | |                  `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |                   `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | |                    +- Re: Custom Storage Pool questionsphilip...@gmail.com
   |    | |                    `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |                     `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | |                      +* Re: Custom Storage Pool questionsStephen Leake
   |    | |                      |+- Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |                      |`- Re: Custom Storage Pool questionsRandy Brukardt
   |    | |                      `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |                       `* Re: Custom Storage Pool questionsRandy Brukardt
   |    | |                        `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |                         `* Re: Custom Storage Pool questionsSimon Wright
   |    | |                          `* Re: Custom Storage Pool questionsDmitry A. Kazakov
   |    | |                           `- Re: Custom Storage Pool questionsShark8
   |    | `- Re: Custom Storage Pool questionsRandy Brukardt
   |    `- Re: Custom Storage Pool questionsRandy Brukardt
   `- Re: Custom Storage Pool questionsDmitry A. Kazakov

Pages:1234
Custom Storage Pool questions

<e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5895&group=comp.lang.ada#5895

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:aa97:: with SMTP id t145mr7686374qke.145.1631494427590;
Sun, 12 Sep 2021 17:53:47 -0700 (PDT)
X-Received: by 2002:a5b:142:: with SMTP id c2mr12074937ybp.425.1631494427362;
Sun, 12 Sep 2021 17:53:47 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sun, 12 Sep 2021 17:53:47 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf
NNTP-Posting-Host: 98.118.241.166
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
Subject: Custom Storage Pool questions
From: jhb.c...@gmail.com (Jere)
Injection-Date: Mon, 13 Sep 2021 00:53:47 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 41
 by: Jere - Mon, 13 Sep 2021 00:53 UTC

I was learning about making user defined storage pools when
I came across an article that made me pause and wonder how
portable storage pools actually can be. In particular, I assumed
that the Size_In_Storage_Elements parameter in the Allocate
operation actually indicated the total number of storage elements
needed.

procedure Allocate(
Pool : in out Root_Storage_Pool;
Storage_Address : out Address;
Size_In_Storage_Elements : in Storage_Elements.Storage_Count;
Alignment : in Storage_Elements.Storage_Count) is abstract;

But after reading the following AdaCore article, my assumption is now
called into question:
https://blog.adacore.com/header-storage-pools

In particular, the blog there advocates for separately counting for
things like unconstrained array First/Last indices or the Prev/Next
pointers used for Controlled objects. Normally I would have assumed
that the Size_In_Storage_Elements parameter in Allocate would account
for that, but the blog clearly shows that it doesn't

So that seems to mean to make a storage pool, I have to make it
compiler specific or else risk someone creating a type like an
array and my allocation size and address values will be off.

Is it intended not to be able to do portable Storage Pools or am
I missing some Ada functionality that helps me out here. I
scanned through the list of attributes but none seem to give
any info about where the object's returned address is relative
to the top of the memory actually allocated for the object. I saw
the attribute Max_Size_In_Storage_Elements, but it doesn't seem
to guarantee to include things like the array indices and it still
doesn't solve the issue of knowing where the returned address
needs to be relative to the top of allocated memory.

I can easily use a generic to ensure that the types I care about
are portably made by the pool, but I can't prevent someone from
using my pool to create other objects that I hadn't accounted for.
Unless there is a way to restrict a pool from allocating objects
of other types?

Re: Custom Storage Pool questions

<shmnk1$lgf$1@franka.jacob-sparre.dk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5896&group=comp.lang.ada#5896

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsfeed.xs3.de!callisto.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail
From: ran...@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Mon, 13 Sep 2021 00:29:35 -0500
Organization: JSA Research & Innovation
Lines: 75
Message-ID: <shmnk1$lgf$1@franka.jacob-sparre.dk>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
Injection-Date: Mon, 13 Sep 2021 05:29:37 -0000 (UTC)
Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226";
logging-data="22031"; 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
 by: Randy Brukardt - Mon, 13 Sep 2021 05:29 UTC

Not sure what you are expecting. There is no requirement that objects are
allocated contigiously. Indeed, Janus/Ada will call Allocate as many times
as needed for each object; for instance, unconstrained arrays are in two
parts (descriptor and data area).

The only thing that you can assume in a portable library is that you get
called the same number of times and sizes/alignment for Allocate and
Deallocate; there's no assumptions about size or alignment that you can
make.

If you want to build a pool around some specific allocated size, then if it
needs to be portable, (A) you have to calculate the allocated size, and (B)
you have to have a mechanism for what to do if some other size is requested.
(Allocate a whole block for smaller sizes, fall back to built-in heap for
too large is what I usually do).

More likely, you'll build a pool for a particular implementation. Pools are
very low level by their nature, and useful ones are even more so (because
they are using target facilities to allocate memory, or need to assume
something about the allocations, or because they are doing icky things like
address math, or ...).

Randy.

Randy.

"Jere" <jhb.chat@gmail.com> wrote in message
news:e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com...
>I was learning about making user defined storage pools when
> I came across an article that made me pause and wonder how
> portable storage pools actually can be. In particular, I assumed
> that the Size_In_Storage_Elements parameter in the Allocate
> operation actually indicated the total number of storage elements
> needed.
>
> procedure Allocate(
> Pool : in out Root_Storage_Pool;
> Storage_Address : out Address;
> Size_In_Storage_Elements : in Storage_Elements.Storage_Count;
> Alignment : in Storage_Elements.Storage_Count) is abstract;
>
> But after reading the following AdaCore article, my assumption is now
> called into question:
> https://blog.adacore.com/header-storage-pools
>
> In particular, the blog there advocates for separately counting for
> things like unconstrained array First/Last indices or the Prev/Next
> pointers used for Controlled objects. Normally I would have assumed
> that the Size_In_Storage_Elements parameter in Allocate would account
> for that, but the blog clearly shows that it doesn't
>
> So that seems to mean to make a storage pool, I have to make it
> compiler specific or else risk someone creating a type like an
> array and my allocation size and address values will be off.
>
> Is it intended not to be able to do portable Storage Pools or am
> I missing some Ada functionality that helps me out here. I
> scanned through the list of attributes but none seem to give
> any info about where the object's returned address is relative
> to the top of the memory actually allocated for the object. I saw
> the attribute Max_Size_In_Storage_Elements, but it doesn't seem
> to guarantee to include things like the array indices and it still
> doesn't solve the issue of knowing where the returned address
> needs to be relative to the top of allocated memory.
>
> I can easily use a generic to ensure that the types I care about
> are portably made by the pool, but I can't prevent someone from
> using my pool to create other objects that I hadn't accounted for.
> Unless there is a way to restrict a pool from allocating objects
> of other types?

Re: Custom Storage Pool questions

<shnbn8$5he$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5898&group=comp.lang.ada#5898

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ros...@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Mon, 13 Sep 2021 13:12:39 +0200
Organization: Adalog
Lines: 36
Message-ID: <shnbn8$5he$1@dont-email.me>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 13 Sep 2021 11:12:41 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="05fe24b4bffd1349bcdf3a02a20b4a95";
logging-data="5678"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/95Y3XKzi6N2AziM98f1wK"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:w1ksWcD4DfM/HSj14B/0toCFXt8=
In-Reply-To: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
Content-Language: fr
 by: J-P. Rosen - Mon, 13 Sep 2021 11:12 UTC

Le 13/09/2021 à 02:53, Jere a écrit :
> I was learning about making user defined storage pools when
> I came across an article that made me pause and wonder how
> portable storage pools actually can be. In particular, I assumed
> that the Size_In_Storage_Elements parameter in the Allocate
> operation actually indicated the total number of storage elements
> needed.
>
> procedure Allocate(
> Pool : in out Root_Storage_Pool;
> Storage_Address : out Address;
> Size_In_Storage_Elements : in Storage_Elements.Storage_Count;
> Alignment : in Storage_Elements.Storage_Count) is abstract;
>
> But after reading the following AdaCore article, my assumption is now
> called into question:
> https://blog.adacore.com/header-storage-pools
>
> In particular, the blog there advocates for separately counting for
> things like unconstrained array First/Last indices or the Prev/Next
> pointers used for Controlled objects. Normally I would have assumed
> that the Size_In_Storage_Elements parameter in Allocate would account
> for that, but the blog clearly shows that it doesn't
[...]

That blog shows a special use for Storage_Pools, where you allocate
/user/ data on top of the requested memory. When called by the compiler,
it is up to the compiler to compute how much memory is needed, and your
duty is to just allocate that.

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr

Re: Custom Storage Pool questions

<bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5905&group=comp.lang.ada#5905

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:81c:: with SMTP id s28mr2389005qks.45.1631580495722;
Mon, 13 Sep 2021 17:48:15 -0700 (PDT)
X-Received: by 2002:a25:3086:: with SMTP id w128mr18904648ybw.139.1631580495526;
Mon, 13 Sep 2021 17:48:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 13 Sep 2021 17:48:15 -0700 (PDT)
In-Reply-To: <shnbn8$5he$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf
NNTP-Posting-Host: 98.118.241.166
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com> <shnbn8$5he$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
Subject: Re: Custom Storage Pool questions
From: jhb.c...@gmail.com (Jere)
Injection-Date: Tue, 14 Sep 2021 00:48:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Jere - Tue, 14 Sep 2021 00:48 UTC

On Monday, September 13, 2021 at 7:12:43 AM UTC-4, J-P. Rosen wrote:
> Le 13/09/2021 à 02:53, Jere a écrit :
> > I was learning about making user defined storage pools when
> > I came across an article that made me pause and wonder how
> > portable storage pools actually can be. In particular, I assumed
> > that the Size_In_Storage_Elements parameter in the Allocate
> > operation actually indicated the total number of storage elements
> > needed.
> >
> > procedure Allocate(
> > Pool : in out Root_Storage_Pool;
> > Storage_Address : out Address;
> > Size_In_Storage_Elements : in Storage_Elements.Storage_Count;
> > Alignment : in Storage_Elements.Storage_Count) is abstract;
> >
> > But after reading the following AdaCore article, my assumption is now
> > called into question:
> > https://blog.adacore.com/header-storage-pools
> >
> > In particular, the blog there advocates for separately counting for
> > things like unconstrained array First/Last indices or the Prev/Next
> > pointers used for Controlled objects. Normally I would have assumed
> > that the Size_In_Storage_Elements parameter in Allocate would account
> > for that, but the blog clearly shows that it doesn't
> [...]
>
> That blog shows a special use for Storage_Pools, where you allocate
> /user/ data on top of the requested memory. When called by the compiler,
> it is up to the compiler to compute how much memory is needed, and your
> duty is to just allocate that.
>
Yes, but if you look at that blog, they are allocating space for the /user/ data
and for the Next/Prev for controlled types and First/Last for unconstrained
arrays in addition to the size specified by allocate.

I agree I feel it is up to the compiler to provide the correct size to Allocate,
but the blog would indicate that GNAT does not (or did not..old blog..so
who knows?). Does the RM require that an implementation pass the full
amount of memory needed to Allocate when new is called?

Re: Custom Storage Pool questions

<036086ba-ea40-44cb-beb7-cded0f501cfbn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5906&group=comp.lang.ada#5906

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ad4:40d1:: with SMTP id x17mr2689400qvp.7.1631581487781;
Mon, 13 Sep 2021 18:04:47 -0700 (PDT)
X-Received: by 2002:a25:4f8a:: with SMTP id d132mr18306877ybb.486.1631581487542;
Mon, 13 Sep 2021 18:04:47 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 13 Sep 2021 18:04:47 -0700 (PDT)
In-Reply-To: <shmnk1$lgf$1@franka.jacob-sparre.dk>
Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf
NNTP-Posting-Host: 98.118.241.166
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com> <shmnk1$lgf$1@franka.jacob-sparre.dk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <036086ba-ea40-44cb-beb7-cded0f501cfbn@googlegroups.com>
Subject: Re: Custom Storage Pool questions
From: jhb.c...@gmail.com (Jere)
Injection-Date: Tue, 14 Sep 2021 01:04:47 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 101
 by: Jere - Tue, 14 Sep 2021 01:04 UTC

On Monday, September 13, 2021 at 1:29:39 AM UTC-4, Randy Brukardt wrote:
> Not sure what you are expecting. There is no requirement that objects are
> allocated contigiously. Indeed, Janus/Ada will call Allocate as many times
> as needed for each object; for instance, unconstrained arrays are in two
> parts (descriptor and data area).
>
No expectations. Just questions. I wasn't concerned with whether the
allocated memory was contiguous or not, but whether an implementation
is required to supply the correct size of memory needed to allocate an object
or if it is allowed to pass a value to Size that is less than the amount of
memory actually needed. For example, the blog there indicates the
maintainer of the custom storage pool needs to account for First/Last
indexes of an unconstrained array separately instead of assuming that value is
included as part of the Size parameter's value.

If the Size parameter doesn't require that it includes space for First/Last
for unconstrained arrays or Prev/Next for controlled objects (assuming
that is even the implementation picked of course), then I'm not seeing
a way to write a custom storage pool that is portable because you need
to account for each implementation's "hidden" values that are not represented
in the Size parameter. For example if Janus calculated Size to have
both the size of the array and the size of First and Last but GNAT didn't
and my storage pool assumed the JANUS method, then if someone
used my storage pool with GNAT then it would access memory
from some other location potentially and erroneously.

> The only thing that you can assume in a portable library is that you get
> called the same number of times and sizes/alignment for Allocate and
> Deallocate; there's no assumptions about size or alignment that you can
> make.
So to be clear, you cannot assume that Size and Alignment are appropriate
for the actual object being allocated correct? Size could actually be
less than the actual amount of memory needed and the alignment may only
apply to part of the object being allocated, not the full object?

Is that correct? I'm asking because that is what the blog suggests with
the example it gave.

>
> If you want to build a pool around some specific allocated size, then if it
> needs to be portable, (A) you have to calculate the allocated size, and (B)
> you have to have a mechanism for what to do if some other size is requested.
> (Allocate a whole block for smaller sizes, fall back to built-in heap for
> too large is what I usually do).
>
Are there any good tricks to handle this? For example, if I design a
storage pool around constructing a particular type of object, what is
normally done to discourage another programmer from using the pool with
an entirely different type? Maybe raise an exception if the size isn't exact?
I'm not sure what else, unless maybe there is an Aspect/Attribute that
can be set to ensure only a specific type of object can be constructed.

HISTORY:
>
>
>
> "Jere" <> wrote in message
> news:e3c5c553-4a7f-408a...@googlegroups.com...
> >I was learning about making user defined storage pools when
> > I came across an article that made me pause and wonder how
> > portable storage pools actually can be. In particular, I assumed
> > that the Size_In_Storage_Elements parameter in the Allocate
> > operation actually indicated the total number of storage elements
> > needed.
> >
> > procedure Allocate(
> > Pool : in out Root_Storage_Pool;
> > Storage_Address : out Address;
> > Size_In_Storage_Elements : in Storage_Elements.Storage_Count;
> > Alignment : in Storage_Elements.Storage_Count) is abstract;
> >
> > But after reading the following AdaCore article, my assumption is now
> > called into question:
> > https://blog.adacore.com/header-storage-pools
> >
> > In particular, the blog there advocates for separately counting for
> > things like unconstrained array First/Last indices or the Prev/Next
> > pointers used for Controlled objects. Normally I would have assumed
> > that the Size_In_Storage_Elements parameter in Allocate would account
> > for that, but the blog clearly shows that it doesn't
> >
> > So that seems to mean to make a storage pool, I have to make it
> > compiler specific or else risk someone creating a type like an
> > array and my allocation size and address values will be off.
> >
> > Is it intended not to be able to do portable Storage Pools or am
> > I missing some Ada functionality that helps me out here. I
> > scanned through the list of attributes but none seem to give
> > any info about where the object's returned address is relative
> > to the top of the memory actually allocated for the object. I saw
> > the attribute Max_Size_In_Storage_Elements, but it doesn't seem
> > to guarantee to include things like the array indices and it still
> > doesn't solve the issue of knowing where the returned address
> > needs to be relative to the top of allocated memory.
> >
> > I can easily use a generic to ensure that the types I care about
> > are portably made by the pool, but I can't prevent someone from
> > using my pool to create other objects that I hadn't accounted for.
> > Unless there is a way to restrict a pool from allocating objects
> > of other types?

Re: Custom Storage Pool questions

<shpe9f$17j$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5907&group=comp.lang.ada#5907

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ros...@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Tue, 14 Sep 2021 08:08:48 +0200
Organization: Adalog
Lines: 36
Message-ID: <shpe9f$17j$1@dont-email.me>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me>
<bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 14 Sep 2021 06:08:47 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="0ecb7a9213884667d432fcf8701789bd";
logging-data="1267"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+23EpNnDl0P+V4ZTWbZ9e9"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:DclbkluBBWqEPQUp0TcKJzZe1I4=
In-Reply-To: <bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
Content-Language: fr
 by: J-P. Rosen - Tue, 14 Sep 2021 06:08 UTC

Le 14/09/2021 à 02:48, Jere a écrit :
>>> In particular, the blog there advocates for separately counting for
>>> things like unconstrained array First/Last indices or the Prev/Next
>>> pointers used for Controlled objects. Normally I would have assumed
>>> that the Size_In_Storage_Elements parameter in Allocate would account
>>> for that, but the blog clearly shows that it doesn't
>> [...]
>>
>> That blog shows a special use for Storage_Pools, where you allocate
>> /user/ data on top of the requested memory. When called by the compiler,
>> it is up to the compiler to compute how much memory is needed, and your
>> duty is to just allocate that.
>>
> Yes, but if you look at that blog, they are allocating space for the /user/ data
> and for the Next/Prev for controlled types and First/Last for unconstrained
> arrays in addition to the size specified by allocate.
>
> I agree I feel it is up to the compiler to provide the correct size to Allocate,
> but the blog would indicate that GNAT does not (or did not..old blog..so
> who knows?). Does the RM require that an implementation pass the full
> amount of memory needed to Allocate when new is called?
>

The RM says that an allocator allocates storage from the storage pool.
You could argue that it does not say "allocates all needed storage...",
but that would be a bit far fetched.

Anyway, a blog is not the proper place to get information from for that
kind of issue. Look at the Gnat documentation.

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr

Re: Custom Storage Pool questions

<shpf4d$1a6s$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5908&group=comp.lang.ada#5908

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Tue, 14 Sep 2021 08:23:08 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shpf4d$1a6s$1@gioia.aioe.org>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me>
<bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="43228"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Tue, 14 Sep 2021 06:23 UTC

On 2021-09-14 02:48, Jere wrote:

> Yes, but if you look at that blog, they are allocating space for the /user/ data
> and for the Next/Prev for controlled types and First/Last for unconstrained
> arrays in addition to the size specified by allocate.

I do not understand your concern. The blog discusses how to add service
data to the objects allocated in the pool.

I use such pools extensively in Simple Components. E.g. linked lists are
implemented this way. The list links are allocated in front of list
elements which can be of any type, unconstrained arrays included.

The problem with unconstrained arrays is not that the bounds are not
allocated, they are, but the semantics of X'Address when applied to arrays.

A'Address is the address of the first array element, not of the array
object. For a pool designer it constitutes a problem of getting the
array object by address. This is what Emmanuel discusses in the blog.

[ The motivation behind Ada choice was probably to keep the semantics
implementation-independent. ]

Consider for example a list of String elements. When Allocate is called
with String, it returns the address of all String. But that is not the
address you would get if you applied 'Address. You have to add/subtract
some offset in order to get one from another.

In Simple Components this offset is determined at run-time for each
generic instance.

Of course, a proper solution would be fixing Ada by adding another
address attribute:

X'Object_Address

returning the first address of the object as allocated.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Custom Storage Pool questions

<shpg9b$t23$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5909&group=comp.lang.ada#5909

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ros...@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Tue, 14 Sep 2021 08:42:52 +0200
Organization: Adalog
Lines: 17
Message-ID: <shpg9b$t23$1@dont-email.me>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me>
<bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
<shpf4d$1a6s$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 14 Sep 2021 06:42:51 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="0ecb7a9213884667d432fcf8701789bd";
logging-data="29763"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+H5nnSiQJSxm1xwYiGS/+K"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:4uy/Bc0Rcckcg1ht8tM64BP4t8Y=
In-Reply-To: <shpf4d$1a6s$1@gioia.aioe.org>
Content-Language: fr
 by: J-P. Rosen - Tue, 14 Sep 2021 06:42 UTC

Le 14/09/2021 à 08:23, Dmitry A. Kazakov a écrit :
> Of course, a proper solution would be fixing Ada by adding another
> address attribute:
>
>    X'Object_Address
>
> returning the first address of the object as allocated.
But you cannot assume that the object is allocated as one big chunk.
Bounds can be allocated at a different place. What would be
X'Object_Address in that case?

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr

Re: Custom Storage Pool questions

<shph9u$6rk$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5912&group=comp.lang.ada#5912

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Tue, 14 Sep 2021 09:00:13 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shph9u$6rk$1@gioia.aioe.org>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me>
<bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
<shpf4d$1a6s$1@gioia.aioe.org> <shpg9b$t23$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="7028"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Tue, 14 Sep 2021 07:00 UTC

On 2021-09-14 08:42, J-P. Rosen wrote:
> Le 14/09/2021 à 08:23, Dmitry A. Kazakov a écrit :
>> Of course, a proper solution would be fixing Ada by adding another
>> address attribute:
>>
>>     X'Object_Address
>>
>> returning the first address of the object as allocated.
> But you cannot assume that the object is allocated as one big chunk.
> Bounds can be allocated at a different place. What would be
> X'Object_Address in that case?

The object address, without bounds, same as X'Address.

What Allocate returns is not what A'Address tells. The compiler always
knows the difference, the programmer have to know it too. Nothing more.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Custom Storage Pool questions

<6db89043-7d5b-4856-b4e5-093219685b9bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5914&group=comp.lang.ada#5914

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:1671:: with SMTP id d17mr4396601qko.191.1631616893248;
Tue, 14 Sep 2021 03:54:53 -0700 (PDT)
X-Received: by 2002:a25:d497:: with SMTP id m145mr21849123ybf.389.1631616893032;
Tue, 14 Sep 2021 03:54:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Tue, 14 Sep 2021 03:54:52 -0700 (PDT)
In-Reply-To: <bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=89.8.134.225; posting-account=uulyKwoAAAA86DO0ODu--rZtbje8Sytn
NNTP-Posting-Host: 89.8.134.225
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me> <bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6db89043-7d5b-4856-b4e5-093219685b9bn@googlegroups.com>
Subject: Re: Custom Storage Pool questions
From: ehh.pub...@gmail.com (Egil H H)
Injection-Date: Tue, 14 Sep 2021 10:54:53 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 28
 by: Egil H H - Tue, 14 Sep 2021 10:54 UTC

On Tuesday, September 14, 2021 at 2:48:16 AM UTC+2, Jere wrote:
>
> Yes, but if you look at that blog, they are allocating space for the /user/ data
> and for the Next/Prev for controlled types and First/Last for unconstrained
> arrays in addition to the size specified by allocate.
>

Yes, but if you look at that blog, they explain the default layout of fat pointers,
and the special value that need to be set on access types for the layout to
change. If you use such a GNAT-ism, your storage pool will also be bound
to GNAT...

ie:
"GNAT typically uses a "fat pointer" for this purpose: the access itself is in fact
a record of two pointers, one of which points to the bounds, the other points to
the data. This representation is not appropriate in the case of the header
storage pool, so we need to change the memory layout here."

and:
"we need to ensure that the bounds for unconstrained arrays are stored next to
the element, not in a separate memory block, to improve performance. This is
done by setting the Size attribute on the type. When we set this size to that of
a standard pointer, GNAT automatically changes the layout,"

--
~egilhh

Re: Custom Storage Pool questions

<fd9b1185-a642-457c-909f-e94d1221759fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5917&group=comp.lang.ada#5917

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:624a:: with SMTP id w71mr7825871qkb.81.1631664701780;
Tue, 14 Sep 2021 17:11:41 -0700 (PDT)
X-Received: by 2002:a25:b782:: with SMTP id n2mr2463284ybh.159.1631664699346;
Tue, 14 Sep 2021 17:11:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Tue, 14 Sep 2021 17:11:38 -0700 (PDT)
In-Reply-To: <6db89043-7d5b-4856-b4e5-093219685b9bn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf
NNTP-Posting-Host: 98.118.241.166
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me> <bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
<6db89043-7d5b-4856-b4e5-093219685b9bn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fd9b1185-a642-457c-909f-e94d1221759fn@googlegroups.com>
Subject: Re: Custom Storage Pool questions
From: jhb.c...@gmail.com (Jere)
Injection-Date: Wed, 15 Sep 2021 00:11:41 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 63
 by: Jere - Wed, 15 Sep 2021 00:11 UTC

On Tuesday, September 14, 2021 at 6:54:54 AM UTC-4, ehh wrote:
> On Tuesday, September 14, 2021 at 2:48:16 AM UTC+2, Jere wrote:
> >
> > Yes, but if you look at that blog, they are allocating space for the /user/ data
> > and for the Next/Prev for controlled types and First/Last for unconstrained
> > arrays in addition to the size specified by allocate.
> >
> Yes, but if you look at that blog, they explain the default layout of fat pointers,
> and the special value that need to be set on access types for the layout to
> change. If you use such a GNAT-ism, your storage pool will also be bound
> to GNAT...
>
>
> ie:
> "GNAT typically uses a "fat pointer" for this purpose: the access itself is in fact
> a record of two pointers, one of which points to the bounds, the other points to
> the data. This representation is not appropriate in the case of the header
> storage pool, so we need to change the memory layout here."
>
> and:
> "we need to ensure that the bounds for unconstrained arrays are stored next to
> the element, not in a separate memory block, to improve performance. This is
> done by setting the Size attribute on the type. When we set this size to that of
> a standard pointer, GNAT automatically changes the layout,"
>

What I am seeing in the blog is if I *do not* use the GNAT ism in my storage pool
and assume that the Size parameter indicates the full size needed, then if someone
uses my pool with a GNAT compiler it would erroneously access memory.

You can clearly see the calculation in the blog is:
Aligned_Size : constant Storage_Count := -- bytes
Size + Header_Allocation + Extra_Offset;

Where Size is specified by Allocate, Header_Allocation is the user supplied fields
of the storage pool, and ***Extra_Offset*** is a separate size value that accounts
for First/Last or Previous/Next

Finalization_Master_Size : constant Storage_Count :=
2 * Standard'Address_Size; -- for Previous and Next
Extra_Offset : constant Storage_Count :=
(Element_Type'Descriptor_Size + Finalization_Master_Size)
/ Storage_Unit; -- convert from bits to bytes

The blog quotes:
"""The size for the bounds is given by the attribute Descriptor_Size. For most types,
the value of this attribute is 0. However, in the case of unconstrained array types, it
is the size of two integers"""

These values are specified separate from the Size parameter and added to it in the
Allocate function shown in the blog there.

If I were to write my own storage pool and I didn't do the Extra_Offset calculation and just
assumed the compiler would call Allocate with the correct Size value for everything,
the logic in that blog then would indicate that GNAT would assume I did the Extra_Offset
calculation anyways and it could access those fields even if I didn't explicitly allocate
them separately as GNAT does. In that case the fields would be part of some other object's
memory or random memory.

My original question is if the intended premise in Ada is that Storage pools aren't expected to be
created to be portable due to just being low level because compilers can just assume
you will know to allocate hidden fields in addition to what the Size parameter specifies.

Does that help clarify what I'm confused on? Sorry, I am not great with wording.

Re: Custom Storage Pool questions

<72b0f8af-8b07-4989-be3f-82d53e729aben@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5918&group=comp.lang.ada#5918

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:6145:: with SMTP id d5mr7403473qtm.197.1631665264798;
Tue, 14 Sep 2021 17:21:04 -0700 (PDT)
X-Received: by 2002:a25:c6c1:: with SMTP id k184mr2557807ybf.277.1631665264575;
Tue, 14 Sep 2021 17:21:04 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Tue, 14 Sep 2021 17:21:04 -0700 (PDT)
In-Reply-To: <shpf4d$1a6s$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf
NNTP-Posting-Host: 98.118.241.166
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me> <bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
<shpf4d$1a6s$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <72b0f8af-8b07-4989-be3f-82d53e729aben@googlegroups.com>
Subject: Re: Custom Storage Pool questions
From: jhb.c...@gmail.com (Jere)
Injection-Date: Wed, 15 Sep 2021 00:21:04 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 20
 by: Jere - Wed, 15 Sep 2021 00:21 UTC

On Tuesday, September 14, 2021 at 2:23:15 AM UTC-4, Dmitry A. Kazakov wrote:
> On 2021-09-14 02:48, Jere wrote:
>
> > Yes, but if you look at that blog, they are allocating space for the /user/ data
> > and for the Next/Prev for controlled types and First/Last for unconstrained
> > arrays in addition to the size specified by allocate.
> I do not understand your concern. The blog discusses how to add service
> data to the objects allocated in the pool.
>
I tried to better articulate my concern in my response to egilhh if you want
to take a quick look at that and see if it clarifies better.

> I use such pools extensively in Simple Components. E.g. linked lists are
> implemented this way. The list links are allocated in front of list
> elements which can be of any type, unconstrained arrays included.
>
The blog I saw was old, so it is completely possible it no longer is
true that GNAT does what the blog suggests. I'll take a look at your
storage pools and see how they handle things like this.

Re: Custom Storage Pool questions

<75749f8d-0f2c-45ef-b45f-fe55500d6bf8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5919&group=comp.lang.ada#5919

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:8287:: with SMTP id e129mr7806288qkd.415.1631666383602;
Tue, 14 Sep 2021 17:39:43 -0700 (PDT)
X-Received: by 2002:a25:c6c1:: with SMTP id k184mr2641480ybf.277.1631666383403;
Tue, 14 Sep 2021 17:39:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Tue, 14 Sep 2021 17:39:43 -0700 (PDT)
In-Reply-To: <shpe9f$17j$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf
NNTP-Posting-Host: 98.118.241.166
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me> <bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
<shpe9f$17j$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <75749f8d-0f2c-45ef-b45f-fe55500d6bf8n@googlegroups.com>
Subject: Re: Custom Storage Pool questions
From: jhb.c...@gmail.com (Jere)
Injection-Date: Wed, 15 Sep 2021 00:39:43 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 60
 by: Jere - Wed, 15 Sep 2021 00:39 UTC

On Tuesday, September 14, 2021 at 2:08:49 AM UTC-4, J-P. Rosen wrote:
> Le 14/09/2021 à 02:48, Jere a écrit :
> >>> In particular, the blog there advocates for separately counting for
> >>> things like unconstrained array First/Last indices or the Prev/Next
> >>> pointers used for Controlled objects. Normally I would have assumed
> >>> that the Size_In_Storage_Elements parameter in Allocate would account
> >>> for that, but the blog clearly shows that it doesn't
> >> [...]
> >>
> >> That blog shows a special use for Storage_Pools, where you allocate
> >> /user/ data on top of the requested memory. When called by the compiler,
> >> it is up to the compiler to compute how much memory is needed, and your
> >> duty is to just allocate that.
> >>
> > Yes, but if you look at that blog, they are allocating space for the /user/ data
> > and for the Next/Prev for controlled types and First/Last for unconstrained
> > arrays in addition to the size specified by allocate.
> >
> > I agree I feel it is up to the compiler to provide the correct size to Allocate,
> > but the blog would indicate that GNAT does not (or did not..old blog..so
> > who knows?). Does the RM require that an implementation pass the full
> > amount of memory needed to Allocate when new is called?
> >
> The RM says that an allocator allocates storage from the storage pool.
> You could argue that it does not say "allocates all needed storage...",
> but that would be a bit far fetched.
I agree, but the blog made reconsider how far fetched it was.

>
> Anyway, a blog is not the proper place to get information from for that
> kind of issue. Look at the Gnat documentation.
> --
I'll take a look at the GNAT docs to see (and of course that blog is old,
so GNAT may not do this anymore anyways), but I mainly asking in the
frame of what Ada allows and/or expects. I'd like to be able to allocate
storage simply without worrying how the compiler does it under the hood
and just assume that any calls to Allocate will ask for the full amount of
memory.

Am I correct to assume that Ada doesn't provide any language means
to restrict what types a pool can make objects of. The times that I have
wanted to make a pool are generally for specific types and it is often
simpler to design them if I can assume only those types are being generated

Thanks for the response. I'm sorry for all the questions. That's how I
learn and I realize it isn't a popular way to learn in the community, but
I have always learned very differently than most.

Re: Custom Storage Pool questions

<shs5ag$12eu$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5920&group=comp.lang.ada#5920

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Wed, 15 Sep 2021 08:54:07 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shs5ag$12eu$1@gioia.aioe.org>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me>
<bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
<shpf4d$1a6s$1@gioia.aioe.org>
<72b0f8af-8b07-4989-be3f-82d53e729aben@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="35294"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Wed, 15 Sep 2021 06:54 UTC

On 2021-09-15 02:21, Jere wrote:
> On Tuesday, September 14, 2021 at 2:23:15 AM UTC-4, Dmitry A. Kazakov wrote:
>> On 2021-09-14 02:48, Jere wrote:
>>
>>> Yes, but if you look at that blog, they are allocating space for the /user/ data
>>> and for the Next/Prev for controlled types and First/Last for unconstrained
>>> arrays in addition to the size specified by allocate.
>> I do not understand your concern. The blog discusses how to add service
>> data to the objects allocated in the pool.
>>
> I tried to better articulate my concern in my response to egilhh if you want
> to take a quick look at that and see if it clarifies better.

Not really. It seems that you are under impression that Allocate must
allocate more size than its Size parameter asks. The answer is no,
unless *you* wanted to add something to each allocated object.

>> I use such pools extensively in Simple Components. E.g. linked lists are
>> implemented this way. The list links are allocated in front of list
>> elements which can be of any type, unconstrained arrays included.
>>
> The blog I saw was old, so it is completely possible it no longer is
> true that GNAT does what the blog suggests. I'll take a look at your
> storage pools and see how they handle things like this.

I calculate the offset at run time. I keep the list of recently
allocated blocks. The first time the address is asked from an element,
that is, the first time an element allocated in the pool becomes known
to the pool, its address is searched through the list of blocks. The
minimal difference between the block address and the element address
(X'Address) is the offset.

This is more portable than GNAT-specific attribute Descriptor_Size.

Again, if attributes to be added, then it should be the object address
as allocated. The compiler always knows the proper address because this
address is passed to Free, not X'Address!

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Custom Storage Pool questions

<lyee9qb9up.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5921&group=comp.lang.ada#5921

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!RKN7TKnHC01q0gdg6EhkbQ.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Wed, 15 Sep 2021 08:01:50 +0100
Organization: Aioe.org NNTP Server
Message-ID: <lyee9qb9up.fsf@pushface.org>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me>
<bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
<shpe9f$17j$1@dont-email.me>
<75749f8d-0f2c-45ef-b45f-fe55500d6bf8n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="41372"; posting-host="RKN7TKnHC01q0gdg6EhkbQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
Cancel-Lock: sha1:W29s7/Ogv6o7Ee7F3OJHeQKS+4o=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Simon Wright - Wed, 15 Sep 2021 07:01 UTC

Jere <jhb.chat@gmail.com> writes:

> Thanks for the response. I'm sorry for all the questions. That's how
> I learn and I realize it isn't a popular way to learn in the
> community, but I have always learned very differently than most.

Seems to me you ask interesting questions which generate enlightening
responses!

Re: Custom Storage Pool questions

<ly5yv1bxgy.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5923&group=comp.lang.ada#5923

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!RKN7TKnHC01q0gdg6EhkbQ.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Wed, 15 Sep 2021 17:43:57 +0100
Organization: Aioe.org NNTP Server
Message-ID: <ly5yv1bxgy.fsf@pushface.org>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="26662"; posting-host="RKN7TKnHC01q0gdg6EhkbQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
Cancel-Lock: sha1:NWesgLrxYwRv5Lz7vejus3LXCjk=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Simon Wright - Wed, 15 Sep 2021 16:43 UTC

Jere <jhb.chat@gmail.com> writes:

> But after reading the following AdaCore article, my assumption is now
> called into question:
> https://blog.adacore.com/header-storage-pools
>
> In particular, the blog there advocates for separately counting for
> things like unconstrained array First/Last indices or the Prev/Next
> pointers used for Controlled objects. Normally I would have assumed
> that the Size_In_Storage_Elements parameter in Allocate would account
> for that, but the blog clearly shows that it doesn't

Well, I may well have missed the point somewhere, and maybe things have
changed since 2015, but as far as I can see, with FSF GCC 11.1.0, the
technique described in the blog is completely unnecessary.

To save having to recompile the runtime with debug symbols, I wrote a
tiny pool which delegates to GNAT's
System.Pool_Global.Global_Pool_Object (the default pool), e.g.

overriding procedure Allocate
(Pool : in out My_Pool.Pool;
Storage_Address : out Address;
Size_In_Storage_Elements : in Storage_Elements.Storage_Count;
Alignment : in Storage_Elements.Storage_Count)
is
pragma Unreferenced (Pool);
begin
Global_Pool_Object.Allocate
(Address => Storage_Address,
Storage_Size => Size_In_Storage_Elements,
Alignment => Alignment);
end Allocate;

and I find with

Pool : My_Pool.Pool;

type C is new Ada.Finalization.Controlled with null record;
type Cs is array (Natural range <>) of C;
type Csp is access Cs with Storage_Pool => Pool;
procedure Free is new Ada.Unchecked_Deallocation (Cs, Csp);
Pcs : Csp;

begin

Pcs := new Cs (0 .. 5);
Free (Pcs);

that

* the alignment requested is 8 (was 4 for an array of Boolean);
* the size requested is 72, which is 24 bytes more than required for the
6 minimal POs;
* the value returned by Allocate is 24 bytes more than the address of
the array object Pcs (which is the same as that of Pcs(0));
* the value passed to Deallocate is the same as that returned by
Allocate.

I think it's more than likely (!) that the extra allocation of 24 bytes
is made up of 2 pointers at 8 bytes each, used to implement the
finalization chain, and two integers at 4 bytes each, holding the array
bounds.

So I'd say that to create a pool with extra header information, you'd
need to allocate space for your header + padding to ensure that the
compiler's object is properly aligned + the compiler-requested size,
aligned to the max of your header's alignment and the compiler-requested
alignment.

Mind, I don't quite see how to actually access the header info for a
particular allocation ...

Re: Custom Storage Pool questions

<ly1r5pbwk0.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5924&group=comp.lang.ada#5924

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!RKN7TKnHC01q0gdg6EhkbQ.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Wed, 15 Sep 2021 18:03:43 +0100
Organization: Aioe.org NNTP Server
Message-ID: <ly1r5pbwk0.fsf@pushface.org>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<ly5yv1bxgy.fsf@pushface.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="45775"; posting-host="RKN7TKnHC01q0gdg6EhkbQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:tX38ZtGrsd6VRtyc8UdsvNK9kSM=
 by: Simon Wright - Wed, 15 Sep 2021 17:03 UTC

Simon Wright <simon@pushface.org> writes:

> Well, I may well have missed the point somewhere, and maybe things
> have changed since 2015, but as far as I can see, with FSF GCC 11.1.0,
> the technique described in the blog is completely unnecessary.

Looking at the current implementation in [1] it seems that I was right
(I don't quite follow the complication of Typed.Header_Of at line 114;
goes to show that if you're writing the compiler you can add attributes
whenever it suits you, even if IMO they weren't actually needed)

[1] https://github.com/AdaCore/gnatcoll-core/blob/master/src/gnatcoll-storage_pools-headers.adb

Re: Custom Storage Pool questions

<shtg99$tgd$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5925&group=comp.lang.ada#5925

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Wed, 15 Sep 2021 21:07:22 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shtg99$tgd$1@gioia.aioe.org>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<ly5yv1bxgy.fsf@pushface.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="30221"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Wed, 15 Sep 2021 19:07 UTC

On 2021-09-15 18:43, Simon Wright wrote:

> To save having to recompile the runtime with debug symbols, I wrote a
> tiny pool which delegates to GNAT's
> System.Pool_Global.Global_Pool_Object (the default pool), e.g.
>
> overriding procedure Allocate
> (Pool : in out My_Pool.Pool;
> Storage_Address : out Address;
> Size_In_Storage_Elements : in Storage_Elements.Storage_Count;
> Alignment : in Storage_Elements.Storage_Count)
> is
> pragma Unreferenced (Pool);
> begin
> Global_Pool_Object.Allocate
> (Address => Storage_Address,
> Storage_Size => Size_In_Storage_Elements,
> Alignment => Alignment);
> end Allocate;
>
> and I find with
>
> Pool : My_Pool.Pool;
>
> type C is new Ada.Finalization.Controlled with null record;
> type Cs is array (Natural range <>) of C;
> type Csp is access Cs with Storage_Pool => Pool;

Now define and implement the following function:

function Get_Allocation_Time (Pointer : Csp) return Time;

The function returns the time when the pointed object was allocated in
the pool.

[...]

> Mind, I don't quite see how to actually access the header info for a
> particular allocation ...

By subtracting a fixed offset from Pointer.all'Address. The offset is to
be determined, because X'Address lies.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Custom Storage Pool questions

<lywnnha7y1.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5926&group=comp.lang.ada#5926

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!RKN7TKnHC01q0gdg6EhkbQ.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Wed, 15 Sep 2021 21:40:38 +0100
Organization: Aioe.org NNTP Server
Message-ID: <lywnnha7y1.fsf@pushface.org>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<ly5yv1bxgy.fsf@pushface.org> <shtg99$tgd$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="48561"; posting-host="RKN7TKnHC01q0gdg6EhkbQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
Cancel-Lock: sha1:cQ9exVwmtOU5z5yXiiU1/g9GJFc=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Simon Wright - Wed, 15 Sep 2021 20:40 UTC

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

>> Mind, I don't quite see how to actually access the header info for a
>> particular allocation ...
>
> By subtracting a fixed offset from Pointer.all'Address. The offset is
> to be determined, because X'Address lies.

Obvs.

But my main point was, the blog which was Jere's original problem is in
fact (now?) wrong.

Anyway, the Gnatcoll solution is here ...
https://github.com/AdaCore/gnatcoll-core/blob/master/src/gnatcoll-storage_pools-headers.adb#L114

Re: Custom Storage Pool questions

<1d2551f4-8189-44ec-a54d-4a56a672bedcn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5927&group=comp.lang.ada#5927

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:6214:13ee:: with SMTP id ch14mr3943974qvb.43.1631776379270;
Thu, 16 Sep 2021 00:12:59 -0700 (PDT)
X-Received: by 2002:a25:af49:: with SMTP id c9mr5176173ybj.432.1631776378968;
Thu, 16 Sep 2021 00:12:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 16 Sep 2021 00:12:58 -0700 (PDT)
In-Reply-To: <lywnnha7y1.fsf@pushface.org>
Injection-Info: google-groups.googlegroups.com; posting-host=87.88.29.208; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH
NNTP-Posting-Host: 87.88.29.208
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<ly5yv1bxgy.fsf@pushface.org> <shtg99$tgd$1@gioia.aioe.org> <lywnnha7y1.fsf@pushface.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1d2551f4-8189-44ec-a54d-4a56a672bedcn@googlegroups.com>
Subject: Re: Custom Storage Pool questions
From: briot.em...@gmail.com (Emmanuel Briot)
Injection-Date: Thu, 16 Sep 2021 07:12:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 36
 by: Emmanuel Briot - Thu, 16 Sep 2021 07:12 UTC

I am the original implementor of GNATCOLL.Storage_Pools.Headers, and I have been silent in this discussion because I must admit I forgot a lot of the details... To be sure, we did not add new attributes just for the sake of GNATCOLL, those existed previously so likely had already found other uses.

As has been mentioned several time in the discussion, the compiler is already passing the full size it needs to Allocate, and the storage pool only needs to allocate that exact amount in general. This applies for the usual kinds of storage pools, which would for instance preallocate a pool for objects of fixed sizes, or add stronger alignment requirements.

In the case of the GNATCOLL headers pool, we need to allocate more because the user wants to store extra data. For that data, we are left on our own to find the number of bytes we need, which is part of the computation we do: we of course need the number of bytes for the header's object_size, but also perhaps some extra bytes that are not returned by that object_size in particular for controlled types and arrays.
Note again that those additional bytes are for the header type, not for the type the user is allocating (for which, again, the compiler already passes the number of bytes it needs).

The next difficulty is then to convert from the object's 'Address back to your extra header data. This is when you need to know the size of the prefix added by the compiler (array bounds, tag,...) to skip them and then take into account the alignment, and finally the size of your header.
Dmitry's suggested exercice (storing the timestamp of the allocation) seems like a useful one indeed. It would be nice indeed if GNATCOLL's code was too complicated, but I am afraid this isn't the case. We had used those pools to implement reference counting for various complex types, and ended up with that complexity.

AdaCore (Olivier Hainque) has made a change to the implementation since the blog was published (https://github.com/AdaCore/gnatcoll-core/commits/master/src/gnatcoll-storage_pools-headers.adb), so I got some details wrong in the initial implementation apparently.

Emmanuel

Re: Custom Storage Pool questions

<shv006$g9s$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5928&group=comp.lang.ada#5928

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Thu, 16 Sep 2021 10:41:41 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shv006$g9s$1@gioia.aioe.org>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<ly5yv1bxgy.fsf@pushface.org> <shtg99$tgd$1@gioia.aioe.org>
<lywnnha7y1.fsf@pushface.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="16700"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Thu, 16 Sep 2021 08:41 UTC

On 2021-09-15 22:40, Simon Wright wrote:

> But my main point was, the blog which was Jere's original problem is in
> fact (now?) wrong.

Right, when nothing to be added to the allocated object, there is
nothing to worry about.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Custom Storage Pool questions

<c2d59417-398f-42a0-ab4b-b4f947325be0n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5933&group=comp.lang.ada#5933

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:a094:: with SMTP id j142mr7674563qke.465.1631834519397;
Thu, 16 Sep 2021 16:21:59 -0700 (PDT)
X-Received: by 2002:a25:8409:: with SMTP id u9mr271127ybk.159.1631834519137;
Thu, 16 Sep 2021 16:21:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 16 Sep 2021 16:21:58 -0700 (PDT)
In-Reply-To: <1d2551f4-8189-44ec-a54d-4a56a672bedcn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf
NNTP-Posting-Host: 98.118.241.166
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<ly5yv1bxgy.fsf@pushface.org> <shtg99$tgd$1@gioia.aioe.org>
<lywnnha7y1.fsf@pushface.org> <1d2551f4-8189-44ec-a54d-4a56a672bedcn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c2d59417-398f-42a0-ab4b-b4f947325be0n@googlegroups.com>
Subject: Re: Custom Storage Pool questions
From: jhb.c...@gmail.com (Jere)
Injection-Date: Thu, 16 Sep 2021 23:21:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 29
 by: Jere - Thu, 16 Sep 2021 23:21 UTC

On Thursday, September 16, 2021 at 3:13:00 AM UTC-4, Emmanuel wrote:
> In the case of the GNATCOLL headers pool, we need to allocate more because the user wants to store extra data. For that data, we are left on our own to find the number of bytes we need, which is part of the computation we do: we of course need the number of bytes for the header's object_size, but also perhaps some extra bytes that are not returned by that object_size in particular for controlled types and arrays.
> Note again that those additional bytes are for the header type, not for the type the user is allocating (for which, again, the compiler already passes the number of bytes it needs).
>
> <SNIPEED>
> Emmanuel

Thanks for the response Emmanuel. That clears it up for me. I think the confusion for me
came from the terminology used then. In the blog, that extra space for First/Last and Prev/Next
was mentioned as if it were for the element, which I mistook was the user's object being allocated
and not the header portion. I didn't catch that as the generic formal's name, so that is my mistake.
I guess in my head, I would have expected the formal name to be Header_Type or similar so I
misread it in my haste.

I appreciate the clarity and apologize if I caused too much of a stir. I was asking the question
because I didn't understand, so I hope you don't think too poorly of me for it, despite my mistake.

Re: Custom Storage Pool questions

<96e7199f-c354-402f-a6c6-2a0e042b6747n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5934&group=comp.lang.ada#5934

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:f902:: with SMTP id l2mr7611550qkj.511.1631835172694;
Thu, 16 Sep 2021 16:32:52 -0700 (PDT)
X-Received: by 2002:a05:6902:1549:: with SMTP id r9mr9993366ybu.204.1631835172535;
Thu, 16 Sep 2021 16:32:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 16 Sep 2021 16:32:52 -0700 (PDT)
In-Reply-To: <lyee9qb9up.fsf@pushface.org>
Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf
NNTP-Posting-Host: 98.118.241.166
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<shnbn8$5he$1@dont-email.me> <bec26cfe-a7c3-49b9-8272-9f08be93d7fdn@googlegroups.com>
<shpe9f$17j$1@dont-email.me> <75749f8d-0f2c-45ef-b45f-fe55500d6bf8n@googlegroups.com>
<lyee9qb9up.fsf@pushface.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <96e7199f-c354-402f-a6c6-2a0e042b6747n@googlegroups.com>
Subject: Re: Custom Storage Pool questions
From: jhb.c...@gmail.com (Jere)
Injection-Date: Thu, 16 Sep 2021 23:32:52 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 18
 by: Jere - Thu, 16 Sep 2021 23:32 UTC

On Wednesday, September 15, 2021 at 3:01:52 AM UTC-4, Simon Wright wrote:
> Jere <> writes:
>
> > Thanks for the response. I'm sorry for all the questions. That's how
> > I learn and I realize it isn't a popular way to learn in the
> > community, but I have always learned very differently than most.
> Seems to me you ask interesting questions which generate enlightening
> responses!
Thanks! though in this case, my question was ill formed after I missed a detail
in the blog, so the mistake is on me. I will say I hold back some questions
as it is very intimidating to ask on C.L.A. I mean the first response led off
with "Not sure what you are expecting" so it is hard to know how to formulate
a good question as I always seem to get some harsh responses (which I am
sure is because I asked the question poorly). I'm unfortunately a very visual
person and words are not my forte and I feel like when I ask questions about
the boundaries of the language I manage to put folks on the defensive. I
don't dislike Ada at all, it is my favorite language, but I think it is hard to
craft questions on some topics without putting forth the impression that
I don't like it, at least with my limited ability to word craft.

Re: Custom Storage Pool questions

<a22fca55-489e-4a33-91cf-d19ef4f36460n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5935&group=comp.lang.ada#5935

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:448e:: with SMTP id x14mr8945837qkp.526.1631862527025; Fri, 17 Sep 2021 00:08:47 -0700 (PDT)
X-Received: by 2002:a5b:b04:: with SMTP id z4mr10910097ybp.457.1631862526694; Fri, 17 Sep 2021 00:08:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Fri, 17 Sep 2021 00:08:46 -0700 (PDT)
In-Reply-To: <c2d59417-398f-42a0-ab4b-b4f947325be0n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.88.29.208; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH
NNTP-Posting-Host: 87.88.29.208
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com> <ly5yv1bxgy.fsf@pushface.org> <shtg99$tgd$1@gioia.aioe.org> <lywnnha7y1.fsf@pushface.org> <1d2551f4-8189-44ec-a54d-4a56a672bedcn@googlegroups.com> <c2d59417-398f-42a0-ab4b-b4f947325be0n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a22fca55-489e-4a33-91cf-d19ef4f36460n@googlegroups.com>
Subject: Re: Custom Storage Pool questions
From: briot.em...@gmail.com (Emmanuel Briot)
Injection-Date: Fri, 17 Sep 2021 07:08:46 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 12
 by: Emmanuel Briot - Fri, 17 Sep 2021 07:08 UTC

> Thanks for the response Emmanuel. That clears it up for me. I think the confusion for me
> came from the terminology used then. In the blog, that extra space for First/Last and Prev/Next
> was mentioned as if it were for the element, which I mistook was the user's object being allocated
> and not the header portion. I didn't catch that as the generic formal's name, so that is my mistake.
> I guess in my head, I would have expected the formal name to be Header_Type or similar so I
> misread it in my haste.

Sure, and maybe the blog was not as readable as it should have been. Unfortunately I no longer have
any possibility to amend it, so I guess we'll live with it !

Thanks for the questions

Emmanuel

Re: Custom Storage Pool questions

<lysfy3acw3.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5936&group=comp.lang.ada#5936

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!RKN7TKnHC01q0gdg6EhkbQ.user.46.165.242.75.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Custom Storage Pool questions
Date: Fri, 17 Sep 2021 08:18:20 +0100
Organization: Aioe.org NNTP Server
Message-ID: <lysfy3acw3.fsf@pushface.org>
References: <e3c5c553-4a7f-408a-aaa7-60ec0b70202dn@googlegroups.com>
<ly5yv1bxgy.fsf@pushface.org> <shtg99$tgd$1@gioia.aioe.org>
<lywnnha7y1.fsf@pushface.org>
<1d2551f4-8189-44ec-a54d-4a56a672bedcn@googlegroups.com>
<c2d59417-398f-42a0-ab4b-b4f947325be0n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="5323"; posting-host="RKN7TKnHC01q0gdg6EhkbQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:qovlyQ67V95KqdBkck7o8Nxizp4=
 by: Simon Wright - Fri, 17 Sep 2021 07:18 UTC

Jere <jhb.chat@gmail.com> writes:

> On Thursday, September 16, 2021 at 3:13:00 AM UTC-4, Emmanuel wrote:
>> In the case of the GNATCOLL headers pool, we need to allocate more
>> because the user wants to store extra data. For that data, we are
>> left on our own to find the number of bytes we need, which is part of
>> the computation we do: we of course need the number of bytes for the
>> header's object_size, but also perhaps some extra bytes that are not
>> returned by that object_size in particular for controlled types and
>> arrays.
>> Note again that those additional bytes are for the header type, not
>> for the type the user is allocating (for which, again, the compiler
>> already passes the number of bytes it needs).

> Thanks for the response Emmanuel. That clears it up for me. I think
> the confusion for me came from the terminology used then. In the
> blog, that extra space for First/Last and Prev/Next was mentioned as
> if it were for the element, which I mistook was the user's object
> being allocated and not the header portion. I didn't catch that as
> the generic formal's name, so that is my mistake.

Given this diagram from the blog, you can hardly be blamed (says a
person who leapt to the same conclusion):
+--------+-------+------+----------+------+---------+
| Header | First | Last | Previous | Next | Element |
+--------+-------+------+----------+------+---------+

Pages:1234
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor