UNIX to Linux Porting: A Comprehensive Reference
|
|
F.2. Data Types, Addresses, and Machine Words
When porting applications to Linux on zSeries, it is important to know how the data types and addressing differ on the zSeries platform compared to other hardware platforms. F.2.1. 31-Bit Addresses
Current zSeries models are 64-bit architectures. For historical reasons, the next-smaller address size is 31-bit, not 32-bit. The 31-bit mode might still be in use for compatibility reasons. It is important to note that 31-bit addresses actually do not have a thirty-second bit, so any address 0x80000000 + n actually maps onto 0x00000000 + n. Note, however, that casting an integer value to a pointer value does not conform to the language standard. Also, absolute addresses are most likely platform-dependent, so any code actually affected by the problem just mentioned will probably need changes. Of course, pointer values created using the language's "official" features are always correct. For this reason, the compiler saves the effort to clear the leftmost bit, causing the following expression to yield false: (void*)0x80000000 == (void*)0x00000000 F.2.2. Absolute Addresses
A related problem is caused by applications that try to load code at an absolute address by calling mmap with the flag MAP_FIXED. Such usage of absolute addresses is not portable in general and may need changes. F.2.3. Numbering Conventions for Bits
In Linux, it is common to denote individual bits by the exponent they would have when interpreted as binary numbers. The bits of a 32-bit word, for example, would be denoted as follows: +--+--+--+----+--+--+ | 31 | 30 | 29 | ... 2 | 1 | 0 | +--+--+--+----+--+--+
Documentation related to the zSeries mainframe, however, counts bits from left to right: +--+--+--+-----+--+--+ | 0 | 1 | 2 | ... 29 | 30 | 31 | +--+--+--+-----+--+--+ Here, the rightmost bit with binary value 20 is called "bit 31." On a 64-bit system, this bit is called "bit 63." F.2.4. Standard Data Type Sizes
Table F-1 shows the standard sizes of C data types.
The alignment is always the same as the type sizethat is, a variable of type int is 4 bytes long and is stored at a 4-byte boundary. Table F-2 shows the standard data types of the Linux kernel.
You can find detailed information about data layout in the ELF Application Binary Interface Supplement.[2],[3] [2] http://oss.software.ibm.com/linux390/docu/l390abi0.pdf [3] http://oss.software.ibm.com/linux390/docu/lzsabi0.pdf |
|
|