Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

257 lines
4.9 KiB

  1. /*--
  2. Module Name:
  3. largeint.h
  4. Abstract:
  5. Include file for sample Large Integer Arithmetic routines.
  6. This file includes all of the prototypes for the routines found in
  7. largeint.lib. For complete descriptions of these functions, see the
  8. largeint.s source file for MIPS, or the divlarge.c and largeint.asm
  9. source files for x86.
  10. Revision History:
  11. --*/
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. //
  16. //Large integer arithmetic routines.
  17. //
  18. //
  19. // Large integer add - 64-bits + 64-bits -> 64-bits
  20. //
  21. LARGE_INTEGER
  22. WINAPI
  23. LargeIntegerAdd (
  24. LARGE_INTEGER Addend1,
  25. LARGE_INTEGER Addend2
  26. );
  27. //
  28. // Enlarged integer multiply - 32-bits * 32-bits -> 64-bits
  29. //
  30. LARGE_INTEGER
  31. WINAPI
  32. EnlargedIntegerMultiply (
  33. LONG Multiplicand,
  34. LONG Multiplier
  35. );
  36. //
  37. // Unsigned enlarged integer multiply - 32-bits * 32-bits -> 64-bits
  38. //
  39. LARGE_INTEGER
  40. WINAPI
  41. EnlargedUnsignedMultiply (
  42. ULONG Multiplicand,
  43. ULONG Multiplier
  44. );
  45. //
  46. // Enlarged integer divide - 64-bits / 32-bits > 32-bits
  47. //
  48. ULONG
  49. WINAPI
  50. EnlargedUnsignedDivide (
  51. IN ULARGE_INTEGER Dividend,
  52. IN ULONG Divisor,
  53. IN PULONG Remainder
  54. );
  55. //
  56. // Extended large integer magic divide - 64-bits / 32-bits -> 64-bits
  57. //
  58. LARGE_INTEGER
  59. WINAPI
  60. ExtendedMagicDivide (
  61. LARGE_INTEGER Dividend,
  62. LARGE_INTEGER MagicDivisor,
  63. CCHAR ShiftCount
  64. );
  65. //
  66. // Large Integer divide - 64-bits / 32-bits -> 64-bits
  67. //
  68. LARGE_INTEGER
  69. WINAPI
  70. ExtendedLargeIntegerDivide (
  71. LARGE_INTEGER Dividend,
  72. ULONG Divisor,
  73. PULONG Remainder
  74. );
  75. //
  76. // Large Integer divide - 64-bits / 32-bits -> 64-bits
  77. //
  78. LARGE_INTEGER
  79. WINAPI
  80. LargeIntegerDivide (
  81. LARGE_INTEGER Dividend,
  82. LARGE_INTEGER Divisor,
  83. PLARGE_INTEGER Remainder
  84. );
  85. //
  86. // Extended integer multiply - 32-bits * 64-bits -> 64-bits
  87. //
  88. LARGE_INTEGER
  89. WINAPI
  90. ExtendedIntegerMultiply (
  91. LARGE_INTEGER Multiplicand,
  92. LONG Multiplier
  93. );
  94. //
  95. // Large integer negation - -(64-bits)
  96. //
  97. LARGE_INTEGER
  98. WINAPI
  99. LargeIntegerNegate (
  100. LARGE_INTEGER Subtrahend
  101. );
  102. //
  103. // Large integer subtract - 64-bits - 64-bits -> 64-bits.
  104. //
  105. LARGE_INTEGER
  106. WINAPI
  107. LargeIntegerSubtract (
  108. LARGE_INTEGER Minuend,
  109. LARGE_INTEGER Subtrahend
  110. );
  111. //
  112. // Large integer and - 64-bite & 64-bits -> 64-bits.
  113. //
  114. #define LargeIntegerAnd(Result, Source, Mask) \
  115. { \
  116. Result.HighPart = Source.HighPart & Mask.HighPart; \
  117. Result.LowPart = Source.LowPart & Mask.LowPart; \
  118. }
  119. //
  120. // Large integer conversion routines.
  121. //
  122. //
  123. // Convert signed integer to large integer.
  124. //
  125. LARGE_INTEGER
  126. WINAPI
  127. ConvertLongToLargeInteger (
  128. LONG SignedInteger
  129. );
  130. //
  131. // Convert unsigned integer to large integer.
  132. //
  133. LARGE_INTEGER
  134. WINAPI
  135. ConvertUlongToLargeInteger (
  136. ULONG UnsignedInteger
  137. );
  138. //
  139. // Large integer shift routines.
  140. //
  141. LARGE_INTEGER
  142. WINAPI
  143. LargeIntegerShiftLeft (
  144. LARGE_INTEGER LargeInteger,
  145. CCHAR ShiftCount
  146. );
  147. LARGE_INTEGER
  148. WINAPI
  149. LargeIntegerShiftRight (
  150. LARGE_INTEGER LargeInteger,
  151. CCHAR ShiftCount
  152. );
  153. LARGE_INTEGER
  154. WINAPI
  155. LargeIntegerArithmeticShift (
  156. LARGE_INTEGER LargeInteger,
  157. CCHAR ShiftCount
  158. );
  159. #define LargeIntegerGreaterThan(X,Y) ( \
  160. (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
  161. ((X).HighPart > (Y).HighPart) \
  162. )
  163. #define LargeIntegerGreaterThanOrEqualTo(X,Y) ( \
  164. (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
  165. ((X).HighPart > (Y).HighPart) \
  166. )
  167. #define LargeIntegerEqualTo(X,Y) ( \
  168. !(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
  169. )
  170. #define LargeIntegerNotEqualTo(X,Y) ( \
  171. (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
  172. )
  173. #define LargeIntegerLessThan(X,Y) ( \
  174. (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
  175. ((X).HighPart < (Y).HighPart) \
  176. )
  177. #define LargeIntegerLessThanOrEqualTo(X,Y) ( \
  178. (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
  179. ((X).HighPart < (Y).HighPart) \
  180. )
  181. #define LargeIntegerGreaterThanZero(X) ( \
  182. (((X).HighPart == 0) && ((X).LowPart > 0)) || \
  183. ((X).HighPart > 0 ) \
  184. )
  185. #define LargeIntegerGreaterOrEqualToZero(X) ( \
  186. (X).HighPart >= 0 \
  187. )
  188. #define LargeIntegerEqualToZero(X) ( \
  189. !((X).LowPart | (X).HighPart) \
  190. )
  191. #define LargeIntegerNotEqualToZero(X) ( \
  192. ((X).LowPart | (X).HighPart) \
  193. )
  194. #define LargeIntegerLessThanZero(X) ( \
  195. ((X).HighPart < 0) \
  196. )
  197. #define LargeIntegerLessOrEqualToZero(X) ( \
  198. ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) \
  199. )
  200. #ifdef __cplusplus
  201. }
  202. #endif