Notes on C
For more than 25 years, C has been the preferred programming language for implementing operating systems of all kinds—including Linux. The major part of the kernel—with the exception of a few assembly language segments—is programmed in C. Therefore, it is not possible to understand the kernel without a mastery of C. This book assumes that you have already gained sufficient experience with C in userspace programming. This appendix discusses little-used and very specific aspects of C in kernel programming.
The kernel sources are especially designed for compilation with the GNU C compiler.1 This compiler is available for many architectures (far more than are supported by the kernel) and also features numerous enhancements used by the kernel, as discussed in this appendix.
C.1 How the GNU C Compiler Works
In addition to using GNU enhancements to the C language, the kernel also relies on a number of optimizations performed by the compiler when it generates assembler code from the C sources. Because very close cooperation between the sources and the compiler is necessary at some points in the kernel, this section provides a brief overview of the actions performed by the GNU Compiler Collection (GCC) when it compiles a program and of the various techniques used. The following information is, of course, of a summary nature. For detailed information, refer to the GCC Internals manual provided with the compiler sources and available online at gcc.gnu.org.
C.1.1 From ...