| |||
| Home > The C and C++ Libraries > ISO implementation definition > ANSI C library implementation definition | |||
The ANSI C library variants are listed in Library naming conventions.
The ANSI specification leaves some details to the implementors, but requires their implementation choices to be documented. The implementation details are described in this section.
The macro NULL expands
to the integer constant 0.
If a program redefines a reserved external identifier, an error might occur when the program is linked with the standard libraries. If it is not linked with standard libraries, no error is diagnosed.
The assert() function prints
the following message and then calls the abort() function:
*** assertion failed:expression, file_FILE_, line_LINE_
The following functions test for character values in the range EOF (–1) to 255 (inclusive):
isalnum()
isalpha()
iscntrl()
islower()
isprint()
isupper()
ispunct().
The mathematical functions shown in Table 4.2, when supplied with out-of-range arguments, respond in the way shown.
Table 4.2. Mathematical functions
| Function | Condition | Returned value | Error number |
|---|---|---|---|
acos(x) | abs(x) > 1 | QNaN | EDOM |
asin(x) | abs(x) > 1 | QNaN | EDOM |
atan2(x,y) | x =0, y = 0 | QNaN | EDOM |
atan2(x,y) | x = Inf, y = Inf | QNaN | EDOM |
cos(x) | x=Inf | QNaN | EDOM |
cosh(x) | Overflow | +Inf | ERANGE |
exp(x) | Overflow | +Inf | ERANGE |
exp(x) | Underflow | +0 | ERANGE |
fmod(x,y) | x=Inf | QNaN | EDOM |
fmod(x,y) | y = 0 | QNaN | EDOM |
log(x) | x < 0 | QNaN | EDOM |
log(x) | x = 0 | -Inf | EDOM |
log10(x) | x < 0 | QNaN | EDOM |
log10(x) | x = 0 | -Inf | EDOM |
pow(x,y) | Overflow | +Inf | ERANGE |
pow(x,y) | Underflow | 0 | ERANGE |
pow(x,y) | x=0 or x=Inf, y=0 | +1 | EDOM |
pow(x,y) | x=+0, y<0 | -Inf | EDOM |
pow(x,y) | x=-0,
y<0 and y integer | -Inf | EDOM |
pow(x,y) | x= -0,
y<0 and y noninteger | QNaN | EDOM |
pow(x,y) | x<0, y noninteger | QNaN | EDOM |
pow(x,y) | x=1, y=Inf | QNaN | EDOM |
sqrt(x) | x < 0 | QNaN | EDOM |
sin(x) | x=Inf | QNaN | EDOM |
sinh(x) | Overflow | +Inf | ERANGE |
tan(x) | x=Inf | QNaN | EDOM |
atan(x) | SNaN | SNaN | None |
ceil(x) | SNaN | SNaN | None |
floor(x) | SNaN | SNaN | None |
frexp(x) | SNaN | SNaN | None |
ldexp(x) | SNaN | SNaN | None |
modf(x) | SNaN | SNaN | None |
tanh(x) | SNaN | SNaN | None |
HUGE_VAL is an alias for Inf.
Consult the errno variable for the error number.
Other than the cases shown in Table 4.2, all functions return QNaN when
passed QNaN and throw an invalid operation exception
when passed SNaN.
The signals listed in Table 4.3 are supported by the signal() function.
Table 4.3. Signal function signals
| Signal | Number | Description | Additional argument |
|---|---|---|---|
| SIGABRT | 1 | Abort | None |
| SIGFPE | 2 | Arithmetic exception | A set of bits from {FE_EX_INEXACT, FE_EX_UNDERFLOW, FE_EX_OVERFLOW, FE_EX_DIVBYZERO, FE_EX_INVALID, DIVBYZERO} |
| SIGILL | 3 | Illegal instruction | None |
| SIGINT | 4 | Attention request from user | None |
| SIGSEGV | 5 | Bad memory access | None |
| SIGTERM | 6 | Termination request | None |
| SIGSTAK | 7 | Stack overflow | None |
| SIGRTRED | 8 | Redirection failed on a runtime library input/output stream | Name of file or device being re-opened to redirect a standard stream |
| SIGRTMEM | 9 | Out of heap space | Size of failed request |
| SIGUSR1 | 10 | User-defined | User-defined |
| SIGUSR2 | 11 | User-defined | User-defined |
| SIGPVFN | 12 | A pure virtual function was called from C++ | - |
| SIGCPPL | 13 | Exception from C++ | - |
| reserved | 14-31 | Reserved | Reserved |
| other | > 31 | User-defined | User-defined |
A signal number greater than SIGUSR2 can
be passed through __raise(), and caught by the
default signal handler, but it cannot be caught by a handler registered
using signal().
signal() returns an error code if you
try to register a handler for a signal number greater than SIGUSR2.
The default handling of all recognized signals is to print
a diagnostic message and call exit(). This
default behavior applies at program startup and until you change
it.
The IEEE 754 standard for floating-point processing states that the default action to an exception is to proceed without a trap. A raised exception in floating-point calculations does not, by default, generate SIGFPE.
For all the signals in Table 4.3, when a signal occurs, if the handler
points to a function, the equivalent of signal(sig, SIG_DFL) is
executed before the call to handler.
If the SIGILL signal is received by
a handler specified to by the signal() function,
the default handling is reset.
The generic ARM C library has the following input/output characteristics:
The last line of a text stream does not require a terminating newline character.
Space characters written out to a text stream immediately before a newline character do appear when read back in.
No null characters are appended to a binary output stream.
The file position indicator of an append mode stream is initially placed at the end of the file.
A write to a text stream causes the associated file to be truncated beyond the point where the write occurred if this is the behavior of the device category of the file.
The characteristics of file buffering agree with section 4.9.3 of the ANSI C standard.
A zero-length file, into which no characters have been written by an output stream, does exist.
A file can be opened many times for reading, but only once for writing or updating. A file cannot simultaneously be open for reading on one stream, and open for writing or updating on another.
Local time zones and Daylight Saving Time are not
implemented. The values returned indicate that the information is
not available. For example, the gmtime() function
always returns NULL.
The status returned by exit() is
the same value that was passed to it. For definitions of EXIT_SUCCESS and EXIT_FAILURE,
see the header file stdlib.h.
The error messages returned by the strerror() function
are identical to those given by the perror() function.
If the size of area requested is zero, calloc(), malloc(),
and realloc() return NULL.
abort() closes all open files
and deletes all temporary files.
fprintf() prints %p arguments
in lowercase hexadecimal format as if a precision of 8 had been
specified. If the variant form (%#p) is used,
the number is preceded by the character @.
fscanf() treats %p arguments
exactly the same as %x arguments.
fscanf() always treats the
character "-" in a %...[...] argument as a literal character.
ftell() and fgetpos() set errno to
the value of EDOM on failure.
perror() generates the messages
in Table 4.4.
The following characteristics, required to be specified in an ANSI-compliant implementation, are unspecified in the ARM C library:
the validity of a filename
whether remove() can remove
an open file
the effect of calling the rename() function
when the new name already exists
the effect of calling getenv() (the
default is to return NULL, no value available)
the effect of calling system()
the value returned by clock().