summaryrefslogtreecommitdiff
path: root/src/common/uint128.h
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-02-15 20:04:11 -0400
committerGravatar FernandoS272019-02-15 22:57:16 -0400
commitecccfe033777d6ae7d29bcf0cfc30412f7d3be24 (patch)
treef6504e5f766a6f8675764124f7d231843de40583 /src/common/uint128.h
parentImplement 128 bits Unsigned Integer Multiplication and Division. (diff)
downloadyuzu-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.h23
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
7namespace Common { 7namespace Common {
8 8
9#ifdef _MSC_VER 9u128 Multiply64Into128(u64 a, u64 b);
10#include <intrin.h>
11
12#pragma intrinsic(_umul128)
13#endif
14
15inline u128 umul128(u64 a, u64 b) {
16#ifdef _MSC_VER
17u128 result;
18result[0] = _umul128(a, b, &result[1]);
19#else
20unsigned __int128 tmp = a;
21tmp *= b;
22u128 result;
23std::memcpy(&result, &tmp, sizeof(u128));
24#endif
25return result;
26}
27 10
28std::pair<u64, u64> udiv128(u128 dividend, u64 divisor); 11std::pair<u64, u64> Divide128On64(u128 dividend, u64 divisor);
29 12
30} // namespace Common 13} // namespace Common