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

Defining a locale block

2.7.3. Defining a locale block

The locale data blocks are defined using a set of assembly language macros provided in the rt_locale.s file. Therefore, the recommended way to define locale blocks is by writing an assembly language source file. RVCT provides a set of macros for each type of locale data block, for example LC_CTYPE, LC_COLLATE, LC_MONETARY, LC_NUMERIC, and LC_TIME. You define each locale block in the same way with a _begin macro, some data macros and an _end macro.

Specifying the beginning

To begin defining your locale block, you call the _begin macro. This macro takes two arguments, a prefix and the textual name. For example:

LC_TYPE_begin prefix, name

where:

TYPE

is one of the following:

  • CTYPE

  • COLLATE

  • MONETARY

  • NUMERIC

  • TIME

prefix

is the prefix for the assembler symbols defined within the locale data

name

is the textual name for the locale data.

Specifying the data

To specify the data for your locale block, you call the macros for that locale type in the order specified in the documentation. For example:

LC_TYPE_function

Where:

TYPE

is one of the following:

  • CTYPE

  • COLLATE

  • MONETARY

  • NUMERIC

  • TIME

function

is a specific function related to your locale data.

When specifying locale data, you must call the macro repeatedly for each respective function.

Specifying the ending

To complete the definition of your locale data block, you call the _end macro. This macro takes no arguments. For example:

LC_TYPE_end

where:

TYPE

is one of the following:

  • CTYPE

  • COLLATE

  • MONETARY

  • NUMERIC

  • TIME

Specifying a fixed locale

To write a fixed function that always returns the same locale, you can use the _start symbol name defined by the macros. Example 2.2 shows how this is implemented for the CTYPE locale.

Example 2.2. Fixed locale

        GET rt_locale.s

        AREA my_locales, DATA, READONLY

        LC_CTYPE_begin my_ctype_locale, "MyLocale"

        ...                           ; include other LC_CTYPE_xxx macros here

        LC_CTYPE_end

        AREA my_locale_func, CODE, READONLY

    _get_lc_ctype FUNCTION
        LDR r0, =my_ctype_locale_start
        BX lr
        ENDFUNC

Specifying multiple locales

Contiguous locale blocks suitable for passing to the _findlocale() function must be declared in sequence. You must call the macro LC_index_end to end the sequence of locale blocks. Example 2.3 shows how this is implemented for the CTYPE locale.

Example 2.3. Multiple locales

        GET rt_locale.s

        AREA my_locales, DATA, READONLY

    my_ctype_locales

        LC_CTYPE_begin my_first_ctype_locale, "MyLocale1"

        ...                           ; include other LC_CTYPE_xxx macros here

        LC_CTYPE_end

        LC_CTYPE_begin my_second_ctype_locale, "MyLocale2"

        ...                           ; include other LC_CTYPE_xxx macros here

        LC_CTYPE_end

        LC_index_end

        AREA my_locale_func, CODE, READONLY

        IMPORT _findlocale
    _get_lc_ctype FUNCTION
        LDR r0, =my_ctype_locales
        B _findlocale
        ENDFUNC
Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0378A