1.23.4 ISO-compliant C library input/output characteristics

The generic ARM C library has defined input/output characteristics.

These input/output characteristics are as follows:

  • 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 NUL 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.
  • 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.
  • stdin, stdout, and stderr are assumed to be interactive devices. They are line-buffered at program startup, regardless of what _sys_istty reports for them. An exception is if they have been redirected on the command line.
  • localtime() is implemented and returns the local time. gmtime() is not implemented and returns NULL. Therefore converting between time-zones is not supported.
  • 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. Semihosting, 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(), fsetpos() and fgetpos() set errno to the value of EDOM on failure.
  • perror() generates the messages shown in the following table.

Table 1-11 perror() messages

Error Message
0 No error (errno = 0)
EDOM EDOM - function argument out of range
ERANGE ERANGE - function result not representable
ESIGNUM ESIGNUM - illegal signal number
Others Unknown error

The following characteristics are unspecified in the ARM C library. They must be specified in an ISO-compliant implementation:

  • 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().
Non-ConfidentialPDF file icon PDF versionARM DUI0475M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.