Commit Graph

300 Commits

Author SHA1 Message Date
Howard Hinnant
6886dd19c4 Loosen up the timing requirements on 4 more tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161289 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-04 00:47:42 +00:00
Howard Hinnant
069bdd52c1 Andrew Morrow: There are two tests under test/utilities/memory that heap allocate two
integers which remain unused and are subsequently leaked, so the test
fail when run under valgrind. Unless I'm overlooking a subtle reason
why they are needed I think they can be removed, allowing these tests
to pass under valgrind. The attached patch removes the variables. If
there is a reason for them to exist, I can change this to just delete
them at the end of the test.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161195 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-02 18:39:48 +00:00
Howard Hinnant
63b2f4f2dc Andrew Morrow: The attached patch updates the lit.config for libc++ unit tests so
that the valgrind configuration passed to lit.py is used to run .pass
tests.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161193 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-02 18:36:47 +00:00
Howard Hinnant
6d39f9f356 Andrew Morrow: This patch fixes
test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
to accept '(nil)' as a valid representation for NULL so that the test
passes on Linux. The same thing is already done in some other tests,
like in /test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161188 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-02 18:12:06 +00:00
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
Howard Hinnant
ca8eb830dd <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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160786 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 17:09:09 +00:00
Howard Hinnant
499c61f999 noexcept and constexpr applied to <mutex>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160604 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-21 16:13:09 +00:00
Howard Hinnant
f57bd564fd noexcept and constexpr applied to <ios>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160593 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-21 01:03:40 +00:00
Howard Hinnant
410f2def47 constexpr applied to <complex>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160585 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 22:18:27 +00:00
Howard Hinnant
fe4c9dd747 Relax the tolerances on some timing tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160566 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 19:48:05 +00:00
Howard Hinnant
d06a640ba7 noexcept applied to <iterator>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160565 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 19:36:34 +00:00
Howard Hinnant
08bce1754d constexpr applied to <array>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160564 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 19:20:49 +00:00
Howard Hinnant
c425307238 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>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160285 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-16 16:17:34 +00:00
Howard Hinnant
473f838128 Applied constexpr to <chrono>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160184 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-13 19:17:27 +00:00
Howard Hinnant
1ca23672a0 Fixed a bug in wstring_convert concerning zero-length inputs. Thanks to Jonathan Coxhead for reporting this bug.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160136 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 18:07:41 +00:00
Howard Hinnant
d586248597 Add test for self-referencing emplace test.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159921 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-09 02:47:43 +00:00
Howard Hinnant
90d8723476 Apply constexpr to <bitset>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159899 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-07 17:04:52 +00:00
Howard Hinnant
5394c1ed30 Give tuple a constexpr default constructor.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159857 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06 20:39:45 +00:00
Howard Hinnant
71499ad176 Add noexcept test for offsetof macro per [support.types]/p4.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159846 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06 18:39:01 +00:00
Howard Hinnant
7a44515588 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159836 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06 17:31:14 +00:00
Howard Hinnant
caee2b093f Fix a few testsuite bugs involving trailing null (or lack thereof) in strstream.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@157832 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-01 20:02:59 +00:00
Howard Hinnant
635ce1d127 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()).
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@157503 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-25 22:04:21 +00:00
Richard Smith
9efdc0bd5f libc++: Add some missing #includes to atomics tests. libc++ doesn't need these
at the moment, but they allow these tests to be used to test clang against
libstdc++. Add myself to the credits file, as suggested by Howard.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@155085 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-19 00:50:47 +00:00
David Chisnall
d3eca759a2 Fix the remaining atomic tests, all of which were wrong for the case where a
compare-and-exchange failed (it should update the expected value to the current
value, and the tests were checking that it didn't...).

Results of the atomics part of the test suite on FreeBSD with clang trunk and
the atomic.c from compiler-rt (currently kludged into the test, not installed
properly):

****************************************************
Results for /root/libc++/test/atomics:
using clang version 3.1 (trunk 153415)
Target: x86_64-unknown-freebsd10.0
Thread model: posix
with -std=c++0x -stdlib=libc++ -pthread /tmp/atomic.o  
----------------------------------------------------
sections without tests   : 0
sections with failures   : 0
sections without failures: 14
                       +   ----
total number of sections : 14
----------------------------------------------------
number of tests failed   : 0
number of tests passed   : 52
                       +   ----
total number of tests    : 52
****************************************************

Yay!



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@154095 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-05 13:48:16 +00:00
David Chisnall
1ee87fa41a Fix test cases that were trying to make atomic things that are not trivially copyable.
Now all of the test cases compile.  Some of them even run!



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@154094 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-05 13:23:08 +00:00
Howard Hinnant
8efd3dac5d Update <random> with constexpr support. Patch contributed by Jonathan Sauer.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@153896 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-02 21:00:45 +00:00
Howard Hinnant
2cf89a71df Fix test for default constructor of discrete_distribution. This partially addresses http://llvm.org/bugs/show_bug.cgi?id=12436.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@153873 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-02 15:00:14 +00:00
Howard Hinnant
dc1345fd44 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@153855 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-01 23:10:42 +00:00
Howard Hinnant
87c61a61fe 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@153036 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-19 15:40:23 +00:00
David Chisnall
b407d45d83 Don't refer to a function that doesn't exist in the quick_exit test.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@152716 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-14 14:02:15 +00:00
Jeffrey Yasskin
558ae17391 Fix moneypunct_byname algorithm to more accurately represent C locales in C++.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@152501 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-10 18:31:43 +00:00
David Chisnall
f2b2cc6440 Make the failure reporting in testit a bit more useful.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@151719 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-29 13:00:44 +00:00
Howard Hinnant
a231c37df7 update test for explicit bool operator.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@151461 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-25 21:43:14 +00:00
Howard Hinnant
896baa2547 Silence some warnings in a test.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@151451 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-25 20:04:11 +00:00
Howard Hinnant
4300839b5f 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@151406 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-24 23:32:26 +00:00
Dave Zarzycki
b9344c218b Use Xcode relative compilers when possible
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@151108 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-22 00:20:30 +00:00
Howard Hinnant
3fadda314a 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@151084 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-21 21:02:58 +00:00
Howard Hinnant
6df1412ca6 Relax pointer output test to accept glibc's output. Patch supplied by Jeffrey Yasskin.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@150927 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-19 14:51:01 +00:00
Howard Hinnant
01198b313c Exercise rvalue arguements to make_shared for C++11 mode.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@150887 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-18 20:12:03 +00:00
Howard Hinnant
2848444954 tuple was accidentally lacking a valid copy assignment operator. It went undetected because I had failed to test assigning from a const lvalue. This fixes http://llvm.org/bugs/show_bug.cgi?id=11921
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@150613 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-15 20:13:52 +00:00
Howard Hinnant
b04ad4162d Do not parse sign if a sign is not the next legal character when parsing floating point from an input stream. Fixes http://llvm.org/bugs/show_bug.cgi?id=11871
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@150609 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-15 19:19:37 +00:00
Howard Hinnant
8e50a9cf73 Remove quotes from locale name identifier. Credit Edward Meewis.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@146655 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-15 15:01:38 +00:00
Howard Hinnant
40c13d31c5 Starting using murmur2 when combining multiple size_t's into a single hash, and also for basic_string. Also made hash<thread::id> ever so slighly more portable. I had to tweak one test which is questionable (definitely not portable) anyway.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145795 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-05 00:08:45 +00:00
Howard Hinnant
f836d531b4 unord test fixes by Edward Meewis
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145707 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-02 21:23:14 +00:00
Howard Hinnant
f6d875f7f5 Fix http://llvm.org/bugs/show_bug.cgi?id=11428. Fix provided by Alberto Ganesh Barbati
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145698 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-02 19:36:40 +00:00
Howard Hinnant
ce6884cc76 Fix ratio arithmetic with zero
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@143519 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-01 23:13:37 +00:00
Howard Hinnant
b97de44471 Fix <rdar://problem/10256836> getline of an empty string mistakenly causes failure
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@141506 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-09 15:20:46 +00:00
Howard Hinnant
c6fe8cafc3 Fix <rdar://problem/10255403> match_results::begin() is off by one
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@141494 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-08 14:36:16 +00:00
Howard Hinnant
c0d0cbad9e Windows porting work by Ruben Van Boxem
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@141003 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-03 15:23:59 +00:00
Howard Hinnant
8452d21f41 Updated testit to run on Windows and fresh Windows results by Ruben Van Boxem
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@140950 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-01 15:34:27 +00:00