A P P E N D I X  C

Implementation-Defined ISO/IEC C99 Behavior

The ISO/IEC 9899:1999, Programming Languages - C standard specifies the form and establishes the interpretation of programs written in C. However, this standard leaves a number of issues as implementation-defined, that is, as varying from compiler to compiler. This chapter details these areas. The section numbers are provided as part of the headings in this appendix for ready comparison to the ISO/IEC 9899:1999 standard itself:


C.1 J.3 Implementation-defined Behavior

A conforming implementation is required to document its choice of behavior in each of the areas listed in this subclause. The following are implementation-defined:

C.1.1 J.3.1 Translation

Error and warning messages have the following format:

filename, line number: message

Where filename is the name of the file that contains the error or warning,

line number is the number of the line on which the error or warning is found, and message is the diagnostic message.

A sequence of nonempty characters consisting of a tab (\t), form-feed (\f), or vertical-feed (\v) are replaced by a single space character.

C.1.2 J.3.2 Environment

There are eight bits in a character for the ASCII portion; locale-specific multiples of eight bits for locale-specific extended portion.

The implementation is hosted environment.

The implementation is in a hosted environment.

There is no alternative way to define main other than that defined in the standard.

argv is an array of pointers to the command-line arguments, where argv[0] represents the program name if it is available.

An interactive device is one for which the system library call isatty() returns a nonzero value

The following table shows the semantics for each signal as recognized by the signal function:

TABLE C-1 Semantics of signal Function Signals

Signal Number

Default Event

Semantics of Signal

SIGHUP 1

Exit

hangup

SIGINT 2

Exit

interrupt (rubout)

SIGQUIT 3

Core

quit (ASCII FS)

SIGILL 4

Core

illegal instruction (not reset when caught)

SIGTRAP 5

Core

trace trap (not reset when caught)

SIGIOT 6

Core

IOT instruction

SIGABRT 6

Core

Used by abort

SIGEMT 7

Core

EMT instruction

SIGFPE 8

Core

floating point exception

SIGKILL 9

Exit

kill (cannot be caught or ignored)

SIGBUS 10

Core

bus error

SIGSEGV 11

Core

segmentation violation

SIGSYS 12

Core

bad argument to system call

SIGPIPE 13

Exit

write on a pipe with no one to read it

SIGALRM 14

Exit

alarm clock

SIGTERM 15

Exit

software termination signal from kill

SIGUSR1 16

Exit

user defined signal 1

SIGUSR2 17

Exit

user defined signal 2

SIGCLD 18

Ignore

child status change

SIGCHLD 18

Ignore

child status change alias (POSIX)

SIGPWR 19

Ignore

power-fail restart

SIGWINCH 20

Ignore

window size change

SIGURG 21

Ignore

urgent socket condition

SIGPOLL 22

Exit

pollable event occurred

SIGIO 22

Sigpoll

socket I/O possible

SIGSTOP 23

Stop

stop (cannot be caught or ignored)

SIGTSTP 24

Stop

user stop requested from tty

SIGCONT 25

Ignore

stopped process has been continued

SIGTTIN 26

Stop

background tty read attempted

SIGTTOU 27

Stop

background tty write attempted

SIGVTALRM 28

Exit

virtual timer expired

SIGPROF 29

Exit

profiling timer expired

SIGXCPU 30

Core

exceeded cpu limit

SIGXFSZ 31

Core

exceeded file size limit

SIGWAITING 32

Ignore

reserved signal no longer used by threading code

SIGLWP 33

Ignore

reserved signal no longer used by threading code

SIGFREEZE 34

Ignore

Checkpoint suspend

SIGTHAW 35

Ignore

Checkpoint resume

SIGCANCEL 36

Ignore

Cancellation signal used by threads library

SIGLOST 37

Ignore

resource lost (record-lock lost)

SIGXRES 38

Ignore

Resource control exceeded (see setrctl(2))

SIGJVM1 39

Ignore

Reserved for Java Virtual Machine 1

SIGJVM2 40

Ignore

Reserved for Java Virtual Machine 2


SIGILL, SIGFPE, SIGSEGV, SIGTRAP, SIGBUS, and SIGEMT, see TABLE C-1.

SIGILL, SIGFPE, SIGSEGV, SIGTRAP, SIGBUS, and SIGEMT, see TABLE C-1.

The environment names are listed in the man page environ(5).

From the system(3C) man page:

The system() function causes string to be given to the shell as input, as if string had been typed as a command at a terminal. The invoker waits until the shell has completed, then returns the exit status of the shell in the format specified by waitpid(2).

If string is a null pointer, system() checks if the shell exists and is executable. If the shell is available, system() returns a non-zero value; otherwise, it returns 0.

C.1.3 J.3.3 Identifiers

None

1023

C.1.4 J.3.4 Characters

There are 8 bits in a byte.

Mapping is identical between source and execution characters.

It is the numerical value of the low order 8 bits associated with the character assigned to the char object.

A signed char is treated as a "plain" char (SPARC) (Intel).

Mapping is identical between source and execution characters.

A multiple-character constant that is not an escape sequence has a value derived from the numeric values of each character.

A multiple-character wide character constant that is not an escape sequence has a value derived from the numeric values of each character.

The valid locale specified by LC_ALL, LC_CTYPE, or LANG environment variable.

The valid locale specified by LC_ALL, LC_CTYPE, or LANG environment variable.

Each byte of the multibyte character forms a character of the string literal, with a value equivalent to the numerical value of that byte in the multibyte character.

C.1.5 J.3.5 Integers

None

Signed integer types are represented as two's complement. Extraordinary value is an ordinary value.

Not applicable to this implementation.

When an integer is converted to a shorter signed integer, the low order bits are copied from the longer integer to the shorter signed integer. The result may be negative.

When an unsigned integer is converted to a signed integer of equal size, the low order bits are copied from the unsigned integer to the signed integer. The result may be negative.

The result of a bitwise operation applied to a signed type is the bitwise operation of the operands, including the sign bit. Thus, each bit in the result is set if--and only if--each of the corresponding bits in both of the operands is set.

C.1.6 J.3.6 Floating point

The accuracy of floating point operations is consistent with the settings of FLT_EVAL_METHOD. The accuracy of the library functions in <math.h> and <complex.h> is as specified in the libm(3LIB) man page.

Not applicable to this implementation.

Not applicable to this implementation.

It honors the prevailing rounding direction mode.

It honors the prevailing rounding direction mode.

Floating-point constant is always rounded to the nearest representable value.

Not applicable to this implementation.

For -fsimple=0, the default value is ON. Otherwise for all other values of -fsimple, the default value for FENV_ACCESS is OFF.

Not applicable to this implementation.

For -fsimple=0, the default value is OFF. Otherwise for all other values of -fsimple, the default value for FENV_ACCESS is ON.

Results are indeterminable.

The hardware does not raise underflow or inexact in such cases when trapping on underflow is disabled (the default).

C.1.7 J.3.7 Arrays and Pointers

The bit pattern does not change when converting pointers and integers. Except when the results cannot be represented in the integer or pointer type, and then the results are undefined.

int as defined in stddef.h. long for -Xarch=v9

C.1.8 J.3.8 Hints

The number of effective register declarations depends on patterns of use and definition within each function and is bounded by the number of registers available for allocation. Neither the compiler nor the optimizer is required to honor register declarations.

The inline keyword is effective in causing the inlining of code only when using optimization, and only when the optimizer determines it is profitable to inline. See Section A.1.1, Optimization and Performance Options for a list of optimization options.

C.1.9 J.3.9 Structures, Unions, Enumerations, and Bit-fields

It is treated as an unsigned int.

A bit field can be declared as any integer type.

Bit-fields do not straddle storage-unit boundaries.

Bit-fields are allocated within a storage unit from high-order to low-order.

This is an int.

C.1.10 J.3.10 Qualifiers

Each reference to the name of an object constitutes one access to the object.

C.1.11 J.3.11 Preprocessing Directives

Source file characters are mapped to their corresponding ASCII values.

A character constant within a preprocessing directive has the same numeric value as it has within any other expression.

Character constants in this context may have negative values (SPARC) (Intel).

The location of header files depends upon the options specified on the command line, and in which file the #include directive appears. For more information, see Section 2.14, How to Specify Include Files.

The location of header files depends upon the options specified on the command line, and in which file the #include directive appears. For more information, see Section 2.14, How to Specify Include Files.

All the tokens making up the header name (including white space) are treated as the file path used when searching for the header as described in Section 2.14, How to Specify Include Files.

No limit is imposed by the compiler.

No.

See Section 2.8, Pragmas for a description of the behavior of each recognized non-STDC #pragma directive.

These macros are always available from the environment.

C.1.12 J.3.12 Library Functions

The implementation is on a hosted environment.

The diagnostic is structured as follows:

Assertion failed: statement. file filename, line number, function name

statement is the statement which failed the assertion. filename is the value of __FILE__. line number is the value of __LINE__. function name is the value of __func__.

Each exception stored in the status flag by fegetexceptflag expands to an integer constant expression with values such that bitwise-inclusive ORs of all combinations of the constants result in distinct values.

No, "inexact" is not raised.

Intentionaly left blank.

typedef float float_t;

typedef double double_t;

typedef long double float_t;

typedef long double double_t;

ilogb(), ilogbf() and ilogbl() raise the invalid exception if the input argument is 0, +/-Inf or NaN.

The values returned on domain errors in full C99 mode (-xc99=%all,lib), are as specified in Annex F of ISO/IEC 9899:1999, Programming Languages - C.

For underflow range errors: if the value can be represented as a subnormal number, the subnormal number is returned; otherwise +-0 is returned as appropriate.

As for whether errno is set to the value of the macro ERANGE when the integer expression math_errhandling & MATH_ERRNO is nonzero, since (math_errhandling & MATH_ERRNO) == 0 in our implementation, this part does not apply.

Whether the "underflow" floating-point exception is raised when the integer expression math_errhandling & MATH_ERREXCEPT is nonzero (7.12.1), the exception is raised when a floating-point underflow is coupled with loss of accuracy.

A domain error occurs.

31.

The equivalent of signal(sig, SIG_DFL); is executed prior to the call of a signal handler.

NULL expands to 0.

The last line does not need to end in a newline.

All characters appear when the stream is read.

No null characters are appended to a binary stream.

The file position indicator is initially positioned at the end of the file.

A write on a text stream does not cause a file to be truncated beyond that point unless a hardware device forces it to happen.

Output streams, with the exception of the standard error stream (stderr), are by default-buffered if the output refers to a file, and line-buffered if the output refers to a terminal. The standard error output stream (stderr) is by default unbuffered.

A buffered output stream saves many characters, and then writes the characters as a block. An unbuffered output stream queues information for immediate writing on the destination file or terminal immediately. Line-buffered output queues each line of output until the line is complete (a newline character is requested).

A zero-length file does exist since it has a directory entry.

A valid file name can be from 1 to 1,023 characters in length and can use all character except the characters null and / (slash).

The same file can be opened multiple times.

The encodings used for multibyte characters are the same for each file.

The file is deleted on the last call which closes the file. A program cannot open a file which has already been removed.

If the file exists, it is removed and the new file is written over the previously existing file.

If the process is killed in the period between file creation and unlinking, a permanent file may be left behind. See the freopen(3C) man page.

The following changes of mode are permitted, depending upon the access mode of the file descriptor underlying the stream:

See the freopen(3C) man page.

[-]Inf, [-]NaN. With F conversion specifier, [-]INF, [-]NAN.

The output for %p is equivalent to %x.

If a - is in the scanlist and is not the first character, nor the second where the first character is a ^, nor the last character, it indicates a range of characters to be matched.

See the fscanf(3C) man page.

Matches the set of sequences that is the same as the set of sequences that is produced by the %p conversion of the corresponding printf(3C) functions. The corresponding argument must be a pointer to a pointer to void. If the input item is a value converted earlier during the same program execution, the pointer that results will compare equal to that value; otherwise the behavior of the %p conversion is undefined.

See the fscanf(3C) man page.

No special meaning is given to the n-char sequence.

Yes, errno is set to ERANGE on underflow.

Either a null pointer or a unique pointer that can be passed to free() is returned.

See the malloc(3C) man page.

The abnormal termination processing includes at least the effect of fclose(3C) on all open streams. See the abort(3C) man page.

Open streams are closed and do not flush open streams. See the _Exit(2) man page.

The status made available to wait(3C) or waitpid(3C) by abort will be that of a process terminated by the SIGABRT signal. See the abort(3C), exit(1), and _Exit(2) man pages.

The termination status returned by exit, or _Exit, depends on the what the parent process of the calling process is doing.

If the parent process of the calling process is executing a wait(3C), wait3(3C), waitid(2), or waitpid(3C), and has neither set its SA_NOCLDWAIT flag nor set SIGCHLD to SIG_IGN, it is notified of the calling process's termination and the low-order eight bits (that is, bits 0377) of status are made available to it. If the parent is not waiting, the child's status is made available to it when the parent subsequently executes wait(), wait3(), waitid(), or waitpid().

The exit status of the shell in the format specified by waitpid(3C).

The local time zone is set by the environment variable TZ.

The precision of clock_t and time_t is one millionth of a second. The range is -2147483647-1 to 4294967295 millionths of a second on x86 and sparc v8. And -9223372036854775807LL-1 to 18446744073709551615 on SPARC v9.

The era for the clock is represented as clock ticks with the origin at the beginning of the execution of the program.

The time zone name or abbreviation, or by no characters if no time zone is determinable.

The inexact exception is generally raised when the result is not exactly representable. The inexact exception can be raised even when the result is exactly representable.

No attempt is made to force the default rounding direction mode for all functions in <math.h>.

C.1.13 J.3.13 Architecture

#define CHAR_BIT 8 /* max # of bits in a "char" */
#define SCHAR_MIN (-128) /* min value of a "signed char" */
#define SCHAR_MAX 127 /* max value of a "signed char" */
#define CHAR_MIN SCHAR_MIN /* min value of a "char" */
#define CHAR_MAX SCHAR_MAX /* max value of a "char" */
#define MB_LEN_MAX 5
#define SHRT_MIN (-32768) /* min value of a "short int" */
#define SHRT_MAX 32767 /* max value of a "short int" */
#define USHRT_MAX 65535 /* max value of "unsigned short int" */
#define INT_MIN (-2147483647-1) /* min value of an "int" */
#define INT_MAX 2147483647 /* max value of an "int" */
#define UINT_MAX 4294967295U /* max value of an "unsigned int" */
#define LONG_MIN (-2147483647L-1L)
#define LONG_MAX 2147483647L /* max value of a "long int" */
#define ULONG_MAX 4294967295UL /* max value of "unsigned long int" */
#define LLONG_MIN (-9223372036854775807LL-1LL)
#define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL
 
#define FLT_RADIX 2
#define FLT_MANT_DIG 24
#define DBL_MANT_DIG 53
#define LDBL_MANT_DIG 64
 
#if defined(__sparc)
#define DECIMAL_DIG 36
#elif defined(__i386)
#define DECIMAL_DIG 21
#endif
#define FLT_DIG 6
#define DBL_DIG 15
#if defined(__sparc)
#define LDBL_DIG 33
#elif defined(__i386)
#define LDBL_DIG 18
#endif
 
#define FLT_MIN_EXP (-125)
#define DBL_MIN_EXP (-1021)
#define LDBL_MIN_EXP (-16381)
 
#define FLT_MIN_10_EXP (-37)
#define DBL_MIN_10_EXP (-307)
#define LDBL_MIN_10_EXP (-4931)
 
#define FLT_MAX_EXP (+128)
#define DBL_MAX_EXP (+1024)
#define LDBL_MAX_EXP (+16384)
 
#define FLT_EPSILON 1.192092896E-07F
#define DBL_EPSILON 2.2204460492503131E-16
 
#if defined(__sparc)
#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L
#elif defined(__i386)
#define LDBL_EPSILON 1.0842021724855044340075E-19L
#endif
 
#define FLT_MIN 1.175494351E-38F
#define DBL_MIN 2.2250738585072014E-308
 
#if defined(__sparc)
#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L
#elif defined(__i386)
#define LDBL_MIN 3.3621031431120935062627E-4932L
#endif
 
#define INT8_MAX (127)
#define INT16_MAX (32767)
#define INT32_MAX (2147483647)
#define INT64_MAX (9223372036854775807LL)
 
#define INT8_MIN (-128)
#define INT16_MIN (-32767-1)
#define INT32_MIN (-2147483647-1)
#define INT64_MIN (-9223372036854775807LL-1)
 
#define UINT8_MAX (255U)
#define UINT16_MAX (65535U)
#define UINT32_MAX (4294967295U)
#define UINT64_MAX (18446744073709551615ULL)
 
#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST64_MIN INT64_MIN
 
#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MAX INT64_MAX
 
#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
 
#define INT_FAST8_MIN INT8_MIN
#define INT_FAST16_MIN INT16_MIN
#define INT_FAST32_MIN INT32_MIN
#define INT_FAST64_MIN INT64_MIN
 
#define INT_FAST8_MAX INT8_MAX
#define INT_FAST16_MAX INT16_MAX
#define INT_FAST32_MAX INT32_MAX
#define INT_FAST64_MAX INT64_MAX
 
#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST16_MAX UINT16_MAX
#define UINT_FAST32_MAX UINT32_MAX
#define UINT_FAST64_MAX UINT64_MAX

The implementation-defined number, order, and encodings of objects not explicitly specified in the 1999 C standard have be defined elsewhere in this chapter.

The following table lists the results for sizeof.

TABLE C-4 Results From the sizeof Operator in Bytes

Type

Size in Bytes

char

1

short

2

int

4

long

4

long v9

8

long long

8

float

4

double

8

long double (SPARC)

16

long double (Intel)

12

pointer

4

pointer v9

8

 

_Complex float

8

 

_Complex double

16

 

_Complex long double

32

 

_Imaginary float

4

 

_Imaginary double

8

 

_Imaginary long double (SPARC)

16

 

_Imaginary long double (Intel)

12


C.1.14 J.4 Locale-specific Behavior

The following characteristics of a hosted environment are locale-specific and are required to be documented by the implementation:

Locale-specific (no extension in C locale).

There are no multibyte characters present in the execution characters set in the default or C locales.

There are no shift states.

Printing is always left to right.

Locale-specific ("." in C locale).

Locale-specific ("." in C locale).

The control character set is comprised of horizontal tab, vertical tab, form feed, alert, backspace, carriage return, and new line.

See the isalpha(3C) and iswalpha(3C) man pages for descriptions of isalpha() and iswalpha() as well as information on the related macros mentioned above. Note that their behaviors can be modified by changing locale.

The native environment is specified by the LANG and LC_* environment variables as described in the setlocale(3C) man page. However, if these environment variables are not set, the native environment is set to the C locale.

The radix character is defined in the program's locale (category LC_NUMERIC), and may be defined as something other than a period (.).

Locale-specific (ASCII collation in C locale).

If the application is linked with -lintl, then messages returned by this function are in the native language specified by the LC_MESSAGES locale category. Otherwise they are in the C locale.

Locale-specific. Formats for the C locale are shown in the tables below.

The names of the months are specified below:

TABLE C-5 The Names of the Months

January

May

September

February

June

October

March

July

November

April

August

December


The names of the days of the week are specified below:

TABLE C-6 Days and Abbreviated Days of the Week

Days

Abbreviated Days

Sunday Thursday

Sun Thu

Monday Friday

Mon Fri

Tuesday Saturday

Tue Sat

Wednesday

Wed


The format for time is:

%H:%M:%S

The format for date is:

%m/%d/ -Xc mode.

The formats for AM and PM designation are: AM PM

The rules of the coded character set defined by character mapping information in the program's locale (category LC_CTYPE) may provide for character mappings other than tolower and toupper. Refer to the Solaris Internationalization Guide For Developers, for details of available locales and their definitions.

See the Solaris Internationalization Guide For Developers, for details of available locales and any non-standard reserved character classifications.