[atomics.flag] completed. Initialization is not working on clang and can't be made to work without defaulted default constructors.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@115207 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f701e25c49
commit
79101aec3a
@ -2556,7 +2556,7 @@ typedef struct _LIBCPP_VISIBLE atomic_flag
|
||||
atomic_flag() = default;
|
||||
#else
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
atomic_flag() : __flg_(false) {};
|
||||
atomic_flag() {};
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
|
34
test/atomics/atomics.flag/atomic_flag_clear.pass.cpp
Normal file
34
test/atomics/atomics.flag/atomic_flag_clear.pass.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <atomic>
|
||||
|
||||
// struct atomic_flag
|
||||
|
||||
// void atomic_flag_clear(volatile atomic_flag*);
|
||||
// void atomic_flag_clear(atomic_flag*);
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
atomic_flag_clear(&f);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
atomic_flag_clear(&f);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <atomic>
|
||||
|
||||
// struct atomic_flag
|
||||
|
||||
// void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order);
|
||||
// void atomic_flag_clear_explicit(atomic_flag*, memory_order);
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_consume);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_consume);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
}
|
34
test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
Normal file
34
test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <atomic>
|
||||
|
||||
// struct atomic_flag
|
||||
|
||||
// bool atomic_flag_test_and_set(volatile atomic_flag*);
|
||||
// bool atomic_flag_test_and_set(atomic_flag*);
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(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(f.test_and_set() == 1);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <atomic>
|
||||
|
||||
// struct atomic_flag
|
||||
|
||||
// bool atomic_flag_test_and_set_explicit(volatile atomic_flag*, memory_order);
|
||||
// bool atomic_flag_test_and_set_explicit(atomic_flag*, memory_order);
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(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(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(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(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(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(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(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(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(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(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(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(f.test_and_set() == 1);
|
||||
}
|
||||
}
|
82
test/atomics/atomics.flag/clear.pass.cpp
Normal file
82
test/atomics/atomics.flag/clear.pass.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <atomic>
|
||||
|
||||
// struct atomic_flag
|
||||
|
||||
// void clear(memory_order = memory_order_seq_cst);
|
||||
// void clear(memory_order = memory_order_seq_cst) volatile;
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
f.clear();
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
f.clear(std::memory_order_relaxed);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
f.clear(std::memory_order_consume);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
f.clear(std::memory_order_release);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
f.clear(std::memory_order_seq_cst);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
f.clear();
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
f.clear(std::memory_order_relaxed);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
f.clear(std::memory_order_consume);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
f.clear(std::memory_order_release);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.test_and_set();
|
||||
f.clear(std::memory_order_seq_cst);
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
||||
}
|
24
test/atomics/atomics.flag/copy_assign.fail.cpp
Normal file
24
test/atomics/atomics.flag/copy_assign.fail.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <atomic>
|
||||
|
||||
// struct atomic_flag
|
||||
|
||||
// atomic_flag& operator=(const atomic_flag&) = delete;
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::atomic_flag f0;
|
||||
std::atomic_flag f;
|
||||
f = f0;
|
||||
}
|
23
test/atomics/atomics.flag/copy_ctor.fail.cpp
Normal file
23
test/atomics/atomics.flag/copy_ctor.fail.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <atomic>
|
||||
|
||||
// struct atomic_flag
|
||||
|
||||
// atomic_flag(const atomic_flag&) = delete;
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::atomic_flag f0;
|
||||
std::atomic_flag f(f0);
|
||||
}
|
24
test/atomics/atomics.flag/copy_volatile_assign.fail.cpp
Normal file
24
test/atomics/atomics.flag/copy_volatile_assign.fail.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <atomic>
|
||||
|
||||
// struct atomic_flag
|
||||
|
||||
// atomic_flag& operator=(const atomic_flag&) = delete;
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::atomic_flag f0;
|
||||
volatile std::atomic_flag f;
|
||||
f = f0;
|
||||
}
|
22
test/atomics/atomics.flag/default.pass.cpp
Normal file
22
test/atomics/atomics.flag/default.pass.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <atomic>
|
||||
|
||||
// struct atomic_flag
|
||||
|
||||
// atomic_flag() = default;
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::atomic_flag f;
|
||||
}
|
23
test/atomics/atomics.flag/init.pass.cpp
Normal file
23
test/atomics/atomics.flag/init.pass.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <atomic>
|
||||
|
||||
// struct atomic_flag
|
||||
|
||||
// atomic_flag() = ATOMIC_FLAG_INIT;
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||
assert(f.test_and_set() == 0);
|
||||
}
|
@ -19,7 +19,88 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
std::atomic_flag f;
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_relaxed) == 0);
|
||||
assert(f.test_and_set(std::memory_order_relaxed) == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_consume) == 0);
|
||||
assert(f.test_and_set(std::memory_order_consume) == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_acquire) == 0);
|
||||
assert(f.test_and_set(std::memory_order_acquire) == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_release) == 0);
|
||||
assert(f.test_and_set(std::memory_order_release) == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_acq_rel) == 0);
|
||||
assert(f.test_and_set(std::memory_order_acq_rel) == 1);
|
||||
}
|
||||
{
|
||||
std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_seq_cst) == 0);
|
||||
assert(f.test_and_set(std::memory_order_seq_cst) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set() == 0);
|
||||
assert(f.test_and_set() == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_relaxed) == 0);
|
||||
assert(f.test_and_set(std::memory_order_relaxed) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_consume) == 0);
|
||||
assert(f.test_and_set(std::memory_order_consume) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_acquire) == 0);
|
||||
assert(f.test_and_set(std::memory_order_acquire) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_release) == 0);
|
||||
assert(f.test_and_set(std::memory_order_release) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_acq_rel) == 0);
|
||||
assert(f.test_and_set(std::memory_order_acq_rel) == 1);
|
||||
}
|
||||
{
|
||||
volatile std::atomic_flag f;
|
||||
f.clear();
|
||||
assert(f.test_and_set(std::memory_order_seq_cst) == 0);
|
||||
assert(f.test_and_set(std::memory_order_seq_cst) == 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user