mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Murali Vijayaraghavan <vmurali@csail.mit.edu>
To: musl@lists.openwall.com
Subject: Re: Using unistd functions vs calling syscall straight in the code
Date: Sat, 11 Aug 2012 00:40:25 +0900	[thread overview]
Message-ID: <CAFNG3t72BNnN=-9Fi-CMYtOCcO3YMKdwJVXZFXwcUrKxM0uWFg@mail.gmail.com> (raw)
In-Reply-To: <20120810145923.GB20243@port70.net>

[-- Attachment #1: Type: text/plain, Size: 2349 bytes --]

On Fri, Aug 10, 2012 at 11:59 PM, Szabolcs Nagy <nsz@port70.net> wrote:

> * Murali Vijayaraghavan <vmurali@csail.mit.edu> [2012-08-10 23:32:11
> +0900]:
> > 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?
> >
>
> that's not how it works,
>
> unistd is no more posix than stdio
> they are all part of the posix api
>
> stdio functions are also defined by the
> c standard so in this sense it's good
> that the stdio implementation does not
> depend on the larger posix api
> (it only depends on the syscall api)
>
> but yes otherwise stdio could use unistd
> functions and then it would be a bit
> slower (+1 call) and +1 symbol resolution
> during linking i guess
>

Oh k. I thought one was on top of the other. If they are all supposed to be
part of POSIX, I guess it makes more sense to avoid an extra call.

>
> > 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
>
> you are not supposed to change the functions
>
> you only need to implement the syscalls
> and dummy out the ones you don't use
> (ie. have a large switch, with a defalut: return -ENOSYS;)
>
> if you modify the .c source files you are
> doing it wrong
>
> > 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.
>
> even if you have special instructions
> in your emulator i don't see why you
> cannot implement the syscall api
> (actually that seems simpler and more
> correct to me than putting random special
> instructions all over the place)
>

I suppose I can do this. I was just more familiar with unistd functions'
semantics than the syscall API's. But moving forward, this is more
maintainable. Thanks.

[-- Attachment #2: Type: text/html, Size: 3089 bytes --]

  reply	other threads:[~2012-08-10 15:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-10 12:47 Murali Vijayaraghavan
2012-08-10 14:16 ` Szabolcs Nagy
2012-08-10 14:32   ` Murali Vijayaraghavan
2012-08-10 14:59     ` Szabolcs Nagy
2012-08-10 15:40       ` Murali Vijayaraghavan [this message]
2012-08-10 17:59         ` Rich Felker
2012-08-10 18:40           ` Murali Vijayaraghavan

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='CAFNG3t72BNnN=-9Fi-CMYtOCcO3YMKdwJVXZFXwcUrKxM0uWFg@mail.gmail.com' \
    --to=vmurali@csail.mit.edu \
    --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).