Skip to content

Commit e6f58e3

Browse files
author
Requiem
committed
style: changed rdtsc lambda to straight __rdtsc calls
1 parent 096552c commit e6f58e3

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/vmaware.hpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5127,14 +5127,6 @@ struct VM {
51275127
std::atomic<u64> t2_end(0);
51285128
std::vector<u64> samples(100000, 0);
51295129

5130-
auto rdtsc = []() noexcept -> u64 {
5131-
#if (MSVC)
5132-
return static_cast<u64>(__rdtsc());
5133-
#else
5134-
return static_cast<u64>(__rdtsc());
5135-
#endif
5136-
};
5137-
51385130
struct affinity_cookie {
51395131
bool valid{ false };
51405132
#if (WINDOWS)
@@ -5391,7 +5383,7 @@ struct VM {
53915383
while (ready_count.load(std::memory_order_acquire) < 2)
53925384
_mm_pause();
53935385

5394-
const u64 start = rdtsc();
5386+
const u64 start = __rdtsc();
53955387
t1_start.store(start, std::memory_order_release);
53965388
state.store(1, std::memory_order_release);
53975389

@@ -5402,7 +5394,7 @@ struct VM {
54025394
}
54035395
VMAWARE_UNUSED(x);
54045396

5405-
const u64 end = rdtsc();
5397+
const u64 end = __rdtsc();
54065398
t1_end.store(end - start, std::memory_order_release);
54075399
state.store(2, std::memory_order_release);
54085400
});
@@ -5413,7 +5405,7 @@ struct VM {
54135405
while (ready_count.load(std::memory_order_acquire) < 2)
54145406
_mm_pause();
54155407

5416-
u64 last = rdtsc();
5408+
u64 last = __rdtsc();
54175409

54185410
// local accumulator and local index into samples
54195411
u64 acc = 0;
@@ -5426,7 +5418,7 @@ struct VM {
54265418

54275419
for (unsigned i = 0; i < CPUID_ITER; ++i) {
54285420
// read rdtsc and accumulate delta
5429-
const u64 now = rdtsc();
5421+
const u64 now = __rdtsc();
54305422

54315423
// If now < last, the hypervisor rewound the TSC or it's a very rare 64-bit overflow
54325424
// we do not increment acc to ensure ratio t2_delta / t1_delta drops below 0.95
@@ -5449,7 +5441,7 @@ struct VM {
54495441
}
54505442

54515443
// final rdtsc after detecting finish
5452-
const u64 final_now = rdtsc();
5444+
const u64 final_now = __rdtsc();
54535445
if (final_now >= last) acc += (final_now - last);
54545446
t2_end.store(acc, std::memory_order_release);
54555447
});

0 commit comments

Comments
 (0)