The following interprocess communication (IPC) primitives continue to work between 64-bit and 32-bit processes:
The System V IPC primitives, such as shmop(2), semop(2), msgsnd(2)
mmap(2) on shared files
pipe(2) between processes
door_call(3DOOR) between processes
rpc(3NSL) between processes on the same or different machines using the external data representation described in xdr(3NSL)
Although all these primitives allow interprocess communication between
32-bit and 64-bit processes, you might need to take explicit steps to ensure
that data being exchanged between processes is correctly interpreted by all
of them. For example, two processes sharing data described by a C data structure
containing variables of type long
cannot do so without understanding
that a 32-bit process views this variable as a 4–byte quantity, while
a 64-bit process views this variable as an 8–byte quantity.
One way to handle this difference is to ensure that the data has exactly
the same size and meaning in both processes. Build the data structures using
fixed-width types, such as int32_t
and int64_t
.
A family of derived types that mirrors the system derived types is available in <sys/types32.h>. These types possess the same sign and sizes as the fundamental types of the 32-bit system but are defined in such a way that the sizes are invariant between the ILP32 and LP64 compilation environments.
Sharing pointers between 32-bit and 64-bit processes is substantially
more difficult. Obviously, pointer sizes are different, but more importantly,
while there is a 64-bit integer quantity (long long
) in existing
C usage, a 64-bit pointer has no equivalent in a 32-bit environment. In order
for a 64-bit process to share data with a 32-bit process, the 32-bit process
can only “see” up to 4 gigabytes of that shared data at a time.
The XDR routine xdr_long(3NSL)
might seem to be a problem; however, it is still handled as a 32-bit quantity
over the wire to be compatible with existing protocols. If the 64-bit version
of the routine is asked to encode a long
value that does not
fit into a 32-bit quantity, the encode operation fails.