libc dependency

Nemanja Boric via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 20 04:18:17 PDT 2017


On Tuesday, 20 June 2017 at 11:08:15 UTC, Moritz Maxeiner wrote:
> On Tuesday, 20 June 2017 at 11:00:00 UTC, Nemanja Boric wrote:
>> On Monday, 19 June 2017 at 21:45:56 UTC, Moritz Maxeiner wrote:
>>> On Monday, 19 June 2017 at 21:35:56 UTC, Steven Schveighoffer 
>>> wrote:
>>>> IIRC, Tango did not depend on libc at all. It only used 
>>>> system calls. So it certainly is possible.
>>>
>>> How did they invoke those system calls? They are usually 
>>> access via libc on POSIX systems, so you don't have to 
>>> implement accessing e.g. vdso on Linux yourself.
>>
>> Tango just didn't use C abstractions (`FILE*`, say), but 
>> rather it would call functions such `read(2)`, `write(2)`, 
>> `seek(2)`, etc. and implement buffering/seeking/etc manually.
>
> Only the second one of those are the system calls I was talking 
> about :p
>

Yeah, I saw the Steve's answer late, but there's no editing posts 
here :(. :-)


>> So, the library just declared `extern (C) read (...);`/`extern 
>> (C) write`.. and expected for the right library (which doesn't 
>> have to be libc, just the one that exposes these syscall 
>> wrappers) linked.
>
> If you have a library that exposes to you via C API those 
> functions that you need of libc, then that library *is* your 
> (albeit partial) libc (since a libc is defined as any library 
> that exposes such functions). In any case, that's the same way 
> that druntime depends on libc AFAIK.

Yeah, that stands, but I thought the point of this topic was that 
(IIRC, not a phobos experienced user) Phobos (_not_ druntime) 
uses C _standard library_ abstractions for many things, and 
that's why the OP said we can't beat C in speed. I don't think 
it's reasonable thing to think that writing syscall wrappers 
would help D gain to much speed :-).




More information about the Digitalmars-d-learn mailing list