comp.lang.ada
 help / color / mirror / Atom feed
* Allocating memory for class-wide types with Aonix Raven PPC cross-compiler
@ 2004-03-10 13:58 Paul Nardini
  2004-03-10 20:37 ` Simon Wright
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Nardini @ 2004-03-10 13:58 UTC (permalink / raw)


We use the Raven compiler in my office, and I have some code which
attempts to instantiate a doubly linked list package with a class-wide
type.  The list package allocates / deallocates space for the items
placed on the list in a custom memory pool though an access type
passed in as a generic formal parameter with the list's data type. 
The access type I am passing at instantiation is the access type
corresponding to the class-wide type I am passing the generic.  A
snippet of what I am trying to do is below:

type FOO_TYPE is tagged record
    FIELD1 : INTEGER;
end record;

type BAR_TYPE is new FOO_TYPE with record
    FIELD2 : INTEGER;
end record;

type FOO_ACCESS_TYPE is access FOO_TYPE'Class;

-- MY_STORAGE_POOL is a finite pool used only by the list class where
allocation
-- and deallocation are allowed.
for FOO_ACCESS_TYPE'Storage_Pool use MY_STORAGE_POOL;

generic
    DATA_TYPE(<>) is tagged private;
    DATA_ACCESS_TYPE is access DATA_TYPE;
    SIZE : POSITIVE := 256
package List is 
   
 ...

procedure Free is new Ada.Unchecked_Deallocation(DATA_TYPE,
DATA_ACCESS_TYPE);
  
procedure Add_To_Tail(ITEM : in DATA_TYPE) is
begin

 ...
 -- DATA_PTR is of type DATA_ACCESS_TYPE
 NEW_TAIL_PTR.DATA_PTR := new DATA_TYPE'(ITEM);

end Add_To_Tail;

procedure Delete(ITEM : in ITERATOR) is
begin

  ...
  -- DATA_PTR is of type DATA_ACCESS_TYPE
  Free(ITEM.DATA_PTR);
end Delete;

...

end List;

package My_List is new List(FOO_TYPE'Class,
                            FOO_ACCESS_TYPE.
                            256);

The code is written for a messaging framework where the type of the
message coming in is only known to be of the messaging class; the
message is taken off the list and dispatched to a handler according to
its 'Tag attribute.

The code compiles fine under the Raven PowerPC cross-compiler, but
when I go to link it I get errors stating that the following symbols
are undefined:

Rts_tagged_finalize_and_deallocate_from_pool
Rts_classwide_allocate_from_pool_and_assign

The undefined procedures are called whenever I do allocation /
deallocation of an element on the list.  I have this same list package
instantiated for non-classwide types, and those link fine.  It is only
when I try to use the instantiation for the class-wide type do I have
a problem.  Has anyone had similar linker problems occur?  If so, how
did you resolve them, if they are resolvable at all?  It appears that
I am starting to hit a wall, so any help that anyone can offer would
be greatly appreciated.

Thanks,
Paul Nardini
paul.nardini@itt.com



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Allocating memory for class-wide types with Aonix Raven PPC cross-compiler
  2004-03-10 13:58 Allocating memory for class-wide types with Aonix Raven PPC cross-compiler Paul Nardini
@ 2004-03-10 20:37 ` Simon Wright
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Wright @ 2004-03-10 20:37 UTC (permalink / raw)


paul.nardini@itt.com (Paul Nardini) writes:

> generic
>     DATA_TYPE(<>) is tagged private;
>     DATA_ACCESS_TYPE is access DATA_TYPE;
>     SIZE : POSITIVE := 256
> package List is 

> package My_List is new List(FOO_TYPE'Class,
>                             FOO_ACCESS_TYPE.
>                             256);

I would have thought your vendor's tech support would be more likely
to know .. the service tends not to be cheap, use it!

That said, although GNAT compiles a little example something like this
fine, I'm surprised .. I qouldn't have expected FOO_TYPE'Class to
match "tagged"?

-- 
Simon Wright                               100% Ada, no bugs.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-03-10 20:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-10 13:58 Allocating memory for class-wide types with Aonix Raven PPC cross-compiler Paul Nardini
2004-03-10 20:37 ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox