| |||
| Home > The ARM C and C++ libraries > Definition of locale data blocks in the C library | |||
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, 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.
To begin defining your locale block, call the _begin macro.
This macro takes two arguments, a prefix and the textual name, as
follows:
LC_TYPE_begin prefix, name
where:
TYPEis one of the following:
CTYPE
COLLATE
MONETARY
NUMERIC
TIME.
prefixis the prefix for the assembler symbols defined within the locale data
nameis the textual name for the locale data.
To specify the data for your locale block, call the macros for that locale type in the order specified for that particular locale type. The syntax is as follows:
LC_TYPE_function
Where:
TYPEis one of the following:
CTYPE
COLLATE
MONETARY
NUMERIC
TIME.
functionis a specific function, table(), full_wctype(),
or multibyte(), related to your locale data.
When specifying locale data, you must call the macro repeatedly for each respective function.
To complete the definition of your locale data block, you
call the _end macro. This macro takes no arguments,
as follows:
LC_TYPE_end
where:
TYPEis one of the following:
CTYPE
COLLATE
MONETARY
NUMERIC
TIME.
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:
Example 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
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:
Example 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