Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenlargeint.h
Go to the documentation of this file.
00001 /* 00002 largeint.h 00003 00004 Header for 64 bit integer arithmetics library 00005 00006 */ 00007 #ifndef _LARGEINT_H 00008 #define _LARGEINT_H 00009 00010 #include <windows.h> 00011 00012 #ifdef __cplusplus 00013 extern "C" { 00014 #endif 00015 00016 #ifdef _HAVE_INT64 00017 #define _toi (__int64) 00018 #define _toui (unsigned __int64) 00019 #else 00020 #error "64 bit integers not supported" 00021 #endif 00022 00023 /* 00024 We don't let the compiler see the prototypes if we are compiling the 00025 library because if it does it will choke on conflicting types in the 00026 prototypes. 00027 */ 00028 00029 #if defined(LARGEINT_PROTOS) || defined(__COMPILING_LARGEINT) 00030 00031 #ifndef __COMPILING_LARGEINT 00032 /* addition/subtraction */ 00033 LARGE_INTEGER WINAPI LargeIntegerAdd (LARGE_INTEGER, LARGE_INTEGER); 00034 LARGE_INTEGER WINAPI LargeIntegerSubtract (LARGE_INTEGER, LARGE_INTEGER); 00035 00036 /* bit operations */ 00037 LARGE_INTEGER WINAPI LargeIntegerArithmeticShift (LARGE_INTEGER, int); 00038 LARGE_INTEGER WINAPI LargeIntegerShiftLeft (LARGE_INTEGER, int); 00039 LARGE_INTEGER WINAPI LargeIntegerShiftRight (LARGE_INTEGER, int); 00040 LARGE_INTEGER WINAPI LargeIntegerNegate (LARGE_INTEGER); 00041 00042 /* conversion */ 00043 LARGE_INTEGER WINAPI ConvertLongToLargeInteger (LONG); 00044 LARGE_INTEGER WINAPI ConvertUlongToLargeInteger (ULONG); 00045 00046 /* multiplication */ 00047 LARGE_INTEGER WINAPI EnlargedIntegerMultiply (LONG, LONG); 00048 LARGE_INTEGER WINAPI EnlargedUnsignedMultiply (ULONG, ULONG); 00049 LARGE_INTEGER WINAPI ExtendedIntegerMultiply (LARGE_INTEGER, LONG); 00050 /* FIXME: is this not part of largeint? */ 00051 LARGE_INTEGER WINAPI LargeIntegerMultiply (LARGE_INTEGER, LARGE_INTEGER); 00052 #endif /* __COMPILING_LARGEINT */ 00053 00054 #else 00055 00056 #define LargeIntegerAdd(a,b) (LARGE_INTEGER)(_toi(a) + _toi(b)) 00057 #define LargeIntegerSubtract(a,b) (LARGE_INTEGER)(_toi(a) - _toi(b)) 00058 #define LargeIntegerRightShift(i,n) (LARGE_INTEGER)(_toi(i) >> (n)) 00059 #define LargeIntegerArithmeticShift LargeIntegerRightShift 00060 #define LargeIntegerLeftShift(i,n) (LARGE_INTEGER)(_toi(i) << (n)) 00061 #define LargeIntegerNegate(i) (LARGE_INTEGER)(- _toi(i)) 00062 #define EnlargedIntegerMultiply(a,b) (LARGE_INTEGER)(_toi(a) * _toi(b)) 00063 #define EnlargedUnsignedMultiply(a,b) (LARGE_INTEGER)(_toui(a) * _toui(b)) 00064 #define ExtendedIntegerMultiply(a,b) (LARGE_INTEGER)(_toi(a) * _toi(b)) 00065 /* FIXME: should this exist */ 00066 #define LargeIntegerMultiply(a,b) (LARGE_INTEGER)(_toi(a) * _toi(b)) 00067 #define ConvertLongToLargeInteger(l) (LARGE_INTEGER)(_toi(l)) 00068 #define ConvertUlongToLargeInteger(ul) (LARGE_INTEGER)(_toui(ul)) 00069 00070 #endif /* LARGEINT_PROTOS || __COMPILING_LARGEINT */ 00071 00072 #ifndef __COMPILING_LARGEINT 00073 /* division; no macros of these because of multiple expansion */ 00074 LARGE_INTEGER WINAPI LargeIntegerDivide (LARGE_INTEGER, LARGE_INTEGER, PLARGE_INTEGER); 00075 ULONG WINAPI EnlargedUnsignedDivide (ULARGE_INTEGER, ULONG, PULONG); 00076 LARGE_INTEGER WINAPI ExtendedLargeIntegerDivide (LARGE_INTEGER, ULONG, PULONG); 00077 LARGE_INTEGER WINAPI ExtendedMagicDivide (LARGE_INTEGER, LARGE_INTEGER, int); 00078 #endif /* __COMPILING_LARGEINT */ 00079 00080 #define LargeIntegerAnd(dest, src, m) \ 00081 { \ 00082 dest._STRUCT_NAME(u.)LowPart = s._STRUCT_NAME(u.)LowPart & m._STRUCT_NAME(u.)LowPart; \ 00083 dest._STRUCT_NAME(u.)HighPart = s._STRUCT_NAME(u.)HighPart & m._STRUCT_NAME(u.)HighPart; \ 00084 } 00085 00086 /* comparision */ 00087 #define LargeIntegerGreaterThan(a,b) (_toi(a) > _toi(b)) 00088 #define LargeIntegerGreaterThanOrEqual(a,b) (_toi(a) >= _toi(b)) 00089 #define LargeIntegerEqualTo(a,b) (_toi(a) == _toi(b)) 00090 #define LargeIntegerNotEqualTo(a,b) (_toi(a) != _toi(b)) 00091 #define LargeIntegerLessThan(a,b) (_toi(a) < _toi(b)) 00092 #define LargeIntegerLessThanOrEqualTo(a,b) (_toi(a) <= _toi(b)) 00093 #define LargeIntegerGreaterThanZero(a) (_toi(a) > 0) 00094 #define LargeIntegerGreaterOrEqualToZero(a) ((a)._STRUCT_NAME(u.)HighPart > 0) 00095 #define LargeIntegerEqualToZero(a) !((a)._STRUCT_NAME(u.)LowPart | (a)._STRUCT_NAME(u.)HighPart) 00096 #define LargeIntegerNotEqualToZero(a) ((a)._STRUCT_NAME(u.)LowPart | (a)._STRUCT_NAME(u.)HighPart) 00097 #define LargeIntegerLessThanZero(a) ((a)._STRUCT_NAME(u.)HighPart < 0) 00098 #define LargeIntegerLessOrEqualToZero(a) (_toi(a) <= 0) 00099 00100 #ifndef __COMPILING_LARGEINT 00101 #undef _toi 00102 #undef _toui 00103 #endif 00104 00105 #ifdef __cplusplus 00106 } 00107 #endif 00108 00109 #endif /* _LARGEINT_H */ Generated on Mon May 28 2012 04:31:26 for ReactOS by
1.7.6.1
|