next up previous contents index
Next: 3.2 Common Header Files Up: 3.1 Header File Conventions Previous: 3.1.1 Basic Structure

3.1.2 Namespace Cleanliness

A similar namespace cleanliness issue applies to the actual symbols defined by many the OSKit header files. In particular, all OSKit header files defining COM interfaces, as well as any related header files that they cross-include such as oskit/types.h and oskit/error.h, only define symbols having a prefix of oskit_, OSKIT_, osenv_, or OSENV_. This rule allows these headers to be included along with arbitrary other headers from different environments without introducing a significant chance of name conflicts. In fact, the OSKit components derived from legacy systems, such as the Linux driver set and the FreeBSD drivers and TCP/IP stack, depend on this property, to allow them to include the OSKit headers defining the COM interfaces they are expected to export, along with the native Linux or BSD header files that the legacy code itself relies on.

Once again, this rule creates a potential problem for header files whose purpose is to declare standard, well-known symbols, such as the minimal C library header files. For example, string.h clearly should declare memcpy simply as memcpy and not as oskit_memcpy or somesuch, since in the latter case the ``C library'' wouldn't be conforming to the standard C library interface. However, there are many types, structures, and definitions that are needed in both the minimal C library headers and the COM interfaces: for example, both the oskit_ttystream COM interface and the minimal C library's termios.h need to have some kind of termios structure; however, in the former case a disambiguating oskit_ prefix is required, whereas in the latter case such a prefix is not allowed. Although technically these two termios structures exist in separate contexts and could be defined independently, for practical purposes it would be very convenient for them to coincide, to avoid having to perform unnecessary conversions in code that uses both sets of headers. Therefore, the solution used throughout the OSKit header files is to define the non-prefixed versions of equivalent symbols with respect to the prefixed versions whenever possible: for example, the errno.h provided by the minimal C library simply does a `#include <oskit/error.h>' and then defines all the errno values with lines of the form:

#define EDOM    OSKIT_EDOM
#define ERANGE  OSKIT_ERANGE

Unfortunately this is not possible for structures since C does not have a form of typedef statement for defining one structure tag as an alias for another. Therefore, the few structures that need to exist in both contexts (such as the termios structure mentioned above) are simply defined twice. Since these structures are generally well-defined and standardized by ANSI C, POSIX, or CAE, they are not expected to change much over time, so the added maintenance burden should not be significant and is vastly outweighed by the additional flexibility provided by the clean separation of namespaces.


next up previous contents index
Next: 3.2 Common Header Files Up: 3.1 Header File Conventions Previous: 3.1.1 Basic Structure

University of Utah Flux Research Group