OSDN Git Service

709f60f604e56b2cea82c49eebeca3bdd906bebc
[mingw/mingw-org-wsl.git] / w32api / lib / largeint.c
1 /*
2   largeint.c
3
4   Large (64 bits) integer arithmetics library
5
6   Written by Anders Norlander <anorland@hem2.passagen.se>
7
8   This file is part of a free library for the Win32 API.
9
10   This library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 */
15
16 #define __COMPILING_LARGEINT
17
18 #include <largeint.h>
19
20 __int64 WINAPI
21 LargeIntegerAdd (__int64 i1, __int64 i2)
22 {
23   return i1 + i2;
24 }
25
26 __int64 WINAPI
27 LargeIntegerSubtract (__int64 i1, __int64 i2)
28 {
29   return i1 - i2;
30 }
31
32 __int64 WINAPI
33 LargeIntegerArithmeticShift (__int64 i, int n)
34 {
35   return i >> n;
36 }
37
38 __int64 WINAPI
39 LargeIntegerShiftLeft (__int64 i, int n)
40 {
41   return i << n;
42 }
43
44 __int64 WINAPI
45 LargeIntegerShiftRight (__int64 i, int n)
46 {
47   return i >> n;
48 }
49
50 __int64 WINAPI
51 LargeIntegerNegate (__int64 i)
52 {
53   return -i;
54 }
55
56 __int64 WINAPI
57 ConvertLongToLargeInteger (LONG l)
58 {
59   return (__int64) l;
60 }
61
62 __int64 WINAPI
63 ConvertUlongToLargeInteger (ULONG ul)
64 {
65   return _toi(_toui(ul));
66 }
67
68 __int64 WINAPI
69 EnlargedIntegerMultiply (LONG l1, LONG l2)
70 {
71   return _toi(l1) * _toi(l2);
72 }
73
74 __int64 WINAPI
75 EnlargedUnsignedMultiply (ULONG ul1, ULONG ul2)
76 {
77   return _toi(_toui(ul1) * _toui(ul2));
78 }
79
80 __int64 WINAPI
81 ExtendedIntegerMultiply (__int64 i, LONG l)
82 {
83   return i * _toi(l);
84 }
85
86 __int64 WINAPI
87 LargeIntegerMultiply (__int64 i1, __int64 i2)
88 {
89   return i1 * i2;
90 }
91
92 __int64 WINAPI LargeIntegerDivide (__int64 i1, __int64 i2, __int64 *remainder)
93 {
94   if (remainder)
95     *remainder = i1 % i2;
96   return i1 / i2;
97 }
98
99 ULONG WINAPI
100 EnlargedUnsignedDivide (unsigned __int64 i1, ULONG i2, PULONG remainder)
101 {
102   if (remainder)
103     *remainder = i1 % _toi(i2);
104   return i1 / _toi(i2);
105 }
106 __int64 WINAPI
107 ExtendedLargeIntegerDivide (__int64 i1, ULONG i2, PULONG remainder)
108 {
109   if (remainder)
110     *remainder = i1 % _toi(i2);
111   return i1 / _toi(i2);
112 }
113
114 /* FIXME: what is this function supposed to do? */
115 __int64 WINAPI ExtendedMagicDivide (__int64 i1, __int64 i2, int n)
116 {
117   return 0;
118 }