Skip to content

Commit

Permalink
Various cleanups: <xatomic_wait.h> constants (#4147)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej authored Nov 7, 2023
1 parent ceec966 commit bc5a5c3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions stl/inc/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void _Atomic_wait_direct(
return;
}

__std_atomic_wait_direct(_Storage_ptr, &_Expected_bytes, sizeof(_Value_type), _Atomic_wait_no_timeout);
__std_atomic_wait_direct(_Storage_ptr, &_Expected_bytes, sizeof(_Value_type), __std_atomic_wait_no_timeout);
}
}
#endif // _HAS_CXX20
Expand Down Expand Up @@ -716,7 +716,7 @@ struct _Atomic_storage {
} // unlock

__std_atomic_wait_indirect(_Storage_ptr, _Expected_ptr, sizeof(_TVal), &_Spinlock,
&_Atomic_wait_compare_non_lock_free<decltype(_Spinlock)>, _Atomic_wait_no_timeout);
&_Atomic_wait_compare_non_lock_free<decltype(_Spinlock)>, __std_atomic_wait_no_timeout);
}
}

Expand Down Expand Up @@ -1356,7 +1356,7 @@ struct _Atomic_storage<_Ty&, 16> { // lock-free using 16-byte intrinsics
}

__std_atomic_wait_indirect(_Storage_ptr, _Expected_ptr, sizeof(_TVal), nullptr,
&_Atomic_wait_compare_16_bytes, _Atomic_wait_no_timeout);
&_Atomic_wait_compare_16_bytes, __std_atomic_wait_no_timeout);
}
}

Expand Down
2 changes: 1 addition & 1 deletion stl/inc/memory
Original file line number Diff line number Diff line change
Expand Up @@ -3839,7 +3839,7 @@ protected:
if (!_Equal) {
break;
}
__std_atomic_wait_direct(&_Ptr, &_Old, sizeof(_Old), _Atomic_wait_no_timeout);
__std_atomic_wait_direct(&_Ptr, &_Old, sizeof(_Old), __std_atomic_wait_no_timeout);
}
}

Expand Down
2 changes: 1 addition & 1 deletion stl/inc/semaphore
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public:
ptrdiff_t _Current = _Counter.load(memory_order_relaxed);
for (;;) {
while (_Current == 0) {
_Wait(_Atomic_wait_no_timeout);
_Wait(__std_atomic_wait_no_timeout);
_Current = _Counter.load(memory_order_relaxed);
}
_STL_VERIFY(_Current > 0 && _Current <= _Least_max_value,
Expand Down
5 changes: 2 additions & 3 deletions stl/inc/xatomic_wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new

_INLINE_VAR constexpr unsigned long long _Atomic_wait_no_deadline = 0xFFFF'FFFF'FFFF'FFFF;
_INLINE_VAR constexpr unsigned long _Atomic_wait_no_timeout = 0xFFFF'FFFF; // Pass as partial timeout

extern "C" {
inline constexpr unsigned long __std_atomic_wait_no_timeout = 0xFFFF'FFFF; // Pass as partial timeout

enum class __std_atomic_api_level : unsigned long {
__not_set,
__detecting,
Expand Down
7 changes: 4 additions & 3 deletions stl/src/atomic_wait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <Windows.h>

namespace {
constexpr unsigned long long _Atomic_wait_no_deadline = 0xFFFF'FFFF'FFFF'FFFF;

constexpr size_t _Wait_table_size_power = 8;
constexpr size_t _Wait_table_size = 1 << _Wait_table_size_power;
Expand Down Expand Up @@ -317,7 +318,7 @@ int __stdcall __std_atomic_wait_indirect(const void* _Storage, void* _Comparand,
return FALSE;
}

if (_Remaining_timeout != _Atomic_wait_no_timeout) {
if (_Remaining_timeout != __std_atomic_wait_no_timeout) {
// spurious wake to recheck the clock
return TRUE;
}
Expand All @@ -333,8 +334,8 @@ unsigned long long __stdcall __std_atomic_wait_get_deadline(const unsigned long
}

unsigned long __stdcall __std_atomic_wait_get_remaining_timeout(unsigned long long _Deadline) noexcept {
static_assert(_Atomic_wait_no_timeout == INFINITE,
"_Atomic_wait_no_timeout is passed directly to underlying API, so should match it");
static_assert(__std_atomic_wait_no_timeout == INFINITE,
"__std_atomic_wait_no_timeout is passed directly to underlying API, so should match it");

if (_Deadline == _Atomic_wait_no_deadline) {
return INFINITE;
Expand Down
2 changes: 1 addition & 1 deletion stl/src/parallel_algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void __stdcall __std_wait_for_threadpool_work_callbacks(PTP_WORK _Work, BOOL _Ca
}

void __stdcall __std_execution_wait_on_uchar(const volatile unsigned char* _Address, unsigned char _Compare) noexcept {
__std_atomic_wait_direct(const_cast<const unsigned char*>(_Address), &_Compare, 1, _Atomic_wait_no_timeout);
__std_atomic_wait_direct(const_cast<const unsigned char*>(_Address), &_Compare, 1, __std_atomic_wait_no_timeout);
}

void __stdcall __std_execution_wake_by_address_all(const volatile void* _Address) noexcept {
Expand Down

0 comments on commit bc5a5c3

Please sign in to comment.