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.
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:
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, you call the macros for that locale type in the order specified in the documentation. For example:
LC_TYPE_function
Where:
TYPEis one of the following:
CTYPE
COLLATE
MONETARY
NUMERIC
TIME
functionis a specific function 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. For example:
LC_TYPE_end
where:
TYPEis 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