Skip to content

Commit 85bf853

Browse files
committed
chore: guarded timer struct inside x86
1 parent 83c7050 commit 85bf853

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

src/vmaware.hpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,12 +3050,13 @@ struct VM {
30503050

30513051
#if (WINDOWS)
30523052
// timer helper functionalities
3053+
#if (x86)
30533054
struct timer {
3054-
#if (x86_64)
3055-
using timer_tick_t = u64;
3056-
#else
3057-
using timer_tick_t = u32;
3058-
#endif
3055+
#if (x86_64)
3056+
using timer_tick_t = u64;
3057+
#else
3058+
using timer_tick_t = u32;
3059+
#endif
30593060

30603061
#if (MSVC)
30613062
#pragma warning(push)
@@ -3427,7 +3428,6 @@ struct VM {
34273428
timer::timer_tick_t& r_pre,
34283429
timer::timer_tick_t& r_post
34293430
) noexcept {
3430-
#if (x86)
34313431
switch (count) {
34323432
case 1:
34333433
r_pre = counter;
@@ -3472,7 +3472,6 @@ struct VM {
34723472
r_post = counter;
34733473
break;
34743474
}
3475-
#endif
34763475
}
34773476

34783477
// fully unrolled timing paths for AMD (LFENCE) or older Intel
@@ -3482,7 +3481,6 @@ struct VM {
34823481
timer::timer_tick_t& r_pre,
34833482
timer::timer_tick_t& r_post
34843483
) noexcept {
3485-
#if (x86)
34863484
switch (count) {
34873485
case 1:
34883486
r_pre = counter;
@@ -3550,12 +3548,10 @@ struct VM {
35503548
r_post = counter;
35513549
break;
35523550
}
3553-
#endif
35543551
}
35553552

35563553
// we dont use cpu::cpuid on purpose
35573554
static VMAWARE_FORCE_INLINE void vmexit() {
3558-
#if (x86)
35593555
#if (GCC || CLANG)
35603556
u32 a = 0;
35613557
u32 b, c, d;
@@ -3567,7 +3563,6 @@ struct VM {
35673563
int dummy[4];
35683564
__cpuid(dummy, 0);
35693565
#endif
3570-
#endif
35713566
}
35723567

35733568
[[nodiscard]] static timer_tick_t calculate_latency(const std::vector<timer_tick_t>& samples_in) {
@@ -3622,6 +3617,7 @@ struct VM {
36223617
std::atomic_signal_fence(std::memory_order_acq_rel);
36233618
}
36243619
};
3620+
#endif
36253621
#endif
36263622

36273623
// miscellaneous functionalities

0 commit comments

Comments
 (0)