]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/CRT/Gcc.c
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..
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.
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.
17 #include <Library/UefiLib.h>
18 #include <Library/DebugLib.h>
19 #include <sys/EfiCdefs.h>
21 #include <Library/BaseLib.h>
23 // Shift Datum left by Count bits.
24 // ===========================================================================
25 //int __ashlsi3(int Datum, int Count)
27 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
28 // return (int) LShiftU64 ((UINT64)Datum, (UINTN)Count);
31 INT64
__ashldi3(INT64 Datum
, int Count
)
33 DebugPrint(DEBUG_INFO
, "%a:\n", __func__
);
34 return LShiftU64 (Datum
, (UINTN
)Count
);
37 //long long __ashlti3(long long Datum, int Count)
39 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
40 // return (long long) LShiftU64 ((UINT64)Datum, (UINTN)Count);
43 // Arithmetically shift Datum right by Count bits.
44 // ===========================================================================
45 //int __ashrsi3(int Datum, int Count)
47 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
48 // return (int) ARShiftU64 ((UINT64) Datum, (UINTN)Count);
51 INT64
__ashrdi3(INT64 Datum
, int Count
)
53 DebugPrint(DEBUG_INFO
, "%a:\n", __func__
);
54 return ARShiftU64 ( Datum
, (UINTN
)Count
);
57 //long long __ashrti3(long long Datum, int Count)
59 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
60 // return (long long) ARShiftU64 ((UINT64) Datum, (UINTN)Count);
63 // Return the quotient of the signed division of Dividend and Divisor
64 // ===========================================================================
65 //int __divsi3(int Dividend, int Divisor)
67 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
68 // return (int) DivS64x64Remainder ((INT64) Dividend, (INT64) Divisor, NULL);
71 INT64
__divdi3(INT64 Dividend
, INT64 Divisor
)
75 Quotient
= DivS64x64Remainder ((INT64
) Dividend
, (INT64
) Divisor
, NULL
);
76 DebugPrint(DEBUG_INFO
, "%a: %Ld / %Ld = %Ld\n", __func__
, Dividend
, Divisor
, Quotient
);
81 //long long __divti3(long long Dividend, long long Divisor)
83 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
84 // return (long long) DivS64x64Remainder ((INT64) Dividend, (INT64) Divisor, NULL);
87 // Logically shift Datum right by Count bits
88 // ===========================================================================
89 //int __lshrsi3(int Datum, int Count)
91 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
92 // return (int) RShiftU64 ((UINT64) Datum, (UINTN)Count);
95 INT64
__lshrdi3(INT64 Datum
, int Count
)
97 DebugPrint(DEBUG_INFO
, "%a:\n", __func__
);
98 return RShiftU64 ( Datum
, (UINTN
)Count
);
101 //long long __lshrti3(int Datum, int Count)
103 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
104 // return (long long) RShiftU64 ((UINT64) Datum, (UINTN)Count);
107 // Return the remainder of the signed division of Dividend and Divisor
108 // ===========================================================================
109 //int __modsi3(int Dividend, int Divisor)
113 // (void) DivS64x64Remainder ((INT64) Dividend, (INT64) Divisor, &Remainder);
114 // DebugPrint(DEBUG_INFO, "modsi3: %d %% %d = %d\n", Dividend, Divisor, (int)Remainder);
116 // return (int) Remainder;
119 INT64
__moddi3(INT64 Dividend
, INT64 Divisor
)
123 (void) DivS64x64Remainder ((INT64
) Dividend
, (INT64
) Divisor
, &Remainder
);
124 DebugPrint(DEBUG_INFO
, "moddi3: %Ld %% %Ld = %Ld\n", (INT64
)Dividend
, (INT64
)Divisor
, Remainder
);
129 //long long __modti3(long long Dividend, long long Divisor)
133 // (void) DivS64x64Remainder ((INT64) Dividend, (INT64) Divisor, &Remainder);
134 // DebugPrint(DEBUG_INFO, "modti3: %Ld %% %Ld = %Ld\n", (INT64)Dividend, (INT64)Divisor, Remainder);
136 // return (long long) Remainder;
139 // These functions return the product of the Multiplicand and Multiplier.
140 // ===========================================================================
141 //long long __multi3(long long Multiplicand, long long Multiplier)
143 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
144 // return (long long) MultS64x64 ((INT64)Multiplicand, (INT64)Multiplier);
147 // Return the quotient of the unsigned division of a and b.
148 // ===========================================================================
149 //unsigned int __udivsi3(unsigned int Dividend, unsigned int Divisor)
151 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
152 // return (int) DivU64x64Remainder ((UINT64) Dividend, (UINT64) Divisor, NULL);
155 UINT64
__udivdi3(UINT64 Dividend
, UINT64 Divisor
)
157 DebugPrint(DEBUG_INFO
, "%a:\n", __func__
);
158 return DivU64x64Remainder ((UINT64
) Dividend
, (UINT64
) Divisor
, NULL
);
161 //unsigned long long __udivti3(unsigned long long Dividend, unsigned long long Divisor)
163 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
164 // return (long long) DivU64x64Remainder ((UINT64) Dividend, (UINT64) Divisor, NULL);
167 // ===========================================================================
168 //unsigned int __umodsi3(unsigned int Dividend, unsigned int Divisor)
172 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
173 // (void) DivU64x64Remainder ((UINT64) Dividend, (UINT64) Divisor, &Remainder);
175 // return (unsigned int) Remainder;
178 UINT64
__umoddi3(UINT64 Dividend
, UINT64 Divisor
)
182 DebugPrint(DEBUG_INFO
, "%a:\n", __func__
);
183 (void) DivU64x64Remainder ((UINT64
) Dividend
, (UINT64
) Divisor
, &Remainder
);
188 //unsigned long long __umodti3(unsigned long long Dividend, unsigned long long Divisor)
192 // DebugPrint(DEBUG_INFO, "%a:\n", __func__);
193 // (void) DivU64x64Remainder ((UINT64) Dividend, (UINT64) Divisor, &Remainder);
195 // return (unsigned long long) Remainder;