mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Re: use of varargs in open and various functions
Date: Fri, 12 Apr 2019 07:48:45 -0400	[thread overview]
Message-ID: <20190412114845.GZ23599@brightrain.aerifal.cx> (raw)
In-Reply-To: <CADYdroPbnSrOPNKa5Htf7Mw0oRh4JRYYnE2tFtnsa+wrDcqa8Q@mail.gmail.com>

On Thu, Apr 11, 2019 at 06:36:31PM +0200, Norbert Lange wrote:
> > On Thu, Apr 11, 2019 at 04:25:50PM +0200, Norbert Lange wrote:
> > > Hello,
> > >
> > > I had some dealings with software that forwards arguments from vararg functions,
> > > the kind with optional but known fixed type.
> > > open, fcntl, ioctl are some examples.
> > >
> > > What happens in musl is that the optional argument is optionally or
> > > always retrieved (fcntl).
> > > I think this is pretty much pointless,
> > Tough. The interfaces are just defined this way. In case of fcntl, it
> > is merely a convenience of circumstance that allows musl to do what it
> > does. fcntl()'s third argument can be a pointer to various structures,
> > or an unsigned long. Linux requires a C implementation where pointers
> > can be losslessly converted to long and back, but that is the only
> > reason this call to va_arg() works.
> 
> Those are C interfaces, they can be implemented in any language you
> you see fit.
> if you write asm, you can just pick the registers or pull the values from
> the stack.
> declaration can and should stay the same, no point stressing this further.

I think what you're not understanding is that the goal of musl is not
to provide C that translates into asm/machine code that matches a
particular ABI. It's to provide C that's valid as C, which makes it
useful and interesting in a much larger context and relevant to the
future, where C very well may be consumed mainly in some kind of
memory-safe abstract machine that has little to do with our current
conceptions of machine ABIs, rather than just the present.

Naturally, the C library can't be implemented entirely in C, so this
goal is always incomplete. The adapted version of this goal then
becomes minimizing the amount of code that's not portable C (i.e. asm
source files, inline asm, C extensions, code that's C but that assumes
particular addressing/stack/etc. models, ...) to what's strictly
necessary.

Rich


  reply	other threads:[~2019-04-12 11:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 16:36 Norbert Lange
2019-04-12 11:48 ` Rich Felker [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-04-11 16:03 Norbert Lange
2019-04-11 16:23 ` Rich Felker

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=20190412114845.GZ23599@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).