summaryrefslogtreecommitdiffstats
path: root/libcxx/include/memory
Commit message (Collapse)AuthorAgeFilesLines
...
* [libcxx] Optimize vectors uninitialized construction of trivial types from ↵Eric Fiselier2015-03-311-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | an iterator range. Summary: In certain cases vector can use memcpy to construct a range of elements at the back of the vector. We currently don't do this resulting in terrible code gen in non-optimized mode and a very large slowdown compared to libstdc++. This patch adds a `__construct_forward_range(Allocator, Iter, Iter, _Ptr&)` and `__construct_forward_range(Allocator, Tp*, Tp*, Tp*&)` functions to `allocator_traits` which act similarly to the existing `__construct_forward(...)` functions. This patch also changes vectors `__construct_at_end(Iter, Iter)` to be `__construct_at_end(Iter, Iter, SizeType)` where SizeType is the size of the range. `__construct_at_end(Iter, Iter, SizeType)` now calls `allocator_traits<Tp>::__construct_forward_range(...)`. This patch is based off the design of `__swap_out_circular_buffer(...)` which uses `allocator_traits<Tp>::__construct_forward(...)`. On my machine this code performs 4x better than the current implementation when tested against `std::vector<int>`. Reviewers: howard.hinnant, titus, kcc, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8109 llvm-svn: 233711
* Handle function name conflicts in _LIBCPP_MSVCRT modeSaleem Abdulrasool2015-02-131-0/+1
| | | | | | | | | | Visual Studio's SAL extension uses a macro named __deallocate. This macro is used pervasively, and gets included through various different ways. This conflicts with the similarly named interfaces in libc++. Introduce a undef header similar to __undef_min_max to handle this. This fixes a number of errors due to the macro replacing the function name. llvm-svn: 229162
* Remove use of _[A-Z] identifiers and poison them to detect usageEric Fiselier2015-02-051-10/+10
| | | | llvm-svn: 228353
* Implement LWG2400 - 'shared_ptr's get_deleter() should use addressof()', and ↵Marshall Clow2014-11-171-1/+1
| | | | | | add tests. Mark LWG2400 and LWG2404 as complete llvm-svn: 222161
* Fix typo in allocator_traits::construct. This fixes PR14175, which shows up ↵Marshall Clow2014-11-111-1/+1
| | | | | | if an allocator has a no-args construct method llvm-svn: 221697
* Add support for "fancy" pointers to shared_ptr. Fixes PR20616Eric Fiselier2014-10-231-25/+39
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch add support for "fancy pointers/allocators" as well as fixing support for shared_pointer and "minimal" allocators. Fancy pointers are class types that meet the NullablePointer requirements. In our case they are created by fancy allocators. `support/min_allocator.h` is an archetype for these types. There are three types of changes made in this patch: 1. `_Alloc::template rebind<T>::other` -> `__allocator_traits_rebind<_Alloc, T>::type`. This change was made because allocators don't need a rebind template. `__allocator_traits_rebind` is used instead of `allocator_traits::rebind` because use of `allocator_traits::rebind` requires a workaround for when template aliases are unavailable. 2. `a.deallocate(this, 1)` -> `a.deallocate(pointer_traits<self>::pointer_to(*this), 1)`. This change change is made because fancy pointers aren't always constructible from raw pointers. 3. `p.get()` -> `addressof(*p.get())`. Fancy pointers aren't actually a pointer. When we need a "real" pointer we take the address of dereferencing the fancy pointer. This should give us the actual raw pointer. Test Plan: Tests were added using `support/min_allocator.h` to each affected shared_ptr overload and creation function. These tests can only be executed in C++11 or greater since min_allocator is only available then. A extra test was added for the non-variadic versions of allocate_shared. Reviewers: danalbert, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4859 llvm-svn: 220469
* Allow libc++ to be built on systems without POSIX threadsJonathan Roelofs2014-09-051-3/+3
| | | | | | | | | | If you're crazy enough to want this sort of thing, then add -D_LIBCPP_HAS_NO_THREADS to your CXXFLAGS and --param=additiona_features=libcpp-has-no-threads to your lit commnad line. http://reviews.llvm.org/D3969 llvm-svn: 217271
* Fix a typo in the noexcept calculation for __compressed_pair::swap. Thanks ↵Marshall Clow2014-06-301-6/+6
| | | | | | to EricWF for the bug report and the fix. llvm-svn: 212046
* Some calls to get<>() were qualified. Some were not. Qualify them all. Fixes ↵Marshall Clow2014-06-241-8/+8
| | | | | | bug #20092. Thanks to Agustín Bergé for the bug report and the fix. llvm-svn: 211563
* Use __builtin_operator_new/__builtin_operator_delete when available. ThisRichard Smith2014-06-041-4/+4
| | | | | | allows allocations and deallocations to be optimized out. llvm-svn: 210211
* Fix bug #18350. Add tests for tuples of all the smart pointers (except auto_ptr)Marshall Clow2014-04-261-3/+4
| | | | llvm-svn: 207307
* Update synposis in <memory> to show move semantics for weak_ptr; add tests ↵Marshall Clow2014-03-051-0/+4
| | | | | | for already existing move semantics. Mark LWG issues #2315 (no changes needed), 2316 (move semantics for weak_ptr), 2252 (previous commit) and 2271 (previous commit) as complete. llvm-svn: 202931
* Remove default function template argument from the header.Logan Chien2014-01-311-99/+94
| | | | | | | | | | | GCC will treat the default function template arguments as a compilation error if C++0x is not enabled. This commit workaround the compilation error by moving the SFINAE check to function argument instead of the template argument. llvm-svn: 200523
* This fixes a very subtle ABI problem concerning the copy constructor ofHoward Hinnant2013-11-131-29/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pair, and a couple of pair-like implementation detail types. The C++98/03 and 11 standards all specify that the copy constructor of pair<int, int> is trivial. However as libc++ tracked the draft C++11 standard over the years, this copy constructor became non-trivial, and then just recently was corrected back to trivial for C++11. Unfortunately (for libc++1) the Itanium ABI specifies different calling conventions for trivial and non-trivial copy constructors. Therefore currently the C++03 libc++ copy constructor for pair<int, int> is ABI incompatible with the C++11 libc++ copy constructor for pair<int, int>. This is Bad(tm). This patch corrects the situation by making this copy constructor trivial in C++03 mode as well. Just in case it is needed for an incomplete C++11 compiler, libc++ retains the ability to support pair with rvalue references, but without defaulted special members. However the pair needs non-trivial special members to implement this special case, (as it did when clang was in this place a couple of years ago). During this work a bug was also found and fixed in is_trivially_constructible. And there is a minor drive-by fix in <__config> regarding __type_visibility__. A test is updated to ensure that the copy constructor of pair<int, int> is trivial in both C++03 and C++11. This test will necessarily fail for a compiler that implements rvalue references but not defaulted special members. llvm-svn: 194536
* David Chisnall: macro protect 'test' in __has_pointer_type_imp.Howard Hinnant2013-09-211-3/+3
| | | | llvm-svn: 191126
* G M: Make shared_ptr a little more gentle for some compilers. No impact on ↵Howard Hinnant2013-09-131-4/+4
| | | | | | clang. llvm-svn: 190732
* Updated the synopsis for weak_ptr<T>::owner_before to match the code. No ↵Marshall Clow2013-09-031-2/+2
| | | | | | code changes. llvm-svn: 189812
* LWG Issue 2162: mark allocator_traits::maxsize as noexceptMarshall Clow2013-08-271-2/+2
| | | | llvm-svn: 189399
* Nico Rieck: this patch series fixes visibility issues on Windows as ↵Howard Hinnant2013-08-121-37/+37
| | | | | | explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>. llvm-svn: 188192
* My previous reorganization of addressof broke -std=c++03. Thanks much to ↵Howard Hinnant2013-08-081-49/+1
| | | | | | Arnold Schwaighofer for catching this. This patch also catches a few more missing addressof in <future>, thanks go to Zhihao Yuan for catching these. llvm-svn: 187997
* Revert r187927.Arnold Schwaighofer2013-08-081-1/+49
| | | | | | | | Zhihao Yuan: Replace operator& with addressof in reference_wrapper constructor. It breaks a clang bootstrap. llvm-svn: 187959
* Zhihao Yuan: Replace operator& with addressof in reference_wrapper constructor.Howard Hinnant2013-08-071-49/+1
| | | | llvm-svn: 187927
* Matthew Dempsky: Attached patch replaces the type punning with memcpy(), ↵Howard Hinnant2013-07-031-32/+42
| | | | | | | | which on x86/x86-64 clang optimizes to direct word accesses anyway. This fixes an unaligned word access in murmurhash/cityhash. llvm-svn: 185558
* Adorn make_unique with visibility and inline attributesMarshall Clow2013-07-021-0/+2
| | | | llvm-svn: 185468
* Implement n3656 - make_unique. Thanks to Howard for the review and suggestions.Marshall Clow2013-07-011-0/+45
| | | | llvm-svn: 185352
* Minor bug fix for allowing an extension of const-qualified types in containers.Howard Hinnant2013-06-071-1/+1
| | | | llvm-svn: 183481
* Expose accidentally removed __compressed_pair constructor taking ↵Howard Hinnant2013-05-061-20/+20
| | | | | | piecewise_construct_t. This fixes http://llvm.org/bugs/show_bug.cgi?id=15918 . llvm-svn: 181217
* default_delete needs a static_assert against void types. I had previously ↵Howard Hinnant2013-04-241-0/+2
| | | | | | thought that sizeof(void) would take care of this. I was wrong. llvm-svn: 180213
* addressof misbehaving for type with an implicit conversion operator to ↵Howard Hinnant2013-04-161-1/+1
| | | | | | char&. This fixes http://llvm.org/bugs/show_bug.cgi?id=15754 llvm-svn: 179608
* No functionality change at this time. I've split _LIBCPP_VISIBLE up into ↵Howard Hinnant2013-03-061-31/+31
| | | | | | two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute. llvm-svn: 176593
* Alexey Samsonov: #ifdefs out undefined function in static build of libc++ ↵Howard Hinnant2013-02-251-3/+6
| | | | | | w/o RTTI. llvm-svn: 176026
* Fix exception safety bug in vector::push_backHoward Hinnant2013-01-111-1/+4
| | | | llvm-svn: 172250
* Rename uses of _ and __ because these are getting stepped on by macros from ↵Howard Hinnant2012-10-301-15/+15
| | | | | | other system code. llvm-svn: 167038
* Dimitry Andric: many visibility fixes. Howard: Much appreciated. Can you ↵Howard Hinnant2012-09-141-4/+4
| | | | | | send me a patch to CREDITS.TXT? llvm-svn: 163862
* Implement [util.smartptr.shared.atomic]. This is the last unimplementedHoward Hinnant2012-07-301-1/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Appy constexpr to <memory>. Picked up a few missing noexcepts as well.Howard Hinnant2012-07-071-14/+25
| | | | llvm-svn: 159902
* Revert fix to http://llvm.org/bugs/show_bug.cgi?id=12867 for the reason now ↵Howard Hinnant2012-05-191-2/+3
| | | | | | included in the code comment. llvm-svn: 157128
* Protect __shared_weak_count::__get_deleter declaration with _LIBCPP_NO_RTTI. ↵Howard Hinnant2012-05-181-0/+2
| | | | | | Fixes http://llvm.org/bugs/show_bug.cgi?id=12867 llvm-svn: 157049
* Greatly scale back ambitions of emulating move semantics in C++03 mode. It ↵Howard Hinnant2012-05-011-42/+18
| | | | | | was causing more problems than it solved. This fixes http://llvm.org/bugs/show_bug.cgi?id=12704. llvm-svn: 155918
* Modernize conversion to bool to the explicit bool conversion operator ↵Howard Hinnant2012-02-211-6/+7
| | | | | | (library wide). This fixes http://llvm.org/bugs/show_bug.cgi?id=12058. llvm-svn: 151088
* Modernize relational operators for shared_ptr and unique_ptr. This includes ↵Howard Hinnant2012-02-211-2/+227
| | | | | | adding support for nullptr, and using less<T*>. Fixes http://llvm.org/bugs/show_bug.cgi?id=12056. llvm-svn: 151084
* Implement a few optimizations for vector push_back and insert. Fixes r10828365.Howard Hinnant2012-02-151-0/+63
| | | | llvm-svn: 150542
* Enable full functionality of shared_ptr<const void> by adding ↵Howard Hinnant2012-01-191-0/+11
| | | | | | allocator<const void>. Credit to John Hurley for discovering this bug. llvm-svn: 148508
* 1. Fix make_shared<const T>. 2. Allow allocator<const T> as an extension. ↵Howard Hinnant2012-01-021-115/+460
| | | | | | 3. Refactor work which fixed unique_ptr<const T[]>. 4. Remove no-longer-needed private declarations from unique_ptr. 5. Add constraints to some shared_ptr and weak_ptr constructors and assignment operators so that is_constructible/is_assignable give the correct answers for shared_ptr and weak_ptr. 6. Make defensive preparations in the shared_ptr free functions for the introduction of shared_ptr<T[]> in the future. 7. As an optimization, add move constructor and move assignment to weak_ptr. llvm-svn: 147437
* The exception recovery mechanism for the uninitialized_* algorithms did not ↵Howard Hinnant2011-12-291-20/+64
| | | | | | work for iterators into discontiguous memory. llvm-svn: 147343
* Fix http://llvm.org/bugs/show_bug.cgi?id=11616Howard Hinnant2011-12-191-59/+78
| | | | llvm-svn: 146881
* Allow unique_ptr<T const []> to be constructed and assigned from a ↵Howard Hinnant2011-12-181-19/+77
| | | | | | unique_ptr<T[]> llvm-svn: 146853
* Allow unique_ptr<T const []> to be constructed with a T* (in addition to a ↵Howard Hinnant2011-12-161-4/+22
| | | | | | const T*) llvm-svn: 146736
* Fix http://llvm.org/bugs/show_bug.cgi?id=11461. Credit Alberto Ganesh Barbati.Howard Hinnant2011-12-111-2/+10
| | | | llvm-svn: 146345
* Installation of CityHash by Craig SilversteinHoward Hinnant2011-12-101-44/+164
| | | | llvm-svn: 146329
OpenPOWER on IntegriCloud