public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Anthony Green <green@moxielogic.com>
To: jhi@iki.fi
Cc: Andrew Haley <aph@redhat.com>,
	libffi-discuss <libffi-discuss@sourceware.org>
Subject: Re: How to call 'printf' using libffi?
Date: Fri, 19 Mar 2021 07:33:29 -0400	[thread overview]
Message-ID: <CACxje58N83O2t7EKpTPZdOY=-kZ9bFdAhDYO-F5RgMAkWUq-6Q@mail.gmail.com> (raw)
In-Reply-To: <fdf82738-c452-dc46-b725-256358eaee3f@iki.fi>

On Fri, Mar 19, 2021 at 7:26 AM Jarkko Hietaniemi <jhi@iki.fi> wrote:

> >>    /* This printf call is variadic */
> >>    ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 3, &ffi_type_sint,
> arg_types);
> >
> > Surely that only works if a varargs call uses the same ABI as a normal
> > call. They don't always,
> >
>
> Yeah, it's a mess, e.g.
>
>
> https://www.quora.com/How-are-varargs-typically-implemented-in-C-under-the-hood
>
>

Libffi has you covered with ffi_prep_cif_var()

AG

      reply	other threads:[~2021-03-19 11:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 14:04 ShaJunxing
2021-03-18 15:25 ` Anthony Green
2021-03-19  2:08   ` ShaJunxing
2021-03-19  2:36     ` Kaz Kylheku (libffi)
2021-03-19  3:09       ` ShaJunxing
2021-03-19 10:13   ` Andrew Haley
2021-03-19 11:01     ` Anthony Green
2021-03-19 11:43       ` Andrew Haley
2021-03-20 22:40         ` Anthony Green
2021-03-20 23:56           ` Anthony Green
2021-03-22 10:36             ` Andrew Haley
2021-03-19 11:26     ` Jarkko Hietaniemi
2021-03-19 11:33       ` Anthony Green [this message]

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='CACxje58N83O2t7EKpTPZdOY=-kZ9bFdAhDYO-F5RgMAkWUq-6Q@mail.gmail.com' \
    --to=green@moxielogic.com \
    --cc=aph@redhat.com \
    --cc=jhi@iki.fi \
    --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).