Specifications

Red Hat Enterprise Linux to Oracle Solaris Porting Guide
21
The story is little different for member data in a structure, union, or class objects. The struct
member variables must be aligned to the highest bytes of the size of any member variables to prevent
performance penalties.
// 4-byte alignment
struct mystruct
{
char a; // size = 1 byte
// 3 bytes padding
int i; // size = 4 bytes
};
In the above example, the size of mystruct is 8 bytes.
// 8-byte alignment
struct mystruct_1
{
char a; // size = 1 byte
// 7 bytes padding
double i; // size = 8 bytes
};
In the above example, the size of mystruct_1 is 16 bytes.
Low-Level Code, Bit-Level Operations
When migrating from a 32-bit RHEL application to a 64-bit Oracle Solaris SPARC application, the
bit-shifting operations used inattentively in typical legacy C code can cause lots of problems. The
following example is a function that does a shift operation. Note that untyped integral constants are of
type unsigned int. During shifting, this can lead to unexpected truncation.
For example, in the following code, the maximum value for
i can be 31. This is because the type of
1 << i” is int.
long j = 1 << i;
To get the shift done on a 64-bit SPARC system, 1L should be used, as shown below:
long j = 1L << i;
System APIs
System Call Mapping
Both RHEL and Oracle Solaris are UNIX operating systems that follow the POSIX standard. Both
provide well-defined system call interfaces. Most of the system calls available on RHEL are also