mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Wasm support patch 2 (static syscalls)
Date: Tue, 28 Nov 2017 13:59:48 +0100	[thread overview]
Message-ID: <20171128125948.GK15263@port70.net> (raw)
In-Reply-To: <VI1PR0502MB38858E8FC5B89323C105D080E73A0@VI1PR0502MB3885.eurprd05.prod.outlook.com>

* Nicholas Wilson <nicholas.wilson@realvnc.com> [2017-11-28 12:31:18 +0000]:
> Imagine an application that calls "getpid()".  This will cause "getpid.o" to be linked in, to provide the C API:
> 
> pid_t getpid(void)
> {
> 	return __syscall(SYS_getpid);
> }
> 
> On all of Musl's existing archs, the syscalls are implemented via a seven generic "__syscallN" functions. The assumption is that the kernel provides all syscalls.
> 
> For Wasm, what I've done is made it so that the interpreter environment instead provides *named* syscall functions, in this case, a "__syscall_getpid" function. Then, at link-time, when the linker links against libc.a it's able to link in to the application only the syscalls that are actually used.

we may change the syscall abstraction at some point, but
to do what you want, there is no need for intrusive changes.
just have

static inline long __syscall0(long n)
{
	switch (n) {
	...
	case SYS_getpid: return __syscall_getpid();
	...
	}
}

in arc/wasm/syscall_arch.h and the compiler will do the
right thing without any change to generic musl code.


  reply	other threads:[~2017-11-28 12:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-28 12:31 Nicholas Wilson
2017-11-28 12:59 ` Szabolcs Nagy [this message]
2017-11-28 13:23   ` Nicholas Wilson
2017-11-28 14:05     ` Szabolcs Nagy
2017-11-28 14:34       ` Nicholas Wilson
2017-11-28 14:35         ` Szabolcs Nagy
2017-11-28 14:53           ` Nicholas Wilson
2017-11-28 15:08             ` Szabolcs Nagy
2017-11-28 15:50               ` Rich Felker
2017-11-28 16:20                 ` Nicholas Wilson
2017-11-28 16:51         ` John Starks
2017-11-28 17:52           ` Szabolcs Nagy
2017-11-28 18:55             ` Rich Felker
2017-11-28 17:53           ` Nicholas Wilson

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=20171128125948.GK15263@port70.net \
    --to=nsz@port70.net \
    --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).