The 64-bit architecture has the following advantages:
- A 64-bit application can directly access 4 exabytes( 1 exabyte = 1018 bytes (or) 260 bytes ) of virtual memory, and the Intel Itanium processor provides a contiguous linear address space.
- 64-bit Linux allows for file sizes up to 4 exabytes, a very significant advantage to servers accessing large databases.
32-bit and 64-bit data models
Note:
The disadvantage of the LP64 model is that storing a long into an int may overflow. On the other hand, casting a pointer to a long will work. In the LLP model, the reverse is true.
The difference among the three 64-bit models (LP64, LLP64, and ILP64) lies in the non-pointer data types. When the width of one or more of the C data types changes from one model to another, applications may be affected in various ways. These effects fall into two main categories:
ILP32 | LP64 | LLP64 | ILP64 | |
---|---|---|---|---|
char | 8 | 8 | 8 | 8 |
short | 16 | 16 | 16 | 16 |
int | 32 | 32 | 32 | 64 |
long | 32 | 64 | 32 | 64 |
long long | 64 | 64 | 64 | 64 |
pointer | 32 | 64 | 64 | 64 |
The disadvantage of the LP64 model is that storing a long into an int may overflow. On the other hand, casting a pointer to a long will work. In the LLP model, the reverse is true.
The difference among the three 64-bit models (LP64, LLP64, and ILP64) lies in the non-pointer data types. When the width of one or more of the C data types changes from one model to another, applications may be affected in various ways. These effects fall into two main categories:
- Size of data objects. The compilers align data types on a natural boundary; in other words, 32-bit data types are aligned on a 32-bit boundary on 64-bit systems, and 64-bit data types are aligned on a 64-bit boundary on 64-bit systems. This means that the size of data objects such as a structure or a union will be different on 32-bit and 64-bit systems.
- Size of fundamental data types. Common assumptions about the relationships between the fundamental data types may no longer be valid in a 64-bit data model. Applications that depend on those relationships will fail when compiled on a 64-bit platform. For example, the assumption
sizeof (int) = sizeof (long) = sizeof (pointer)
is valid for the ILP32 data model, but not valid for others.
Sample Operating Systems:
Microsoft Win64 (X64/IA64) => LLP64
Fujitsu-owned HAL Computer Systems => ILP64
Endianism refers to the way in which data is stored, and defines how bytes are addressed in integral and floating point data types.
Little-endian means that the least significant byte is stored at the lowest memory address and the most significant byte is stored at the highest memory address.
Big-endian means that the most significant byte is stored at the lowest memory address and the least significant byte is stored at the highest memory address.
Table 3 shows a sample layout of a 64-bit long integer.
Table 3. Layout of a 64-bit long int
Low address | High address | |||||||
---|---|---|---|---|---|---|---|---|
Little endian | Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7 |
Big endian | Byte 7 | Byte 6 | Byte 5 | Byte 4 | Byte 3 | Byte 2 | Byte 1 | Byte 0 |
For example, the 32-bit word 0x12345678 will be laid out on a big endian machine as follows:
Table 4. 0x12345678 on a big-endian system
Memory offset | 0 | 1 | 2 | 3 |
Memory content | 0x12 | 0x34 | 0x56 | 0x78 |
If we view 0x12345678 as two half words, 0x1234 and 0x5678, we would see the following in a big endian machine:
Table 5. 0x12345678 as two half words on a big-endian system
Memory offset | 0 | 2 |
Memory content | 0x1234 | 0x5678 |
However, on a little endian machine, the word 0x12345678 will be laid out as follows:
Table 6. 0x12345678 on a little-endian system
Memory offset | 0 | 1 | 2 | 3 |
Memory content | 0x78 | 0x56 | 0x34 | 0x12 |
Similarly, the two half-words 0x1234 and 0x5678 would look like the following:
Table 7. 0x12345678 as two half words on a little-endian system
Memory offset | 0 | 2 |
Memory content | 0x5678 | 0x1234 |
The following example illustrates the difference in byte order between big endian and little endian machines.
The C program below will print out "Big endian" when compiled and run on a big endian machine, and "Little endian" when compiled and run on a little endian machine.
Listing 2. Big endian vs. little endian
#include
|
ref:
Porting Linux Applications to 64bit - http://www.ibm.com/developerworks/library/l-port64/index.html
Migrating to Solaris 64-bit: 32-bit Applications and Data Model - http://developers.sun.com/solaris/articles/solarisupgrade/64bit/Convert.html
Converting 32-bit Applications Into 64-bit Applications: Things to Consider - http://developers.sun.com/solaris/articles/ILP32toLP64Issues.html