Check out the new USENIX Web site. next up previous
Next: Requirements of Common Sense Up: uCRC and C++ Previous: What uCR is not

Requirements of the Languages

Both C and C++ place some minimum requirements on the execution environment, but many of the constraints are imposed by the compiler, not the language. If some language construct can be handled easily by the CPU, then the compiler typically just generates the assembly code to deal with it. That is what compilers are for. However, when something is too hard, it gives up and generates a call to external code.

The C language is relatively easy to compile and the compiler only generates call instructions for calls to external functions. Floating point emulation is often placed in a library as well, if the target can reasonably be expected not to have a floating point unit. The C++ language is a bit more interesting. It has difficult constructs that compilers often give up on, like dynamic memory allocation.

The C language standard has a substandard, the freestanding C standard [1], to guide the implementer on what can be left out of the development environement and still be worthy of the name ``C''. In a nutshell, libraries are optional in a freestanding environment. It is rare for an environment to not include some of the more important optional parts, though.

The C++ Working Paper has a similar substandard.gif [3] The standard libraries are not required of a freestanding C++ environemnt. Only a few support libraries, some specific C library routines, and support for the ``new'' and ``delete'' operators are expected. Things like streamio are certainly not required of a freestanding C++ execution environment, although a specific implementation may choose to provide it.

Static initializers must obviously be done correctly. To fail to initialize static objects is a clear and gross error, but the compiler certainly does not know how to arrange that on my toaster CPU. That, like the minimum library support, becomes a matter for the runtime, namely uCR.

The g++ compiler generates external calls for new and delete. This way, memory allocation can easily be provided with some help at link time. Most targets have memory available for allocation, and some have several different kinds of memory for allocation. Even if the default allocation operators do not apply, the placement ``new'' operator has some interesting advantages.


next up previous
Next: Requirements of Common Sense Up: uCRC and C++ Previous: What uCR is not

Stephen Williams
Sun May 4 15:28:26 PDT 1997