cxx/test
Howard Hinnant 5fec82dc0d 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).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160940 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-30 01:40:57 +00:00
..
algorithms Fixed PR10574: http://llvm.org/bugs/show_bug.cgi?id=10574 2011-08-12 21:56:02 +00:00
atomics libc++: Add some missing #includes to atomics tests. libc++ doesn't need these 2012-04-19 00:50:47 +00:00
containers constexpr applied to <array>. 2012-07-20 19:20:49 +00:00
depr Fix a few testsuite bugs involving trailing null (or lack thereof) in strstream. 2012-06-01 20:02:59 +00:00
diagnostics Fix http://llvm.org/bugs/show_bug.cgi?id=11428. Fix provided by Alberto Ganesh Barbati 2011-12-02 19:36:40 +00:00
input.output noexcept and constexpr applied to <ios>. 2012-07-21 01:03:40 +00:00
iterators noexcept applied to <iterator>. 2012-07-20 19:36:34 +00:00
language.support Add noexcept test for offsetof macro per [support.types]/p4. 2012-07-06 18:39:01 +00:00
localization <algorithm> no longer needs to include <cstdlib>, but can get away with just <cstddef>. This was brought to my attention by Salvatore Benedetto in his port to a bare-metal coretex-m3. This exposed two test bugs where an explicit #include <cstdlib> was needed. 2012-07-26 17:09:09 +00:00
numerics constexpr applied to <complex>. 2012-07-20 22:18:27 +00:00
re Fix <rdar://problem/10255403> match_results::begin() is off by one 2011-10-08 14:36:16 +00:00
strings Fix <rdar://problem/10256836> getline of an empty string mistakenly causes failure 2011-10-09 15:20:46 +00:00
thread noexcept and constexpr applied to <mutex>. 2012-07-21 16:13:09 +00:00
utilities Implement [util.smartptr.shared.atomic]. This is the last unimplemented 2012-07-30 01:40:57 +00:00
CMakeLists.txt Allow libc++ to be built with CMake from within the LLVM tree. The libc++ part is just some renaming as the variable was already in use, conflicting with something else in the LLVM tree. Contributed by Ruben Van Boxem. 2012-03-19 15:40:23 +00:00
hexfloat.h Correction to hexfloat hack. 2011-05-14 14:33:56 +00:00
lit.cfg Teach the Lit configuration to actually use the cxx0x setting when 2011-01-23 01:05:20 +00:00
lit.site.cfg.in Add CMake build and fix major Linux blockers. 2010-12-10 19:47:54 +00:00
nothing_to_do.pass.cpp license change 2010-11-16 22:09:02 +00:00
platform_support.h Windows porting work by Ruben Van Boxem 2011-10-03 15:23:59 +00:00
testit libc++: Add some missing #includes to atomics tests. libc++ doesn't need these 2012-04-19 00:50:47 +00:00