system calls in a library
freebsd at edvax.de
Sun Apr 28 18:12:39 UTC 2019
On Sun, 28 Apr 2019 03:37:27 GMT, Mayuresh Kathe wrote:
> from previous discussions on this list, i know that the system interfaces
> exposed by the freebsd kernel are also included and exposed via libc, in
> addition to the standard c library functions. did i get that right?
More or less, the system calls (kernel calls) translate 1:1 to
system call (call number, set of arguments, syscall / int 80h).
Their prototypes are listed in the corresponding header files.
The implementation itself is found in the kernel sources, and
many of them are written in assembly. The libc interface makes
it easy to call, for example, write() without requiring the
setup in assembly or a C-equivalent. As per the C standard, libc
adds more convenient wrappers to the kernel interfaces, for
example fopen() as an extension of open(), simplified speaking.
> if yes, is it possible to expose those kernel system interfaces via a c++
> library? but one which is devoid of c++ library functions?
Sure it is. The could be "lifted" into the "OO space", providing
objects that don't do more than the system call would do, but that
completely defeats the high-level purpose and approach of C++,
which relates to C as lung cancer relates to lung. ;-)
> which in the
> case of freebsd is included in something like libstdcpp?
FreeBSD's libstdc++ is the Standard C++ Library (as per the
language definitions and requirements) which contains the
higher-level stuff as mentioned above. I don't know if it's even
intended to expose the lower-level interfaces directly in C++,
as even libc provides a more convenient interface to what the
system calls can do, and the "syscall level" is usually reserved
for use in device drivers and kernel-internal code, and most of it
is written in assembly.
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions