C19 Pointer Arithmetic

Normally, pointers may be used for computations in C only if they have an explicit type; for example, int * or long *. Otherwise, it is not possible to establish which increment steps are to be used. The GNU compiler circumnavigates this restriction and supports arithmetic with void pointers and function pointers — these are also used by the kernel at various points. In both cases, the increment step is 1 byte.

Interestingly, GCC had at least once support for a bit-addressable architecture — the Texas Instruments 34010 processor. Incrementing a pointer on this machine means that the memory position is advanced by one bit, not one byte — a feature that did not quite become ubiquitous. While the pure existence of the machine would most likely not be worth mentioning here, the fact that Andrew Morton — one of the key persons for the development of the 2.6 kernel series — once wrote a real-time kernel for this processor certainly does. You can download the source code from www.zip.com.au/~akpm/.

Continue reading here: C21 Reference Counters

Was this article helpful?

0 0