Installation guide

The following sections discuss each of these areas and the changes you
must make to your program to take full advantage of the 64-bit
environment, and to permit interoperability with 32-bit systems.
7.3.1 Pointers
This section describes migration problems that some applications will
encounter because they make assignments based on the assumption that
pointers are the same length as int variables. This section also contains
information on how to overcome problems with pointer-to-int assignments
with little or no recoding. (Information about other types of pointer
assignments that may require recoding is provided in Section 7.3.4.2.)
The following table shows the lengths of the data types that are used to
hold addresses and that can, in some usage situations, cause problems
when migrating an application to a DIGITAL UNIX system:
ULTRIX DIGITAL UNIX
Pointer
32 bits 64 bits
int
32 bits 32 bits
long
32 bits 64 bits
Many C programs, especially older C programs that do not conform to
currently accepted programming practices, assign pointers to int
variables. Such assignments are not recommended, but they do produce
correct results on systems in which pointers and int variables are the
same size. However, on a DIGITAL UNIX system, this practice can produce
incorrect results because the high-order 32 bits of a DIGITAL UNIX
address are lost when a 64-bit pointer is assigned to a 32-bit int variable.
The following code fragment shows this problem using DIGITAL UNIX:
{
char *x; /* 64-bit pointer */
int z; /* 32-bit int variable */
.
.
.
x = malloc(1024); /* get memory and store address in 64 bits */
z = x; /* assign low-order 32 bits of 64-bit pointer to
32-bit int variable */
}
Similar problems with the length of pointers occur in applications that
consist of a mix of C and FORTRAN programs in which a pointer in a C
program is declared as an INTEGER*4 variable in a FORTRAN program,
leaving the conversion implicit and causing the loss of the 32 high-order
bits in the pointer.
7–6 Migrating Your ULTRIX Application to a DIGITAL UNIX System