forked from OSchip/llvm-project
[libc++] [test] Qualify calls to std::atomic_flag_{clear,test} functions. NFCI.
We shouldn't be calling these functions via ADL -- and neither should anybody in the wild be calling it via ADL, so it's not like we need to test the ADL ability of these functions in particular. Reviewed as part of D119860.
This commit is contained in:
parent
98bb747c87
commit
f033bf88b4
|
@ -24,14 +24,14 @@ int main(int, char**)
|
|||
std::atomic_flag f;
|
||||
f.clear();
|
||||
f.test_and_set();
|
||||
atomic_flag_clear(&f);
|
||||
std::atomic_flag_clear(&f);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
f.test_and_set();
|
||||
atomic_flag_clear(&f);
|
||||
std::atomic_flag_clear(&f);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,44 +22,44 @@ int main(int, char**)
|
|||
{
|
||||
{
|
||||
std::atomic_flag f; // uninitialized first
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||
assert(f.test_and_set() == 0);
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||
assert(f.test_and_set() == 0);
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||
assert(f.test_and_set() == 0);
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||
assert(f.test_and_set() == 0);
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||
assert(f.test_and_set() == 0);
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||
assert(f.test_and_set() == 0);
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||
std::atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,16 +23,16 @@ int main(int, char**)
|
|||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test(&f) == 0);
|
||||
assert(std::atomic_flag_test(&f) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test(&f) == 1);
|
||||
assert(std::atomic_flag_test(&f) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test(&f) == 0);
|
||||
assert(std::atomic_flag_test(&f) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test(&f) == 1);
|
||||
assert(std::atomic_flag_test(&f) == 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -23,13 +23,13 @@ int main(int, char**)
|
|||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set(&f) == 0);
|
||||
assert(std::atomic_flag_test_and_set(&f) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set(&f) == 0);
|
||||
assert(std::atomic_flag_test_and_set(&f) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,73 +23,73 @@ int main(int, char**)
|
|||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_relaxed) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_relaxed) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_consume) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_consume) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acquire) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_acquire) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_release) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_release) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acq_rel) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_acq_rel) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_seq_cst) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_seq_cst) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_relaxed) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_relaxed) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_consume) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_consume) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acquire) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_acquire) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_release) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_release) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acq_rel) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_acq_rel) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_seq_cst) == 0);
|
||||
assert(std::atomic_flag_test_and_set_explicit(&f, std::memory_order_seq_cst) == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,90 +23,90 @@ int main(int, char**)
|
|||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_relaxed) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_relaxed) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_relaxed) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_relaxed) == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_consume) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_consume) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_consume) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_consume) == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_acquire) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_acquire) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_acquire) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_acquire) == 1);
|
||||
}
|
||||
#ifdef _LIBCPP_VERSION // Don't violate precondition [atomics.flag]/6
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_release) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_release) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_release) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_release) == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_acq_rel) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_acq_rel) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_acq_rel) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_acq_rel) == 1);
|
||||
}
|
||||
#endif // _LIBCPP_VERSION
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_seq_cst) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_seq_cst) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_seq_cst) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_seq_cst) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_relaxed) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_relaxed) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_relaxed) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_relaxed) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_consume) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_consume) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_consume) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_consume) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_acquire) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_acquire) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_acquire) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_acquire) == 1);
|
||||
}
|
||||
#ifdef _LIBCPP_VERSION // Don't violate precondition [atomics.flag]/6
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_release) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_release) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_release) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_release) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_acq_rel) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_acq_rel) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_acq_rel) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_acq_rel) == 1);
|
||||
}
|
||||
#endif // _LIBCPP_VERSION
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_seq_cst) == 0);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_seq_cst) == 0);
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(atomic_flag_test_explicit(&f, std::memory_order_seq_cst) == 1);
|
||||
assert(std::atomic_flag_test_explicit(&f, std::memory_order_seq_cst) == 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue