ARM® Compiler v5.06 for µVision® Version 5 ARM C and C++ Libraries and Floating-Point Support User Guide Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights reserved. ARM DUI0378G ARM® Compiler v5.06 for µVision® ARM® Compiler v5.06 for µVision® ARM C and C++ Libraries and Floating-Point Support User Guide Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights reserved. Release Information Document History Issue Date Confidentiality Change A May 2007 Non-Confidential Release for RVCT v3.1 Release for µVision B December 2008 Non-Confidential Release for RVCT v4.0 for µVision C June 2011 Non-Confidential Release for ARM Compiler v4.1 for µVision D July 2012 Non-Confidential Release for ARM Compiler v5.02 for µVision E 30 May 2014 Non-Confidential Release for ARM Compiler v5.04 for µVision F 12 December 2014 Non-Confidential Release for ARM Compiler v5.05 for µVision G 15 August 2015 Non-Confidential Release for ARM Compiler v5.06 for µVision Non-Confidential Proprietary Notice This document is protected by copyright and other related rights and the practice or implementation of the information contained in this document may be protected by one or more patents or pending patent applications. No part of this document may be reproduced in any form by any means without the express prior written permission of ARM. No license, express or implied, by estoppel or otherwise to any intellectual property rights is granted by this document unless specifically stated. Your access to the information in this document is conditional upon your acceptance that you will not use or permit others to use the information for the purposes of determining whether implementations infringe any third party patents. THIS DOCUMENT IS PROVIDED “AS IS”. ARM PROVIDES NO REPRESENTATIONS AND NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, NON-INFRINGEMENT OR FITNESS FOR A PARTICULAR PURPOSE WITH RESPECT TO THE DOCUMENT. For the avoidance of doubt, ARM makes no representation with respect to, and has undertaken no analysis to identify or understand the scope and content of, third party patents, copyrights, trade secrets, or other rights. This document may include technical inaccuracies or typographical errors. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL ARM BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF ANY USE OF THIS DOCUMENT, EVEN IF ARM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. This document consists solely of commercial items. You shall be responsible for ensuring that any use, duplication or disclosure of this document complies fully with any relevant export laws and regulations to assure that this document or any portion thereof is not exported, directly or indirectly, in violation of such export laws. Use of the word “partner” in reference to ARM’s customers is not intended to create or refer to any partnership relationship with any other company. ARM may make changes to this document at any time and without notice. If any of the provisions contained in these terms conflict with any of the provisions of any signed written agreement covering this document with ARM, then the signed written agreement prevails over and supersedes the conflicting provisions of these terms. This document may be translated into other languages for convenience, and you agree that if there is any conflict between the English version of this document and any translation, the terms of the English version of the Agreement shall prevail. Words and logos marked with ® or ™ are registered trademarks or trademarks of ARM Limited or its affiliates in the EU and/or elsewhere. All rights reserved. Other brands and names mentioned in this document may be the trademarks of their respective owners. Please follow ARM’s trademark usage guidelines at http://www.arm.com/about/trademark-usage-guidelines.php Copyright © [2007, 2008, 2011, 2012, 2014, 2015], ARM Limited or its affiliates. All rights reserved. ARM DUI0378G Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights 2 reserved. Non-Confidential ARM® Compiler v5.06 for µVision® ARM Limited. Company 02557590 registered in England. 110 Fulbourn Road, Cambridge, England CB1 9NJ. LES-PRE-20349 Additional Notices 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 http://www.arm.com ARM DUI0378G Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights 3 reserved. Non-Confidential Contents ARM® Compiler v5.06 for µVision® ARM C and C++ Libraries and Floating-Point Support User Guide Preface About this book .......................................................................................................... 12 Chapter 1 The ARM C and C++ Libraries 1.1 Mandatory linkage with the C library ...................................................................... 1-16 1.2 C and C++ runtime libraries .................................................................................... 1-17 1.3 C and C++ library features ...................................................................................... 1-22 1.4 C++ and C libraries and the std namespace .......................................................... 1-23 1.5 Multithreaded support in ARM C libraries ................................................................ 1-24 1.6 Support for building an application with the C library .............................................. 1-34 1.7 Support for building an application without the C library ........................................ 1-40 1.8 Tailoring the C library to a new execution environment .......................................... 1-47 1.9 Assembler macros that tailor locale functions in the C library ................................ 1-52 1.10 Modification of C library functions for error signaling, error handling, and program exit .. .................................................................................................................................. 1-61 1.11 Stack and heap memory allocation and the ARM C and C++ libraries .................. 1-62 1.12 Tailoring input/output functions in the C and C++ libraries ...................................... 1-69 1.13 Target dependencies on low-level functions in the C and C++ libraries .................. 1-70 1.14 The C library printf family of functions .................................................................... 1-72 1.15 The C library scanf family of functions .................................................................... 1-73 1.16 Redefining low-level library functions to enable direct use of high-level library functions in the C library ........................................................................................................ 1-74 ARM DUI0378G Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights 4 reserved. Non-Confidential 1.17 The C library functions fread(), fgets() and gets() .................................................... 1-76 1.18 Re-implementing __backspace() in the C library .................................................... 1-77 1.19 Re-implementing __backspacewc() in the C library ................................................ 1-78 1.20 Redefining target-dependent system I/O functions in the C library ........................ 1-79 1.21 Tailoring non-input/output C library functions .......................................................... 1-81 1.22 Real-time integer division in the ARM libraries ........................................................ 1-82 1.23 ISO C library implementation definition .................................................................. 1-83 1.24 C library functions and extensions .......................................................................... 1-89 1.25 Compiler generated and library-resident helper functions ...................................... 1-90 1.26 C and C++ library naming conventions .................................................................. 1-91 1.27 Using macro__ARM_WCHAR_NO_IO to disable FILE declaration and wide I/O function prototypes .................................................................................................. 1-94 1.28 Using library functions with execute-only memory .................................................. 1-95 Chapter 2 The ARM C Micro-library 2.1 About microlib .......................................................................................................... 2-97 2.2 Differences between microlib and the default C library .......................................... 2-98 2.3 Library heap usage requirements of microlib ........................................................ 2-100 2.4 ISO C features missing from microlib .................................................................... 2-101 2.5 Building an application with microlib ...................................................................... 2-103 2.6 Configuring the stack and heap for use with microlib ............................................ 2-104 2.7 Entering and exiting programs linked with microlib .............................................. 2-105 2.8 Tailoring the microlib input/output functions .......................................................... 2-106 Chapter 3 Floating-point Support 3.1 About floating-point support .................................................................................. 3-108 3.2 The software floating-point library, fplib ................................................................ 3-109 3.3 Controlling the ARM floating-point environment .................................................... 3-115 3.4 Using C99 signaling NaNs provided by mathlib (_WANT_SNAN) ........................ 3-127 3.5 mathlib double and single-precision floating-point functions ................................ 3-128 3.6 IEEE 754 arithmetic .............................................................................................. 3-129 3.7 Using the Vector Floating-Point (VFP) support libraries ........................................ 3-137 Chapter 4 The C and C++ Library Functions reference 4.1 __aeabi_errno_addr() ............................................................................................ 4-140 4.2 alloca() .................................................................................................................. 4-141 4.3 clock() .................................................................................................................... 4-142 4.4 _clock_init() .......................................................................................................... 4-143 4.5 __default_signal_handler() .................................................................................... 4-144 4.6 errno ...................................................................................................................... 4-145 4.7 _findlocale() .......................................................................................................... 4-146 4.8 _fisatty() ................................................................................................................ 4-147 4.9 _get_lconv() .......................................................................................................... 4-148 4.10 getenv() ................................................................................................................ 4-149 4.11 _getenv_init() ........................................................................................................ 4-150 4.12 __heapstats() ........................................................................................................ 4-151 4.13 __heapvalid() ........................................................................................................ 4-152 4.14 lconv structure ...................................................................................................... 4-153 4.15 localeconv() .......................................................................................................... 4-155 ARM DUI0378G Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights 5 reserved. Non-Confidential 4.16 _membitcpybl(), _membitcpybb(), _membitcpyhl(), _membitcpyhb(), _membitcpywl(), _membitcpywb(), _membitmovebl(), _membitmovebb(), _membitmovehl(), _membitmovehb(), _membitmovewl(), _membitmovewb() .................................... 4-156 4.17 posix_memalign() .................................................................................................. 4-157 4.18 #pragma import(_main_redirection) ...................................................................... 4-158 4.19 __raise() ................................................................................................................ 4-159 4.20 _rand_r() ................................................................................................................ 4-160 4.21 remove() ................................................................................................................ 4-161 4.22 rename() ................................................................................................................ 4-162 4.23 __rt_entry .............................................................................................................. 4-163 4.24 __rt_errno_addr() .................................................................................................. 4-164 4.25 __rt_exit() .............................................................................................................. 4-165 4.26 __rt_fp_status_addr() ............................................................................................ 4-166 4.27 __rt_heap_extend() .............................................................................................. 4-167 4.28 __rt_lib_init() .......................................................................................................... 4-168 4.29 __rt_lib_shutdown() .............................................................................................. 4-169 4.30 __rt_raise() ............................................................................................................ 4-170 4.31 __rt_stackheap_init() ............................................................................................ 4-171 4.32 setlocale() .............................................................................................................. 4-172 4.33 _srand_r() .............................................................................................................. 4-174 4.34 strcasecmp() .......................................................................................................... 4-175 4.35 strncasecmp() ........................................................................................................ 4-176 4.36 strlcat() .................................................................................................................. 4-177 4.37 strlcpy() .................................................................................................................. 4-178 4.38 _sys_close() .......................................................................................................... 4-179 4.39 _sys_command_string() ........................................................................................ 4-180 4.40 _sys_ensure() ........................................................................................................ 4-181 4.41 _sys_exit() ............................................................................................................ 4-182 4.42 _sys_flen() ............................................................................................................ 4-183 4.43 _sys_istty() ............................................................................................................ 4-184 4.44 _sys_open() .......................................................................................................... 4-185 4.45 _sys_read() ............................................................................................................ 4-186 4.46 _sys_seek() .......................................................................................................... 4-187 4.47 _sys_tmpnam() ...................................................................................................... 4-188 4.48 _sys_write() .......................................................................................................... 4-189 4.49 system() ................................................................................................................ 4-190 4.50 time() .................................................................................................................... 4-191 4.51 _ttywrch() .............................................................................................................. 4-192 4.52 __user_heap_extend() .......................................................................................... 4-193 4.53 __user_heap_extent() .......................................................................................... 4-194 4.54 __user_setup_stackheap() .................................................................................... 4-195 4.55 __vectab_stack_and_reset .................................................................................... 4-196 4.56 wcscasecmp() ........................................................................................................ 4-197 4.57 wcsncasecmp() ...................................................................................................... 4-198 4.58 wcstombs() ............................................................................................................ 4-199 4.59 Thread-safe C library functions ............................................................................ 4-200 4.60 C library functions that are not thread-safe .......................................................... 4-202 4.61 Legacy function __user_initial_stackheap() .......................................................... 4-204 ARM DUI0378G Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights 6 reserved. Non-Confidential Chapter 5 Floating-point Support Functions Reference 5.1 _clearfp() .............................................................................................................. 5-206 5.2 _controlfp() ............................................................................................................ 5-207 5.3 __fp_status() .......................................................................................................... 5-209 5.4 gamma(), gamma_r() ............................................................................................ 5-211 5.5 __ieee_status() ...................................................................................................... 5-212 5.6 j0(), j1(), jn(), Bessel functions of the first kind ...................................................... 5-215 5.7 significand(), fractional part of a number .............................................................. 5-216 5.8 _statusfp() .............................................................................................................. 5-217 5.9 y0(), y1(), yn(), Bessel functions of the second kind .............................................. 5-218 ARM DUI0378G Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights 7 reserved. Non-Confidential List of Figures ARM® Compiler v5.06 for µVision® ARM C and C++ Libraries and Floating-Point Support User Guide Figure 3-1 IEEE 754 single-precision floating-point format ................................................................... 3-129 Figure 3-2 IEEE 754 double-precision floating-point format ................................................................. 3-130 Figure 5-1 Floating-point status word layout ......................................................................................... 5-209 Figure 5-2 IEEE status word layout ...................................................................................................... 5-212 ARM DUI0378G Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights 8 reserved. Non-Confidential List of Tables ARM® Compiler v5.06 for µVision® ARM C and C++ Libraries and Floating-Point Support User Guide Table 1-1 C library callouts .................................................................................................................... 1-26 Table 1-2 Direct semihosting dependencies .......................................................................................... 1-37 Table 1-3 Indirect semihosting dependencies ....................................................................................... 1-38 Table 1-4 Published API definitions ....................................................................................................... 1-38 Table 1-5 Standalone C library functions ............................................................................................... 1-40 Table 1-6 Default ISO8859-1 locales ..................................................................................................... 1-52 Table 1-7 Default Shift-JIS and UTF-8 locales ...................................................................................... 1-53 Table 1-8 Trap and error handling ......................................................................................................... 1-61 Table 1-9 Input/output dependencies .................................................................................................... 1-70 Table 1-10 Signals supported by the signal() function ............................................................................. 1-84 Table 1-11 perror() messages ................................................................................................................. 1-86 Table 1-12 Standard C++ library differences ........................................................................................... 1-87 Table 1-13 C library extensions ............................................................................................................... 1-89 Table 3-1 Arithmetic routines ............................................................................................................... 3-110 Table 3-2 Number format conversion routines ..................................................................................... 3-111 Table 3-3 Floating-point comparison routines ...................................................................................... 3-112 Table 3-4 fplib C99 functions ............................................................................................................... 3-113 Table 3-5 FE_EX_INTYPE_MASK operand type flags ....................................................................... 3-122 Table 3-6 FE_EX_OUTTYPE_MASK operand type flags ................................................................... 3-122 Table 3-7 FE_EX_FN_MASK operation type flags .............................................................................. 3-123 Table 3-8 FE_EX_CMPRET_MASK comparison type flags ................................................................ 3-123 Table 3-9 Sample single-precision floating-point values ..................................................................... 3-131 ARM DUI0378G Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights 9 reserved. Non-Confidential Table 3-10 Sample double-precision floating-point values .................................................................... 3-132 Table 4-1 Functions that are thread-safe ............................................................................................. 4-200 Table 4-2 Functions that are not thread-safe ....................................................................................... 4-202 Table 5-1 _controlfp argument macros ............................................................................................... 5-207 Table 5-2 Status word bit modification ................................................................................................. 5-212 Table 5-3 Rounding mode control ....................................................................................................... 5-213 ARM DUI0378G Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights 10 reserved. Non-Confidential
Description: