📄 libgcc.texi
字号:
@c Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.@c This is part of the GCC manual.@c For copying conditions, see the file gcc.texi.@c Contributed by Aldy Hernandez <aldy@quesejoda.com>@node Libgcc@chapter The GCC low-level runtime libraryGCC provides a low-level runtime library, @file{libgcc.a} or@file{libgcc_s.so.1} on some platforms. GCC generates calls toroutines in this library automatically, whenever it needs to performsome operation that is too complicated to emit inline code for.Most of the routines in @code{libgcc} handle arithmetic operationsthat the target processor cannot perform directly. This includesinteger multiply and divide on some machines, and all floating-pointand fixed-point operations on other machines. @code{libgcc} also includesroutines for exception handling, and a handful of miscellaneous operations.Some of these routines can be defined in mostly machine-independent C@.Others must be hand-written in assembly language for each processorthat needs them.GCC will also generate calls to C library routines, such as@code{memcpy} and @code{memset}, in some cases. The set of routinesthat GCC may possibly use is documented in @ref{OtherBuiltins,,,gcc, Using the GNU Compiler Collection (GCC)}.These routines take arguments and return values of a specific machinemode, not a specific C type. @xref{Machine Modes}, for an explanationof this concept. For illustrative purposes, in this chapter thefloating point type @code{float} is assumed to correspond to @code{SFmode};@code{double} to @code{DFmode}; and @code{@w{long double}} to both@code{TFmode} and @code{XFmode}. Similarly, the integer types @code{int}and @code{@w{unsigned int}} correspond to @code{SImode}; @code{long} and@code{@w{unsigned long}} to @code{DImode}; and @code{@w{long long}} and@code{@w{unsigned long long}} to @code{TImode}.@menu* Integer library routines::* Soft float library routines::* Decimal float library routines::* Fixed-point fractional library routines::* Exception handling routines::* Miscellaneous routines::@end menu@node Integer library routines@section Routines for integer arithmeticThe integer arithmetic routines are used on platforms that don't providehardware support for arithmetic operations on some modes.@subsection Arithmetic functions@deftypefn {Runtime Function} int __ashlsi3 (int @var{a}, int @var{b})@deftypefnx {Runtime Function} long __ashldi3 (long @var{a}, int @var{b})@deftypefnx {Runtime Function} {long long} __ashlti3 (long long @var{a}, int @var{b})These functions return the result of shifting @var{a} left by @var{b} bits.@end deftypefn@deftypefn {Runtime Function} int __ashrsi3 (int @var{a}, int @var{b})@deftypefnx {Runtime Function} long __ashrdi3 (long @var{a}, int @var{b})@deftypefnx {Runtime Function} {long long} __ashrti3 (long long @var{a}, int @var{b})These functions return the result of arithmetically shifting @var{a} rightby @var{b} bits.@end deftypefn@deftypefn {Runtime Function} int __divsi3 (int @var{a}, int @var{b})@deftypefnx {Runtime Function} long __divdi3 (long @var{a}, long @var{b})@deftypefnx {Runtime Function} {long long} __divti3 (long long @var{a}, long long @var{b})These functions return the quotient of the signed division of @var{a} and@var{b}.@end deftypefn@deftypefn {Runtime Function} int __lshrsi3 (int @var{a}, int @var{b})@deftypefnx {Runtime Function} long __lshrdi3 (long @var{a}, int @var{b})@deftypefnx {Runtime Function} {long long} __lshrti3 (long long @var{a}, int @var{b})These functions return the result of logically shifting @var{a} right by@var{b} bits.@end deftypefn@deftypefn {Runtime Function} int __modsi3 (int @var{a}, int @var{b})@deftypefnx {Runtime Function} long __moddi3 (long @var{a}, long @var{b})@deftypefnx {Runtime Function} {long long} __modti3 (long long @var{a}, long long @var{b})These functions return the remainder of the signed division of @var{a}and @var{b}.@end deftypefn@deftypefn {Runtime Function} int __mulsi3 (int @var{a}, int @var{b})@deftypefnx {Runtime Function} long __muldi3 (long @var{a}, long @var{b})@deftypefnx {Runtime Function} {long long} __multi3 (long long @var{a}, long long @var{b})These functions return the product of @var{a} and @var{b}.@end deftypefn@deftypefn {Runtime Function} long __negdi2 (long @var{a})@deftypefnx {Runtime Function} {long long} __negti2 (long long @var{a})These functions return the negation of @var{a}.@end deftypefn@deftypefn {Runtime Function} {unsigned int} __udivsi3 (unsigned int @var{a}, unsigned int @var{b})@deftypefnx {Runtime Function} {unsigned long} __udivdi3 (unsigned long @var{a}, unsigned long @var{b})@deftypefnx {Runtime Function} {unsigned long long} __udivti3 (unsigned long long @var{a}, unsigned long long @var{b})These functions return the quotient of the unsigned division of @var{a}and @var{b}.@end deftypefn@deftypefn {Runtime Function} {unsigned long} __udivmoddi3 (unsigned long @var{a}, unsigned long @var{b}, unsigned long *@var{c})@deftypefnx {Runtime Function} {unsigned long long} __udivti3 (unsigned long long @var{a}, unsigned long long @var{b}, unsigned long long *@var{c})These functions calculate both the quotient and remainder of the unsigneddivision of @var{a} and @var{b}. The return value is the quotient, andthe remainder is placed in variable pointed to by @var{c}.@end deftypefn@deftypefn {Runtime Function} {unsigned int} __umodsi3 (unsigned int @var{a}, unsigned int @var{b})@deftypefnx {Runtime Function} {unsigned long} __umoddi3 (unsigned long @var{a}, unsigned long @var{b})@deftypefnx {Runtime Function} {unsigned long long} __umodti3 (unsigned long long @var{a}, unsigned long long @var{b})These functions return the remainder of the unsigned division of @var{a}and @var{b}.@end deftypefn@subsection Comparison functionsThe following functions implement integral comparisons. These functionsimplement a low-level compare, upon which the higher level comparisonoperators (such as less than and greater than or equal to) can beconstructed. The returned values lie in the range zero to two, to allowthe high-level operators to be implemented by testing the returnedresult using either signed or unsigned comparison.@deftypefn {Runtime Function} int __cmpdi2 (long @var{a}, long @var{b})@deftypefnx {Runtime Function} int __cmpti2 (long long @var{a}, long long @var{b})These functions perform a signed comparison of @var{a} and @var{b}. If@var{a} is less than @var{b}, they return 0; if @var{a} is greater than@var{b}, they return 2; and if @var{a} and @var{b} are equal they return 1.@end deftypefn@deftypefn {Runtime Function} int __ucmpdi2 (unsigned long @var{a}, unsigned long @var{b})@deftypefnx {Runtime Function} int __ucmpti2 (unsigned long long @var{a}, unsigned long long @var{b})These functions perform an unsigned comparison of @var{a} and @var{b}.If @var{a} is less than @var{b}, they return 0; if @var{a} is greater than@var{b}, they return 2; and if @var{a} and @var{b} are equal they return 1.@end deftypefn@subsection Trapping arithmetic functionsThe following functions implement trapping arithmetic. These functionscall the libc function @code{abort} upon signed arithmetic overflow.@deftypefn {Runtime Function} int __absvsi2 (int @var{a})@deftypefnx {Runtime Function} long __absvdi2 (long @var{a})These functions return the absolute value of @var{a}.@end deftypefn@deftypefn {Runtime Function} int __addvsi3 (int @var{a}, int @var{b})@deftypefnx {Runtime Function} long __addvdi3 (long @var{a}, long @var{b})These functions return the sum of @var{a} and @var{b}; that is@code{@var{a} + @var{b}}.@end deftypefn@deftypefn {Runtime Function} int __mulvsi3 (int @var{a}, int @var{b})@deftypefnx {Runtime Function} long __mulvdi3 (long @var{a}, long @var{b})The functions return the product of @var{a} and @var{b}; that is@code{@var{a} * @var{b}}.@end deftypefn@deftypefn {Runtime Function} int __negvsi2 (int @var{a})@deftypefnx {Runtime Function} long __negvdi2 (long @var{a})These functions return the negation of @var{a}; that is @code{-@var{a}}.@end deftypefn@deftypefn {Runtime Function} int __subvsi3 (int @var{a}, int @var{b})@deftypefnx {Runtime Function} long __subvdi3 (long @var{a}, long @var{b})These functions return the difference between @var{b} and @var{a};that is @code{@var{a} - @var{b}}.@end deftypefn@subsection Bit operations@deftypefn {Runtime Function} int __clzsi2 (int @var{a})@deftypefnx {Runtime Function} int __clzdi2 (long @var{a})@deftypefnx {Runtime Function} int __clzti2 (long long @var{a})These functions return the number of leading 0-bits in @var{a}, startingat the most significant bit position. If @var{a} is zero, the result isundefined.@end deftypefn@deftypefn {Runtime Function} int __ctzsi2 (int @var{a})@deftypefnx {Runtime Function} int __ctzdi2 (long @var{a})@deftypefnx {Runtime Function} int __ctzti2 (long long @var{a})These functions return the number of trailing 0-bits in @var{a}, startingat the least significant bit position. If @var{a} is zero, the result isundefined.@end deftypefn@deftypefn {Runtime Function} int __ffsdi2 (long @var{a})@deftypefnx {Runtime Function} int __ffsti2 (long long @var{a})These functions return the index of the least significant 1-bit in @var{a},or the value zero if @var{a} is zero. The least significant bit is indexone.@end deftypefn@deftypefn {Runtime Function} int __paritysi2 (int @var{a})@deftypefnx {Runtime Function} int __paritydi2 (long @var{a})@deftypefnx {Runtime Function} int __parityti2 (long long @var{a})These functions return the value zero if the number of bits set in@var{a} is even, and the value one otherwise.@end deftypefn@deftypefn {Runtime Function} int __popcountsi2 (int @var{a})@deftypefnx {Runtime Function} int __popcountdi2 (long @var{a})@deftypefnx {Runtime Function} int __popcountti2 (long long @var{a})These functions return the number of bits set in @var{a}.@end deftypefn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -