]>
Commit | Line | Data |
---|---|---|
aa5f2556 | 1 | /** @file\r |
2 | Integer division worker functions for Ia32.\r | |
3 | \r | |
f0b0ba31 | 4 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r |
9344f092 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
aa5f2556 | 6 | \r |
7 | **/\r | |
8 | \r | |
47fc17d8 | 9 | #include "BaseLibInternals.h"\r |
aa5f2556 | 10 | \r |
11 | /**\r | |
12 | Worker function that Divides a 64-bit signed integer by a 64-bit signed integer and\r | |
13 | generates a 64-bit signed result and a optional 64-bit signed remainder.\r | |
14 | \r | |
15 | This function divides the 64-bit signed value Dividend by the 64-bit\r | |
16 | signed value Divisor and generates a 64-bit signed quotient. If Remainder\r | |
17 | is not NULL, then the 64-bit signed remainder is returned in Remainder.\r | |
18 | This function returns the 64-bit signed quotient.\r | |
19 | \r | |
20 | @param Dividend A 64-bit signed value.\r | |
21 | @param Divisor A 64-bit signed value.\r | |
22 | @param Remainder A pointer to a 64-bit signed value. This parameter is\r | |
23 | optional and may be NULL.\r | |
24 | \r | |
25 | @return Dividend / Divisor\r | |
26 | \r | |
27 | **/\r | |
28 | INT64\r | |
29 | EFIAPI\r | |
30 | InternalMathDivRemS64x64 (\r | |
2f88bd3a MK |
31 | IN INT64 Dividend,\r |
32 | IN INT64 Divisor,\r | |
33 | OUT INT64 *Remainder OPTIONAL\r | |
aa5f2556 | 34 | )\r |
35 | {\r | |
2f88bd3a | 36 | INT64 Quot;\r |
aa5f2556 | 37 | \r |
38 | Quot = InternalMathDivRemU64x64 (\r | |
2f88bd3a MK |
39 | (UINT64)(Dividend >= 0 ? Dividend : -Dividend),\r |
40 | (UINT64)(Divisor >= 0 ? Divisor : -Divisor),\r | |
41 | (UINT64 *)Remainder\r | |
aa5f2556 | 42 | );\r |
2f88bd3a | 43 | if ((Remainder != NULL) && (Dividend < 0)) {\r |
aa5f2556 | 44 | *Remainder = -*Remainder;\r |
45 | }\r | |
2f88bd3a | 46 | \r |
aa5f2556 | 47 | return (Dividend ^ Divisor) >= 0 ? Quot : -Quot;\r |
48 | }\r |