4.13.1. 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 following functions test for character values in the range EOF (–1) to 255 (inclusive):

Mathematical functions

The mathematical functions shown in Table 4.17, when supplied with out-of-range arguments, respond in the way shown.

Table 4.17. Mathematical functions

FunctionConditionReturned valueError number
acos(x)abs(x) > 1QNaNEDOM
asin(x)abs(x) > 1QNaNEDOM
atan2(x,y)x =0, y = 0QNaNEDOM
atan2(x,y)x = Inf, y = InfQNaNEDOM
fmod(x,y)y = 0QNaNEDOM
log(x)x < 0QNaNEDOM
log(x)x = 0-InfEDOM
log10(x)x < 0QNaNEDOM
log10(x)x = 0-InfEDOM
pow(x,y)x=0 or x=Inf, y=0+1EDOM
pow(x,y)x=+0, y<0-InfEDOM
pow(x,y)x=-0, y<0 and y integer-InfEDOM
pow(x,y)x= -0, y<0 and y nonintegerQNaNEDOM
pow(x,y)x<0, y nonintegerQNaNEDOM
pow(x,y)x=1, y=InfQNaNEDOM
sqrt(x)x < 0QNaNEDOM

HUGE_VAL is an alias for Inf. Consult the errno variable for the error number. Other than the cases shown in Table 4.17, all functions return QNaN when passed QNaN and throw an invalid operation exception when passed SNaN.

Signal function

The signals listed in Table 4.18 are supported by the signal() function. See also Table 4.10 for signals used by the C and C++ libraries.

Table 4.18. Signal function signals

SignalNumberDescriptionAdditional argument
SIGILL3Illegal instructionNone
SIGINT4Attention request from userNone
SIGSEGV5Bad memory accessNone
SIGTERM6Termination requestNone
SIGSTAK7Stack overflowNone
SIGRTRED8Redirection failed on a runtime library input/output streamName of file or device being re-opened to redirect a standard stream
SIGRTMEM9Out of heap spaceSize of failed request
SIGPVFN12A pure virtual function was called from C++-
SIGCPPL13Exception from C++-
reserved 14-31ReservedReserved
other > 31User-definedUser-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 fp error handling by tailoring the functions and definitions in fenv.h. See Tailoring error signaling, error handling, and program exit, Chapter 5 Floating-point Support, and the chapter on floating-point in the ADS Developer Guide.

For all the signals in Table 4.18, 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.

Input/output characteristics

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. If semihosting is used, the maximum number of open files is limited by the available target memory.

  • 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 semihosting SWI, 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(), 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.19.

    Table 4.19. perror() messages

    0No error (errno = 0)

    EDOM - function argument out of range


    ERANGE - function result not representable


    ESIGNUM - illegal signal number


    Unknown error

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().

Copyright © 1999-2001 ARM Limited. All rights reserved.ARM DUI 0067D