libc dependency

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 20 04:08:15 PDT 2017


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

> 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.


More information about the Digitalmars-d-learn mailing list