| |||
| Home > The C and C++ Libraries > ISO implementation definition > ISO C library implementation definition | |||
The ISO specification leaves some details to the implementors, but requires that implementation choices be documented. This section describes the ARM library implementation.
In the generic ARM C library:
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 __aeabi_assert() function
prints details of the failing diagnostic on stderr and
then calls the abort() function:
*** assertion failed: expression, file name, line number
The behavior of the assert macro depends
on the conditions in operation at the most recent occurrence of #include <assert.h> (see Exiting from an assert for details).
The following functions test for character values in the range EOF (–1)
to 255 (inclusive):
isalnum()
isalpha()
iscntrl()
islower()
isprint()
isupper()
ispunct().
The ISO C library variants are listed in Library naming conventions.
Table 5.18 shows how the mathematical functions respond when supplied with out-of-range arguments.
Table 5.18. 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 non-integer | QNaN | EDOM |
pow(x,y) | x<0, y non-integer | 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 5.18, all functions return QNaN when
passed QNaN and throw an invalid operation exception
when passed SNaN.
Table 5.19 shows
the signals supported by the signal() function.
Table 5.19. Signal functions
| Signal | Number | Description | Additional argument |
|---|---|---|---|
| SIGABRT | 1 | This signal is only used if abort() or assert() are called
by your application. | None |
| SIGFPE | 2 | Used to signal any arithmetic exception, for example, division by zero. Used by hard and soft floating-point and by integer division. | 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 was detected. | 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 during initialization or after corruption. | 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++. | - |
| SIGOUTOFHEAP | 14 | Returned by the C++ function ::operator
new when out of heap space. | Size of failed request |
| reserved | 15-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.
You can modify floating-point error handling by tailoring the functions
and definitions in fenv.h. See Tailoring error signaling, error handling,
and program exit and Chapter 6 Floating-point Support for more
details on floating-point.
For all the signals in Table 5.19, when a signal occurs, if the handler points
to a function, the equivalent of signal(sig, SIG_DFL) is
executed before the call to the 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 ISO C standard. If semihosting is used, the maximum number of open files is limited by the available target memory.
A zero-length file exists, that is, where no characters have been written by an output stream.
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 semihosting SVC, however,
does not pass the status back to the execution environment.
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() and realloc() return NULL.
If the size of area requested is zero, malloc() returns a
pointer to a zero-size block.
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
shown in Table 5.20.
Table 5.20. perror() messages
| Error | Message |
|---|---|
0 | No error (errno = 0) |
EDOM |
|
|
|
|
|
Others |
|
The following characteristics must be specified in an ISO-compliant implementation (these 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().