ReactOS 0.4.16-dev-303-g11d5cb8
largeint.c File Reference
#include <rtl.h>
#include <debug.h>
Include dependency graph for largeint.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define LOWER_32(A)   ((A) & 0xffffffff)
 
#define UPPER_32(A)   ((A) >> 32)
 

Functions

LARGE_INTEGER NTAPI RtlConvertLongToLargeInteger (LONG SignedInteger)
 
LARGE_INTEGER NTAPI RtlConvertUlongToLargeInteger (ULONG UnsignedInteger)
 
LARGE_INTEGER NTAPI RtlEnlargedIntegerMultiply (LONG Multiplicand, LONG Multiplier)
 
ULONG NTAPI RtlEnlargedUnsignedDivide (ULARGE_INTEGER Dividend, ULONG Divisor, PULONG Remainder)
 
LARGE_INTEGER NTAPI RtlEnlargedUnsignedMultiply (ULONG Multiplicand, ULONG Multiplier)
 
LARGE_INTEGER NTAPI RtlExtendedIntegerMultiply (LARGE_INTEGER Multiplicand, LONG Multiplier)
 
LARGE_INTEGER NTAPI RtlExtendedLargeIntegerDivide (LARGE_INTEGER Dividend, ULONG Divisor, PULONG Remainder)
 
LARGE_INTEGER NTAPI RtlExtendedMagicDivide (LARGE_INTEGER Dividend, LARGE_INTEGER MagicDivisor, CCHAR ShiftCount)
 
LARGE_INTEGER NTAPI RtlLargeIntegerAdd (LARGE_INTEGER Addend1, LARGE_INTEGER Addend2)
 
LARGE_INTEGER NTAPI RtlLargeIntegerArithmeticShift (LARGE_INTEGER LargeInteger, CCHAR ShiftCount)
 
LARGE_INTEGER NTAPI RtlLargeIntegerDivide (LARGE_INTEGER Dividend, LARGE_INTEGER Divisor, PLARGE_INTEGER Remainder)
 
LARGE_INTEGER NTAPI RtlLargeIntegerNegate (LARGE_INTEGER Subtrahend)
 
LARGE_INTEGER NTAPI RtlLargeIntegerShiftLeft (LARGE_INTEGER LargeInteger, CCHAR ShiftCount)
 
LARGE_INTEGER NTAPI RtlLargeIntegerShiftRight (LARGE_INTEGER LargeInteger, CCHAR ShiftCount)
 
LARGE_INTEGER NTAPI RtlLargeIntegerSubtract (LARGE_INTEGER Minuend, LARGE_INTEGER Subtrahend)
 

Macro Definition Documentation

◆ LOWER_32

#define LOWER_32 (   A)    ((A) & 0xffffffff)

Definition at line 169 of file largeint.c.

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file largeint.c.

◆ UPPER_32

#define UPPER_32 (   A)    ((A) >> 32)

Definition at line 170 of file largeint.c.

Function Documentation

◆ RtlConvertLongToLargeInteger()

LARGE_INTEGER NTAPI RtlConvertLongToLargeInteger ( LONG  SignedInteger)

Definition at line 31 of file largeint.c.

34{
36
37 RC.QuadPart = SignedInteger;
38
39 return RC;
40}
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by WSPCloseSocket(), and WSPShutdown().

◆ RtlConvertUlongToLargeInteger()

LARGE_INTEGER NTAPI RtlConvertUlongToLargeInteger ( ULONG  UnsignedInteger)

Definition at line 47 of file largeint.c.

50{
52
53 RC.QuadPart = UnsignedInteger;
54
55 return RC;
56}

Referenced by HalpGetResourceSortValue(), NdisAllocateMemory(), NdisMDeregisterIoPortRange(), and NdisMRegisterIoPortRange().

◆ RtlEnlargedIntegerMultiply()

LARGE_INTEGER NTAPI RtlEnlargedIntegerMultiply ( LONG  Multiplicand,
LONG  Multiplier 
)

Definition at line 63 of file largeint.c.

67{
69
70 RC.QuadPart = (LONGLONG) Multiplicand * Multiplier;
71
72 return RC;
73}
int64_t LONGLONG
Definition: typedefs.h:68

◆ RtlEnlargedUnsignedDivide()

ULONG NTAPI RtlEnlargedUnsignedDivide ( ULARGE_INTEGER  Dividend,
ULONG  Divisor,
PULONG  Remainder 
)

Definition at line 80 of file largeint.c.

85{
86 if (Remainder)
87 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
88
89 return (ULONG)(Dividend.QuadPart / Divisor);
90}
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
uint32_t ULONG
Definition: typedefs.h:59
_In_ LARGE_INTEGER Divisor
Definition: rtlfuncs.h:3061
_In_ LARGE_INTEGER _Out_opt_ PLARGE_INTEGER Remainder
Definition: rtlfuncs.h:3062

◆ RtlEnlargedUnsignedMultiply()

LARGE_INTEGER NTAPI RtlEnlargedUnsignedMultiply ( ULONG  Multiplicand,
ULONG  Multiplier 
)

Definition at line 97 of file largeint.c.

101{
102 LARGE_INTEGER RC;
103
104 RC.QuadPart = (ULONGLONG) Multiplicand * Multiplier;
105
106 return RC;
107}
uint64_t ULONGLONG
Definition: typedefs.h:67

◆ RtlExtendedIntegerMultiply()

LARGE_INTEGER NTAPI RtlExtendedIntegerMultiply ( LARGE_INTEGER  Multiplicand,
LONG  Multiplier 
)

Definition at line 114 of file largeint.c.

118{
119 LARGE_INTEGER RC;
120
121 RC.QuadPart = Multiplicand.QuadPart * Multiplier;
122
123 return RC;
124}

◆ RtlExtendedLargeIntegerDivide()

LARGE_INTEGER NTAPI RtlExtendedLargeIntegerDivide ( LARGE_INTEGER  Dividend,
ULONG  Divisor,
PULONG  Remainder 
)

Definition at line 131 of file largeint.c.

136{
137 LARGE_INTEGER RC;
138
139 if (Remainder)
140 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
141
142 RC.QuadPart = Dividend.QuadPart / Divisor;
143
144 return RC;
145}

◆ RtlExtendedMagicDivide()

LARGE_INTEGER NTAPI RtlExtendedMagicDivide ( LARGE_INTEGER  Dividend,
LARGE_INTEGER  MagicDivisor,
CCHAR  ShiftCount 
)

Definition at line 176 of file largeint.c.

179{
180 ULONGLONG dividend_high;
181 ULONGLONG dividend_low;
182 ULONGLONG inverse_divisor_high;
183 ULONGLONG inverse_divisor_low;
184 ULONGLONG ah_bl;
185 ULONGLONG al_bh;
188
189 if (Dividend.QuadPart < 0)
190 {
191 dividend_high = UPPER_32((ULONGLONG) -Dividend.QuadPart);
192 dividend_low = LOWER_32((ULONGLONG) -Dividend.QuadPart);
193 positive = FALSE;
194 }
195 else
196 {
197 dividend_high = UPPER_32((ULONGLONG) Dividend.QuadPart);
198 dividend_low = LOWER_32((ULONGLONG) Dividend.QuadPart);
199 positive = TRUE;
200 }
201 inverse_divisor_high = UPPER_32((ULONGLONG) MagicDivisor.QuadPart);
202 inverse_divisor_low = LOWER_32((ULONGLONG) MagicDivisor.QuadPart);
203
204 ah_bl = dividend_high * inverse_divisor_low;
205 al_bh = dividend_low * inverse_divisor_high;
206
207 result.QuadPart =
208 (LONGLONG) ((dividend_high * inverse_divisor_high +
209 UPPER_32(ah_bl) +
210 UPPER_32(al_bh) +
211 UPPER_32(LOWER_32(ah_bl) + LOWER_32(al_bh) +
212 UPPER_32(dividend_low * inverse_divisor_low))) >> ShiftCount);
213 if (!positive)
214 {
215 result.QuadPart = -result.QuadPart;
216 }
217
218 return result;
219}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLuint64EXT * result
Definition: glext.h:11304
#define UPPER_32(A)
Definition: largeint.c:170
#define LOWER_32(A)
Definition: largeint.c:169
Definition: unary.h:15

◆ RtlLargeIntegerAdd()

LARGE_INTEGER NTAPI RtlLargeIntegerAdd ( LARGE_INTEGER  Addend1,
LARGE_INTEGER  Addend2 
)

Definition at line 227 of file largeint.c.

231{
232 LARGE_INTEGER RC;
233
234 RC.QuadPart = Addend1.QuadPart + Addend2.QuadPart;
235
236 return RC;
237}
_In_ LARGE_INTEGER Addend2
Definition: rtlfuncs.h:3104

◆ RtlLargeIntegerArithmeticShift()

LARGE_INTEGER NTAPI RtlLargeIntegerArithmeticShift ( LARGE_INTEGER  LargeInteger,
CCHAR  ShiftCount 
)

Definition at line 244 of file largeint.c.

248{
249 LARGE_INTEGER RC;
250 CHAR Shift;
251
252 Shift = ShiftCount % 64;
253
254 if (Shift < 32)
255 {
256 RC.QuadPart = LargeInteger.QuadPart >> Shift;
257 }
258 else
259 {
260 /* copy the sign bit */
261 RC.u.HighPart = (LargeInteger.u.HighPart & 0x80000000);
262 RC.u.LowPart = LargeInteger.u.HighPart >> Shift;
263 }
264
265 return RC;
266}
struct _LARGE_INTEGER::@2303 u
_In_ ULONG Shift
Definition: rtlfuncs.h:2698
char CHAR
Definition: xmlstorage.h:175

◆ RtlLargeIntegerDivide()

LARGE_INTEGER NTAPI RtlLargeIntegerDivide ( LARGE_INTEGER  Dividend,
LARGE_INTEGER  Divisor,
PLARGE_INTEGER  Remainder 
)

Definition at line 273 of file largeint.c.

278{
279 LARGE_INTEGER RC;
280
281 if (Remainder)
283
284 RC.QuadPart = Dividend.QuadPart / Divisor.QuadPart;
285
286 return RC;
287}

◆ RtlLargeIntegerNegate()

LARGE_INTEGER NTAPI RtlLargeIntegerNegate ( LARGE_INTEGER  Subtrahend)

Definition at line 294 of file largeint.c.

297{
298 LARGE_INTEGER RC;
299
300 RC.QuadPart = - Subtrahend.QuadPart;
301
302 return RC;
303}

◆ RtlLargeIntegerShiftLeft()

LARGE_INTEGER NTAPI RtlLargeIntegerShiftLeft ( LARGE_INTEGER  LargeInteger,
CCHAR  ShiftCount 
)

Definition at line 310 of file largeint.c.

314{
315 LARGE_INTEGER RC;
316 CCHAR Shift;
317
318 Shift = ShiftCount % 64;
319 RC.QuadPart = LargeInteger.QuadPart << Shift;
320
321 return RC;
322}
char CCHAR
Definition: typedefs.h:51

◆ RtlLargeIntegerShiftRight()

LARGE_INTEGER NTAPI RtlLargeIntegerShiftRight ( LARGE_INTEGER  LargeInteger,
CCHAR  ShiftCount 
)

Definition at line 329 of file largeint.c.

333{
334 LARGE_INTEGER RC;
335 CCHAR Shift;
336
337 Shift = ShiftCount % 64;
338 RC.QuadPart = LargeInteger.QuadPart >> Shift;
339
340 return RC;
341}

◆ RtlLargeIntegerSubtract()

LARGE_INTEGER NTAPI RtlLargeIntegerSubtract ( LARGE_INTEGER  Minuend,
LARGE_INTEGER  Subtrahend 
)

Definition at line 348 of file largeint.c.

352{
353 LARGE_INTEGER RC;
354
355 RC.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart;
356
357 return RC;
358}