libgcc.texi revision 296373
1@c Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. 2@c This is part of the GCC manual. 3@c For copying conditions, see the file gcc.texi. 4@c Contributed by Aldy Hernandez <aldy@quesejoda.com> 5 6@node Libgcc 7@chapter The GCC low-level runtime library 8 9GCC provides a low-level runtime library, @file{libgcc.a} or 10@file{libgcc_s.so.1} on some platforms. GCC generates calls to 11routines in this library automatically, whenever it needs to perform 12some operation that is too complicated to emit inline code for. 13 14Most of the routines in @code{libgcc} handle arithmetic operations 15that the target processor cannot perform directly. This includes 16integer multiply and divide on some machines, and all floating-point 17operations on other machines. @code{libgcc} also includes routines 18for exception handling, and a handful of miscellaneous operations. 19 20Some of these routines can be defined in mostly machine-independent C@. 21Others must be hand-written in assembly language for each processor 22that needs them. 23 24GCC will also generate calls to C library routines, such as 25@code{memcpy} and @code{memset}, in some cases. The set of routines 26that GCC may possibly use is documented in @ref{Other 27Builtins,,,gcc, Using the GNU Compiler Collection (GCC)}. 28 29These routines take arguments and return values of a specific machine 30mode, not a specific C type. @xref{Machine Modes}, for an explanation 31of this concept. For illustrative purposes, in this chapter the 32floating point type @code{float} is assumed to correspond to @code{SFmode}; 33@code{double} to @code{DFmode}; and @code{@w{long double}} to both 34@code{TFmode} and @code{XFmode}. Similarly, the integer types @code{int} 35and @code{@w{unsigned int}} correspond to @code{SImode}; @code{long} and 36@code{@w{unsigned long}} to @code{DImode}; and @code{@w{long long}} and 37@code{@w{unsigned long long}} to @code{TImode}. 38 39@menu 40* Integer library routines:: 41* Soft float library routines:: 42* Decimal float library routines:: 43* Exception handling routines:: 44* Miscellaneous routines:: 45@end menu 46 47@node Integer library routines 48@section Routines for integer arithmetic 49 50The integer arithmetic routines are used on platforms that don't provide 51hardware support for arithmetic operations on some modes. 52 53@subsection Arithmetic functions 54 55@deftypefn {Runtime Function} int __ashlsi3 (int @var{a}, int @var{b}) 56@deftypefnx {Runtime Function} long __ashldi3 (long @var{a}, int @var{b}) 57@deftypefnx {Runtime Function} {long long} __ashlti3 (long long @var{a}, int @var{b}) 58These functions return the result of shifting @var{a} left by @var{b} bits. 59@end deftypefn 60 61@deftypefn {Runtime Function} int __ashrsi3 (int @var{a}, int @var{b}) 62@deftypefnx {Runtime Function} long __ashrdi3 (long @var{a}, int @var{b}) 63@deftypefnx {Runtime Function} {long long} __ashrti3 (long long @var{a}, int @var{b}) 64These functions return the result of arithmetically shifting @var{a} right 65by @var{b} bits. 66@end deftypefn 67 68@deftypefn {Runtime Function} int __divsi3 (int @var{a}, int @var{b}) 69@deftypefnx {Runtime Function} long __divdi3 (long @var{a}, long @var{b}) 70@deftypefnx {Runtime Function} {long long} __divti3 (long long @var{a}, long long @var{b}) 71These functions return the quotient of the signed division of @var{a} and 72@var{b}. 73@end deftypefn 74 75@deftypefn {Runtime Function} int __lshrsi3 (int @var{a}, int @var{b}) 76@deftypefnx {Runtime Function} long __lshrdi3 (long @var{a}, int @var{b}) 77@deftypefnx {Runtime Function} {long long} __lshrti3 (long long @var{a}, int @var{b}) 78These functions return the result of logically shifting @var{a} right by 79@var{b} bits. 80@end deftypefn 81 82@deftypefn {Runtime Function} int __modsi3 (int @var{a}, int @var{b}) 83@deftypefnx {Runtime Function} long __moddi3 (long @var{a}, long @var{b}) 84@deftypefnx {Runtime Function} {long long} __modti3 (long long @var{a}, long long @var{b}) 85These functions return the remainder of the signed division of @var{a} 86and @var{b}. 87@end deftypefn 88 89@deftypefn {Runtime Function} int __mulsi3 (int @var{a}, int @var{b}) 90@deftypefnx {Runtime Function} long __muldi3 (long @var{a}, long @var{b}) 91@deftypefnx {Runtime Function} {long long} __multi3 (long long @var{a}, long long @var{b}) 92These functions return the product of @var{a} and @var{b}. 93@end deftypefn 94 95@deftypefn {Runtime Function} long __negdi2 (long @var{a}) 96@deftypefnx {Runtime Function} {long long} __negti2 (long long @var{a}) 97These functions return the negation of @var{a}. 98@end deftypefn 99 100@deftypefn {Runtime Function} {unsigned int} __udivsi3 (unsigned int @var{a}, unsigned int @var{b}) 101@deftypefnx {Runtime Function} {unsigned long} __udivdi3 (unsigned long @var{a}, unsigned long @var{b}) 102@deftypefnx {Runtime Function} {unsigned long long} __udivti3 (unsigned long long @var{a}, unsigned long long @var{b}) 103These functions return the quotient of the unsigned division of @var{a} 104and @var{b}. 105@end deftypefn 106 107@deftypefn {Runtime Function} {unsigned long} __udivmoddi3 (unsigned long @var{a}, unsigned long @var{b}, unsigned long *@var{c}) 108@deftypefnx {Runtime Function} {unsigned long long} __udivti3 (unsigned long long @var{a}, unsigned long long @var{b}, unsigned long long *@var{c}) 109These functions calculate both the quotient and remainder of the unsigned 110division of @var{a} and @var{b}. The return value is the quotient, and 111the remainder is placed in variable pointed to by @var{c}. 112@end deftypefn 113 114@deftypefn {Runtime Function} {unsigned int} __umodsi3 (unsigned int @var{a}, unsigned int @var{b}) 115@deftypefnx {Runtime Function} {unsigned long} __umoddi3 (unsigned long @var{a}, unsigned long @var{b}) 116@deftypefnx {Runtime Function} {unsigned long long} __umodti3 (unsigned long long @var{a}, unsigned long long @var{b}) 117These functions return the remainder of the unsigned division of @var{a} 118and @var{b}. 119@end deftypefn 120 121@subsection Comparison functions 122 123The following functions implement integral comparisons. These functions 124implement a low-level compare, upon which the higher level comparison 125operators (such as less than and greater than or equal to) can be 126constructed. The returned values lie in the range zero to two, to allow 127the high-level operators to be implemented by testing the returned 128result using either signed or unsigned comparison. 129 130@deftypefn {Runtime Function} int __cmpdi2 (long @var{a}, long @var{b}) 131@deftypefnx {Runtime Function} int __cmpti2 (long long @var{a}, long long @var{b}) 132These functions perform a signed comparison of @var{a} and @var{b}. If 133@var{a} is less than @var{b}, they return 0; if @var{a} is greater than 134@var{b}, they return 2; and if @var{a} and @var{b} are equal they return 1. 135@end deftypefn 136 137@deftypefn {Runtime Function} int __ucmpdi2 (unsigned long @var{a}, unsigned long @var{b}) 138@deftypefnx {Runtime Function} int __ucmpti2 (unsigned long long @var{a}, unsigned long long @var{b}) 139These functions perform an unsigned comparison of @var{a} and @var{b}. 140If @var{a} is less than @var{b}, they return 0; if @var{a} is greater than 141@var{b}, they return 2; and if @var{a} and @var{b} are equal they return 1. 142@end deftypefn 143 144@subsection Trapping arithmetic functions 145 146The following functions implement trapping arithmetic. These functions 147call the libc function @code{abort} upon signed arithmetic overflow. 148 149@deftypefn {Runtime Function} int __absvsi2 (int @var{a}) 150@deftypefnx {Runtime Function} long __absvdi2 (long @var{a}) 151These functions return the absolute value of @var{a}. 152@end deftypefn 153 154@deftypefn {Runtime Function} int __addvsi3 (int @var{a}, int @var{b}) 155@deftypefnx {Runtime Function} long __addvdi3 (long @var{a}, long @var{b}) 156These functions return the sum of @var{a} and @var{b}; that is 157@code{@var{a} + @var{b}}. 158@end deftypefn 159 160@deftypefn {Runtime Function} int __mulvsi3 (int @var{a}, int @var{b}) 161@deftypefnx {Runtime Function} long __mulvdi3 (long @var{a}, long @var{b}) 162The functions return the product of @var{a} and @var{b}; that is 163@code{@var{a} * @var{b}}. 164@end deftypefn 165 166@deftypefn {Runtime Function} int __negvsi2 (int @var{a}) 167@deftypefnx {Runtime Function} long __negvdi2 (long @var{a}) 168These functions return the negation of @var{a}; that is @code{-@var{a}}. 169@end deftypefn 170 171@deftypefn {Runtime Function} int __subvsi3 (int @var{a}, int @var{b}) 172@deftypefnx {Runtime Function} long __subvdi3 (long @var{a}, long @var{b}) 173These functions return the difference between @var{b} and @var{a}; 174that is @code{@var{a} - @var{b}}. 175@end deftypefn 176 177@subsection Bit operations 178 179@deftypefn {Runtime Function} int __clzsi2 (int @var{a}) 180@deftypefnx {Runtime Function} int __clzdi2 (long @var{a}) 181@deftypefnx {Runtime Function} int __clzti2 (long long @var{a}) 182These functions return the number of leading 0-bits in @var{a}, starting 183at the most significant bit position. If @var{a} is zero, the result is 184undefined. 185@end deftypefn 186 187@deftypefn {Runtime Function} int __ctzsi2 (int @var{a}) 188@deftypefnx {Runtime Function} int __ctzdi2 (long @var{a}) 189@deftypefnx {Runtime Function} int __ctzti2 (long long @var{a}) 190These functions return the number of trailing 0-bits in @var{a}, starting 191at the least significant bit position. If @var{a} is zero, the result is 192undefined. 193@end deftypefn 194 195@deftypefn {Runtime Function} int __ffsdi2 (long @var{a}) 196@deftypefnx {Runtime Function} int __ffsti2 (long long @var{a}) 197These functions return the index of the least significant 1-bit in @var{a}, 198or the value zero if @var{a} is zero. The least significant bit is index 199one. 200@end deftypefn 201 202@deftypefn {Runtime Function} int __paritysi2 (int @var{a}) 203@deftypefnx {Runtime Function} int __paritydi2 (long @var{a}) 204@deftypefnx {Runtime Function} int __parityti2 (long long @var{a}) 205These functions return the value zero if the number of bits set in 206@var{a} is even, and the value one otherwise. 207@end deftypefn 208 209@deftypefn {Runtime Function} int __popcountsi2 (int @var{a}) 210@deftypefnx {Runtime Function} int __popcountdi2 (long @var{a}) 211@deftypefnx {Runtime Function} int __popcountti2 (long long @var{a}) 212These functions return the number of bits set in @var{a}. 213@end deftypefn 214 215@deftypefn {Runtime Function} int32_t __bswapsi2 (int32_t @var{a}) 216@deftypefnx {Runtime Function} int64_t __bswapdi2 (int64_t @var{a}) 217These functions return the @var{a} byteswapped. 218@end deftypefn 219 220@node Soft float library routines 221@section Routines for floating point emulation 222@cindex soft float library 223@cindex arithmetic library 224@cindex math library 225@opindex msoft-float 226 227The software floating point library is used on machines which do not 228have hardware support for floating point. It is also used whenever 229@option{-msoft-float} is used to disable generation of floating point 230instructions. (Not all targets support this switch.) 231 232For compatibility with other compilers, the floating point emulation 233routines can be renamed with the @code{DECLARE_LIBRARY_RENAMES} macro 234(@pxref{Library Calls}). In this section, the default names are used. 235 236Presently the library does not support @code{XFmode}, which is used 237for @code{long double} on some architectures. 238 239@subsection Arithmetic functions 240 241@deftypefn {Runtime Function} float __addsf3 (float @var{a}, float @var{b}) 242@deftypefnx {Runtime Function} double __adddf3 (double @var{a}, double @var{b}) 243@deftypefnx {Runtime Function} {long double} __addtf3 (long double @var{a}, long double @var{b}) 244@deftypefnx {Runtime Function} {long double} __addxf3 (long double @var{a}, long double @var{b}) 245These functions return the sum of @var{a} and @var{b}. 246@end deftypefn 247 248@deftypefn {Runtime Function} float __subsf3 (float @var{a}, float @var{b}) 249@deftypefnx {Runtime Function} double __subdf3 (double @var{a}, double @var{b}) 250@deftypefnx {Runtime Function} {long double} __subtf3 (long double @var{a}, long double @var{b}) 251@deftypefnx {Runtime Function} {long double} __subxf3 (long double @var{a}, long double @var{b}) 252These functions return the difference between @var{b} and @var{a}; 253that is, @w{@math{@var{a} - @var{b}}}. 254@end deftypefn 255 256@deftypefn {Runtime Function} float __mulsf3 (float @var{a}, float @var{b}) 257@deftypefnx {Runtime Function} double __muldf3 (double @var{a}, double @var{b}) 258@deftypefnx {Runtime Function} {long double} __multf3 (long double @var{a}, long double @var{b}) 259@deftypefnx {Runtime Function} {long double} __mulxf3 (long double @var{a}, long double @var{b}) 260These functions return the product of @var{a} and @var{b}. 261@end deftypefn 262 263@deftypefn {Runtime Function} float __divsf3 (float @var{a}, float @var{b}) 264@deftypefnx {Runtime Function} double __divdf3 (double @var{a}, double @var{b}) 265@deftypefnx {Runtime Function} {long double} __divtf3 (long double @var{a}, long double @var{b}) 266@deftypefnx {Runtime Function} {long double} __divxf3 (long double @var{a}, long double @var{b}) 267These functions return the quotient of @var{a} and @var{b}; that is, 268@w{@math{@var{a} / @var{b}}}. 269@end deftypefn 270 271@deftypefn {Runtime Function} float __negsf2 (float @var{a}) 272@deftypefnx {Runtime Function} double __negdf2 (double @var{a}) 273@deftypefnx {Runtime Function} {long double} __negtf2 (long double @var{a}) 274@deftypefnx {Runtime Function} {long double} __negxf2 (long double @var{a}) 275These functions return the negation of @var{a}. They simply flip the 276sign bit, so they can produce negative zero and negative NaN@. 277@end deftypefn 278 279@subsection Conversion functions 280 281@deftypefn {Runtime Function} double __extendsfdf2 (float @var{a}) 282@deftypefnx {Runtime Function} {long double} __extendsftf2 (float @var{a}) 283@deftypefnx {Runtime Function} {long double} __extendsfxf2 (float @var{a}) 284@deftypefnx {Runtime Function} {long double} __extenddftf2 (double @var{a}) 285@deftypefnx {Runtime Function} {long double} __extenddfxf2 (double @var{a}) 286These functions extend @var{a} to the wider mode of their return 287type. 288@end deftypefn 289 290@deftypefn {Runtime Function} double __truncxfdf2 (long double @var{a}) 291@deftypefnx {Runtime Function} double __trunctfdf2 (long double @var{a}) 292@deftypefnx {Runtime Function} float __truncxfsf2 (long double @var{a}) 293@deftypefnx {Runtime Function} float __trunctfsf2 (long double @var{a}) 294@deftypefnx {Runtime Function} float __truncdfsf2 (double @var{a}) 295These functions truncate @var{a} to the narrower mode of their return 296type, rounding toward zero. 297@end deftypefn 298 299@deftypefn {Runtime Function} int __fixsfsi (float @var{a}) 300@deftypefnx {Runtime Function} int __fixdfsi (double @var{a}) 301@deftypefnx {Runtime Function} int __fixtfsi (long double @var{a}) 302@deftypefnx {Runtime Function} int __fixxfsi (long double @var{a}) 303These functions convert @var{a} to a signed integer, rounding toward zero. 304@end deftypefn 305 306@deftypefn {Runtime Function} long __fixsfdi (float @var{a}) 307@deftypefnx {Runtime Function} long __fixdfdi (double @var{a}) 308@deftypefnx {Runtime Function} long __fixtfdi (long double @var{a}) 309@deftypefnx {Runtime Function} long __fixxfdi (long double @var{a}) 310These functions convert @var{a} to a signed long, rounding toward zero. 311@end deftypefn 312 313@deftypefn {Runtime Function} {long long} __fixsfti (float @var{a}) 314@deftypefnx {Runtime Function} {long long} __fixdfti (double @var{a}) 315@deftypefnx {Runtime Function} {long long} __fixtfti (long double @var{a}) 316@deftypefnx {Runtime Function} {long long} __fixxfti (long double @var{a}) 317These functions convert @var{a} to a signed long long, rounding toward zero. 318@end deftypefn 319 320@deftypefn {Runtime Function} {unsigned int} __fixunssfsi (float @var{a}) 321@deftypefnx {Runtime Function} {unsigned int} __fixunsdfsi (double @var{a}) 322@deftypefnx {Runtime Function} {unsigned int} __fixunstfsi (long double @var{a}) 323@deftypefnx {Runtime Function} {unsigned int} __fixunsxfsi (long double @var{a}) 324These functions convert @var{a} to an unsigned integer, rounding 325toward zero. Negative values all become zero. 326@end deftypefn 327 328@deftypefn {Runtime Function} {unsigned long} __fixunssfdi (float @var{a}) 329@deftypefnx {Runtime Function} {unsigned long} __fixunsdfdi (double @var{a}) 330@deftypefnx {Runtime Function} {unsigned long} __fixunstfdi (long double @var{a}) 331@deftypefnx {Runtime Function} {unsigned long} __fixunsxfdi (long double @var{a}) 332These functions convert @var{a} to an unsigned long, rounding 333toward zero. Negative values all become zero. 334@end deftypefn 335 336@deftypefn {Runtime Function} {unsigned long long} __fixunssfti (float @var{a}) 337@deftypefnx {Runtime Function} {unsigned long long} __fixunsdfti (double @var{a}) 338@deftypefnx {Runtime Function} {unsigned long long} __fixunstfti (long double @var{a}) 339@deftypefnx {Runtime Function} {unsigned long long} __fixunsxfti (long double @var{a}) 340These functions convert @var{a} to an unsigned long long, rounding 341toward zero. Negative values all become zero. 342@end deftypefn 343 344@deftypefn {Runtime Function} float __floatsisf (int @var{i}) 345@deftypefnx {Runtime Function} double __floatsidf (int @var{i}) 346@deftypefnx {Runtime Function} {long double} __floatsitf (int @var{i}) 347@deftypefnx {Runtime Function} {long double} __floatsixf (int @var{i}) 348These functions convert @var{i}, a signed integer, to floating point. 349@end deftypefn 350 351@deftypefn {Runtime Function} float __floatdisf (long @var{i}) 352@deftypefnx {Runtime Function} double __floatdidf (long @var{i}) 353@deftypefnx {Runtime Function} {long double} __floatditf (long @var{i}) 354@deftypefnx {Runtime Function} {long double} __floatdixf (long @var{i}) 355These functions convert @var{i}, a signed long, to floating point. 356@end deftypefn 357 358@deftypefn {Runtime Function} float __floattisf (long long @var{i}) 359@deftypefnx {Runtime Function} double __floattidf (long long @var{i}) 360@deftypefnx {Runtime Function} {long double} __floattitf (long long @var{i}) 361@deftypefnx {Runtime Function} {long double} __floattixf (long long @var{i}) 362These functions convert @var{i}, a signed long long, to floating point. 363@end deftypefn 364 365@deftypefn {Runtime Function} float __floatunsisf (unsigned int @var{i}) 366@deftypefnx {Runtime Function} double __floatunsidf (unsigned int @var{i}) 367@deftypefnx {Runtime Function} {long double} __floatunsitf (unsigned int @var{i}) 368@deftypefnx {Runtime Function} {long double} __floatunsixf (unsigned int @var{i}) 369These functions convert @var{i}, an unsigned integer, to floating point. 370@end deftypefn 371 372@deftypefn {Runtime Function} float __floatundisf (unsigned long @var{i}) 373@deftypefnx {Runtime Function} double __floatundidf (unsigned long @var{i}) 374@deftypefnx {Runtime Function} {long double} __floatunditf (unsigned long @var{i}) 375@deftypefnx {Runtime Function} {long double} __floatundixf (unsigned long @var{i}) 376These functions convert @var{i}, an unsigned long, to floating point. 377@end deftypefn 378 379@deftypefn {Runtime Function} float __floatuntisf (unsigned long long @var{i}) 380@deftypefnx {Runtime Function} double __floatuntidf (unsigned long long @var{i}) 381@deftypefnx {Runtime Function} {long double} __floatuntitf (unsigned long long @var{i}) 382@deftypefnx {Runtime Function} {long double} __floatuntixf (unsigned long long @var{i}) 383These functions convert @var{i}, an unsigned long long, to floating point. 384@end deftypefn 385 386@subsection Comparison functions 387 388There are two sets of basic comparison functions. 389 390@deftypefn {Runtime Function} int __cmpsf2 (float @var{a}, float @var{b}) 391@deftypefnx {Runtime Function} int __cmpdf2 (double @var{a}, double @var{b}) 392@deftypefnx {Runtime Function} int __cmptf2 (long double @var{a}, long double @var{b}) 393These functions calculate @math{a <=> b}. That is, if @var{a} is less 394than @var{b}, they return @minus{}1; if @var{a} is greater than @var{b}, they 395return 1; and if @var{a} and @var{b} are equal they return 0. If 396either argument is NaN they return 1, but you should not rely on this; 397if NaN is a possibility, use one of the higher-level comparison 398functions. 399@end deftypefn 400 401@deftypefn {Runtime Function} int __unordsf2 (float @var{a}, float @var{b}) 402@deftypefnx {Runtime Function} int __unorddf2 (double @var{a}, double @var{b}) 403@deftypefnx {Runtime Function} int __unordtf2 (long double @var{a}, long double @var{b}) 404These functions return a nonzero value if either argument is NaN, otherwise 0. 405@end deftypefn 406 407There is also a complete group of higher level functions which 408correspond directly to comparison operators. They implement the ISO C 409semantics for floating-point comparisons, taking NaN into account. 410Pay careful attention to the return values defined for each set. 411Under the hood, all of these routines are implemented as 412 413@smallexample 414 if (__unord@var{X}f2 (a, b)) 415 return @var{E}; 416 return __cmp@var{X}f2 (a, b); 417@end smallexample 418 419@noindent 420where @var{E} is a constant chosen to give the proper behavior for 421NaN@. Thus, the meaning of the return value is different for each set. 422Do not rely on this implementation; only the semantics documented 423below are guaranteed. 424 425@deftypefn {Runtime Function} int __eqsf2 (float @var{a}, float @var{b}) 426@deftypefnx {Runtime Function} int __eqdf2 (double @var{a}, double @var{b}) 427@deftypefnx {Runtime Function} int __eqtf2 (long double @var{a}, long double @var{b}) 428These functions return zero if neither argument is NaN, and @var{a} and 429@var{b} are equal. 430@end deftypefn 431 432@deftypefn {Runtime Function} int __nesf2 (float @var{a}, float @var{b}) 433@deftypefnx {Runtime Function} int __nedf2 (double @var{a}, double @var{b}) 434@deftypefnx {Runtime Function} int __netf2 (long double @var{a}, long double @var{b}) 435These functions return a nonzero value if either argument is NaN, or 436if @var{a} and @var{b} are unequal. 437@end deftypefn 438 439@deftypefn {Runtime Function} int __gesf2 (float @var{a}, float @var{b}) 440@deftypefnx {Runtime Function} int __gedf2 (double @var{a}, double @var{b}) 441@deftypefnx {Runtime Function} int __getf2 (long double @var{a}, long double @var{b}) 442These functions return a value greater than or equal to zero if 443neither argument is NaN, and @var{a} is greater than or equal to 444@var{b}. 445@end deftypefn 446 447@deftypefn {Runtime Function} int __ltsf2 (float @var{a}, float @var{b}) 448@deftypefnx {Runtime Function} int __ltdf2 (double @var{a}, double @var{b}) 449@deftypefnx {Runtime Function} int __lttf2 (long double @var{a}, long double @var{b}) 450These functions return a value less than zero if neither argument is 451NaN, and @var{a} is strictly less than @var{b}. 452@end deftypefn 453 454@deftypefn {Runtime Function} int __lesf2 (float @var{a}, float @var{b}) 455@deftypefnx {Runtime Function} int __ledf2 (double @var{a}, double @var{b}) 456@deftypefnx {Runtime Function} int __letf2 (long double @var{a}, long double @var{b}) 457These functions return a value less than or equal to zero if neither 458argument is NaN, and @var{a} is less than or equal to @var{b}. 459@end deftypefn 460 461@deftypefn {Runtime Function} int __gtsf2 (float @var{a}, float @var{b}) 462@deftypefnx {Runtime Function} int __gtdf2 (double @var{a}, double @var{b}) 463@deftypefnx {Runtime Function} int __gttf2 (long double @var{a}, long double @var{b}) 464These functions return a value greater than zero if neither argument 465is NaN, and @var{a} is strictly greater than @var{b}. 466@end deftypefn 467 468@subsection Other floating-point functions 469 470@deftypefn {Runtime Function} float __powisf2 (float @var{a}, int @var{b}) 471@deftypefnx {Runtime Function} double __powidf2 (double @var{a}, int @var{b}) 472@deftypefnx {Runtime Function} {long double} __powitf2 (long double @var{a}, int @var{b}) 473@deftypefnx {Runtime Function} {long double} __powixf2 (long double @var{a}, int @var{b}) 474These functions convert raise @var{a} to the power @var{b}. 475@end deftypefn 476 477@deftypefn {Runtime Function} {complex float} __mulsc3 (float @var{a}, float @var{b}, float @var{c}, float @var{d}) 478@deftypefnx {Runtime Function} {complex double} __muldc3 (double @var{a}, double @var{b}, double @var{c}, double @var{d}) 479@deftypefnx {Runtime Function} {complex long double} __multc3 (long double @var{a}, long double @var{b}, long double @var{c}, long double @var{d}) 480@deftypefnx {Runtime Function} {complex long double} __mulxc3 (long double @var{a}, long double @var{b}, long double @var{c}, long double @var{d}) 481These functions return the product of @math{@var{a} + i@var{b}} and 482@math{@var{c} + i@var{d}}, following the rules of C99 Annex G@. 483@end deftypefn 484 485@deftypefn {Runtime Function} {complex float} __divsc3 (float @var{a}, float @var{b}, float @var{c}, float @var{d}) 486@deftypefnx {Runtime Function} {complex double} __divdc3 (double @var{a}, double @var{b}, double @var{c}, double @var{d}) 487@deftypefnx {Runtime Function} {complex long double} __divtc3 (long double @var{a}, long double @var{b}, long double @var{c}, long double @var{d}) 488@deftypefnx {Runtime Function} {complex long double} __divxc3 (long double @var{a}, long double @var{b}, long double @var{c}, long double @var{d}) 489These functions return the quotient of @math{@var{a} + i@var{b}} and 490@math{@var{c} + i@var{d}} (i.e., @math{(@var{a} + i@var{b}) / (@var{c} 491+ i@var{d})}), following the rules of C99 Annex G@. 492@end deftypefn 493 494@node Decimal float library routines 495@section Routines for decimal floating point emulation 496@cindex decimal float library 497@cindex IEEE-754R 498 499The software decimal floating point library implements IEEE 754R 500decimal floating point arithmetic and is only activated on selected 501targets. 502 503@subsection Arithmetic functions 504 505@deftypefn {Runtime Function} _Decimal32 __addsd3 (_Decimal32 @var{a}, _Decimal32 @var{b}) 506@deftypefnx {Runtime Function} _Decimal64 __adddd3 (_Decimal64 @var{a}, _Decimal64 @var{b}) 507@deftypefnx {Runtime Function} _Decimal128 __addtd3 (_Decimal128 @var{a}, _Decimal128 @var{b}) 508These functions return the sum of @var{a} and @var{b}. 509@end deftypefn 510 511@deftypefn {Runtime Function} _Decimal32 __subsd3 (_Decimal32 @var{a}, _Decimal32 @var{b}) 512@deftypefnx {Runtime Function} _Decimal64 __subdd3 (_Decimal64 @var{a}, _Decimal64 @var{b}) 513@deftypefnx {Runtime Function} _Decimal128 __subtd3 (_Decimal128 @var{a}, _Decimal128 @var{b}) 514These functions return the difference between @var{b} and @var{a}; 515that is, @w{@math{@var{a} - @var{b}}}. 516@end deftypefn 517 518@deftypefn {Runtime Function} _Decimal32 __mulsd3 (_Decimal32 @var{a}, _Decimal32 @var{b}) 519@deftypefnx {Runtime Function} _Decimal64 __muldd3 (_Decimal64 @var{a}, _Decimal64 @var{b}) 520@deftypefnx {Runtime Function} _Decimal128 __multd3 (_Decimal128 @var{a}, _Decimal128 @var{b}) 521These functions return the product of @var{a} and @var{b}. 522@end deftypefn 523 524@deftypefn {Runtime Function} _Decimal32 __divsd3 (_Decimal32 @var{a}, _Decimal32 @var{b}) 525@deftypefnx {Runtime Function} _Decimal64 __divdd3 (_Decimal64 @var{a}, _Decimal64 @var{b}) 526@deftypefnx {Runtime Function} _Decimal128 __divtd3 (_Decimal128 @var{a}, _Decimal128 @var{b}) 527These functions return the quotient of @var{a} and @var{b}; that is, 528@w{@math{@var{a} / @var{b}}}. 529@end deftypefn 530 531@deftypefn {Runtime Function} _Decimal32 __negsd2 (_Decimal32 @var{a}) 532@deftypefnx {Runtime Function} _Decimal64 __negdd2 (_Decimal64 @var{a}) 533@deftypefnx {Runtime Function} _Decimal128 __negtd2 (_Decimal128 @var{a}) 534These functions return the negation of @var{a}. They simply flip the 535sign bit, so they can produce negative zero and negative NaN@. 536@end deftypefn 537 538@subsection Conversion functions 539 540@c DFP/DFP conversions 541@deftypefn {Runtime Function} _Decimal64 __extendsddd2 (_Decimal32 @var{a}) 542@deftypefnx {Runtime Function} _Decimal128 __extendsdtd2 (_Decimal32 @var{a}) 543@deftypefnx {Runtime Function} _Decimal128 __extendddtd2 (_Decimal64 @var{a}) 544@c DFP/binary FP conversions 545@deftypefnx {Runtime Function} _Decimal32 __extendsfsd (float @var{a}) 546@deftypefnx {Runtime Function} double __extendsddf (_Decimal32 @var{a}) 547@deftypefnx {Runtime Function} {long double} __extendsdxf (_Decimal32 @var{a}) 548@deftypefnx {Runtime Function} _Decimal64 __extendsfdd (float @var{a}) 549@deftypefnx {Runtime Function} _Decimal64 __extenddfdd (double @var{a}) 550@deftypefnx {Runtime Function} {long double} __extendddxf (_Decimal64 @var{a}) 551@deftypefnx {Runtime Function} _Decimal128 __extendsftd (float @var{a}) 552@deftypefnx {Runtime Function} _Decimal128 __extenddftd (double @var{a}) 553@deftypefnx {Runtime Function} _Decimal128 __extendxftd ({long double} @var{a}) 554These functions extend @var{a} to the wider mode of their return type. 555@end deftypefn 556 557@c DFP/DFP conversions 558@deftypefn {Runtime Function} _Decimal32 __truncddsd2 (_Decimal64 @var{a}) 559@deftypefnx {Runtime Function} _Decimal32 __trunctdsd2 (_Decimal128 @var{a}) 560@deftypefnx {Runtime Function} _Decimal64 __trunctddd2 (_Decimal128 @var{a}) 561@c DFP/binary FP conversions 562@deftypefnx {Runtime Function} float __truncsdsf (_Decimal32 @var{a}) 563@deftypefnx {Runtime Function} _Decimal32 __truncdfsd (double @var{a}) 564@deftypefnx {Runtime Function} _Decimal32 __truncxfsd ({long double} @var{a}) 565@deftypefnx {Runtime Function} float __truncddsf (_Decimal64 @var{a}) 566@deftypefnx {Runtime Function} double __truncdddf (_Decimal64 @var{a}) 567@deftypefnx {Runtime Function} _Decimal64 __truncxfdd ({long double} @var{a}) 568@deftypefnx {Runtime Function} float __trunctdsf (_Decimal128 @var{a}) 569@deftypefnx {Runtime Function} double __trunctddf (_Decimal128 @var{a}) 570@deftypefnx {Runtime Function} {long double} __trunctdxf (_Decimal128 @var{a}) 571These functions truncate @var{a} to the narrower mode of their return 572type. 573@end deftypefn 574 575@deftypefn {Runtime Function} int __fixsdsi (_Decimal32 @var{a}) 576@deftypefnx {Runtime Function} int __fixddsi (_Decimal64 @var{a}) 577@deftypefnx {Runtime Function} int __fixtdsi (_Decimal128 @var{a}) 578These functions convert @var{a} to a signed integer. 579@end deftypefn 580 581@deftypefn {Runtime Function} long __fixsddi (_Decimal32 @var{a}) 582@deftypefnx {Runtime Function} long __fixdddi (_Decimal64 @var{a}) 583@deftypefnx {Runtime Function} long __fixtddi (_Decimal128 @var{a}) 584These functions convert @var{a} to a signed long. 585@end deftypefn 586 587@deftypefn {Runtime Function} {unsigned int} __fixunssdsi (_Decimal32 @var{a}) 588@deftypefnx {Runtime Function} {unsigned int} __fixunsddsi (_Decimal64 @var{a}) 589@deftypefnx {Runtime Function} {unsigned int} __fixunstdsi (_Decimal128 @var{a}) 590These functions convert @var{a} to an unsigned integer. Negative values all become zero. 591@end deftypefn 592 593@deftypefn {Runtime Function} {unsigned long} __fixunssddi (_Decimal32 @var{a}) 594@deftypefnx {Runtime Function} {unsigned long} __fixunsdddi (_Decimal64 @var{a}) 595@deftypefnx {Runtime Function} {unsigned long} __fixunstddi (_Decimal128 @var{a}) 596These functions convert @var{a} to an unsigned long. Negative values 597all become zero. 598@end deftypefn 599 600@deftypefn {Runtime Function} _Decimal32 __floatsisd (int @var{i}) 601@deftypefnx {Runtime Function} _Decimal64 __floatsidd (int @var{i}) 602@deftypefnx {Runtime Function} _Decimal128 __floatsitd (int @var{i}) 603These functions convert @var{i}, a signed integer, to decimal floating point. 604@end deftypefn 605 606@deftypefn {Runtime Function} _Decimal32 __floatdisd (long @var{i}) 607@deftypefnx {Runtime Function} _Decimal64 __floatdidd (long @var{i}) 608@deftypefnx {Runtime Function} _Decimal128 __floatditd (long @var{i}) 609These functions convert @var{i}, a signed long, to decimal floating point. 610@end deftypefn 611 612@deftypefn {Runtime Function} _Decimal32 __floatunssisd (unsigned int @var{i}) 613@deftypefnx {Runtime Function} _Decimal64 __floatunssidd (unsigned int @var{i}) 614@deftypefnx {Runtime Function} _Decimal128 __floatunssitd (unsigned int @var{i}) 615These functions convert @var{i}, an unsigned integer, to decimal floating point. 616@end deftypefn 617 618@deftypefn {Runtime Function} _Decimal32 __floatunsdisd (unsigned long @var{i}) 619@deftypefnx {Runtime Function} _Decimal64 __floatunsdidd (unsigned long @var{i}) 620@deftypefnx {Runtime Function} _Decimal128 __floatunsditd (unsigned long @var{i}) 621These functions convert @var{i}, an unsigned long, to decimal floating point. 622@end deftypefn 623 624@subsection Comparison functions 625 626@deftypefn {Runtime Function} int __unordsd2 (_Decimal32 @var{a}, _Decimal32 @var{b}) 627@deftypefnx {Runtime Function} int __unorddd2 (_Decimal64 @var{a}, _Decimal64 @var{b}) 628@deftypefnx {Runtime Function} int __unordtd2 (_Decimal128 @var{a}, _Decimal128 @var{b}) 629These functions return a nonzero value if either argument is NaN, otherwise 0. 630@end deftypefn 631 632There is also a complete group of higher level functions which 633correspond directly to comparison operators. They implement the ISO C 634semantics for floating-point comparisons, taking NaN into account. 635Pay careful attention to the return values defined for each set. 636Under the hood, all of these routines are implemented as 637 638@smallexample 639 if (__unord@var{X}d2 (a, b)) 640 return @var{E}; 641 return __cmp@var{X}d2 (a, b); 642@end smallexample 643 644@noindent 645where @var{E} is a constant chosen to give the proper behavior for 646NaN@. Thus, the meaning of the return value is different for each set. 647Do not rely on this implementation; only the semantics documented 648below are guaranteed. 649 650@deftypefn {Runtime Function} int __eqsd2 (_Decimal32 @var{a}, _Decimal32 @var{b}) 651@deftypefnx {Runtime Function} int __eqdd2 (_Decimal64 @var{a}, _Decimal64 @var{b}) 652@deftypefnx {Runtime Function} int __eqtd2 (_Decimal128 @var{a}, _Decimal128 @var{b}) 653These functions return zero if neither argument is NaN, and @var{a} and 654@var{b} are equal. 655@end deftypefn 656 657@deftypefn {Runtime Function} int __nesd2 (_Decimal32 @var{a}, _Decimal32 @var{b}) 658@deftypefnx {Runtime Function} int __nedd2 (_Decimal64 @var{a}, _Decimal64 @var{b}) 659@deftypefnx {Runtime Function} int __netd2 (_Decimal128 @var{a}, _Decimal128 @var{b}) 660These functions return a nonzero value if either argument is NaN, or 661if @var{a} and @var{b} are unequal. 662@end deftypefn 663 664@deftypefn {Runtime Function} int __gesd2 (_Decimal32 @var{a}, _Decimal32 @var{b}) 665@deftypefnx {Runtime Function} int __gedd2 (_Decimal64 @var{a}, _Decimal64 @var{b}) 666@deftypefnx {Runtime Function} int __getd2 (_Decimal128 @var{a}, _Decimal128 @var{b}) 667These functions return a value greater than or equal to zero if 668neither argument is NaN, and @var{a} is greater than or equal to 669@var{b}. 670@end deftypefn 671 672@deftypefn {Runtime Function} int __ltsd2 (_Decimal32 @var{a}, _Decimal32 @var{b}) 673@deftypefnx {Runtime Function} int __ltdd2 (_Decimal64 @var{a}, _Decimal64 @var{b}) 674@deftypefnx {Runtime Function} int __lttd2 (_Decimal128 @var{a}, _Decimal128 @var{b}) 675These functions return a value less than zero if neither argument is 676NaN, and @var{a} is strictly less than @var{b}. 677@end deftypefn 678 679@deftypefn {Runtime Function} int __lesd2 (_Decimal32 @var{a}, _Decimal32 @var{b}) 680@deftypefnx {Runtime Function} int __ledd2 (_Decimal64 @var{a}, _Decimal64 @var{b}) 681@deftypefnx {Runtime Function} int __letd2 (_Decimal128 @var{a}, _Decimal128 @var{b}) 682These functions return a value less than or equal to zero if neither 683argument is NaN, and @var{a} is less than or equal to @var{b}. 684@end deftypefn 685 686@deftypefn {Runtime Function} int __gtsd2 (_Decimal32 @var{a}, _Decimal32 @var{b}) 687@deftypefnx {Runtime Function} int __gtdd2 (_Decimal64 @var{a}, _Decimal64 @var{b}) 688@deftypefnx {Runtime Function} int __gttd2 (_Decimal128 @var{a}, _Decimal128 @var{b}) 689These functions return a value greater than zero if neither argument 690is NaN, and @var{a} is strictly greater than @var{b}. 691@end deftypefn 692 693@node Exception handling routines 694@section Language-independent routines for exception handling 695 696document me! 697 698@smallexample 699 _Unwind_DeleteException 700 _Unwind_Find_FDE 701 _Unwind_ForcedUnwind 702 _Unwind_GetGR 703 _Unwind_GetIP 704 _Unwind_GetLanguageSpecificData 705 _Unwind_GetRegionStart 706 _Unwind_GetTextRelBase 707 _Unwind_GetDataRelBase 708 _Unwind_RaiseException 709 _Unwind_Resume 710 _Unwind_SetGR 711 _Unwind_SetIP 712 _Unwind_FindEnclosingFunction 713 _Unwind_SjLj_Register 714 _Unwind_SjLj_Unregister 715 _Unwind_SjLj_RaiseException 716 _Unwind_SjLj_ForcedUnwind 717 _Unwind_SjLj_Resume 718 __deregister_frame 719 __deregister_frame_info 720 __deregister_frame_info_bases 721 __register_frame 722 __register_frame_info 723 __register_frame_info_bases 724 __register_frame_info_table 725 __register_frame_info_table_bases 726 __register_frame_table 727@end smallexample 728 729@node Miscellaneous routines 730@section Miscellaneous runtime library routines 731 732@subsection Cache control functions 733@deftypefn {Runtime Function} void __clear_cache (char *@var{beg}, char *@var{end}) 734This function clears the instruction cache between @var{beg} and @var{end}. 735@end deftypefn 736