public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: "Kaz Kylheku \(libffi\)" <382-725-6798@kylheku.com>
Cc: libffi-discuss@sourceware.org
Subject: Re: Cosure return value issue on Linux PPC64
Date: Mon, 29 May 2017 12:31:00 -0000	[thread overview]
Message-ID: <8737bnetf4.fsf@bapiya> (raw)
In-Reply-To: <53985e874a349c551e7943677d21c766@mail.kylheku.com> (Kaz	Kylheku's message of "Sat, 27 May 2017 09:59:36 -0700")

Kaz> Is this documented somewhere?

A while back I tried to document all these little oddities in the
manual.  It's difficult and ABI-breaking to fix libffi to be more in
line with user expectation, but at least in the meantime the docs can be
correct...

The closure docs say:

    @item ret
    [...]
    Otherwise, @var{fun} must fill the object to which this points,
    following the same special promotion behavior as @code{ffi_call}.
    That is, in most cases, @var{ret} points to an object of exactly the
    size of the type specified when @var{cif} was constructed.  However,
    integral types narrower than the system register size are widened.  In
    these cases your program may assume that @var{ret} points to an
    @code{ffi_arg} object.

I hope this helps, but if it's still insufficiently clear, I'd
appreciate suggestions for how to improve it.

From your other note:

Kaz> I'm not a complete idiot; I was taken for a ride by the simple
Kaz> example from some (perhaps outdated?) libffi texinfo
Kaz> documentation. This one:

You're definitely not an idiot, this has bitten many people, has been
asked on StackOverflow, has been filed as a bug in github a few times,
etc.

Alan Modra fixed up this documentation example back in 2013, according
to git blame.  Seems like libffi is overdue for a release :-)

Anyway, I think the in-tree docs should be a bit clearer here.  For
example they mention the promotion behavior now.

Tom

  parent reply	other threads:[~2017-05-29 12:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-27 16:59 Kaz Kylheku (libffi)
2017-05-29  7:44 ` Andrew Haley
2017-05-29 12:31 ` Tom Tromey [this message]
2017-05-29 15:30   ` Andrew Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8737bnetf4.fsf@bapiya \
    --to=tom@tromey.com \
    --cc=382-725-6798@kylheku.com \
    --cc=libffi-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).