OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/WINNT/client_osi/largeint.h
00001 /*--
00002 
00003 Module Name:
00004 
00005     largeint.h
00006 
00007 Abstract:
00008 
00009     Include file for sample Large Integer Arithmetic routines.
00010     This file includes all of the prototypes for the routines found in
00011     largeint.lib.  For complete descriptions of these functions, see the
00012     largeint.s source file for MIPS, or the divlarge.c and largeint.asm
00013     source files for x86.
00014 
00015 Revision History:
00016 
00017 --*/
00018 
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022 
00023 //
00024 //Large integer arithmetic routines.
00025 //
00026 
00027 //
00028 // Large integer add - 64-bits + 64-bits -> 64-bits
00029 //
00030 
00031 LARGE_INTEGER
00032 LargeIntegerAdd (
00033     LARGE_INTEGER Addend1,
00034     LARGE_INTEGER Addend2
00035     );
00036 
00037 //
00038 // Enlarged integer multiply - 32-bits * 32-bits -> 64-bits
00039 //
00040 
00041 LARGE_INTEGER
00042 EnlargedIntegerMultiply (
00043     LONG Multiplicand,
00044     LONG Multiplier
00045     );
00046 
00047 //
00048 // Unsigned enlarged integer multiply - 32-bits * 32-bits -> 64-bits
00049 //
00050 
00051 LARGE_INTEGER
00052 EnlargedUnsignedMultiply (
00053     ULONG Multiplicand,
00054     ULONG Multiplier
00055     );
00056 
00057 //
00058 // Enlarged integer divide - 64-bits / 32-bits > 32-bits
00059 //
00060 
00061 ULONG
00062 EnlargedUnsignedDivide (
00063     IN ULARGE_INTEGER Dividend,
00064     IN ULONG Divisor,
00065     IN PULONG Remainder
00066     );
00067 
00068 //
00069 // Extended large integer magic divide - 64-bits / 32-bits -> 64-bits
00070 //
00071 
00072 LARGE_INTEGER
00073 ExtendedMagicDivide (
00074     LARGE_INTEGER Dividend,
00075     LARGE_INTEGER MagicDivisor,
00076     CCHAR ShiftCount
00077     );
00078 
00079 //
00080 // Large Integer divide - 64-bits / 32-bits -> 64-bits
00081 //
00082 
00083 LARGE_INTEGER
00084 ExtendedLargeIntegerDivide (
00085     LARGE_INTEGER Dividend,
00086     ULONG Divisor,
00087     PULONG Remainder
00088     );
00089 
00090 //
00091 // Large Integer divide - 64-bits / 32-bits -> 64-bits
00092 //
00093 
00094 LARGE_INTEGER
00095 LargeIntegerDivide (
00096     LARGE_INTEGER Dividend,
00097     LARGE_INTEGER Divisor,
00098     PLARGE_INTEGER Remainder
00099     );
00100 
00101 //
00102 // Extended integer multiply - 32-bits * 64-bits -> 64-bits
00103 //
00104 
00105 LARGE_INTEGER
00106 ExtendedIntegerMultiply (
00107     LARGE_INTEGER Multiplicand,
00108     LONG Multiplier
00109     );
00110 
00111 //
00112 // Large integer negation - -(64-bits)
00113 //
00114 
00115 LARGE_INTEGER
00116 LargeIntegerNegate (
00117     LARGE_INTEGER Subtrahend
00118     );
00119 
00120 //
00121 // Large integer subtract - 64-bits - 64-bits -> 64-bits.
00122 //
00123 
00124 LARGE_INTEGER
00125 LargeIntegerSubtract (
00126     LARGE_INTEGER Minuend,
00127     LARGE_INTEGER Subtrahend
00128     );
00129 
00130 //
00131 // Large integer and - 64-bite & 64-bits -> 64-bits.
00132 //
00133 
00134 #define LargeIntegerAnd(Result, Source, Mask)   \
00135         {                                           \
00136             Result.HighPart = Source.HighPart & Mask.HighPart; \
00137             Result.LowPart = Source.LowPart & Mask.LowPart; \
00138         }
00139 
00140 
00141 //
00142 // Large integer conversion routines.
00143 //
00144 
00145 //
00146 // Convert signed integer to large integer.
00147 //
00148 
00149 LARGE_INTEGER
00150 ConvertLongToLargeInteger (
00151     LONG SignedInteger
00152     );
00153 
00154 //
00155 // Convert unsigned integer to large integer.
00156 //
00157 
00158 LARGE_INTEGER
00159 ConvertUlongToLargeInteger (
00160     ULONG UnsignedInteger
00161     );
00162 
00163 
00164 //
00165 // Large integer shift routines.
00166 //
00167 
00168 LARGE_INTEGER
00169 LargeIntegerShiftLeft (
00170     LARGE_INTEGER LargeInteger,
00171     CCHAR ShiftCount
00172     );
00173 
00174 LARGE_INTEGER
00175 LargeIntegerShiftRight (
00176     LARGE_INTEGER LargeInteger,
00177     CCHAR ShiftCount
00178     );
00179 
00180 LARGE_INTEGER
00181 LargeIntegerArithmeticShift (
00182     LARGE_INTEGER LargeInteger,
00183     CCHAR ShiftCount
00184     );
00185 
00186 #define LargeIntegerGreaterThan(X,Y) (                              \
00187     (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
00188     ((X).HighPart > (Y).HighPart)                                      \
00189 )
00190 
00191 #define LargeIntegerGreaterThanOrEqualTo(X,Y) (                      \
00192     (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
00193     ((X).HighPart > (Y).HighPart)                                       \
00194 )
00195 
00196 #define LargeIntegerEqualTo(X,Y) (                              \
00197     !(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
00198 )
00199 
00200 #define LargeIntegerNotEqualTo(X,Y) (                          \
00201     (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \
00202 )
00203 
00204 #define LargeIntegerLessThan(X,Y) (                                 \
00205     (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
00206     ((X).HighPart < (Y).HighPart)                                      \
00207 )
00208 
00209 #define LargeIntegerLessThanOrEqualTo(X,Y) (                         \
00210     (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
00211     ((X).HighPart < (Y).HighPart)                                       \
00212 )
00213 
00214 #define LargeIntegerGreaterThanZero(X) (       \
00215     (((X).HighPart == 0) && ((X).LowPart > 0)) || \
00216     ((X).HighPart > 0 )                           \
00217 )
00218 
00219 #define LargeIntegerGreaterOrEqualToZero(X) ( \
00220     (X).HighPart >= 0                            \
00221 )
00222 
00223 #define LargeIntegerEqualToZero(X) ( \
00224     !((X).LowPart | (X).HighPart)       \
00225 )
00226 
00227 #define LargeIntegerNotEqualToZero(X) ( \
00228     ((X).LowPart | (X).HighPart)           \
00229 )
00230 
00231 #define LargeIntegerLessThanZero(X) ( \
00232     ((X).HighPart < 0)                   \
00233 )
00234 
00235 #define LargeIntegerLessOrEqualToZero(X) (           \
00236     ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) \
00237 )
00238 
00239 #ifdef __cplusplus
00240 }
00241 #endif
00242 
 All Data Structures Files Functions Variables