The data model refers to the size of the integer, long, and pointer data types. On 32-bit architectures, the data model is typically ILP32, where integers, longs, and pointers are 32-bits. On 64-bit architectures, the data model is typically LP64, where longs and pointers are 64-bits, but integers are 32-bits.
The ANSI C standard is architecture neutral, so it does not specify the size of these data types. It only requires that integers and short integers be at least 16 bits, and that long integers be at least as long as integers and not less than 32-bits.
Since the Linux kernel can be compiled and executed on many different architectures, it is important to be aware of how the data model can affect the portability of software from one architecture to another. In particular:
Integer and long data types must be chosen with care and not treated as interchangeable. Long values must not be assigned to integer values without careful consideration.
Integers and pointers may not be the same size, so the practice of storing pointers in integer variables is not safe.
In the POSIX standard and also in the Linux kernel many uses of integers and long integers have been replaced with new data types. This clarifies the use of the variables, improves error checking by the compiler, and is generally considered good programming practice. In addition, it improves architecture neutrality because it localizes the dependency on the data model.
Copyright © 2009 by Bruce Blinn