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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8ecbc35ea893182f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.germany.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Interfacing to C: big structures Date: Fri, 29 Feb 2008 11:45:32 +0100 Message-ID: <62q62hF24r7d6U1@mid.individual.net> References: <62idb0F23ddfnU1@mid.individual.net> <56a177e4-506f-4bc8-a531-7f2dd15d50c8@i7g2000prf.googlegroups.com> <21af9a6a-d522-4ba5-9d67-68eace9cd1b1@n77g2000hse.googlegroups.com> <62nkanF24b2toU1@mid.individual.net> Reply-To: alejandro@mosteo.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net v5PKIOClCTfdqq4EACWmOgOowTghLvwrp1xTPFy+b2JsGLiwk= Cancel-Lock: sha1:5pANTCrVjNrYuqskl3puXgbJBNA= User-Agent: Thunderbird 2.0.0.12 (X11/20080227) In-Reply-To: Xref: g2news1.google.com comp.lang.ada:20144 Date: 2008-02-29T11:45:32+01:00 List-Id: Robert A Duff wrote: > "Alex R. Mosteo" writes: > >> Actually I would have expected these types to be allocated in the stack. > > Me, too. > >> I likened them to indefinite types, but certainly the maximum size of >> some indefinite types may be known at compile time, so this set them >> apart and I was simplifying too much. Besides, at least one >> implementation, as Randy Brukardt said, uses the heap for them. Even if >> it's the compiler doing the management, this may be a no-go in some real >> time environments. >> >> Using the heap may be easier for an implementation; ... > > Yes. > >> ...another question is >> if it is still doable in the stack. > > Yes, it is doable. > >> ...I wonder what gnat does. > > Puts it on the primary stack. > >> ...Is the >> secondary gnat stack considered a kind of heap? > > No. It's a stack. > >> ...Is this what gnat uses? > > No. The secondary stack is for objects of unknown size that > are returned as function results. I think GNAT also uses > it in some other cases, such as records containing > controlled parts. > >> Are there pragma Restrictions that could clarify this? > > You can say: > > pragma Restrictions (No_Implicit_Heap_Allocations); > >> ...Just throwing >> questions in the air. >> >> I guess that if my proposal is deemed unacceptable, one can neither use >> anymore things like >> >> type T (Len : Natural) is record >> Name : String (1 .. Len); >> Others : Whatever; >> -- ... >> end record; > > There are certainly cases where the above should not be used with > "Len => ", because it prevents you from > calculating the maximum stack size for each task. Or, you can > calculate it, but the answer is "the size of the address space", > which isn't very useful. > > It might be OK if you change Natural to a range 1..100. Thanks for that great a deal of information!