Skip to content

Commit 25bc9b7

Browse files
author
Maxim Egorushkin
committed
Revert "De-alias dynamically allocated arrays explicitly. Compiler strict aliasing rules may not de-alias these."
This reverts commit 8ad53fc.
1 parent dbd0c72 commit 25bc9b7

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

include/atomic_queue/atomic_queue.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ constexpr T nil() noexcept {
125125
}
126126

127127
template<class T>
128-
ATOMIC_QUEUE_INLINE static void destroy_n(T* ATOMIC_QUEUE_RESTRICT p, unsigned n) noexcept {
128+
ATOMIC_QUEUE_INLINE static void destroy_n(T* p, unsigned n) noexcept {
129129
for(auto q = p + n; p != q;)
130130
(p++)->~T();
131131
}
@@ -387,7 +387,7 @@ class AtomicQueue : public AtomicQueueCommon<AtomicQueue<T, SIZE, NIL, MINIMIZE_
387387

388388
AtomicQueue() noexcept {
389389
assert(std::atomic<T>{NIL}.is_lock_free()); // Queue element type T is not atomic. Use AtomicQueue2/AtomicQueueB2 for such element types.
390-
for(auto* ATOMIC_QUEUE_RESTRICT p = elements_, q = elements_ + size_; p != q; ++p)
390+
for(auto p = elements_, q = elements_ + size_; p != q; ++p)
391391
p->store(NIL, X);
392392
}
393393

@@ -453,7 +453,7 @@ class AtomicQueueB : private std::allocator_traits<A>::template rebind_alloc<std
453453
// AtomicQueueCommon members are stored into by readers and writers.
454454
// Allocate these immutable members on another cache line which never gets invalidated by stores.
455455
alignas(CACHE_LINE_SIZE) unsigned size_;
456-
std::atomic<T>* ATOMIC_QUEUE_RESTRICT elements_;
456+
std::atomic<T>* elements_;
457457

458458
ATOMIC_QUEUE_INLINE T do_pop(unsigned tail) noexcept {
459459
std::atomic<T>& q_element = details::map<SHUFFLE_BITS>(elements_, tail & (size_ - 1));
@@ -534,8 +534,8 @@ class AtomicQueueB2 : private std::allocator_traits<A>::template rebind_alloc<un
534534
// AtomicQueueCommon members are stored into by readers and writers.
535535
// Allocate these immutable members on another cache line which never gets invalidated by stores.
536536
alignas(CACHE_LINE_SIZE) unsigned size_;
537-
AtomicState* ATOMIC_QUEUE_RESTRICT states_;
538-
T* ATOMIC_QUEUE_RESTRICT elements_;
537+
AtomicState* states_;
538+
T* elements_;
539539

540540
static constexpr auto STATES_PER_CACHE_LINE = CACHE_LINE_SIZE / sizeof(AtomicState);
541541
static_assert(STATES_PER_CACHE_LINE, "Unexpected STATES_PER_CACHE_LINE.");
@@ -580,7 +580,7 @@ class AtomicQueueB2 : private std::allocator_traits<A>::template rebind_alloc<un
580580
std::uninitialized_fill_n(states_, size_, Base::EMPTY);
581581
A a = get_allocator();
582582
assert(a == allocator); // The standard requires the original and rebound allocators to manage the same state.
583-
for(auto* ATOMIC_QUEUE_RESTRICT p = elements_, q = elements_ + size_; p < q; ++p)
583+
for(auto p = elements_, q = elements_ + size_; p < q; ++p)
584584
std::allocator_traits<A>::construct(a, p);
585585
}
586586

@@ -600,7 +600,7 @@ class AtomicQueueB2 : private std::allocator_traits<A>::template rebind_alloc<un
600600
~AtomicQueueB2() noexcept {
601601
if(elements_) {
602602
A a = get_allocator();
603-
for(auto* ATOMIC_QUEUE_RESTRICT p = elements_, q = elements_ + size_; p < q; ++p)
603+
for(auto p = elements_, q = elements_ + size_; p < q; ++p)
604604
std::allocator_traits<A>::destroy(a, p);
605605
deallocate_(elements_);
606606
details::destroy_n(states_, size_);

include/atomic_queue/defs.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,11 @@ namespace atomic_queue {
8585
#define ATOMIC_QUEUE_UNLIKELY(expr) __builtin_expect(static_cast<bool>(expr), 0)
8686
#define ATOMIC_QUEUE_NOINLINE __attribute__((noinline))
8787
#define ATOMIC_QUEUE_INLINE inline __attribute__((always_inline))
88-
#define ATOMIC_QUEUE_RESTRICT __restrict__
8988
#else
9089
#define ATOMIC_QUEUE_LIKELY(expr) (expr)
9190
#define ATOMIC_QUEUE_UNLIKELY(expr) (expr)
9291
#define ATOMIC_QUEUE_NOINLINE
9392
#define ATOMIC_QUEUE_INLINE inline
94-
#ifdef _MSC_VER
95-
#define ATOMIC_QUEUE_RESTRICT __restrict
96-
#else
97-
#define ATOMIC_QUEUE_RESTRICT
98-
#endif
9993
#endif
10094

10195
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)