Solaris 7 64-bit Developer's Guide

Repack Structures

Internal data structures in applications should be checked for holes. Extra padding between fields in the structure to meet alignment requirements can be used, since any long or pointer fields will grow to 64 bits for LP64. In the 64-bit environment on SPARC platforms, all types of structures are aligned to at least the size of the largest quantity within them. A simple rule for repacking the structure is to move the long and pointer fields to the beginning of the structure.


Example 4-7

struct bar {
		int i;
		long j;
		int k;
		char *p;
};			/* sizeof (struct bar) = 32 */

Suggested use:


struct bar {
		char *p;
		long j;
		int i;
		int k;
};			/* sizeof (struct bar) = 24 */