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

Exiting from the program

2.5.3. Exiting from the program

The program can exit normally at the end of main() or it can exit prematurely because of an error.

Exiting from an assert

The behavior of the assert macro depends on the conditions in operation at the most recent occurrence of #include <assert.h>:

  1. If the NDEBUG macro is defined (on the command line or as part of a source file), the assert macro has no effect.

  2. If the NDEBUG macro is not defined, the assert expression (the expression given to the assert macro) is evaluated. If the result is TRUE, that is != 0, the assert macro has no further effect.

  3. If the assert expression evaluates to FALSE, the assert macro calls the __aeabi_assert() function if any of the following are true:

    • you are compiling with ‑‑strict

    • you are using ‑O0 or ‑O1

    • you are compiling with ‑‑library_interface=aeabi_clib or ‑‑library_interface=aeabi_glibc

    • __ASSERT_MSG is defined

    • _AEABI_PORTABILITY_LEVEL is defined and not 0.

  4. Otherwise, if the assert expression evaluates to FALSE and the conditions specified in point 3 above do not apply, the assert macro calls abort(). Then:

    1. abort() calls __rt_raise().

    2. If __rt_raise() returns, abort() tries to finalize the library.

If you are creating an application that does not use the library, __aeabi_assert() works if you re‑implement abort() and the stdio functions.

Another solution for retargeting is to re‑implement the __aeabi_assert() function itself. The function prototype is:

void __aeabi_assert(const char *expr, const char *file, int line);

where:

  • expr points to the string representation of the expression that was not TRUE

  • file and line identify the source location of the assertion.

The behavior for __aeabi_assert() supplied in the ARM C library to print a message on stderr and call abort().

You can restore the default behavior for __aeabi_assert() at higher optimization levels by defining __ASSERT_MSG.

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