9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Latchesar Ionkov <lucho@gmx.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] calling function with (variable number of) parameters
Date: Thu, 21 Jun 2001 11:17:12 -0400	[thread overview]
Message-ID: <20010621111712.A2711@gmx.net> (raw)
In-Reply-To: <20010621142423.D9AFF199EB@mail.cse.psu.edu>; from rog@vitanuova.com on Thu, Jun 21, 2001 at 03:33:15PM +0100

Both suggestions are not really alternatives in that case. I am trying to
implement already defined interface, I don't have control on the way the
called functions are declared and they are definitely reentrant. :((

I can, though, hope that nobody in his mind will wrote a function with more
that 15 arguments. Then reserve space for 15 integers in the stack, put as
many argument as needed, call the function and remove 15 integers from the
stack. Of course I'll check and signall error if somebody is crazy enough to
try to use the code with more than 15 arguments.

Thanks again,

	Lucho

On Thu, Jun 21, 2001 at 03:33:15PM +0100, rog@vitanuova.com said:
> > So save space for n + 1 parameters on the stack; the last won't be used
> > by your called function, and you could store the number of parameters in
> > it.  When you return, pop the last item off the stack, and use that to
> > recalculate the frame pointer.
> 
> no actually, parameters are pushed on last first, so the last one
> you've pushed (the one you've got access after the return) is the first
> parameter to the function (which doesn't expect it).
> 
> i think that probably the only way of getting around the problem is to
> change the prototype of the called function so that the first parameter
> signifies the number of parameters.
> 
> the only other alternative is if the function is guaranteed to be
> non-reentrant (fat chance) in which case you could store the number of
> params in a static variable.
> 
> of course, that then makes it incompatible with the original...
> 
>   cheers,
>     rog.


  parent reply	other threads:[~2001-06-21 15:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-21 14:33 rog
2001-06-21 15:16 ` Dan Cross
2001-06-21 15:17 ` Latchesar Ionkov [this message]
2001-06-29 22:11   ` Boyd Roberts
  -- strict thread matches above, loose matches on Subject: below --
2001-06-20 19:51 rog
2001-06-20 19:54 ` Latchesar Ionkov
2001-06-21 12:39   ` Douglas A. Gwyn
2001-06-21 13:48     ` Latchesar Ionkov
2001-06-21 14:13   ` Dan Cross
2001-06-20 14:11 Latchesar Ionkov
2001-06-20 16:30 ` Douglas A. Gwyn
2001-06-20 18:23   ` Latchesar Ionkov

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=20010621111712.A2711@gmx.net \
    --to=lucho@gmx.net \
    --cc=9fans@cse.psu.edu \
    /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 NNTP newsgroup(s).