From: "Alex R. Mosteo" <amosteo@unizar.es>
Subject: Re: Interfacing to C: big structures
Date: Fri, 29 Feb 2008 11:45:32 +0100
Date: 2008-02-29T11:45:32+01:00 [thread overview]
Message-ID: <62q62hF24r7d6U1@mid.individual.net> (raw)
In-Reply-To: <wccmyplgjri.fsf@shell01.TheWorld.com>
Robert A Duff wrote:
> "Alex R. Mosteo" <amosteo@unizar.es> 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 => <dynamic expression>", 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!
next prev parent reply other threads:[~2008-02-29 10:45 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-25 21:17 Interfacing to C: big structures Maciej Sobczak
2008-02-25 23:26 ` Randy Brukardt
2008-02-25 23:26 ` Randy Brukardt
2008-02-27 13:23 ` Maciej Sobczak
2008-02-25 23:26 ` Randy Brukardt
2008-02-25 23:43 ` Robert A Duff
2008-02-26 13:53 ` Stephen Leake
2008-02-26 21:12 ` Randy Brukardt
2008-02-26 2:36 ` Steve
2008-02-26 12:00 ` Alex R. Mosteo
2008-02-26 14:05 ` Robert A Duff
2008-02-26 15:19 ` Alex R. Mosteo
2008-02-26 15:33 ` Robert A Duff
2008-02-26 16:21 ` Alex R. Mosteo
2008-02-27 1:28 ` Robert A Duff
2008-03-10 1:38 ` David Thompson
2008-02-26 17:35 ` Adam Beneschan
2008-02-26 19:47 ` Simon Wright
2008-02-26 21:14 ` Randy Brukardt
2008-02-27 1:40 ` Robert A Duff
2008-02-27 17:12 ` Adam Beneschan
2008-02-27 20:37 ` Simon Wright
2008-02-28 11:30 ` Alex R. Mosteo
2008-02-28 15:53 ` Robert A Duff
2008-02-29 10:45 ` Alex R. Mosteo [this message]
2008-02-27 1:37 ` Robert A Duff
2008-02-27 13:49 ` Maciej Sobczak
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox