summaryrefslogtreecommitdiffstats
path: root/libcxx/include
Commit message (Collapse)AuthorAgeFilesLines
...
* Hyeon-Bin Jeong: 1. sync() should reset it’s external buffer pointers. Howard Hinnant2012-08-241-23/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remaining characters should be discarded once sync() called. If don’t, garbage characters can be inserted to the front of external buffer in underflow(). Because underflow() copies remaining characters in external buffer to it’s front. This results wrong characters insertion when seekpos() or seekoff() is called. this line should be inserted in sync() just before return: __extbufnext_ = __extbufend_ = __extbuf_; 2. sync() should use length() rather than out() to calculate offset. Reversing iterators and calling out() to calculate offset from behind is working fine in stateless character encoding. However, in stateful encoding, escape sequences could differ in length. As a result, out() could return wrong length. For example, if we have internal buffer converted from this external sequence: (capital letters mean escape sequence) … a a a a B b b b b out() produces this sequence. b b b b A a a a a Because out() inserts escape sequence A rather than B, result sequence doesn't match to external sequence. A and B could have different lengths, result offset could be wrong value too. length() method in codecvt is right for calculating offset, but it counts offset from the beginning of buffer. So it requires another state member variable to hold state before conversion. Fixes http://llvm.org/bugs/show_bug.cgi?id=13667 llvm-svn: 162601
* Fix basic_filebuf's internal buffer is shrinking when using with some ↵Howard Hinnant2012-08-241-2/+3
| | | | | | codecvt. http://llvm.org/bugs/show_bug.cgi?id=13602 llvm-svn: 162585
* Fixed order of calling use_facet vs setbuf in basic_filebuf default constructor.Howard Hinnant2012-08-241-1/+1
| | | | llvm-svn: 162571
* basic_filebuf needs to delay obtaining a codecvt facet from the global ↵Howard Hinnant2012-08-241-2/+23
| | | | | | locale to give the client a chance to imbue the proper locale. Fixes http://llvm.org/bugs/show_bug.cgi?id=13663. llvm-svn: 162567
* In C++03 mode add an explicit conversion from int to the emulated class ↵Howard Hinnant2012-08-191-0/+2
| | | | | | enum. Fixes a problem reported by C. Bergström. llvm-svn: 162189
* Patch contributed by Dev Dude for mingw64 port.Howard Hinnant2012-08-191-1/+1
| | | | llvm-svn: 162188
* Apply patches supplied by Michel Morin in ↵Howard Hinnant2012-08-171-4/+8
| | | | | | http://llvm.org/bugs/show_bug.cgi?id=13601 to correct bugs in is_convertible for the case that the intrinsic __is_convertible_to is not available. llvm-svn: 162111
* Consistently label __bit_array as a struct, not a class.Howard Hinnant2012-08-172-3/+3
| | | | llvm-svn: 162108
* Patch constributed by Michel Moren in ↵Howard Hinnant2012-08-131-1/+2
| | | | | | http://llvm.org/bugs/show_bug.cgi?id=13592 . Fixes is_convertible<From, To> when To is an abstract type. llvm-svn: 161755
* std::equal operating on non-const __bit_iterators was not working. This ↵Howard Hinnant2012-08-051-14/+14
| | | | | | fixes it. llvm-svn: 161309
* Performance tweaking rotate.Howard Hinnant2012-08-031-27/+84
| | | | | | | | | | | | | | | | | | | | | | rotate is a critical algorithm because it is often used by other algorithms, both std and non-std. The main thrust of this optimization is a specialized algorithm when the 'distance' to be shifted is 1 (either left or right). To my surprise, this 'optimization' was not effective for types like std::string. std::string favors rotate algorithms which only use swap. But for types like scalars, and especially when the sequence is random access, these new specializations are a big win. If it is a vector<size_t> for example, the rotate is done via a memmove and can be several times faster than the gcd algorithm. I'm using is_trivially_move_assignable to distinguish between types like int and types like string. This is obviously an ad-hoc approximation, but I haven't found a case where it doesn't give good results. I've used a 'static if' (with is_trivially_move_assignable) in three places. Testing with both -Os and -O3 showed that clang eliminated all code not be executed by the 'static if' (including the 'static if' itself). llvm-svn: 161247
* 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
* Patch by Andrew C. Morrow: shims to work around macroized getc and putc on ↵Howard Hinnant2012-07-261-0/+12
| | | | | | | | | linux. On my eglibc 2.13 based Debian system 'getc' is a macro defined in /usr/include/stdio.h. This decision to make it a macro doesn't seem to be guarded by any feature test macro as far as I can see. llvm-svn: 160799
* <algorithm> no longer needs to include <cstdlib>, but can get away with just ↵Howard Hinnant2012-07-261-1/+1
| | | | | | <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. llvm-svn: 160786
* locale::id really needs to be constructed at compile time.Howard Hinnant2012-07-261-1/+1
| | | | llvm-svn: 160785
* libc++: switch from using _ATTRIBUTE(noreturn) (which conflicts with aRichard Smith2012-07-262-11/+11
| | | | | | platform-provided macro on some systems) to _LIBCPP_NORETURN. llvm-svn: 160773
* Apple LWG 2067: ↵Howard Hinnant2012-07-211-6/+6
| | | | | | 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. llvm-svn: 160608
* noexcept applied to <future>.Howard Hinnant2012-07-211-124/+124
| | | | llvm-svn: 160607
* noexcept applied to <thread>.Howard Hinnant2012-07-211-37/+37
| | | | llvm-svn: 160606
* noexcept applied to <condition_variable>.Howard Hinnant2012-07-212-10/+10
| | | | llvm-svn: 160605
* noexcept and constexpr applied to <mutex>.Howard Hinnant2012-07-212-45/+48
| | | | llvm-svn: 160604
* noexcept and constexpr applied to <regex>.Howard Hinnant2012-07-211-29/+28
| | | | llvm-svn: 160594
* noexcept and constexpr applied to <ios>.Howard Hinnant2012-07-211-35/+35
| | | | llvm-svn: 160593
* noexcept applied to <valarray>.Howard Hinnant2012-07-211-11/+11
| | | | llvm-svn: 160592
* constexpr applied to <complex>.Howard Hinnant2012-07-201-21/+21
| | | | llvm-svn: 160585
* noexcept applied to <random>.Howard Hinnant2012-07-201-8/+8
| | | | llvm-svn: 160579
* noexcept applied to <iterator>.Howard Hinnant2012-07-201-14/+14
| | | | llvm-svn: 160565
* constexpr applied to <array>.Howard Hinnant2012-07-201-4/+4
| | | | llvm-svn: 160564
* constexpr applied to <string>.Howard Hinnant2012-07-201-42/+44
| | | | llvm-svn: 160563
* Further tweaks on relaxing complete type checking for function.Howard Hinnant2012-07-202-15/+16
| | | | llvm-svn: 160562
* Relax the complete-type checks that are happening under __invokable<Fp, ↵Howard Hinnant2012-07-161-1/+1
| | | | | | 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>. llvm-svn: 160285
* Applied constexpr to <chrono>.Howard Hinnant2012-07-131-52/+75
| | | | llvm-svn: 160184
* Fixed a bug in wstring_convert concerning zero-length inputs. Thanks to ↵Howard Hinnant2012-07-121-2/+4
| | | | | | Jonathan Coxhead for reporting this bug. llvm-svn: 160136
* Change emplace for vector and deque to create the temporary (when necessary) ↵Howard Hinnant2012-07-082-3/+6
| | | | | | before any changes to the container are made. Nikolay Ivchenkov deserves the credit for pushing this problem and the solution for it. llvm-svn: 159918
* Appy constexpr to <memory>. Picked up a few missing noexcepts as well.Howard Hinnant2012-07-072-14/+29
| | | | llvm-svn: 159902
* Apply constexpr to the mutex constructor. As a conforming extension, apply ↵Howard Hinnant2012-07-071-0/+8
| | | | | | constexpr to the condition_variable constructor. These are important because it enables the compiler to construct these types at compile time, even though the object will be non-const. Since they are constructed at compile time, there is no chance of a data race before they are constructed. llvm-svn: 159901
* Apply constexpr to <bitset>.Howard Hinnant2012-07-072-14/+39
| | | | llvm-svn: 159899
* Apply noexcept to tuple.Howard Hinnant2012-07-061-24/+48
| | | | llvm-svn: 159865
* As a conforming extension give tuple a noexcept default constructor ↵Howard Hinnant2012-07-061-5/+9
| | | | | | conditionalized on its held types. llvm-svn: 159858
* Give tuple a constexpr default constructor.Howard Hinnant2012-07-061-3/+9
| | | | llvm-svn: 159857
* Apply noexcept to those functions implemented in <cstdlib> as a conforming ↵Howard Hinnant2012-07-061-4/+4
| | | | | | extension. llvm-svn: 159850
* Apply noexcept to those functions implemented in <cmath> as a conforming ↵Howard Hinnant2012-07-061-195/+195
| | | | | | extension. llvm-svn: 159849
* This commit establishes a new bucket_count policy in the unordered ↵Howard Hinnant2012-07-061-39/+64
| | | | | | 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. llvm-svn: 159836
* mark operator new(std::nothrow) as noalias (aka __attribute__((malloc))Nuno Lopes2012-06-282-2/+8
| | | | llvm-svn: 159359
* Fixed a bug regarding result_of reported by Sven Behne. The fix is C++11 ↵Howard Hinnant2012-06-261-66/+8
| | | | | | only mainly because result_of is a variadic beast and working with variadics is just such a problem in C++03 mode. This should bring result_of up to full conformance with the C++11 spec. llvm-svn: 159211
* Revert pair constructors back to using is_convertible instead of ↵Howard Hinnant2012-06-091-6/+6
| | | | | | is_constructible. This should pull things into alignment with the final draft. Fixes http://llvm.org/bugs/show_bug.cgi?id=13063#add_comment. llvm-svn: 158280
* Fix dangling else clause. Bug found and fixed by Dimitry Andric.Howard Hinnant2012-05-311-0/+4
| | | | llvm-svn: 157779
* Fix the new _ALIGNAS_TYPE per instructions supplied by Eli Friedman.Howard Hinnant2012-05-311-1/+1
| | | | llvm-svn: 157765
* Protect use of alignas against older versions of clangHoward Hinnant2012-05-311-0/+2
| | | | llvm-svn: 157764
* The rules for emplace in map, multimap, unordered_map and unordered_multimap ↵Howard Hinnant2012-05-252-246/+252
| | | | | | 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()). llvm-svn: 157503
OpenPOWER on IntegriCloud