diff options
| author | 2022-04-03 00:13:27 +0100 | |
|---|---|---|
| committer | 2022-04-03 22:38:12 +0100 | |
| commit | 4052bfb4ada22bc922461dab09bef886e3f114ae (patch) | |
| tree | 9580913d090048d961a5f9ee5feabd3968a000ee /src | |
| parent | native_clock: Use lfence with rdtsc (diff) | |
| download | yuzu-4052bfb4ada22bc922461dab09bef886e3f114ae.tar.gz yuzu-4052bfb4ada22bc922461dab09bef886e3f114ae.tar.xz yuzu-4052bfb4ada22bc922461dab09bef886e3f114ae.zip | |
native_clock: Internal linkage for FencedRDTSC
__forceinline required on MSVC for function to be inlined
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/x64/native_clock.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 63364f839..7fd9d22f8 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp | |||
| @@ -16,15 +16,17 @@ | |||
| 16 | 16 | ||
| 17 | namespace Common { | 17 | namespace Common { |
| 18 | 18 | ||
| 19 | inline u64 FencedRDTSC() { | ||
| 20 | #ifdef _MSC_VER | 19 | #ifdef _MSC_VER |
| 20 | __forceinline static u64 FencedRDTSC() { | ||
| 21 | _mm_lfence(); | 21 | _mm_lfence(); |
| 22 | _ReadWriteBarrier(); | 22 | _ReadWriteBarrier(); |
| 23 | const u64 result = __rdtsc(); | 23 | const u64 result = __rdtsc(); |
| 24 | _mm_lfence(); | 24 | _mm_lfence(); |
| 25 | _ReadWriteBarrier(); | 25 | _ReadWriteBarrier(); |
| 26 | return result; | 26 | return result; |
| 27 | } | ||
| 27 | #else | 28 | #else |
| 29 | static u64 FencedRDTSC() { | ||
| 28 | u64 result; | 30 | u64 result; |
| 29 | asm volatile("lfence\n\t" | 31 | asm volatile("lfence\n\t" |
| 30 | "rdtsc\n\t" | 32 | "rdtsc\n\t" |
| @@ -35,8 +37,8 @@ inline u64 FencedRDTSC() { | |||
| 35 | : | 37 | : |
| 36 | : "rdx", "memory", "cc"); | 38 | : "rdx", "memory", "cc"); |
| 37 | return result; | 39 | return result; |
| 38 | #endif | ||
| 39 | } | 40 | } |
| 41 | #endif | ||
| 40 | 42 | ||
| 41 | u64 EstimateRDTSCFrequency() { | 43 | u64 EstimateRDTSCFrequency() { |
| 42 | // Discard the first result measuring the rdtsc. | 44 | // Discard the first result measuring the rdtsc. |