ReactOS  0.4.15-dev-2704-gd5265b0
largeint.h
Go to the documentation of this file.
1 /*
2  largeint.h
3 
4  Header for 64 bit integer arithmetics library
5 
6  */
7 #ifndef _LARGEINT_H
8 #define _LARGEINT_H
9 
10 #include <windows.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #ifdef _HAVE_INT64
17 #define _toi (__int64)
18 #define _toui (unsigned __int64)
19 #else
20 #error "64 bit integers not supported"
21 #endif
22 
23 /*
24  We don't let the compiler see the prototypes if we are compiling the
25  library because if it does it will choke on conflicting types in the
26  prototypes.
27 */
28 
29 #if defined(LARGEINT_PROTOS) || defined(__COMPILING_LARGEINT)
30 
31 #ifndef __COMPILING_LARGEINT
32 /* addition/subtraction */
35 
36 /* bit operations */
38 LARGE_INTEGER WINAPI LargeIntegerShiftLeft (LARGE_INTEGER, int);
39 LARGE_INTEGER WINAPI LargeIntegerShiftRight (LARGE_INTEGER, int);
41 
42 /* conversion */
45 
46 /* multiplication */
50 /* FIXME: is this not part of largeint? */
52 #endif /* __COMPILING_LARGEINT */
53 
54 #else
55 
56 #define LargeIntegerAdd(a,b) (LARGE_INTEGER)(_toi(a) + _toi(b))
57 #define LargeIntegerSubtract(a,b) (LARGE_INTEGER)(_toi(a) - _toi(b))
58 #define LargeIntegerRightShift(i,n) (LARGE_INTEGER)(_toi(i) >> (n))
59 #define LargeIntegerArithmeticShift LargeIntegerRightShift
60 #define LargeIntegerLeftShift(i,n) (LARGE_INTEGER)(_toi(i) << (n))
61 #define LargeIntegerNegate(i) (LARGE_INTEGER)(- _toi(i))
62 #define EnlargedIntegerMultiply(a,b) (LARGE_INTEGER)(_toi(a) * _toi(b))
63 #define EnlargedUnsignedMultiply(a,b) (LARGE_INTEGER)(_toui(a) * _toui(b))
64 #define ExtendedIntegerMultiply(a,b) (LARGE_INTEGER)(_toi(a) * _toi(b))
65 /* FIXME: should this exist */
66 #define LargeIntegerMultiply(a,b) (LARGE_INTEGER)(_toi(a) * _toi(b))
67 #define ConvertLongToLargeInteger(l) (LARGE_INTEGER)(_toi(l))
68 #define ConvertUlongToLargeInteger(ul) (LARGE_INTEGER)(_toui(ul))
69 
70 #endif /* LARGEINT_PROTOS || __COMPILING_LARGEINT */
71 
72 #ifndef __COMPILING_LARGEINT
73 /* division; no macros of these because of multiple expansion */
78 #endif /* __COMPILING_LARGEINT */
79 
80 #define LargeIntegerAnd(dest, src, m) \
81 { \
82  dest._STRUCT_NAME(u.)LowPart = s._STRUCT_NAME(u.)LowPart & m._STRUCT_NAME(u.)LowPart; \
83  dest._STRUCT_NAME(u.)HighPart = s._STRUCT_NAME(u.)HighPart & m._STRUCT_NAME(u.)HighPart; \
84 }
85 
86 /* comparision */
87 #define LargeIntegerGreaterThan(a,b) (_toi(a) > _toi(b))
88 #define LargeIntegerGreaterThanOrEqual(a,b) (_toi(a) >= _toi(b))
89 #define LargeIntegerEqualTo(a,b) (_toi(a) == _toi(b))
90 #define LargeIntegerNotEqualTo(a,b) (_toi(a) != _toi(b))
91 #define LargeIntegerLessThan(a,b) (_toi(a) < _toi(b))
92 #define LargeIntegerLessThanOrEqualTo(a,b) (_toi(a) <= _toi(b))
93 #define LargeIntegerGreaterThanZero(a) (_toi(a) > 0)
94 #define LargeIntegerGreaterOrEqualToZero(a) ((a)._STRUCT_NAME(u.)HighPart > 0)
95 #define LargeIntegerEqualToZero(a) !((a)._STRUCT_NAME(u.)LowPart | (a)._STRUCT_NAME(u.)HighPart)
96 #define LargeIntegerNotEqualToZero(a) ((a)._STRUCT_NAME(u.)LowPart | (a)._STRUCT_NAME(u.)HighPart)
97 #define LargeIntegerLessThanZero(a) ((a)._STRUCT_NAME(u.)HighPart < 0)
98 #define LargeIntegerLessOrEqualToZero(a) (_toi(a) <= 0)
99 
100 #ifndef __COMPILING_LARGEINT
101 #undef _toi
102 #undef _toui
103 #endif
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* _LARGEINT_H */
#define LargeIntegerArithmeticShift
Definition: largeint.h:59
#define LargeIntegerSubtract(a, b)
Definition: largeint.h:57
LARGE_INTEGER WINAPI LargeIntegerDivide(LARGE_INTEGER, LARGE_INTEGER, PLARGE_INTEGER)
#define ConvertUlongToLargeInteger(ul)
Definition: largeint.h:68
LARGE_INTEGER WINAPI ExtendedLargeIntegerDivide(LARGE_INTEGER, ULONG, PULONG)
#define LargeIntegerAdd(a, b)
Definition: largeint.h:56
long LONG
Definition: pedump.c:60
LARGE_INTEGER WINAPI ExtendedMagicDivide(LARGE_INTEGER, LARGE_INTEGER, int)
#define LargeIntegerNegate(i)
Definition: largeint.h:61
#define WINAPI
Definition: msvc.h:6
#define EnlargedUnsignedMultiply(a, b)
Definition: largeint.h:63
#define LargeIntegerMultiply(a, b)
Definition: largeint.h:66
ULONG WINAPI EnlargedUnsignedDivide(ULARGE_INTEGER, ULONG, PULONG)
#define EnlargedIntegerMultiply(a, b)
Definition: largeint.h:62
unsigned int * PULONG
Definition: retypes.h:1
#define ExtendedIntegerMultiply(a, b)
Definition: largeint.h:64
#define ConvertLongToLargeInteger(l)
Definition: largeint.h:67
unsigned int ULONG
Definition: retypes.h:1