From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12155 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Wasm support patch 2 (static syscalls) Date: Tue, 28 Nov 2017 13:59:48 +0100 Message-ID: <20171128125948.GK15263@port70.net> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1511874020 16139 195.159.176.226 (28 Nov 2017 13:00:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 28 Nov 2017 13:00:20 +0000 (UTC) User-Agent: Mutt/1.6.0 (2016-04-01) To: musl@lists.openwall.com Original-X-From: musl-return-12171-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 28 14:00:03 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eJfUR-0002kG-7S for gllmg-musl@m.gmane.org; Tue, 28 Nov 2017 13:59:55 +0100 Original-Received: (qmail 11736 invoked by uid 550); 28 Nov 2017 13:00:00 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 11713 invoked from network); 28 Nov 2017 13:00:00 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:12155 Archived-At: * Nicholas Wilson [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.