Adjust fileList from perl
[msysgit.git] / include / largeint.h
blobc36db31efde621c8b916a35aa347d252bb82ad40
1 /*
2 largeint.h
4 Header for 64 bit integer arithmetics library
6 */
7 #ifndef _LARGEINT_H
8 #define _LARGEINT_H
10 #include <windows.h>
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
16 #ifdef _HAVE_INT64
17 #define _toi (__int64)
18 #define _toui (unsigned __int64)
19 #else
20 #error "64 bit integers not supported"
21 #endif
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.
29 #if defined(LARGEINT_PROTOS) || defined(__COMPILING_LARGEINT)
31 #ifndef __COMPILING_LARGEINT
32 /* addition/subtraction */
33 LARGE_INTEGER WINAPI LargeIntegerAdd (LARGE_INTEGER, LARGE_INTEGER);
34 LARGE_INTEGER WINAPI LargeIntegerSubtract (LARGE_INTEGER, LARGE_INTEGER);
36 /* bit operations */
37 LARGE_INTEGER WINAPI LargeIntegerArithmeticShift (LARGE_INTEGER, int);
38 LARGE_INTEGER WINAPI LargeIntegerShiftLeft (LARGE_INTEGER, int);
39 LARGE_INTEGER WINAPI LargeIntegerShiftRight (LARGE_INTEGER, int);
40 LARGE_INTEGER WINAPI LargeIntegerNegate (LARGE_INTEGER);
42 /* conversion */
43 LARGE_INTEGER WINAPI ConvertLongToLargeInteger (LONG);
44 LARGE_INTEGER WINAPI ConvertUlongToLargeInteger (ULONG);
46 /* multiplication */
47 LARGE_INTEGER WINAPI EnlargedIntegerMultiply (LONG, LONG);
48 LARGE_INTEGER WINAPI EnlargedUnsignedMultiply (ULONG, ULONG);
49 LARGE_INTEGER WINAPI ExtendedIntegerMultiply (LARGE_INTEGER, LONG);
50 /* FIXME: is this not part of largeint? */
51 LARGE_INTEGER WINAPI LargeIntegerMultiply (LARGE_INTEGER, LARGE_INTEGER);
52 #endif /* __COMPILING_LARGEINT */
54 #else
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))
70 #endif /* LARGEINT_PROTOS || __COMPILING_LARGEINT */
72 #ifndef __COMPILING_LARGEINT
73 /* division; no macros of these because of multiple expansion */
74 LARGE_INTEGER WINAPI LargeIntegerDivide (LARGE_INTEGER, LARGE_INTEGER, PLARGE_INTEGER);
75 ULONG WINAPI EnlargedUnsignedDivide (ULARGE_INTEGER, ULONG, PULONG);
76 LARGE_INTEGER WINAPI ExtendedLargeIntegerDivide (LARGE_INTEGER, ULONG, PULONG);
77 LARGE_INTEGER WINAPI ExtendedMagicDivide (LARGE_INTEGER, LARGE_INTEGER, int);
78 #endif /* __COMPILING_LARGEINT */
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; \
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)
100 #ifndef __COMPILING_LARGEINT
101 #undef _toi
102 #undef _toui
103 #endif
105 #ifdef __cplusplus
107 #endif
109 #endif /* _LARGEINT_H */