next up previous contents index
Next: 9.2 Extended POSIX Support Up: 9 Minimal C Library: Previous: 9 Minimal C Library:

9.1 Introduction

The OSKit's minimal C library is a subset of a standard ANSI/POSIX C library designed specifically for use in kernels or other restricted environments in which a ``full-blown'' C library cannot be used. The minimal C library provides many simple standard functions such as string, memory, and formatted output functions: functions that are often useful in kernels as well as application programs, but because ordinary application-oriented C libraries are unusable in kernels, must usually be reimplemented or manually ``pasted'' into the kernel sources with appropriate modifications to make them usable in the kernel environment. The versions of these functions provided by the OSKit minimal C library, like the other components of the OSKit, are designed to be as generic and context-independent as possible, so that they can be used in arbitrary environments without the developer having to resort to the traditional manual cut-and-paste methods. This cleaner strategy brings with it the well-known advantages of careful code reuse: the kernel itself becomes smaller and simpler due to fewer extraneous ``utility'' functions hanging around in the sources; it is easier to maintain both the kernel, for the above reason, and the standard utility functions it uses, because there is only one copy of each to maintain; finally, the kernel can easily adopt new, improved implementations of common performance-critical functions as they become available, simply by linking against a new version of the minimal C library (e.g., new versions of memcpy or bzero optimized for particular architectures or newer family members of a given architecture).

In general, the minimal C library provides only functions specified in the ANSI C or POSIX.1 standards, and only a subset thereof. Furthermore, the provided implementations of these functions are designed to be as independent as possible from each other and from the environment in which they run, allowing arbitrary subsets of these functions to be used when needed without pulling in any more functionality than necessary and without requiring the OS developer to provide significant support infrastructure. For example, all of the ``simple'' functions which merely perform some computation on or manipulation of supplied data, such as the string instructions, are guaranteed to be completely independent of each other.

The functions that are inherently environment-dependent in some way, such as printf, which assumes the existence of some kind of ``standard output'' or ``console,'' are implemented in terms of other clearly specified, environment-dependent functions. Thus, in order to use the minimal C library's implementation of printf, the OS developer must provide appropriate console_putchar and console_putbytes routines to be used to write characters to whatever acts as the ``standard output'' in the current environment. All such dependencies between C library functions are explicitly stated in this document, so that it is always clear what additional functions the developer must supply in order to make use of a set of functions provided by the minimal C library.

Since almost all of the functions and definitions provided by the OSKit minimal C library implement well-known, well-defined ANSI and POSIX C library interfaces which are amply documented elsewhere, we do not attempt to describe the purpose and behavior of each function in this chapter. Instead, only the peculiarities relevant to the minimal C library, such as implementation interdependencies and side effects, are described here.

Note that many files and functions in the minimal C library are derived or taken directly from other source code bases, particularly Mach and BSD. Specific attributions are made in the source files themselves.


next up previous contents index
Next: 9.2 Extended POSIX Support Up: 9 Minimal C Library: Previous: 9 Minimal C Library:

University of Utah Flux Research Group