Writing Device Drivers

C Language Data Type Models: LP64 and ILP32

The 32-bit Solaris C language data model, called ILP32, defines int, long, and pointers as 32 bits, short as 16 bits, and char as 8 bits. The C data type model chosen for the 64-bit operating system is LP64. This data model defines long and pointers as 64 bits, int as 32 bits, short as 16 bits, and char as 8 bits.

In LP64, only longs and pointers change size; the other C data types stay the same size as in the ILP32 model. Table F-1 lists the standard C data types and their corresponding sizes in bits for ILP32 and LP64.

Table F-1 C Data Type Sizes

C Type 

ILP32 

LP64 

char 

short 

16 

16 

int 

32 

32 

long  

32

64

long long 

64 

64 

pointer 

32

64

In addition to the data model changes, some system-derived types, such as size_t, have been expanded to be 64-bit quantities when compiled in the 64-bit environment.

Potential Problems to Avoid

To run in a 64-bit environment, drivers may need to be converted to use the LP64 data model. There are several potential problem areas caused by the change in size of long and pointers:

  1. Source code that assumes that int, long, and pointer types are the same size are incorrect for 64-bit Solaris.

  2. Type casts may need updating, since the underlying data types may have changed.

  3. Data structures containing long types and pointers will need to be checked for different offset values than expected. This is caused by alignment differences that occur when long and pointer fields grow to 64 bits.