Date: Sun, 28 Apr 2019 20:12:28 +0200 From: Polytropon <freebsd@edvax.de> To: Mayuresh Kathe <mayuresh@sdf.org> Cc: freebsd-questions@freebsd.org Subject: Re: system calls in a library Message-ID: <20190428201228.b847e00a.freebsd@edvax.de> In-Reply-To: <201904280337.x3S3bR25017504@sdf.org> References: <201904280337.x3S3bR25017504@sdf.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190428201228.b847e00a.freebsd>