llvm-project/libcxx/test/utilities
Howard Hinnant d77851e837 Implement [util.smartptr.shared.atomic]. This is the last unimplemented
section in libc++.  This requires a recompiled dylib.  Failure to rebuild
the dylib will result in a link-time error if and only if the functions from
[util.smartptr.shared.atomic] are used.

The implementation is not lock free.  After considerable thought, I know of no
way to make the implementation lock free.  Ideas welcome along that front.  But
changing the ABI of shared_ptr is not on the table at this point.

The mutex used to lock these function is encapsulated by std::__sp_mut.  The
only thing the client knows about std::__sp_mut is that it has a void* data
member, can't be constructed, and has lock and unlock members.  Within the
binary __sp_mut is currently implemented as a pointer to a std::mutex.  That can
change in the future without disturbing the ABI (as long as sizeof(__sp_mut)
remains constant.

I specifically did not make __sp_mut a spin lock as I have a pathological
distrust of spin locks.  Testing on OS X reveals that the use of std::mutex in
this role is not a large performance penalty as long as the contention for the
mutex is low (more likely to get the lock than to have to wait).  In the future
we can still make __sp_mut a spin lock if that is what is desired (without ABI
damage).

The dylib contains 16 __sp_mut's to be chosen based on the hash of the address
of the shared_ptr.  The constant 16 is a ball-park reasonable space/time
tradeoff.

std::hash<T*> was changed to call __murmur2_or_cityhash, instead of the identity
function.  I had thought we had already done this, but I was mistaken.

All of this is under #if __has_feature(cxx_atomic) even though the
implementation is not lock free, because the signatures require access to
std::memory_order, which is currently available only under
__has_feature(cxx_atomic).

llvm-svn: 160940
2012-07-30 01:40:57 +00:00
..
allocator.adaptor Test adjustment for recent changes in allocator_traits 2010-12-10 19:22:37 +00:00
date.time license change 2010-11-16 22:09:02 +00:00
function.objects Relax the complete-type checks that are happening under __invokable<Fp, Args...> to only check Fp, and not Args... . This should be sufficient to give the desired high quality diagnostics under both bind and function. And this allows a test reported by Rich E on cfe-dev to pass. Tracked by <rdar://problem/11880602>. 2012-07-16 16:17:34 +00:00
memory Implement [util.smartptr.shared.atomic]. This is the last unimplemented 2012-07-30 01:40:57 +00:00
meta Hook up to the new clang __is_trivially_constructible and __is_trivially_assignable traits. Fixes r10925427 and http://llvm.org/bugs/show_bug.cgi?id=12038. 2012-02-24 23:32:26 +00:00
ratio Fix ratio arithmetic with zero 2011-11-01 23:13:37 +00:00
template.bitset Apply constexpr to <bitset>. 2012-07-07 17:04:52 +00:00
time Applied constexpr to <chrono>. 2012-07-13 19:17:27 +00:00
tuple Give tuple a constexpr default constructor. 2012-07-06 20:39:45 +00:00
type.index Fixing up some ABI issues 2011-07-07 21:03:52 +00:00
utilities.general license change 2010-11-16 22:09:02 +00:00
utility test for pair piecewise construction 2011-06-22 23:51:19 +00:00
utility.requirements license change 2010-11-16 22:09:02 +00:00
nothing_to_do.pass.cpp license change 2010-11-16 22:09:02 +00:00