Solaris 7 64-bit Developer's Guide

Which Solaris Operating Environment Are You Running?

This Solaris release supports two first-class Application Binary Interfaces simultaneously. In other words, two separate, fully functional system call paths connect into the 64-bit kernel; two sets of libraries support applications. See Figure 2-1.

The 64-bit operating system can only run on 64-bit CPU hardware, while the 32-bit version can run on either 32-bit CPU hardware or 64-bit CPU hardware. Because the Solaris 32-bit and 64-bit environments look very similar, it might not be immediately apparent which version is running on a particular hardware platform. The easiest way to determine which version is running on your system is to use the isainfo(1) command. This new command prints information about the application environments supported on the system.

The following is an example of the isainfo(1) commands executed on an UltraSPARCTM system running the 64-bit operating system:


% isainfo -v
64-bit sparcv9 applications
32-bit sparc applications  

When the same command is run on older SPARC systems, or on UltraSPARC systems running the 32-bit operating system:


% isainfo -v
32-bit sparc applications

When the same command is run on an x86 system:


% isainfo -v
32-bit i386 applications

One useful option of the isainfo(1) command is the -n option, which prints the native instruction set of the running platform:


% isainfo -n
sparcv9

Or the number of bits in the address space of the corresponding native applications environment:


% echo "Welcome to "`isainfo -b`"-bit Solaris"
Welcome to 64-bit Solaris

Applications that must run on earlier versions of Solaris can either base their version check on the output of uname(1), or can check for the existence of /usr/bin/isainfo to determine whether 64-bit capabilities are available.

A related command, isalist(1), that is more suited for use in shell scripts, can be used to print the complete list of supported instruction sets on the platform. Some of the instruction set architectures listed by isalist(1) are highly platform specific, while isainfo(1) describes only the attributes of the most portable applications environments on the system. Both commands are built on the SI_ISALIST suboption of the sysinfo(2) system call. See isalist(5) for further details.

The following is an example of the isalist(1) command executed on an UltraSPARC system running the 64-bit operating system:


% isalist
sparcv9+vis sparcv9 sparcv8plus+vis sparcv8plus sparcv8 
sparcv8-fsmuld sparcv7 sparc 

The list of supported instruction sets are ordered by level of performance and functionality. For more detail on the use of this command, see the isalist(1) man page. Also see the optisa(1) man page.


Note -

In the above example, the isalist(1) command displays sparcv9+vis and sparcv8+vis, which indicates that the system supports the UltraSPARC-1 extended instruction set. Because this extended instruction set is not supported on all SPARC V9 systems, it is recommended that portable applications not rely on its presence and should not code to the specifics of UltraSPARC.


Sample Program

The following sample program directly illustrates the effect of the LP64 versus ILP32 data models. The same program can be compiled as either a 32-bit program or a 64-bit program.


Note -

The default compilation environment is designed to maximize portability, that is, to create 32-bit applications.



% cat foo.c
#include <stdio.h>
int
main(int argc, char *argv[])
{
		(void) printf("char is \t\t%lu bytes\n", sizeof (char));
		(void) printf("short is \t%lu bytes\n", sizeof (short));
		(void) printf("int is \t\t%lu bytes\n", sizeof (int));
		(void) printf("long is \t\t%lu bytes\n", sizeof (long));
		(void) printf("long long is \t\t%lu bytes\n", sizeof (long long));
		(void) printf("pointer is \t%lu bytes\n", sizeof (void *));
		return (0);
} 

32-bit Compilation


% cc -O -o foo32 foo.c
% foo32 
char is          1 bytes
short is         2 bytes
int is           4 bytes
long is          4 bytes
long long is     8 bytes
pointer is       4 bytes   

64-bit Compilation


% cc -xarch=v9 -O -o foo64 foo.c 
% foo64
char is          1 bytes
short is         2 bytes
int is           4 bytes
long is          8 bytes
long long is     8 bytes 
pointer is       8 bytes