public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Robert Kiesling <kiesling@earthlink.net>
To: gcc-help@gcc.gnu.org
Subject: Re: Variable function arguments and the stack
Date: Sun, 09 Dec 2007 14:30:00 -0000	[thread overview]
Message-ID: <E1J1NAB-00042M-GW@owl.gateway.2wire.net> (raw)

> David Daney wrote:
> > Robert Kiesling wrote:
> > > I trying to write a function that calls libc functions with
> > > variable arguments - for example, scanf.  I would like to do
> > > this by pushing the arguments onto the stack and then calling 
> > > the function, something like this.  (This code is for an x86
> > > machine.)
> > > 
> > > static long long int scalar_args[512];
> > > static char *ptr_args[512][BUFSIZE];
> > 
> > Use libffi which ships with GCC.  Doing things like this is what it was 
> > designed for.

Libffi clobbers either the arguments or the stream argument (the 
first argument before the format string in functions like fprintf
or sprintf).  It should make a distinction whether the args or 
the stream are writeable or readable, and that, of course is the 
idea.

Regards,

Robert

-- 
Ctalk Home Page: http://www.ctalklang.org/

             reply	other threads:[~2007-12-09 14:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-09 14:30 Robert Kiesling [this message]
2007-12-15  8:30 ` Andrew Haley
  -- strict thread matches above, loose matches on Subject: below --
2007-12-06  0:00 Robert Kiesling
2007-12-06  0:11 ` David Daney
2007-12-06  0:41   ` Robert Kiesling

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=E1J1NAB-00042M-GW@owl.gateway.2wire.net \
    --to=kiesling@earthlink.net \
    --cc=gcc-help@gcc.gnu.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).