diff options
| author | 2019-02-15 20:04:11 -0400 | |
|---|---|---|
| committer | 2019-02-15 22:57:16 -0400 | |
| commit | ecccfe033777d6ae7d29bcf0cfc30412f7d3be24 (patch) | |
| tree | f6504e5f766a6f8675764124f7d231843de40583 /src/common/uint128.h | |
| parent | Implement 128 bits Unsigned Integer Multiplication and Division. (diff) | |
| download | yuzu-ecccfe033777d6ae7d29bcf0cfc30412f7d3be24.tar.gz yuzu-ecccfe033777d6ae7d29bcf0cfc30412f7d3be24.tar.xz yuzu-ecccfe033777d6ae7d29bcf0cfc30412f7d3be24.zip | |
Use u128 on Clock Cycles calculation.
Diffstat (limited to 'src/common/uint128.h')
| -rw-r--r-- | src/common/uint128.h | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/src/common/uint128.h b/src/common/uint128.h index fda313bcc..45e384c33 100644 --- a/src/common/uint128.h +++ b/src/common/uint128.h | |||
| @@ -1,30 +1,13 @@ | |||
| 1 | #include <array> | 1 | #include <array> |
| 2 | #include <cstdint> | 2 | #include <cstdint> |
| 3 | #include <utility> | ||
| 4 | #include <cstring> | 3 | #include <cstring> |
| 4 | #include <utility> | ||
| 5 | #include "common/common_types.h" | 5 | #include "common/common_types.h" |
| 6 | 6 | ||
| 7 | namespace Common { | 7 | namespace Common { |
| 8 | 8 | ||
| 9 | #ifdef _MSC_VER | 9 | u128 Multiply64Into128(u64 a, u64 b); |
| 10 | #include <intrin.h> | ||
| 11 | |||
| 12 | #pragma intrinsic(_umul128) | ||
| 13 | #endif | ||
| 14 | |||
| 15 | inline u128 umul128(u64 a, u64 b) { | ||
| 16 | #ifdef _MSC_VER | ||
| 17 | u128 result; | ||
| 18 | result[0] = _umul128(a, b, &result[1]); | ||
| 19 | #else | ||
| 20 | unsigned __int128 tmp = a; | ||
| 21 | tmp *= b; | ||
| 22 | u128 result; | ||
| 23 | std::memcpy(&result, &tmp, sizeof(u128)); | ||
| 24 | #endif | ||
| 25 | return result; | ||
| 26 | } | ||
| 27 | 10 | ||
| 28 | std::pair<u64, u64> udiv128(u128 dividend, u64 divisor); | 11 | std::pair<u64, u64> Divide128On64(u128 dividend, u64 divisor); |
| 29 | 12 | ||
| 30 | } // namespace Common | 13 | } // namespace Common |