libc : non-c specific functions!

Lorenzo Salvadore phascolarctos at protonmail.ch
Wed Jan 16 10:09:28 UTC 2019


> is there any way to find out which functions in libc are non-c
> specific, so for example if i had to implement a syslib in
> assembly language, i could just avoid the "c" parts as they
> would be irrelevant.
> all of the above is hypothetical, i just want to know and learn.
> something which this mailing list allows me to do effortlessly.

Someone already answered about it, but I guess the answer was
not clear enough. It would be easier to answer you if you told us
what you know: which programming languages do you know
for example? Are you developing some concrete project or are
you only studying theory (it is pretty hard to study theory
without practice in this subject)?

Now, the answer to your question. C is a language to write
softwares and libraries. What you write in C is called a source code:
you understand the source code, the machine does not. Then you
compile it using a software called a compiler (as gcc or clang):
what you get is an object code in machine code; the machine
understands it, you do not (well if you really want you can but it is very
hard, impossible for average people). Then, after a third passage
called linking (implicit in compilation for easy projects like "hello world"
printing programs), you get your library or software, in machine code.

The final product - the library or software - is in machine code. Not in
C, not in assembly, not in rust. That holds for libc too: it's language is
machine code, at least in the compiled form on your system. When
developers wrote its source code it was most probably written mainly
in C and assembly (you can mix programming languages and often you
need to), but in its compiled form on the system it is in machine code.

The relation of libc with C is that it follows a standard which makes
writing C programs very easily. If you have some experience in C you
surely know the printf function: how the compiler knows what to do
when you write it in a source code? It knows it because it is written in
libc.

Hope this can help you.

Lorenzo Salvadore.


More information about the freebsd-questions mailing list