Welcome to mirror list, hosted at ThFree Co, Russian Federation.

largeint.c « lib « w32api « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 531937e23469798973f8b9368fb4a8d6156c7a4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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;
}