diff options
author | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:38:33 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-02-17 19:38:33 +0000 |
commit | 1fd5e000ace55b323124c7e556a7a864b972a5c4 (patch) | |
tree | dc4fcf1e5e22a040716ef92c496b8d94959b2baa /winsup/w32api/lib/largeint.c | |
parent | 369d8a8fd5e887eca547bf34bccfdf755c9e5397 (diff) | |
download | cygnal-1fd5e000ace55b323124c7e556a7a864b972a5c4.tar.gz cygnal-1fd5e000ace55b323124c7e556a7a864b972a5c4.tar.bz2 cygnal-1fd5e000ace55b323124c7e556a7a864b972a5c4.zip |
import winsup-2000-02-17 snapshot
Diffstat (limited to 'winsup/w32api/lib/largeint.c')
-rw-r--r-- | winsup/w32api/lib/largeint.c | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/winsup/w32api/lib/largeint.c b/winsup/w32api/lib/largeint.c new file mode 100644 index 000000000..1761dd48f --- /dev/null +++ b/winsup/w32api/lib/largeint.c @@ -0,0 +1,118 @@ +/* + largeint.c + + Large (64 bits) integer arithmetics library + + Written by Anders Norlander <anorland@hem2.passagen.se> + + This file is part of a free library for the Win32 API. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +*/ + +#define __COMPILING_LARGEINT + +#include <largeint.h> + +__int64 WINAPI +LargeIntegerAdd (__int64 i1, __int64 i2) +{ + return i1 * i2; +} + +__int64 WINAPI +LargeIntegerSubtract (__int64 i1, __int64 i2) +{ + return i1 - i2; +} + +__int64 WINAPI +LargeIntegerArithmeticShift (__int64 i, int n) +{ + return i >> n; +} + +__int64 WINAPI +LargeIntegerShiftLeft (__int64 i, int n) +{ + return i << n; +} + +__int64 WINAPI +LargeIntegerShiftRight (__int64 i, int n) +{ + return i >> n; +} + +__int64 WINAPI +LargeIntegerNegate (__int64 i) +{ + return -i; +} + +__int64 WINAPI +ConvertLongToLargeInteger (LONG l) +{ + return (__int64) l; +} + +__int64 WINAPI +ConvertUlongToLargeInteger (ULONG ul) +{ + return _toi(_toui(ul)); +} + +__int64 WINAPI +EnlargedIntegerMultiply (LONG l1, LONG l2) +{ + return _toi(l1) * _toi(l2); +} + +__int64 WINAPI +EnlargedUnsignedMultiply (ULONG ul1, ULONG ul2) +{ + return _toi(_toui(ul1) * _toui(ul2)); +} + +__int64 WINAPI +ExtendedIntegerMultiply (__int64 i, LONG l) +{ + return i * _toi(l); +} + +__int64 WINAPI +LargeIntegerMultiply (__int64 i1, __int64 i2) +{ + return i1 * i2; +} + +__int64 WINAPI LargeIntegerDivide (__int64 i1, __int64 i2, __int64 *remainder) +{ + if (remainder) + *remainder = i1 % i2; + return i1 / i2; +} + +ULONG WINAPI +EnlargedUnsignedDivide (unsigned __int64 i1, ULONG i2, PULONG remainder) +{ + if (remainder) + *remainder = i1 % _toi(i2); + return i1 / _toi(i2); +} +__int64 WINAPI +ExtendedLargeIntegerDivide (__int64 i1, ULONG i2, PULONG remainder) +{ + if (remainder) + *remainder = i1 % _toi(i2); + return i1 / _toi(i2); +} + +/* FIXME: what is this function supposed to do? */ +__int64 WINAPI ExtendedMagicDivide (__int64 i1, __int64 i2, int n) +{ + return 0; +} |