1.9.3 Definition of locale data blocks in the C library

Locale data blocks let you customize your own locales.

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

LC_TYPE_begin prefix, name
Begins the definition of a locale block.
LC_TYPE_function
Specifies the data for a locale block.

Note:

  • When specifying locale data, you must call the macro repeatedly for each respective function.
  • To specify the data for your locale block, call the macros for that locale type in the order specified for that particular locale type.
LC_TYPE_end
Ends the definition of a locale block.

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.
function
is a specific function, table(), full_wctype(), or multibyte(), related to your locale data.

Example of a fixed locale block

To write a fixed function that always returns the same locale, you can use the _start symbol name defined by the macros. The following shows how this is implemented for the CTYPE 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

Example of multiple contiguous locale blocks

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. The following shows how this is implemented for the CTYPE locale:

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