Keil™, An ARM® Company

RealView Libraries and Floating Point Support Guide

On-Line Manuals

RealView Libraries and Floating Point Support Guide

Preface
Introduction
The C and C++ Libraries
About the C and C++ libraries
Features of the C and C++ libraries
Namespaces
Writing reentrant and thread‑safe code
Introduction to reentrancy and thread‑safety
Use of static data in the C libraries
The __user_libspace static data area
Managing locks in multithreaded applications
Using the ARM C libraries with a multithreaded app
Thread‑safety in the ARM C libraries
Thread‑safety in the ARM C++ libraries
Building an application with the C library
Using the libraries with an application
Building an application for a semihosted environme
Building an application for a non semihosting envi
Building an application without the C library
Integer and FP helper functions
Bare machine integer C
Bare machine C with floating‑point
Exploiting the C library
The standalone C library functions
Tailoring the C library to a new execution environ
How C and C++ programs use the library functions
__rt_entry
Exiting from the program
__rt_exit()
__rt_lib_init()
__rt_lib_shutdown()
Tailoring static data access
Tailoring locale and CTYPE using assembler macros
Selecting locale at link time
Selecting locale at runtime
Defining a locale block
LC_CTYPE data block
LC_COLLATE data block
LC_MONETARY data block
LC_NUMERIC data block
LC_TIME data block
_get_lconv()
localeconv()
setlocale()
_findlocale()
The lconv structure
Tailoring locale and CTYPE using C macros
Selecting locale at link time
Selecting locale at runtime
Macros and utility functions
_get_lc_ctype()
_get_lc_collate()
_get_lc_monetary()
_get_lc_numeric()
_get_lc_time()
_get_lconv()
localeconv()
setlocale()
_findlocale()
__LC_CTYPE_DEF
__LC_COLLATE_DEF
__LC_TIME_DEF
__LC_NUMERIC_DEF
__LC_MONETARY_DEF
__LC_INDEX_END
The lconv structure
Tailoring error signaling, error handling, and pro
_sys_exit()
errno
__rt_errno_addr()
__raise()
__rt_raise()
__default_signal_handler()
_ttywrch()
__rt_fp_status_addr()
Tailoring storage management
Avoiding the ARM‑supplied heap and heap‑using
Support for malloc
Tailoring the runtime memory model
The memory models
Controlling the runtime memory model
Writing your own memory model
__user_initial_stackheap()
__user_setup_stackheap()
__user_heap_extend()
__user_heap_extent()
__user_stack_cleanup_space()
__rt_heap_extend()
__rt_stack_postlongjmp()
Tailoring the input/output functions
Dependencies on low‑level functions
Target‑dependent input/output support functions
_sys_open()
_sys_close()
_sys_read()
_sys_write()
_sys_ensure()
_sys_flen()
_sys_seek()
_sys_istty()
_sys_tmpnam()
_sys_command_string()
#pragma import(_main_redirection)
Tailoring other C library functions
clock()
_clock_init()
time()
remove()
rename()
system()
getenv()
_getenv_init()
Selecting real‑time division
ISO implementation definition
ISO C library implementation definition
Standard C++ library implementation definition
C library extensions
atoll()
strtoll()
strtoull()
printf()
snprintf()
vsnprintf()
lldiv()
llabs()
wcstombs()
alloca()
strlcpy()
strlcat()
_fisatty()
__heapstats()
__heapvalid()
Library naming conventions
Placing ARM libraries
Helper libraries
Identifying library variants
The C Micro-library
Floating‑point Support

Selecting locale at link time

2.7.1. Selecting locale at link time

The locale subsystem of the C library can be selected at link time or extended to be selectable at runtime. The following describes the use of locale categories by the library:

  • The default implementation of each locale category is for the C locale. The library also provides an alternative, ISO8859‑1 (Latin‑1 alphabet) implementation of each locale category that you can select at link time.

  • Both the C and ISO8859‑1 default implementations usually provide one locale for each category to select at runtime.

  • You can replace each locale category individually.

  • You can include as many locales in each category as you choose and you can name your locales as you choose.

  • Each locale category uses one word in the private static data of the library.

  • The locale category data is read‑only and position independent.

  • scanf() forces the inclusion of the LC_CTYPE locale category, but in either of the default locales this adds only 260 bytes of read‑only data to several kilobytes of code.

ISO8859‑1 Implementation

Table 2.7 shows the ISO8859‑1 (Latin‑1 alphabet) locale categories.

Table 2.7. Default ISO8859‑1 locales

SymbolDescription
__use_iso8859_ctypeSelects the ISO8859‑1 (Latin‑1) classification of characters. This is essentially 7‑bit ASCII, except that the character codes 160‑255 represent a selection of useful European punctuation characters, letters, and accented letters.
__use_iso8859_collateSelects the strcoll/strxfrm collation table appropriate to the Latin‑1 alphabet. The default C locale does not require a collation table.
__use_iso8859_monetarySelects the Sterling monetary category using Latin‑1 coding.
__use_iso8859_numericSelects separating thousands with commas in the printing of numeric values.
__use_iso8859_localeSelects all the ISO8859‑1 selections described in this table.

There is no ISO8859‑1 version of the LC_TIME category.

Shift‑JIS and UTF‑8 Implementation

Table 2.8 shows the Shift‑JIS (Japanese characters) or UTF‑8 (Unicode characters) locale categories.

Table 2.8. Default Shift‑JIS and UTF‑8 locales

FunctionDescription
__use_sjis_ctypeSets the character set to the Shift‑JIS multibyte encoding of Japanese characters
__use_utf8_ctypeSets the character set to the UTF‑8 multibyte encoding of all Unicode characters

The following describes the effects of Shift‑JIS encoding:

  • The ordinary ctype functions behave correctly on any byte value that is a self‑contained character in Shift‑JIS. For example, half‑width katakana characters, which Shift‑JIS encodes as single bytes between 0xA6 and 0xDF, is treated as alphabetic by isalpha().

  • The multibyte conversion functions, such as mbrtowc(), mbsrtowcs(), and wcrtomb(), all convert between wide strings in Unicode and multibyte character strings in Shift‑JIS.

  • printf("%ls") converts a Unicode wide string into Shift‑JIS output, and scanf("%ls") converts Shift‑JIS input into a Unicode wide string.

You can arbitrarily switch between multibyte locales and single‑byte locales at runtime if you include more than one in your application. By default, only one locale at a time is included.

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0378A