JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.3: C User's Guide     Oracle Solaris Studio 12.3 Information Library
search filter icon
search icon

Document Information

Preface

1.  Introduction to the C Compiler

2.  C-Compiler Implementation-Specific Information

2.1 Constants

2.1.1 Integral Constants

2.1.2 Character Constants

2.2 Linker Scoping Specifiers

2.3 Thread Local Storage Specifier

2.4 Floating Point, Nonstandard Mode

2.5 Labels as Values

2.6 long long Data Type

2.6.1 Printing long long Data Types

2.6.2 Usual Arithmetic Conversions

2.7 Case Ranges in Switch Statements

2.8 Assertions

2.9 Supported Attributes

2.10 Warnings and Errors

2.11 Pragmas

2.11.1 align

2.11.2 c99

2.11.3 does_not_read_global_data

2.11.4 does_not_return

2.11.5 does_not_write_global_data

2.11.6 dumpmacros

2.11.7 end_dumpmacros

2.11.8 error_messages

2.11.9 fini

2.11.10 hdrstop

2.11.11 ident

2.11.12 init

2.11.13 inline

2.11.14 int_to_unsigned

2.11.15 must_have_frame

2.11.16 nomemorydepend

2.11.17 no_side_effect

2.11.18 opt

2.11.19 pack

2.11.20 pipeloop

2.11.21 rarely_called

2.11.22 redefine_extname

2.11.23 returns_new_memory

2.11.24 unknown_control_flow

2.11.25 unroll

2.11.26 warn_missing_parameter_info

2.11.27 weak

2.12 Predefined Names

2.13 Preserving the Value of errno

2.14 Extensions

2.14.1 _Restrict Keyword

2.14.2 __asm Keyword

2.14.3 __inline and __inline__

2.14.4 __builtin_constant_p()

2.14.5 __FUNCTION__ and __PRETTY_FUNCTION__

2.15 Environment Variables

2.15.1 PARALLEL

2.15.2 SUN_PROFDATA

2.15.3 SUN_PROFDATA_DIR

2.15.4 TMPDIR

2.16 How to Specify Include Files

2.16.1 Using the -I- Option to Change the Search Algorithm

2.16.1.1 Warnings

2.17 Compiling in Free-Standing Environments

2.18 Compiler Support for Intel MMX and Extended x86 Platform Intrinsics

3.  Parallelizing C Code

4.  lint Source Code Checker

5.  Type-Based Alias Analysis

6.  Transitioning to ISO C

7.  Converting Applications for a 64-Bit Environment

8.  cscope: Interactively Examining a C Program

A.  Compiler Options Grouped by Functionality

B.  C Compiler Options Reference

C.  Implementation-Defined ISO/IEC C99 Behavior

D.  Features of C99

E.  Implementation-Defined ISO/IEC C90 Behavior

F.  ISO C Data Representations

G.  Performance Tuning

H.  Oracle Solaris Studio C: Differences Between K&R C and ISO C

Index

2.17 Compiling in Free-Standing Environments

The Oracle Solaris Studio C compiler supports compilation of programs that link with the standard C library and execute in a runtime environment that includes the standard C library and other runtime support libraries. The C standard terms such an environment a hosted environment. An environment that does not provide the standard library functions is termed a free-standing environment

The C compiler does not support the general case of compilation for free-standing environments because certain runtime support functions that might be called from compiled code are generally available only in the standard C library. The problem is that source code translation by the compiler may introduce calls to runtime support functions in source code constructs that do not contain function calls and these functions are generally not available for use in a freestanding environment. Consider the following example:

% cat -n lldiv.c
     1    void
     2    lldiv(
     3        long long *x,
     4        long long *y,
     5        long long *z)
     6    {
     7        *z = *x / *y ;
     8    }
% cc -c -m32 lldiv.c
% nm lldiv.o | grep " U "
 0x00000000 U __div64
% cc -c -m64 lldiv.c
% nm lldiv.o | grep " U "

In this example, when the source file lldiv.c is compiled to run on a 32–bit platform using the -m32 option, translation of the statement at line 7 results in an external reference to a runtime support function named __div64, which is only available in the 32–bit version of the standard C library.

When the same source file is compiled to run on a 64–bit platform using the -m64 option, the compiler uses the target machine's 64–bit arithmetic instruction set, obviating the need for a runtime support function in the 64–bit version of the standard C library.

Although the use of the C compiler to target a free-standing environment is not supported in the general case, the compiler can be used, with caveats, to compile code for a particular freestanding environment, namely the Oracle Solaris kernel and device drivers.

Code that runs in the Oracle Solaris kernel, including device drivers, must be written so that external function calls reference only functions that are available within the kernel. To make this possible, the following guidelines are recommended:

As noted previously, the compiler might generate calls to runtime support functions as a result of source code translation. For the specific case of the Oracle Solaris kernel, the set of runtime support functions that might be called is smaller than the general case, since the kernel does not use floating-point or complex types, math library functions, or compiler options associated with runtime support libraries.

The following table lists runtime support functions that may be called in code compiled to run in the Oracle Solaris kernel as a result of source code translation by the C compiler. The table lists platforms on which source code translation generates calls, names of called functions, and source constructs or compiler features that cause generation of function calls. Only 64–bit platforms are listed, since all versions of Solaris that support the C compiler run a 64–bit kernel.

When compiling for 32–bit instruction sets, additional machine-specific support functions may be called, due to specific limitations of the instruction set.

Table 2-4 Runtime Support Functions

Function
64–bit Platform
Reference From
__align_cpy_n
SPARC
returning large structs; n is 1,2,4,8, or 16
_memcpy
x86
returning large structs
_memcpy
x86 and SPARC
vectorization
_memmove
x86 and SPARC
vectorization
_memset
x86 and SPARC
vectorization

Note that some versions of the kernel do not provide _memmove(), _memcpy(), or _memset(), but do provide kernel mode analogues of the user mode routines memmove(), memcpy(), and memset().

It is important to note that when compiling Solaris kernel code for x86 platforms, the option -xvector=%none must be used. By default, the C compiler generates code using XMM registers on x86 platforms to improve performance of general user applications, including applications that do not use C floating point arithmetic types. Use of XMM registers is inappropriate for kernel code.

Additional information can be found in the Writing Device Drivers Guide, and the SPARC Compliance Definition, version 2.4.