
Monday February 27, 2006
IPL32 to LP64, Number One Porting Issue
ILP32 - integer, long, and pointer types are 32-bits in size
LP64 - long and pointer types are 64-bits in size, int remains 32-bitsin size
What's the number one issue with porting 32-bit application (ILP32) to a
64-bit environment (LP64)?
Failure to include system header files. Without including system header files system functions, like malloc(), are implicitly defined to return an int. An int is32-bits, with LP64 malloc() returns a 64-bit pointer which won't fit. Most of the time this results in a segmentation fault.
Checklist for getting started coverting an application to be 64-bitclean:
- Review all data structures and interfaces to verify that these are still valid in the 64-bit environment.
- Include <inttypes.h> in your code to pull in the _ILP32 or_LP64 definitions as well as many basic derived types. Systems programsmay wish to include <sys/types.h>(or at a minimum, <sys/isa_defs.h>) to obtain the definitions of _ILP32 or _LP64.
- Move function prototypes and external declarations with non-local scope to headers and include these headers in your code.
- Run lint using the -errchk=longptr64,signext option. Review each warning individually. Keep in mind that not all warnings require a change to the code. Depending on the changes, run lint again in both 32-bit and 64-bit modes, -Xarch=generic64.
- Compile code as both 32-bit and 64-bit.
- Test the application by executing the 32-bit version on the32-bit operating system, and the 64-bit version on the 64-bit operating system. With Solaris you can also test the 32-bit version on the64-bit operating system.
Some helpful links:
( Feb 27 2006, 10:56:11 AM PST )
Permalink