From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1501 Path: news.gmane.org!not-for-mail From: Murali Vijayaraghavan Newsgroups: gmane.linux.lib.musl.general Subject: Re: Using unistd functions vs calling syscall straight in the code Date: Fri, 10 Aug 2012 23:32:11 +0900 Message-ID: References: <20120810141613.GA20243@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0016e6d6446da151d504c6ea35de X-Trace: dough.gmane.org 1344609150 19549 80.91.229.3 (10 Aug 2012 14:32:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Aug 2012 14:32:30 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1502-gllmg-musl=m.gmane.org@lists.openwall.com Fri Aug 10 16:32:31 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1SzqGH-0006pJ-Ep for gllmg-musl@plane.gmane.org; Fri, 10 Aug 2012 16:32:25 +0200 Original-Received: (qmail 30236 invoked by uid 550); 10 Aug 2012 14:32:24 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 30228 invoked from network); 10 Aug 2012 14:32:24 -0000 In-Reply-To: <20120810141613.GA20243@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:1501 Archived-At: --0016e6d6446da151d504c6ea35de Content-Type: text/plain; charset=ISO-8859-1 On Fri, Aug 10, 2012 at 11:16 PM, Szabolcs Nagy wrote: > * Murali Vijayaraghavan [2012-08-10 21:47:59 > +0900]: > > You guys do have a unistd implementation which supposedly implements each > > of the system calls. But you are not consistent with the use of these > > functions to perform the unistd-implemented tasks. Wouldn't it be a lot > > cleaner to call these functions instead of calling syscall / syscall_cp > > directly from the other (top-level) functions? Was there some rationale > or > > is it just code evolution? > > > > i don't understand the question > > can you show with an example what do you mean? > > calling a libc function is not the same as using a linux > syscall, and there is usually a reason why one is used > instead of the other.. > > (the first has posix semantics the second has whatever > semantics linux have, even if these happen to be compatible > then the first one creates an extra call and an extra > internal dependency when static linking is used) > For example, I could have implemented src/stdio/__stdio_read.c using src/unistd/readv.c's readv function instead of calling syscall/syscall_cp(SYS_readv, ...) in lines 20 and 24. I believe unistd is the POSIX compatibility layer (correct me if I am wrong). So shouldn't the C standard library, namely stdio functions like scanf eventually use the unistd functions instead of using the syscall directly? This would have made my job easier because I could have just modified this POSIX compability layer instead of scanning through the C standard library functions and changing them one by one. Remember I have multiple special instructions to perform each IO task instead of a single system call instruction, since it's easier to implement hardware simulator that way - I can get the function type simply by decoding the instruction rather than reading some register. --0016e6d6446da151d504c6ea35de Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Fri, Aug 10, 2012 at 11:16 PM, Szabol= cs Nagy <nsz@port70.net> wrote:
* Murali Vijayaraghavan <vmural= i@csail.mit.edu> [2012-08-10 21:47:59 +0900]:
> You guys do have a unistd implementation which suppo= sedly implements each
> of the system calls. But you are not consistent with the use of these<= br> > functions to perform the unistd-implemented tasks. Wouldn't it be = a lot
> cleaner to call these functions instead of calling syscall / syscall_c= p
> directly from the other (top-level) functions? Was there some rational= e or
> is it just code evolution?
>

i don't understand the question

can you show with an example what do you mean?

calling a libc function is not the same as using a linux
syscall, and there is usually a reason why one is used
instead of the other..

(the first has posix semantics the second has whatever
semantics linux have, even if these happen to be compatible
then the first one creates an extra call and an extra
internal dependency when static linking is used)

<= /div>

For example, I could have implemented src/stdio/__= stdio_read.c using src/unistd/readv.c's readv function instead of calli= ng syscall/syscall_cp(SYS_readv, ...) in lines 20 and 24. I believe unistd = is the POSIX compatibility layer (correct me if I am wrong). So shouldn'= ;t the C standard library, namely stdio functions like scanf eventually use= the unistd functions instead of using the syscall directly?

This would have made my job easier because I could have= just modified this POSIX compability layer instead of scanning through the= C standard library functions and changing them one by one. Remember I have= multiple special instructions to perform each IO task instead of a single = system call instruction, since it's easier to implement hardware simula= tor that way - I can get the function type simply by decoding the instructi= on rather than reading some register.


--0016e6d6446da151d504c6ea35de--