Skip to content

Commit 36344c7

Browse files
author
Maxim Egorushkin
committed
Fix Windows build.
1 parent aea151b commit 36344c7

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

include/atomic_queue/defs.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,6 @@ ATOMIC_QUEUE_INLINE static void spin_loop_pause() noexcept {
4242
_mm_pause();
4343
}
4444

45-
// RDTSCP is not a serializing instruction, but it does wait until all previous instructions have executed and all previous loads are globally visible.
46-
using cycles_t = decltype(__builtin_ia32_rdtscp(0));
47-
48-
ATOMIC_QUEUE_INLINE static cycles_t cycles_start() noexcept {
49-
unsigned tsc_aux;
50-
auto t0 = __builtin_ia32_rdtscp(&tsc_aux);
51-
// If software requires RDTSCP to be executed prior to execution of any subsequent instruction (including any memory accesses), it can execute LFENCE immediately after RDTSCP.
52-
_mm_lfence();
53-
return t0;
54-
}
55-
56-
ATOMIC_QUEUE_INLINE static cycles_t cycles_end() noexcept {
57-
// If software requires RDTSCP to be executed only after all previous stores are globally visible, it can execute MFENCE immediately before RDTSCP.
58-
_mm_mfence();
59-
// RDTSCP is not a serializing instruction, but it does wait until all previous instructions have executed and all previous loads are globally visible.
60-
unsigned tsc_aux;
61-
return __builtin_ia32_rdtscp(&tsc_aux);
62-
}
63-
6445
#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64)
6546
/*
6647
TODO:

src/benchmarks.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ static_assert(std::is_unsigned<cycles_t>::value);
5454
using icycles_t = std::make_signed<cycles_t>::type; // Signed integers convert into double with one AVX instruction, unlike unsigned.
5555
cycles_t constexpr CYCLES_MAX = -1;
5656

57+
// RDTSCP is not a serializing instruction, but it does wait until all previous instructions have executed and all previous loads are globally visible.
58+
using cycles_t = decltype(__builtin_ia32_rdtscp(0));
59+
60+
ATOMIC_QUEUE_INLINE static cycles_t cycles_start() noexcept {
61+
unsigned tsc_aux;
62+
auto t0 = __builtin_ia32_rdtscp(&tsc_aux);
63+
// If software requires RDTSCP to be executed prior to execution of any subsequent instruction (including any memory accesses), it can execute LFENCE immediately after RDTSCP.
64+
_mm_lfence();
65+
return t0;
66+
}
67+
68+
ATOMIC_QUEUE_INLINE static cycles_t cycles_end() noexcept {
69+
// If software requires RDTSCP to be executed only after all previous stores are globally visible, it can execute MFENCE immediately before RDTSCP.
70+
_mm_mfence();
71+
// RDTSCP is not a serializing instruction, but it does wait until all previous instructions have executed and all previous loads are globally visible.
72+
unsigned tsc_aux;
73+
return __builtin_ia32_rdtscp(&tsc_aux);
74+
}
75+
5776
double TSC_TO_SECONDS = 0; // Set in main.
5877

5978
ATOMIC_QUEUE_INLINE double to_seconds(icycles_t cycles) noexcept {

0 commit comments

Comments
 (0)