DESCRIPTION

This document describes the C environment of the kernel, including available standard headers and interfaces.

Standard

X15 must be built with a C compiler supporting the ISO/IEC 9899:2011 (C11) specification with some GCC extensions. It can currently be built with the GCC and Clang compilers.

Environment

The kernel uses the freestanding execution environment. This means the compiler is expected to provide the following headers :

  • <float.h>

  • <iso646.h>

  • <limits.h>

  • <stdalign.h>

  • <stdarg.h>

  • <stdbool.h>

  • <stddef.h>

  • <stdint.h>

  • <stdnoreturn.h>

X15 augments the environment with a small subset of the functions provided in hosted environments. The additional headers are :

  • <assert.h>

  • <errno.h>

  • <limits.h>

  • <stdio.h>

  • <string.h>

Note that these headers do not provide the complete set of interfaces expected in a hosted environment.

Formatting functions

Of particular interest is the <stdio.h> header which provides a subset of the printf and scanf family of functions.

The supported functions are :

  • getchar()

  • putchar()

  • sprintf()

  • snprintf()

  • vsprintf()

  • vsnprintf()

  • sscanf()

  • vsscanf()

The EOF macro is also provided.

The formatting functions only implement a subset of what the standard defines, namely :

  • sprintf() :

    • flags: # 0 - ' ' (space)

    • field width is supported

    • precision is supported

  • sscanf() :

    • flags: *

    • field width is supported

  • common to both :

    • modifiers: hh h l ll z t

    • specifiers: d i o u x X c s p n %

Floating point conversions are currently not supported, but this may change in the future.

SEE