This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cosure return value issue on Linux PPC64


On 27/05/17 17:59, Kaz Kylheku (libffi) wrote:
> 
> The problem is that all the big endian cases are expecting the caller to 
> place the return value at a displaced address.  If the type is int, for 
> instance, the expectation is that the return value is to be stored at 
> *(int *)(retval + 4).  If it is short, then at *(short *)(retval + 6) 
> and so on.
> 
> Is this documented somewhere?
> 
> My code is storing everything at just the retval base address, 
> regardless of size.

On a 64-bit target, use word loads for your return values and cast them
accordingly.  So, don't use

  *(int *)(retval + 4)

use

  (int)*retval

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]