Still working on the basic design of <atomic>. I'm working towards a system by which the compiler only needs to define the strongest intrinsics it can. Weaker atomics in the library automatically try stronger and stronger variants, picking the weakest compiler intrinsic available. If no compiler intrinsics are available for a given operation, the library locks a mutex and does the job. Better documentation to follow...
llvm-svn: 115538
This commit is contained in:
parent
b2c4ca6433
commit
2b672e24a5
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,23 @@
|
|||
//===------------------------- atomic.cpp ---------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "__mutex_base"
|
||||
#include "atomic"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_VISIBLE
|
||||
mutex&
|
||||
__not_atomic_mut()
|
||||
{
|
||||
static mutex m;
|
||||
return m;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
|
@ -25,12 +25,6 @@ int main()
|
|||
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();
|
||||
|
@ -49,12 +43,6 @@ int main()
|
|||
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();
|
||||
|
|
|
@ -31,12 +31,6 @@ int main()
|
|||
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();
|
||||
|
@ -61,12 +55,6 @@ int main()
|
|||
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();
|
||||
|
|
Loading…
Reference in New Issue