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,8ecbc35ea893182f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!solaris.cc.vt.edu!news.vt.edu!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Interfacing to C: big structures Date: Thu, 28 Feb 2008 10:53:21 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: 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> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1204214005 5703 192.74.137.71 (28 Feb 2008 15:53:25 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 28 Feb 2008 15:53:25 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:UnyWdwvCEVQWsDKOIJukcUb7868= Xref: g2news1.google.com comp.lang.ada:20140 Date: 2008-02-28T10:53:21-05:00 List-Id: "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. - Bob