ARM® Compiler ARM C and C++ Libraries and Floating-Point Support User Guide

Version 5.04


Table of Contents

Preface
About this book
Using this book
Glossary
Typographic conventions
Feedback
Other information
1 The ARM C and C++ Libraries
1.1 Mandatory linkage with the C library
1.2 C and C++ runtime libraries
1.3 C and C++ library features
1.4 Library heap usage requirements of the ARM C and C++ libraries
1.5 Compliance with the Application Binary Interface (ABI) for the ARM architecture
1.6 Increasing portability of object files to other CLIBABI implementations
1.7 ARM C and C++ library directory structure
1.8 Selection of ARM C and C++ library variants based on build options
1.9 Thumb C libraries
1.10 C++ and C libraries and the std namespace
1.11 ARM C libraries and multithreading
1.12 ARM C libraries and reentrant functions
1.13 ARM C libraries and thread-safe functions
1.14 Use of static data in the C libraries
1.15 Use of the __user_libspace static data area by the C libraries
1.16 C library functions to access subsections of the __user_libspace static data area
1.17 Re-implementation of legacy function __user_libspace() in the C library
1.18 Management of locks in multithreaded applications
1.19 How to ensure re-implemented mutex functions are called
1.20 Using the ARM C library in a multithreaded environment
1.21 Thread safety in the ARM C library
1.22 Thread safety in the ARM C++ library
1.23 The floating-point status word in a multithreaded environment
1.24 Using the C library with an application
1.25 Using the C and C++ libraries with an application in a semihosting environment
1.26 Using $Sub$$ to mix semihosted and nonsemihosted I/O functionality
1.27 Using the libraries in a nonsemihosting environment
1.28 C++ exceptions in a non-semihosting environment
1.29 Direct semihosting C library function dependencies
1.30 Indirect semihosting C library function dependencies
1.31 C library API definitions for targeting a different environment
1.32 Building an application without the C library
1.33 Creating an application as bare machine C without the C library
1.34 Integer and floating-point compiler functions and building an application without the C library
1.35 Bare machine integer C
1.36 Bare machine C with floating-point processing
1.37 Customized C library startup code and access to C library functions
1.38 Using low-level functions when exploiting the C library
1.39 Using high-level functions when exploiting the C library
1.40 Using malloc() when exploiting the C library
1.41 Tailoring the C library to a new execution environment
1.42 Initialization of the execution environment and execution of the application
1.43 C++ initialization, construction and destruction
1.44 Legacy support for C$$pi_ctorvec instead of .init_array
1.45 Exceptions system initialization
1.46 Emergency buffer memory for exceptions
1.47 Library functions called from main()
1.48 Program exit and the assert macro
1.49 Assembler macros that tailor locale functions in the C library
1.50 Link time selection of the locale subsystem in the C library
1.51 ISO8859-1 implementation
1.52 Shift-JIS and UTF-8 implementation
1.53 Runtime selection of the locale subsystem in the C library
1.54 Definition of locale data blocks in the C library
1.55 LC_CTYPE data block
1.56 LC_COLLATE data block
1.57 LC_MONETARY data block
1.58 LC_NUMERIC data block
1.59 LC_TIME data block
1.60 Modification of C library functions for error signaling, error handling, and program exit
1.61 Avoiding the heap and heap-using library functions supplied by ARM
1.62 C library support for memory allocation functions
1.63 Heap1, standard heap implementation
1.64 Heap2, alternative heap implementation
1.65 Using a heap implementation from bare machine C
1.66 Stack pointer initialization and heap bounds
1.67 Defining __initial_sp, __heap_base and __heap_limit
1.68 Extending heap size at runtime
1.69 Legacy support for __user_initial_stackheap()
1.70 Tailoring input/output functions in the C and C++ libraries
1.71 Target dependencies on low-level functions in the C and C++ libraries
1.72 The C library printf family of functions
1.73 The C library scanf family of functions
1.74 Redefining low-level library functions to enable direct use of high-level library functions in the C library
1.75 The C library functions fread(), fgets() and gets()
1.76 Re-implementing __backspace() in the C library
1.77 Re-implementing __backspacewc() in the C library
1.78 Redefining target-dependent system I/O functions in the C library
1.79 Tailoring non-input/output C library functions
1.80 Real-time integer division in the ARM libraries
1.81 Selecting real-time division in the ARM libraries
1.82 How the ARM C library fulfills ISO C specification requirements
1.83 mathlib error handling
1.84 ISO-compliant implementation of signals supported by the signal() function in the C library and additional type arguments
1.85 ISO-compliant C library input/output characteristics
1.86 Standard C++ library implementation definition
1.87 C library functions and extensions
1.88 Persistence of C and C++ library names across releases of the ARM compilation tools
1.89 Link time selection of C and C++ libraries
1.90 Managing projects that have explicit C or C++ library names in makefiles
1.91 Compiler generated and library-resident helper functions
1.92 C and C++ library naming conventions
1.93 Using macro__ARM_WCHAR_NO_IO to disable FILE declaration and wide I/O function prototypes
1.94 Using library functions with execute-only memory
2 The ARM C Micro-library
2.1 About microlib
2.2 Differences between microlib and the default C library
2.3 Library heap usage requirements of the ARM C micro-library
2.4 ISO C features missing from microlib
2.5 Building an application with microlib
2.6 Creating an initial stack pointer for use with microlib
2.7 Creating the heap for use with microlib
2.8 Entering and exiting programs linked with microlib
2.9 Tailoring the microlib input/output functions
3 Floating-point Support
3.1 About floating-point support
3.2 The software floating-point library, fplib
3.3 Calling fplib routines
3.4 fplib arithmetic on numbers in a particular format
3.5 fplib conversions between floats, long longs, doubles, and ints
3.6 fplib comparisons between floats and doubles
3.7 fplib C99 functions
3.8 Controlling the ARM floating-point environment
3.9 Floating-point functions for compatibility with Microsoft products
3.10 C99-compatible functions for controlling the ARM floating-point environment
3.11 C99 rounding mode and floating-point exception macros
3.12 Exception flag handling
3.13 Functions for handling rounding modes
3.14 Functions for saving and restoring the whole floating-point environment
3.15 Functions for temporarily disabling exceptions
3.16 ARM floating-point compiler extensions to the C99 interface
3.17 Writing a custom exception trap handler
3.18 Example of a custom exception handler
3.19 Exception trap handling by signals
3.20 Using C99 signalling NaNs provided by mathlib (_WANT_SNAN)
3.21 mathlib double and single-precision floating-point functions
3.22 IEEE 754 arithmetic
3.23 Basic data types for IEEE 754 arithmetic
3.24 Single precision data type for IEEE 754 arithmetic
3.25 Double precision data type for IEEE 754 arithmetic
3.26 Sample single precision floating-point values for IEEE 754 arithmetic
3.27 Sample double precision floating-point values for IEEE 754 arithmetic
3.28 IEEE 754 arithmetic and rounding
3.29 Exceptions arising from IEEE 754 floating-point arithmetic
3.30 Exception types recognized by the ARM floating-point environment
3.31 Using the Vector Floating-Point (VFP) support libraries
4 The C and C++ Library Functions
4.1 __aeabi_errno_addr()
4.2 alloca()
4.3 clock()
4.4 _clock_init()
4.5 __default_signal_handler()
4.6 errno
4.7 _findlocale()
4.8 _fisatty()
4.9 _get_lconv()
4.10 getenv()
4.11 _getenv_init()
4.12 __heapstats()
4.13 __heapvalid()
4.14 lconv structure
4.15 localeconv()
4.16 _membitcpybl(), _membitcpybb(), _membitcpyhl(), _membitcpyhb(), _membitcpywl(), _membitcpywb(), _membitmovebl(), _membitmovebb(), _membitmovehl(), _membitmovehb(), _membitmovewl(), _membitmovewb()
4.17 posix_memalign()
4.18 #pragma import(_main_redirection)
4.19 __raise()
4.20 _rand_r()
4.21 remove()
4.22 rename()
4.23 __rt_entry
4.24 __rt_errno_addr()
4.25 __rt_exit()
4.26 __rt_fp_status_addr()
4.27 __rt_heap_extend()
4.28 __rt_lib_init()
4.29 __rt_lib_shutdown()
4.30 __rt_raise()
4.31 __rt_stackheap_init()
4.32 setlocale()
4.33 _srand_r()
4.34 strcasecmp()
4.35 strncasecmp()
4.36 strlcat()
4.37 strlcpy()
4.38 _sys_close()
4.39 _sys_command_string()
4.40 _sys_ensure()
4.41 _sys_exit()
4.42 _sys_flen()
4.43 _sys_istty()
4.44 _sys_open()
4.45 _sys_read()
4.46 _sys_seek()
4.47 _sys_tmpnam()
4.48 _sys_write()
4.49 system()
4.50 time()
4.51 _ttywrch()
4.52 __user_heap_extend()
4.53 __user_heap_extent()
4.54 __user_setup_stackheap()
4.55 __vectab_stack_and_reset
4.56 wcscasecmp()
4.57 wcsncasecmp()
4.58 wcstombs()
4.59 Thread-safe C library functions
4.60 C library functions that are not thread-safe
4.61 Legacy function __user_initial_stackheap()
5 Floating-point Support Functions
5.1 _clearfp()
5.2 _controlfp()
5.3 __fp_status()
5.4 gamma(), gamma_r()
5.5 __ieee_status()
5.6 j0(), j1(), jn(), Bessel functions of the first kind
5.7 significand(), fractional part of a number
5.8 _statusfp()
5.9 y0(), y1(), yn(), Bessel functions of the second kind
A Libraries Document Revisions
A.1 Revisions for ARM C and C++ Libraries and Floating-Point Support User Guide

List of Figures

3-1 IEEE 754 single-precision floating-point format
3-2 IEEE 754 double-precision floating-point format
5-1 Floating-point status word layout
5-2 IEEE status word layout

List of Tables

1-1 C library callouts
1-2 Direct semihosting dependencies
1-3 Indirect semihosting dependencies
1-4 Published API definitions
1-5 Standalone C library functions
1-6 Default ISO8859-1 locales
1-7 Default Shift-JIS and UTF-8 locales
1-8 Trap and error handling
1-9 Input/output dependencies
1-10 Mathematical functions in RVCT 4.0 and earlier
1-11 Signals supported by the signal() function
1-12 perror() messages
1-13 Standard C++ library differences
1-14 C library extensions
3-1 Arithmetic routines
3-2 Number format conversion routines
3-3 Floating-point comparison routines
3-4 fplib C99 functions
3-5 FE_EX_INTYPE_MASK operand type flags
3-6 FE_EX_OUTTYPE_MASK operand type flags
3-7 FE_EX_FN_MASK operation type flags
3-8 FE_EX_CMPRET_MASK comparison type flags
3-9 Sample single-precision floating-point values
3-10 Sample double-precision floating-point values
4-1 Functions that are thread-safe
4-2 Functions that are not thread-safe
5-1 _controlfp argument macros
5-2 Status word bit modification
5-3 Rounding mode control
A-1 Differences between issue I and issue J
A-2 Differences between issue H and issue I
A-3 Differences between issue G and issue H
A-4 Differences between issue F and issue G
A-5 Differences between issue E and issue F
A-6 Differences between issue D and issue E
A-7 Differences between issue C and issue D
A-8 Differences between issue B and issue C
A-9 Differences between issue A and issue B

Release Information

Document History
Issue Date Confidentiality Change
A 28 May 2010 Non-Confidential ARM Compiler v4.1 Release
B 30 September 2010 Non-Confidential Update 1 for ARM Compiler v4.1
C 28 January 2011 Non-Confidential Update 2 for ARM Compiler v4.1 Patch 3
D 30 April 2011 Non-Confidential ARM Compiler v5.0 Release
E 29 July 2011 Non-Confidential Update 1 for ARM Compiler v5.0
F 30 August 2011 Non-Confidential ARM Compiler v5.01 Release
G 29 February 2012 Non-Confidential Document update 1 for ARM Compiler v5.01 Release
H 27 July 2012 Non-Confidential ARM Compiler v5.02 Release
I 31 January 2013 Non-Confidential ARM Compiler v5.03 Release
J 27 November 2013 Non-Confidential ARM Compiler v5.04 Release

Proprietary Notice

Words and logos marked with ® or ™ are registered trademarks or trademarks of ARM® in the EU and other countries, except as otherwise stated below in this proprietary notice. Other brands and names mentioned herein may be the trademarks of their respective owners.

Neither the whole nor any part of the information contained in, or the product described in, this document may be adapted or reproduced in any material form except with the prior written permission of the copyright holder.

The product described in this document is subject to continuous developments and improvements. All particulars of the product and its use contained in this document are given by ARM in good faith. However, all warranties implied or expressed, including but not limited to implied warranties of merchantability, or fitness for purpose, are excluded.

This document is intended only to assist the reader in the use of the product. ARM shall not be liable for any loss or damage arising from the use of any information in this document, or any error or omission in such information, or any incorrect use of the product.

Where the term ARM is used it means “ARM or any of its subsidiaries as appropriate”.

Some material in this document is based on IEEE 754 - 1985 IEEE Standard for Binary Floating-Point Arithmetic. The IEEE disclaims any responsibility or liability resulting from the placement and use in the described manner.

Confidentiality Status

This document is Non-Confidential. The right to use, copy and disclose this document may be subject to license restrictions in accordance with the terms of the agreement entered into by ARM and the party that ARM delivered this document to.

Unrestricted Access is an ARM internal classification.

Product Status

The information in this document is Final, that is for a developed product.

Web Address

Non-ConfidentialPDF file icon PDF versionARM DUI0475J
Copyright © 2010-2013 ARM. All rights reserved.