Checklist for ILP32-to-LP64 pre-migration activities

Use the following checklist prior to migrating an application from ILP32 to LP64. After migration, test the code and confirm that its behavior is the same under LP64 as it was under ILP32. If you see any difference, debug the code and use the checklist again.

  1. Search the source code for patterns that might indicate migration issues. These include:
    • printf specifiers that involve long data types
    • 0xffffffff
    • 2147483647
  2. Verify that all functions are properly prototyped.
    Note: The C compiler assumes that an unprototyped function returns the int type. This could cause undesirable behavior under LP64 while remaining undetectable under ILP32.
  3. Examine all types to determine whether the types should be 4-byte or 8-byte.
    • For system types, the type will be the appropriate size for use with library/system calls.
    • For user-defined types:
      • 4-byte types should be defined based upon int or unsigned int or some system type that is 4 bytes long under LP64.
      • 8-byte types should be defined based upon long or unsigned long or some system type that is 8 bytes long.
  4. Change all types to the chosen type.
    Note: When doing so, examine all arithmetic calculations to make sure that expansion and truncation of data values is done appropriately. Make sure that no assumption is made that pointer values will fit into integer types.
  5. Use the INFO compiler option to identify the following potential problems:
    • Functions not prototyped - Function prototypes allow the compiler to check for mismatched parameters.
    • Functions not prototyped - Return parameter mis-matched, especially when the code expects a pointer. (For example, malloc and family)
    • Assignment of a long or a pointer to an int - This type of assignment could cause truncation. Even assignments with an explicit cast will be flagged.
    • Assignment of an int to a pointer - If the pointer is referenced it might be invalid.