]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/CRT/Gcc.c
Standard Libraries for EDK II.
[mirror_edk2.git] / StdLib / LibC / CRT / Gcc.c
1 /** @file
2 Integer Arithmetic Run-time support functions for GCC.
3 The integer arithmetic routines are used on platforms that don't provide
4 hardware support for arithmetic operations on some modes..
5
6 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16 #include <Uefi.h>
17 #include <Library/UefiLib.h>
18 #include <Library/DebugLib.h>
19 #include <sys/EfiCdefs.h>
20
21 #include <Library/BaseLib.h>
22
23 // Shift Datum left by Count bits.
24 // ===========================================================================
25 //int __ashlsi3(int Datum, int Count)
26 //{
27 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
28 // return (int) LShiftU64 ((UINT64)Datum, (UINTN)Count);
29 //}
30
31 INT64 __ashldi3(INT64 Datum, int Count)
32 {
33 DebugPrint(DEBUG_INFO, "%a:\n", __func__);
34 return LShiftU64 (Datum, (UINTN)Count);
35 }
36
37 //long long __ashlti3(long long Datum, int Count)
38 //{
39 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
40 // return (long long) LShiftU64 ((UINT64)Datum, (UINTN)Count);
41 //}
42
43 // Arithmetically shift Datum right by Count bits.
44 // ===========================================================================
45 //int __ashrsi3(int Datum, int Count)
46 //{
47 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
48 // return (int) ARShiftU64 ((UINT64) Datum, (UINTN)Count);
49 //}
50
51 INT64 __ashrdi3(INT64 Datum, int Count)
52 {
53 DebugPrint(DEBUG_INFO, "%a:\n", __func__);
54 return ARShiftU64 ( Datum, (UINTN)Count);
55 }
56
57 //long long __ashrti3(long long Datum, int Count)
58 //{
59 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
60 // return (long long) ARShiftU64 ((UINT64) Datum, (UINTN)Count);
61 //}
62
63 // Return the quotient of the signed division of Dividend and Divisor
64 // ===========================================================================
65 //int __divsi3(int Dividend, int Divisor)
66 //{
67 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
68 // return (int) DivS64x64Remainder ((INT64) Dividend, (INT64) Divisor, NULL);
69 //}
70
71 INT64 __divdi3(INT64 Dividend, INT64 Divisor)
72 {
73 INT64 Quotient;
74
75 Quotient = DivS64x64Remainder ((INT64) Dividend, (INT64) Divisor, NULL);
76 DebugPrint(DEBUG_INFO, "%a: %Ld / %Ld = %Ld\n", __func__, Dividend, Divisor, Quotient);
77
78 return Quotient;
79 }
80
81 //long long __divti3(long long Dividend, long long Divisor)
82 //{
83 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
84 // return (long long) DivS64x64Remainder ((INT64) Dividend, (INT64) Divisor, NULL);
85 //}
86
87 // Logically shift Datum right by Count bits
88 // ===========================================================================
89 //int __lshrsi3(int Datum, int Count)
90 //{
91 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
92 // return (int) RShiftU64 ((UINT64) Datum, (UINTN)Count);
93 //}
94
95 INT64 __lshrdi3(INT64 Datum, int Count)
96 {
97 DebugPrint(DEBUG_INFO, "%a:\n", __func__);
98 return RShiftU64 ( Datum, (UINTN)Count);
99 }
100
101 //long long __lshrti3(int Datum, int Count)
102 //{
103 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
104 // return (long long) RShiftU64 ((UINT64) Datum, (UINTN)Count);
105 //}
106
107 // Return the remainder of the signed division of Dividend and Divisor
108 // ===========================================================================
109 //int __modsi3(int Dividend, int Divisor)
110 //{
111 // INT64 Remainder;
112
113 // (void) DivS64x64Remainder ((INT64) Dividend, (INT64) Divisor, &Remainder);
114 // DebugPrint(DEBUG_INFO, "modsi3: %d %% %d = %d\n", Dividend, Divisor, (int)Remainder);
115
116 // return (int) Remainder;
117 //}
118
119 INT64 __moddi3(INT64 Dividend, INT64 Divisor)
120 {
121 INT64 Remainder;
122
123 (void) DivS64x64Remainder ((INT64) Dividend, (INT64) Divisor, &Remainder);
124 DebugPrint(DEBUG_INFO, "moddi3: %Ld %% %Ld = %Ld\n", (INT64)Dividend, (INT64)Divisor, Remainder);
125
126 return Remainder;
127 }
128
129 //long long __modti3(long long Dividend, long long Divisor)
130 //{
131 // INT64 Remainder;
132
133 // (void) DivS64x64Remainder ((INT64) Dividend, (INT64) Divisor, &Remainder);
134 // DebugPrint(DEBUG_INFO, "modti3: %Ld %% %Ld = %Ld\n", (INT64)Dividend, (INT64)Divisor, Remainder);
135
136 // return (long long) Remainder;
137 //}
138
139 // These functions return the product of the Multiplicand and Multiplier.
140 // ===========================================================================
141 //long long __multi3(long long Multiplicand, long long Multiplier)
142 //{
143 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
144 // return (long long) MultS64x64 ((INT64)Multiplicand, (INT64)Multiplier);
145 //}
146
147 // Return the quotient of the unsigned division of a and b.
148 // ===========================================================================
149 //unsigned int __udivsi3(unsigned int Dividend, unsigned int Divisor)
150 //{
151 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
152 // return (int) DivU64x64Remainder ((UINT64) Dividend, (UINT64) Divisor, NULL);
153 //}
154
155 UINT64 __udivdi3(UINT64 Dividend, UINT64 Divisor)
156 {
157 DebugPrint(DEBUG_INFO, "%a:\n", __func__);
158 return DivU64x64Remainder ((UINT64) Dividend, (UINT64) Divisor, NULL);
159 }
160
161 //unsigned long long __udivti3(unsigned long long Dividend, unsigned long long Divisor)
162 //{
163 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
164 // return (long long) DivU64x64Remainder ((UINT64) Dividend, (UINT64) Divisor, NULL);
165 //}
166
167 // ===========================================================================
168 //unsigned int __umodsi3(unsigned int Dividend, unsigned int Divisor)
169 //{
170 // UINT64 Remainder;
171
172 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
173 // (void) DivU64x64Remainder ((UINT64) Dividend, (UINT64) Divisor, &Remainder);
174
175 // return (unsigned int) Remainder;
176 //}
177
178 UINT64 __umoddi3(UINT64 Dividend, UINT64 Divisor)
179 {
180 UINT64 Remainder;
181
182 DebugPrint(DEBUG_INFO, "%a:\n", __func__);
183 (void) DivU64x64Remainder ((UINT64) Dividend, (UINT64) Divisor, &Remainder);
184
185 return Remainder;
186 }
187
188 //unsigned long long __umodti3(unsigned long long Dividend, unsigned long long Divisor)
189 //{
190 // UINT64 Remainder;
191
192 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
193 // (void) DivU64x64Remainder ((UINT64) Dividend, (UINT64) Divisor, &Remainder);
194
195 // return (unsigned long long) Remainder;
196 //}