cxx/include
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
..
ext Fix http://llvm.org/bugs/show_bug.cgi?id=11461. Credit Alberto Ganesh Barbati. 2011-12-11 20:31:33 +00:00
support Define _WCHAR_T in solaris/wchar.h. This fixes a bug where Solaris 10 headers 2012-03-02 10:56:04 +00:00
__bit_reference Apply constexpr to <bitset>. 2012-07-07 17:04:52 +00:00
__config libc++: switch from using _ATTRIBUTE(noreturn) (which conflicts with a 2012-07-26 02:04:22 +00:00
__debug Further macro protection by replacing _[A-Z] with _[A-Z]p 2011-11-29 18:15:50 +00:00
__functional_03 Further macro protection by replacing _[A-Z] with _[A-Z]p 2011-11-29 18:15:50 +00:00
__functional_base Modernize relational operators for shared_ptr and unique_ptr. This includes adding support for nullptr, and using less<T*>. Fixes http://llvm.org/bugs/show_bug.cgi?id=12056. 2012-02-21 21:02:58 +00:00
__functional_base_03 Further macro protection by replacing _[A-Z] with _[A-Z]p 2011-11-29 18:15:50 +00:00
__hash_table This commit establishes a new bucket_count policy in the unordered containers: The policy now allows a power-of-2 number of buckets to be requested (and that request honored) by the client. And if the number of buckets is set to a power of 2, then the constraint of the hash to the number of buckets uses & instead of %. If the client does not specify a number of buckets, then the policy remains unchanged: a prime number of buckets is selected. The growth policy is that the number of buckets is roughly doubled when needed. While growing, either the prime, or the power-of-2 strategy will be preserved. There is a small run time cost for putting in this switch. For very cheap hash functions, e.g. identity for int, the cost can be as high as 18%. However with more typical use cases, e.g. strings, the cost is in the noise level. I've measured cases with very cheap hash functions (int) that using a power-of-2 number of buckets can make look up about twice as fast. However I've also noted that a power-of-2 number of buckets is more susceptible to accidental catastrophic collisions. Though I've also noted that accidental catastrophic collisions are also possible when using a prime number of buckets (but seems far less likely). In short, this patch adds an extra tuning knob for those clients trying to get the last bit of performance squeezed out of their hash containers. Casual users of the hash containers will not notice the introduction of this tuning knob. Those clients who swear by power-of-2 hash containers can now opt-in to that strategy. Clients who prefer a prime number of buckets can continue as they have. 2012-07-06 17:31:14 +00:00
__locale locale::id really needs to be constructed at compile time. 2012-07-26 16:14:37 +00:00
__mutex_base noexcept applied to <condition_variable>. 2012-07-21 16:32:53 +00:00
__split_buffer Implement a few optimizations for vector push_back and insert. Fixes r10828365. 2012-02-15 00:41:34 +00:00
__sso_allocator Further macro protection by replacing _[A-Z] with _[A-Z]p 2011-11-29 18:15:50 +00:00
__std_stream Quash a whole bunch of warnings 2011-12-01 20:21:04 +00:00
__tree Further macro protection by replacing _[A-Z] with _[A-Z]p 2011-11-29 18:15:50 +00:00
__tuple I believe tuple is still under development in the standard. Daniel Krugler is/will be making convincing arguments that a modified form of LWG 2051 (currently NAD Future) is easily acheivable and desirable. He has demonstrated that a tuple<T...> where all of the T are implicitly convertible from U... should have a tuple constructor that is also implicit, instead of explicit. This would support the use cases in LWG 2051 while not undermining T... with explicit conversions from U.... This check-in is an experimental implementation of Daniel's work. I believe this work to be mature enough to warrant inclusion into libc++. If anyone sees real-world problems that this check in causes, please let me know and I will revert it, and provide the feedback to the LWG. 2012-04-01 23:10:42 +00:00
__tuple_03 Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
__undef_min_max Add protection from min/max macros 2011-11-29 16:45:27 +00:00
algorithm <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
array constexpr applied to <array>. 2012-07-20 19:20:49 +00:00
atomic Apply noexcept and constexpr to <atomic>. 2012-04-11 20:14:21 +00:00
bitset Apply constexpr to <bitset>. 2012-07-07 17:04:52 +00:00
cassert Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
ccomplex Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
cctype More windows port work by Ruben Van Boxem 2011-10-22 20:59:45 +00:00
cerrno Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
cfenv Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
cfloat Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
chrono Applied constexpr to <chrono>. 2012-07-13 19:17:27 +00:00
cinttypes Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
ciso646 Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
climits Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
clocale Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
cmath Apply noexcept to those functions implemented in <cmath> as a conforming extension. 2012-07-06 19:13:50 +00:00
codecvt Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
complex constexpr applied to <complex>. 2012-07-20 22:18:27 +00:00
complex.h Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
condition_variable noexcept applied to <condition_variable>. 2012-07-21 16:32:53 +00:00
csetjmp Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
csignal Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
cstdarg Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
cstdbool Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
cstddef Give the emulated nullptr_t a default constructor. 2012-02-18 22:01:22 +00:00
cstdint Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
cstdio Patch by Andrew C. Morrow: shims to work around macroized getc and putc on linux. On my eglibc 2.13 based Debian system 'getc' is a macro defined in 2012-07-26 20:01:13 +00:00
cstdlib Apply noexcept to those functions implemented in <cstdlib> as a conforming extension. 2012-07-06 19:16:56 +00:00
cstring Solaris port. Currently sees around 200 test failures, mostly related to 2012-02-29 13:05:08 +00:00
ctgmath Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
ctime Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
cwchar More windows port work by Ruben Van Boxem 2011-10-22 20:59:45 +00:00
cwctype Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
deque Change emplace for vector and deque to create the temporary (when necessary) before any changes to the container are made. Nikolay Ivchenkov deserves the credit for pushing this problem and the solution for it. 2012-07-08 23:23:04 +00:00
exception libc++: switch from using _ATTRIBUTE(noreturn) (which conflicts with a 2012-07-26 02:04:22 +00:00
forward_list Further macro protection by replacing _[A-Z] with _[A-Z]p 2011-11-29 18:15:50 +00:00
fstream Fix http://llvm.org/bugs/show_bug.cgi?id=11752 2012-01-12 23:37:51 +00:00
functional Further tweaks on relaxing complete type checking for function. 2012-07-20 18:56:07 +00:00
future Apple LWG 2067: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3318.html#2067 . This is the only actionable change that has been made to the C++ draft since C++11. In general it has not been decided exactly how libc++ will track changes made to C++11. New features and design changes will probably be #ifdef'd, especially if they are not backwards compatible. Defects and 'dumb mistakes' are more likely to just be put in. Decisions on telling one from the other will be made on a case by case basis. 2012-07-21 19:34:12 +00:00
initializer_list Further macro protection by replacing _[A-Z] with _[A-Z]p 2011-11-29 18:15:50 +00:00
iomanip Further macro protection by replacing _[A-Z] with _[A-Z]p 2011-11-29 18:15:50 +00:00
ios noexcept and constexpr applied to <ios>. 2012-07-21 01:03:40 +00:00
iosfwd Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
iostream Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
istream Modernize conversion to bool to the explicit bool conversion operator (library wide). This fixes http://llvm.org/bugs/show_bug.cgi?id=12058. 2012-02-21 21:46:43 +00:00
iterator noexcept applied to <iterator>. 2012-07-20 19:36:34 +00:00
limits Update <limits> with constexpr support. Patch contributed by Jonathan Sauer. 2012-04-02 19:23:15 +00:00
list Further macro protection by replacing _[A-Z] with _[A-Z]p 2011-11-29 18:15:50 +00:00
locale Fixed a bug in wstring_convert concerning zero-length inputs. Thanks to Jonathan Coxhead for reporting this bug. 2012-07-12 18:07:41 +00:00
map The rules for emplace in map, multimap, unordered_map and unordered_multimap changed a while back and I'm just now updating to these new rules. In a nutshell, you've got to know you're emplacing to a pair and use one of pair's constructors. I made one extension: If you want to emplace the key and default construct the mapped_type, you can just emplace(key), as opposed to emplace(piecewise_construct, forward_as_tuple(key), forward_as_tuple()). 2012-05-25 22:04:21 +00:00
memory Implement [util.smartptr.shared.atomic]. This is the last unimplemented 2012-07-30 01:40:57 +00:00
mutex noexcept and constexpr applied to <mutex>. 2012-07-21 16:13:09 +00:00
new mark operator new(std::nothrow) as noalias (aka __attribute__((malloc)) 2012-06-28 16:47:34 +00:00
numeric More windows port work by Ruben Van Boxem 2011-10-22 20:59:45 +00:00
ostream Modernize conversion to bool to the explicit bool conversion operator (library wide). This fixes http://llvm.org/bugs/show_bug.cgi?id=12058. 2012-02-21 21:46:43 +00:00
queue Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
random noexcept applied to <random>. 2012-07-20 21:44:27 +00:00
ratio Further macro protection by replacing _[A-Z] with _[A-Z]p 2011-11-29 18:15:50 +00:00
regex noexcept and constexpr applied to <regex>. 2012-07-21 01:31:58 +00:00
scoped_allocator Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
set Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
sstream Add protection from min/max macros 2011-11-29 16:45:27 +00:00
stack Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
stdexcept Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
streambuf Quash a whole bunch of warnings 2011-12-01 20:21:04 +00:00
string constexpr applied to <string>. 2012-07-20 19:09:12 +00:00
strstream Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
system_error It appears that the standard accidentally removed the default constructor for error_category. I'm putting it back in. This fixes http://llvm.org/bugs/show_bug.cgi?id=12321. 2012-03-21 16:18:57 +00:00
tgmath.h Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
thread noexcept applied to <thread>. 2012-07-21 16:50:47 +00:00
tuple Appy constexpr to <memory>. Picked up a few missing noexcepts as well. 2012-07-07 20:56:04 +00:00
type_traits Further tweaks on relaxing complete type checking for function. 2012-07-20 18:56:07 +00:00
typeindex Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
typeinfo Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
unordered_map The rules for emplace in map, multimap, unordered_map and unordered_multimap changed a while back and I'm just now updating to these new rules. In a nutshell, you've got to know you're emplacing to a pair and use one of pair's constructors. I made one extension: If you want to emplace the key and default construct the mapped_type, you can just emplace(key), as opposed to emplace(piecewise_construct, forward_as_tuple(key), forward_as_tuple()). 2012-05-25 22:04:21 +00:00
unordered_set Windows support by Ruben Van Boxem. 2011-10-17 20:05:10 +00:00
utility Revert pair constructors back to using is_convertible instead of is_constructible. This should pull things into alignment with the final draft. Fixes http://llvm.org/bugs/show_bug.cgi?id=13063#add_comment. 2012-06-09 20:01:23 +00:00
valarray noexcept applied to <valarray>. 2012-07-21 00:51:28 +00:00
vector Change emplace for vector and deque to create the temporary (when necessary) before any changes to the container are made. Nikolay Ivchenkov deserves the credit for pushing this problem and the solution for it. 2012-07-08 23:23:04 +00:00