http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48835

--- Comment #10 from Mikael Pettersson <mikpe at it dot uu.se> 2011-06-14 
08:12:54 UTC ---
(In reply to comment #9)
> > - __gnat_malloc is defined in Ada to return Address (integer, so in d0), but
> > it's called from a couple of places via fake "extern" declarations that 
> > pretend
> > it returns void* (pointer, so in a0).  The attached patch fixes the two call
> > sites affected (in Interfaces.C.Strings and build_call_alloc_dealloc), as 
> > well
> > as the internal fake prototype (init_gigi_decls).
> > - Source code inspection showed that get_jmpbuf_address probably suffers 
> > from
> > the same issue (mismatching decl and use via wrong intermediate fake 
> > prototype)
> > so I fixed that too.
> 
> I don't think that we want __gnat_malloc to return anything else than a 
> pointer
> in the GCC representation.  Its DECL node is DECL_IS_MALLOC and had better
> mimic a canonical malloc as much as possible.

In that case the Ada side of __gnat_malloc has to be changed to use a pointer
type rather than Address.  Is Interfaces.C.Strings.chars_ptr acceptible, or is
there a better approximation for void* somewhere?

> Andreas mentioned a compatibility trick in comment #6.  How is it implemented?

The effect is that a pointer-valued callee returns its value in both %a0 and
%d0.  A caller that has seen the pointer-valued prototype picks up the value
from %a0, but a caller that hasn't seen that prototype picks it up from %d0. 
The actual implementation is in m68k_function_value.

Reply via email to