Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

286 linhas
17KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Integer library routines (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Integer library routines (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Integer library routines (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Libgcc.html#Libgcc" rel="up" title="Libgcc">
  30. <link href="Soft-float-library-routines.html#Soft-float-library-routines" rel="next" title="Soft float library routines">
  31. <link href="Libgcc.html#Libgcc" rel="prev" title="Libgcc">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Integer-library-routines"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Soft-float-library-routines.html#Soft-float-library-routines" accesskey="n" rel="next">Soft float library routines</a>, Up: <a href="Libgcc.html#Libgcc" accesskey="u" rel="up">Libgcc</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Routines-for-integer-arithmetic"></a>
  68. <h3 class="section">4.1 Routines for integer arithmetic</h3>
  69. <p>The integer arithmetic routines are used on platforms that don&rsquo;t provide
  70. hardware support for arithmetic operations on some modes.
  71. </p>
  72. <a name="Arithmetic-functions"></a>
  73. <h4 class="subsection">4.1.1 Arithmetic functions</h4>
  74. <dl>
  75. <dt><a name="index-_005f_005fashlsi3"></a>Runtime Function: <em>int</em> <strong>__ashlsi3</strong> <em>(int <var>a</var>, int <var>b</var>)</em></dt>
  76. <dt><a name="index-_005f_005fashldi3"></a>Runtime Function: <em>long</em> <strong>__ashldi3</strong> <em>(long <var>a</var>, int <var>b</var>)</em></dt>
  77. <dt><a name="index-_005f_005fashlti3"></a>Runtime Function: <em>long long</em> <strong>__ashlti3</strong> <em>(long long <var>a</var>, int <var>b</var>)</em></dt>
  78. <dd><p>These functions return the result of shifting <var>a</var> left by <var>b</var> bits.
  79. </p></dd></dl>
  80. <dl>
  81. <dt><a name="index-_005f_005fashrsi3"></a>Runtime Function: <em>int</em> <strong>__ashrsi3</strong> <em>(int <var>a</var>, int <var>b</var>)</em></dt>
  82. <dt><a name="index-_005f_005fashrdi3"></a>Runtime Function: <em>long</em> <strong>__ashrdi3</strong> <em>(long <var>a</var>, int <var>b</var>)</em></dt>
  83. <dt><a name="index-_005f_005fashrti3"></a>Runtime Function: <em>long long</em> <strong>__ashrti3</strong> <em>(long long <var>a</var>, int <var>b</var>)</em></dt>
  84. <dd><p>These functions return the result of arithmetically shifting <var>a</var> right
  85. by <var>b</var> bits.
  86. </p></dd></dl>
  87. <dl>
  88. <dt><a name="index-_005f_005fdivsi3"></a>Runtime Function: <em>int</em> <strong>__divsi3</strong> <em>(int <var>a</var>, int <var>b</var>)</em></dt>
  89. <dt><a name="index-_005f_005fdivdi3"></a>Runtime Function: <em>long</em> <strong>__divdi3</strong> <em>(long <var>a</var>, long <var>b</var>)</em></dt>
  90. <dt><a name="index-_005f_005fdivti3"></a>Runtime Function: <em>long long</em> <strong>__divti3</strong> <em>(long long <var>a</var>, long long <var>b</var>)</em></dt>
  91. <dd><p>These functions return the quotient of the signed division of <var>a</var> and
  92. <var>b</var>.
  93. </p></dd></dl>
  94. <dl>
  95. <dt><a name="index-_005f_005flshrsi3"></a>Runtime Function: <em>int</em> <strong>__lshrsi3</strong> <em>(int <var>a</var>, int <var>b</var>)</em></dt>
  96. <dt><a name="index-_005f_005flshrdi3"></a>Runtime Function: <em>long</em> <strong>__lshrdi3</strong> <em>(long <var>a</var>, int <var>b</var>)</em></dt>
  97. <dt><a name="index-_005f_005flshrti3"></a>Runtime Function: <em>long long</em> <strong>__lshrti3</strong> <em>(long long <var>a</var>, int <var>b</var>)</em></dt>
  98. <dd><p>These functions return the result of logically shifting <var>a</var> right by
  99. <var>b</var> bits.
  100. </p></dd></dl>
  101. <dl>
  102. <dt><a name="index-_005f_005fmodsi3"></a>Runtime Function: <em>int</em> <strong>__modsi3</strong> <em>(int <var>a</var>, int <var>b</var>)</em></dt>
  103. <dt><a name="index-_005f_005fmoddi3"></a>Runtime Function: <em>long</em> <strong>__moddi3</strong> <em>(long <var>a</var>, long <var>b</var>)</em></dt>
  104. <dt><a name="index-_005f_005fmodti3"></a>Runtime Function: <em>long long</em> <strong>__modti3</strong> <em>(long long <var>a</var>, long long <var>b</var>)</em></dt>
  105. <dd><p>These functions return the remainder of the signed division of <var>a</var>
  106. and <var>b</var>.
  107. </p></dd></dl>
  108. <dl>
  109. <dt><a name="index-_005f_005fmulsi3"></a>Runtime Function: <em>int</em> <strong>__mulsi3</strong> <em>(int <var>a</var>, int <var>b</var>)</em></dt>
  110. <dt><a name="index-_005f_005fmuldi3"></a>Runtime Function: <em>long</em> <strong>__muldi3</strong> <em>(long <var>a</var>, long <var>b</var>)</em></dt>
  111. <dt><a name="index-_005f_005fmulti3"></a>Runtime Function: <em>long long</em> <strong>__multi3</strong> <em>(long long <var>a</var>, long long <var>b</var>)</em></dt>
  112. <dd><p>These functions return the product of <var>a</var> and <var>b</var>.
  113. </p></dd></dl>
  114. <dl>
  115. <dt><a name="index-_005f_005fnegdi2"></a>Runtime Function: <em>long</em> <strong>__negdi2</strong> <em>(long <var>a</var>)</em></dt>
  116. <dt><a name="index-_005f_005fnegti2"></a>Runtime Function: <em>long long</em> <strong>__negti2</strong> <em>(long long <var>a</var>)</em></dt>
  117. <dd><p>These functions return the negation of <var>a</var>.
  118. </p></dd></dl>
  119. <dl>
  120. <dt><a name="index-_005f_005fudivsi3"></a>Runtime Function: <em>unsigned int</em> <strong>__udivsi3</strong> <em>(unsigned int <var>a</var>, unsigned int <var>b</var>)</em></dt>
  121. <dt><a name="index-_005f_005fudivdi3"></a>Runtime Function: <em>unsigned long</em> <strong>__udivdi3</strong> <em>(unsigned long <var>a</var>, unsigned long <var>b</var>)</em></dt>
  122. <dt><a name="index-_005f_005fudivti3"></a>Runtime Function: <em>unsigned long long</em> <strong>__udivti3</strong> <em>(unsigned long long <var>a</var>, unsigned long long <var>b</var>)</em></dt>
  123. <dd><p>These functions return the quotient of the unsigned division of <var>a</var>
  124. and <var>b</var>.
  125. </p></dd></dl>
  126. <dl>
  127. <dt><a name="index-_005f_005fudivmoddi4"></a>Runtime Function: <em>unsigned long</em> <strong>__udivmoddi4</strong> <em>(unsigned long <var>a</var>, unsigned long <var>b</var>, unsigned long *<var>c</var>)</em></dt>
  128. <dt><a name="index-_005f_005fudivmodti4"></a>Runtime Function: <em>unsigned long long</em> <strong>__udivmodti4</strong> <em>(unsigned long long <var>a</var>, unsigned long long <var>b</var>, unsigned long long *<var>c</var>)</em></dt>
  129. <dd><p>These functions calculate both the quotient and remainder of the unsigned
  130. division of <var>a</var> and <var>b</var>. The return value is the quotient, and
  131. the remainder is placed in variable pointed to by <var>c</var>.
  132. </p></dd></dl>
  133. <dl>
  134. <dt><a name="index-_005f_005fumodsi3"></a>Runtime Function: <em>unsigned int</em> <strong>__umodsi3</strong> <em>(unsigned int <var>a</var>, unsigned int <var>b</var>)</em></dt>
  135. <dt><a name="index-_005f_005fumoddi3"></a>Runtime Function: <em>unsigned long</em> <strong>__umoddi3</strong> <em>(unsigned long <var>a</var>, unsigned long <var>b</var>)</em></dt>
  136. <dt><a name="index-_005f_005fumodti3"></a>Runtime Function: <em>unsigned long long</em> <strong>__umodti3</strong> <em>(unsigned long long <var>a</var>, unsigned long long <var>b</var>)</em></dt>
  137. <dd><p>These functions return the remainder of the unsigned division of <var>a</var>
  138. and <var>b</var>.
  139. </p></dd></dl>
  140. <a name="Comparison-functions"></a>
  141. <h4 class="subsection">4.1.2 Comparison functions</h4>
  142. <p>The following functions implement integral comparisons. These functions
  143. implement a low-level compare, upon which the higher level comparison
  144. operators (such as less than and greater than or equal to) can be
  145. constructed. The returned values lie in the range zero to two, to allow
  146. the high-level operators to be implemented by testing the returned
  147. result using either signed or unsigned comparison.
  148. </p>
  149. <dl>
  150. <dt><a name="index-_005f_005fcmpdi2"></a>Runtime Function: <em>int</em> <strong>__cmpdi2</strong> <em>(long <var>a</var>, long <var>b</var>)</em></dt>
  151. <dt><a name="index-_005f_005fcmpti2"></a>Runtime Function: <em>int</em> <strong>__cmpti2</strong> <em>(long long <var>a</var>, long long <var>b</var>)</em></dt>
  152. <dd><p>These functions perform a signed comparison of <var>a</var> and <var>b</var>. If
  153. <var>a</var> is less than <var>b</var>, they return 0; if <var>a</var> is greater than
  154. <var>b</var>, they return 2; and if <var>a</var> and <var>b</var> are equal they return 1.
  155. </p></dd></dl>
  156. <dl>
  157. <dt><a name="index-_005f_005fucmpdi2"></a>Runtime Function: <em>int</em> <strong>__ucmpdi2</strong> <em>(unsigned long <var>a</var>, unsigned long <var>b</var>)</em></dt>
  158. <dt><a name="index-_005f_005fucmpti2"></a>Runtime Function: <em>int</em> <strong>__ucmpti2</strong> <em>(unsigned long long <var>a</var>, unsigned long long <var>b</var>)</em></dt>
  159. <dd><p>These functions perform an unsigned comparison of <var>a</var> and <var>b</var>.
  160. If <var>a</var> is less than <var>b</var>, they return 0; if <var>a</var> is greater than
  161. <var>b</var>, they return 2; and if <var>a</var> and <var>b</var> are equal they return 1.
  162. </p></dd></dl>
  163. <a name="Trapping-arithmetic-functions"></a>
  164. <h4 class="subsection">4.1.3 Trapping arithmetic functions</h4>
  165. <p>The following functions implement trapping arithmetic. These functions
  166. call the libc function <code>abort</code> upon signed arithmetic overflow.
  167. </p>
  168. <dl>
  169. <dt><a name="index-_005f_005fabsvsi2"></a>Runtime Function: <em>int</em> <strong>__absvsi2</strong> <em>(int <var>a</var>)</em></dt>
  170. <dt><a name="index-_005f_005fabsvdi2"></a>Runtime Function: <em>long</em> <strong>__absvdi2</strong> <em>(long <var>a</var>)</em></dt>
  171. <dd><p>These functions return the absolute value of <var>a</var>.
  172. </p></dd></dl>
  173. <dl>
  174. <dt><a name="index-_005f_005faddvsi3"></a>Runtime Function: <em>int</em> <strong>__addvsi3</strong> <em>(int <var>a</var>, int <var>b</var>)</em></dt>
  175. <dt><a name="index-_005f_005faddvdi3"></a>Runtime Function: <em>long</em> <strong>__addvdi3</strong> <em>(long <var>a</var>, long <var>b</var>)</em></dt>
  176. <dd><p>These functions return the sum of <var>a</var> and <var>b</var>; that is
  177. <code><var>a</var> + <var>b</var></code>.
  178. </p></dd></dl>
  179. <dl>
  180. <dt><a name="index-_005f_005fmulvsi3"></a>Runtime Function: <em>int</em> <strong>__mulvsi3</strong> <em>(int <var>a</var>, int <var>b</var>)</em></dt>
  181. <dt><a name="index-_005f_005fmulvdi3"></a>Runtime Function: <em>long</em> <strong>__mulvdi3</strong> <em>(long <var>a</var>, long <var>b</var>)</em></dt>
  182. <dd><p>The functions return the product of <var>a</var> and <var>b</var>; that is
  183. <code><var>a</var> * <var>b</var></code>.
  184. </p></dd></dl>
  185. <dl>
  186. <dt><a name="index-_005f_005fnegvsi2"></a>Runtime Function: <em>int</em> <strong>__negvsi2</strong> <em>(int <var>a</var>)</em></dt>
  187. <dt><a name="index-_005f_005fnegvdi2"></a>Runtime Function: <em>long</em> <strong>__negvdi2</strong> <em>(long <var>a</var>)</em></dt>
  188. <dd><p>These functions return the negation of <var>a</var>; that is <code>-<var>a</var></code>.
  189. </p></dd></dl>
  190. <dl>
  191. <dt><a name="index-_005f_005fsubvsi3"></a>Runtime Function: <em>int</em> <strong>__subvsi3</strong> <em>(int <var>a</var>, int <var>b</var>)</em></dt>
  192. <dt><a name="index-_005f_005fsubvdi3"></a>Runtime Function: <em>long</em> <strong>__subvdi3</strong> <em>(long <var>a</var>, long <var>b</var>)</em></dt>
  193. <dd><p>These functions return the difference between <var>b</var> and <var>a</var>;
  194. that is <code><var>a</var> - <var>b</var></code>.
  195. </p></dd></dl>
  196. <a name="Bit-operations"></a>
  197. <h4 class="subsection">4.1.4 Bit operations</h4>
  198. <dl>
  199. <dt><a name="index-_005f_005fclzsi2"></a>Runtime Function: <em>int</em> <strong>__clzsi2</strong> <em>(unsigned int <var>a</var>)</em></dt>
  200. <dt><a name="index-_005f_005fclzdi2"></a>Runtime Function: <em>int</em> <strong>__clzdi2</strong> <em>(unsigned long <var>a</var>)</em></dt>
  201. <dt><a name="index-_005f_005fclzti2"></a>Runtime Function: <em>int</em> <strong>__clzti2</strong> <em>(unsigned long long <var>a</var>)</em></dt>
  202. <dd><p>These functions return the number of leading 0-bits in <var>a</var>, starting
  203. at the most significant bit position. If <var>a</var> is zero, the result is
  204. undefined.
  205. </p></dd></dl>
  206. <dl>
  207. <dt><a name="index-_005f_005fctzsi2"></a>Runtime Function: <em>int</em> <strong>__ctzsi2</strong> <em>(unsigned int <var>a</var>)</em></dt>
  208. <dt><a name="index-_005f_005fctzdi2"></a>Runtime Function: <em>int</em> <strong>__ctzdi2</strong> <em>(unsigned long <var>a</var>)</em></dt>
  209. <dt><a name="index-_005f_005fctzti2"></a>Runtime Function: <em>int</em> <strong>__ctzti2</strong> <em>(unsigned long long <var>a</var>)</em></dt>
  210. <dd><p>These functions return the number of trailing 0-bits in <var>a</var>, starting
  211. at the least significant bit position. If <var>a</var> is zero, the result is
  212. undefined.
  213. </p></dd></dl>
  214. <dl>
  215. <dt><a name="index-_005f_005fffsdi2"></a>Runtime Function: <em>int</em> <strong>__ffsdi2</strong> <em>(unsigned long <var>a</var>)</em></dt>
  216. <dt><a name="index-_005f_005fffsti2"></a>Runtime Function: <em>int</em> <strong>__ffsti2</strong> <em>(unsigned long long <var>a</var>)</em></dt>
  217. <dd><p>These functions return the index of the least significant 1-bit in <var>a</var>,
  218. or the value zero if <var>a</var> is zero. The least significant bit is index
  219. one.
  220. </p></dd></dl>
  221. <dl>
  222. <dt><a name="index-_005f_005fparitysi2"></a>Runtime Function: <em>int</em> <strong>__paritysi2</strong> <em>(unsigned int <var>a</var>)</em></dt>
  223. <dt><a name="index-_005f_005fparitydi2"></a>Runtime Function: <em>int</em> <strong>__paritydi2</strong> <em>(unsigned long <var>a</var>)</em></dt>
  224. <dt><a name="index-_005f_005fparityti2"></a>Runtime Function: <em>int</em> <strong>__parityti2</strong> <em>(unsigned long long <var>a</var>)</em></dt>
  225. <dd><p>These functions return the value zero if the number of bits set in
  226. <var>a</var> is even, and the value one otherwise.
  227. </p></dd></dl>
  228. <dl>
  229. <dt><a name="index-_005f_005fpopcountsi2"></a>Runtime Function: <em>int</em> <strong>__popcountsi2</strong> <em>(unsigned int <var>a</var>)</em></dt>
  230. <dt><a name="index-_005f_005fpopcountdi2"></a>Runtime Function: <em>int</em> <strong>__popcountdi2</strong> <em>(unsigned long <var>a</var>)</em></dt>
  231. <dt><a name="index-_005f_005fpopcountti2"></a>Runtime Function: <em>int</em> <strong>__popcountti2</strong> <em>(unsigned long long <var>a</var>)</em></dt>
  232. <dd><p>These functions return the number of bits set in <var>a</var>.
  233. </p></dd></dl>
  234. <dl>
  235. <dt><a name="index-_005f_005fbswapsi2"></a>Runtime Function: <em>int32_t</em> <strong>__bswapsi2</strong> <em>(int32_t <var>a</var>)</em></dt>
  236. <dt><a name="index-_005f_005fbswapdi2"></a>Runtime Function: <em>int64_t</em> <strong>__bswapdi2</strong> <em>(int64_t <var>a</var>)</em></dt>
  237. <dd><p>These functions return the <var>a</var> byteswapped.
  238. </p></dd></dl>
  239. <hr>
  240. <div class="header">
  241. <p>
  242. Next: <a href="Soft-float-library-routines.html#Soft-float-library-routines" accesskey="n" rel="next">Soft float library routines</a>, Up: <a href="Libgcc.html#Libgcc" accesskey="u" rel="up">Libgcc</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  243. </div>
  244. </body>
  245. </html>