C: Difference between revisions

No change in size ,  17 years ago
m
fixed links
[unchecked revision][unchecked revision]
(most of the article taken from parts of the OsFaq)
 
m (fixed links)
Line 11:
In addition to standard C functions (as defined in the ISO standard), a C library might (and usually does) implement further functionality, which might or might not be defined by some standard. The standard C library says nothing about networking, for example. For Unix-alike systems, the POSIX standard defines what is expected from a C library; other systems might differ fundamentally.
 
It should be noted that, in order to implement its functionality, the C library must call kernel functions. So, for your own OS, you can of course take a ready-made C library and just recompile it for your OS - but that requires that you tell the library how to call your kernel functions, and your kernel to actually provide those functions. The good news is that [http://sourceware.org/newlib/libc.html#SEC195| relatively few of the library's functions do use some system call].
 
Available libraries include the [http://www.gnu.org/software/libc/| GNU C library] (with info about porting the glibc), [http://sources.redhat.com/newlib/| newlib] (with info on the required OS functions detailed in the manual), and [http://www.uclibc.org/| uClibC] (although that is highly optimized to be used with an embedded Linux).
 
It should also be noted that in most cases you can not use a usermode C library directly in your kernel. Things such as malloc, free, memcpy need to implemented by you before being used. In GCC the "--nobuiltin" flag tells GCC to not use pre-existing builtin functions such as memcpy.
1,490

edits