Commit Graph

779 Commits

Author SHA1 Message Date
Howard Hinnant
7eb9f1e3a3 Align <atomic> with clang r163964 which disallows const _Atomic types.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@164004 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-16 20:33:09 +00:00
Howard Hinnant
6cb977bf0c Update CREDITS.TXT
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@163949 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-14 23:28:54 +00:00
Howard Hinnant
33be35effe Dimitry Andric: many visibility fixes. Howard: Much appreciated. Can you send me a patch to CREDITS.TXT?
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@163862 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-14 00:39:16 +00:00
Howard Hinnant
5c90cbad38 Dimitry Andric: FreeBSD porting tweaks for PTHREAD_MUTEX_INITIALIZER and PTHREAD_COND_INITIALIZER
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@163626 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-11 16:10:20 +00:00
Howard Hinnant
460b4cadde Some minor mingw64 porting tweaks from Glen.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@163120 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-03 18:13:11 +00:00
Howard Hinnant
cf115d2cc6 Change sleep_for, sleep_until, and the condition_variable timed wait
functions to protect against duration and time_point overflow.  Since
we're about to wait anyway, we can afford to spend a few more cycles on
this checking.  I purposefully did not treat the timed try_locks with
overflow checking.  This fixes
http://llvm.org/bugs/show_bug.cgi?id=13721 .  I'm unsure if the standard
needs clarification in this area, or if this is simply QOI.  The
<chrono> facilities were never intended to overflow check, but just to
not overflow if durations stayed within +/- 292 years.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162925 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-30 19:14:33 +00:00
Howard Hinnant
c417a802ed Hyeon-bin Jeong: libc++ fails to create any classes inherit from basic_ios if they
provided char type other than char or wchar_t. It throw exception during
construction, so there is no chance to imbue own ctype.

This fixes http://llvm.org/bugs/show_bug.cgi?id=13698

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162648 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-26 18:05:35 +00:00
Howard Hinnant
70e441a9b0 Update CREDITS.TXT
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162647 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-26 17:46:29 +00:00
Howard Hinnant
a5160283a4 Michel Morin: My previous fix for C++03 was incomplete.
It does not consider user-defined conversions that convert an rvalue
into an lvalue and works incorrectly for types with such a conversion
operator.
For example, 

    struct foo
    {
        operator int&();
    };

 returns false_type. 
Attached a patch that fixes this problem. 
http://llvm.org/bugs/show_bug.cgi?id=13601

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162644 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-25 15:06:50 +00:00
Howard Hinnant
3882d397c4 Wrap throw in _LIBCPP_NO_EXCEPTIONS in debug.cpp. Calls abort if can't throw an exception. Fixes http://llvm.org/bugs/show_bug.cgi?id=13082.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162613 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 22:15:12 +00:00
Howard Hinnant
37bdf0e6bd Have basic_istream seekg, putback and unget first clear eofbit. Fixes http://llvm.org/bugs/show_bug.cgi?id=13089.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162608 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 22:03:03 +00:00
Howard Hinnant
d57de091c3 Add Hyeon-bin Jeong to CREDITS.TXT
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162604 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 21:45:19 +00:00
Howard Hinnant
d305d3c1a2 Hyeon-Bin Jeong: 1. sync() should reset it’s external buffer pointers.
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162601 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 21:20:56 +00:00
Howard Hinnant
ec423cb8d4 Fix basic_filebuf's internal buffer is shrinking when using with some codecvt. http://llvm.org/bugs/show_bug.cgi?id=13602
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162585 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 20:37:00 +00:00
Howard Hinnant
e7d59f2601 Fixed order of calling use_facet vs setbuf in basic_filebuf default constructor.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162571 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 18:06:47 +00:00
Howard Hinnant
8540d4c9d2 basic_filebuf needs to delay obtaining a codecvt facet from the global locale to give the client a chance to imbue the proper locale. Fixes http://llvm.org/bugs/show_bug.cgi?id=13663.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162567 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-24 16:52:47 +00:00
Marshall Clow
08a0b48c09 Fix a typo in the docs
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162335 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-22 00:57:11 +00:00
Howard Hinnant
ffab05833f In C++03 mode add an explicit conversion from int to the emulated class enum. Fixes a problem reported by C. Bergström.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162189 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-19 17:14:47 +00:00
Howard Hinnant
96c60b482e Patch contributed by Dev Dude for mingw64 port.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162188 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-19 15:13:16 +00:00
Howard Hinnant
a0852ffbe8 Apply patches supplied by Michel Morin in 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162111 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-17 17:54:11 +00:00
Howard Hinnant
4ae952ab9a Consistently label __bit_array as a struct, not a class.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162108 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-17 17:10:18 +00:00
Howard Hinnant
364e94575b Remove obsolete do-installhdrs target (again).
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161761 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-13 16:32:15 +00:00
Howard Hinnant
2a03b71f09 Remove obsolete do-installhdrs target.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161760 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-13 16:17:12 +00:00
Howard Hinnant
e87514aa94 Patch constributed by Michel Moren in http://llvm.org/bugs/show_bug.cgi?id=13592 . Fixes is_convertible<From, To> when To is an abstract type.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161755 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-13 12:29:17 +00:00
Howard Hinnant
4490c4aaed Change size of reference count field in __libcpp_nmstr from 32 bits to 64 bits for 64 bit targets. This is controls the data layout of all exceptions defined in <stdexcept>. This aligns the ABI with that of gcc-4.2.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161497 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-08 16:17:31 +00:00
Howard Hinnant
584db4287b std::equal operating on non-const __bit_iterators was not working. This fixes it.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161309 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-05 21:43:11 +00:00
Howard Hinnant
e103a3d69b Andrew Morrow: The current CMake setup for libc++ incorrectly uses the variable
LLVM_ENABLE_ASSERTIONS instead of LIBCXX_ENABLE_ASSERTIONS when
figuring out what _DEBUG/NDEBUG defines to set. It also tries to test
the non-existent variable 'uppercase_CMAKE_BUILD_TYPE', which the top
level LLVM CMakeLists.txt sets up, but which the top level libc++
CMakeLists.txt currently does not. Changing the variable name tested
and creating the uppercase release name variable allows libc++ to
honor the LIBCXX_ENABLE_ASSERTIONS option correctly.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161308 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-05 17:37:39 +00:00
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
4b2f4203a2 Performance tweaking rotate.
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).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161247 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-03 18:01:20 +00:00
Howard Hinnant
cd99236231 Andrew Morrow: The attached patch updates the initialization of the 'struct tm' in
__time_get_storage<char> to match the initialization behavior in
__time_get_storage<wchar>. Without the initialization, valgrind
reports errors in the subsequent calls to strftime_l.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161196 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-02 18:44:17 +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
ef793f2513 Andrew Morrow: Among the various libc++ tests that currently don't pass on Linux are
localization/locale.categories/category.collate/category.ctype/locale.ctype.byname/is_1.pass.cpp
and scan_is.pass.cpp. The tests fail when the character class being
tested is compound, like ctype_base::alnum or ctype_base::graph,
because the existing series of conditionals in do_is an do_scan_is
will abort too early. For instance, if the character class being
tested is alnum, and the character is numeric, do_is will return false
because iswalpha_l will return false, 'result' becomes false, and the
'true' result from the later call to iswdigit_l ends up being ignored
. A similar problem exists in do_scan_is.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161192 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-02 18:35:07 +00:00
Howard Hinnant
403f91ad2c Andrew Morrow: The attached patch is an attempt to implement
std:🧵:hardware_concurrency for platforms that don't offer
sysctl, but do provide a POSIX sysconf and _SC_NPROCESSORS_ONLN.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161190 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-02 18:17:49 +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
ee7a0bf265 Andrew Morrow: Attached is a writeup of the current state of the libc++ test suite on Linux.
There are a few tests that are listed as failing here for which I have
a patch in the works. I'll be sending those along soon. There are
others where I know what is going on but don't yet have a solution,
and I've included some notes for those. Several still need to be
investigated, mostly in localization and the regex test suite. I think
that many of these failures are due to locale implementation
variations that make the expected test results not match the actual
results. I'm not sure what the best way to make the tests accomodate
this sort of variation might be.

The failures in the unique_ptr test suite are very new and are caused
by a clang crash which I've not yet looked into.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161079 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-31 21:30:28 +00:00
Howard Hinnant
65f059b842 Despite my pathological distrust of spin locks, the number just don't lie. I've put a small spin in __sp_mut::lock() on std::mutex::try_lock(), which is testing quite well. In my experience, putting in a yield for every failed iteration is also a major performance booster. This change makes one of the performance tests I was using (a highly contended one) run about 20 times faster.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160967 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-30 17:13:21 +00:00
Howard Hinnant
7a7b6d8283 Updated status
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160959 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-30 13:59:36 +00:00
Howard Hinnant
30055c68d4 Updated the complete by-chapter graph
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160943 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-30 02:29:34 +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
116ce6a312 Update CREDITS.TXT
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160812 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 20:22:37 +00:00
Howard Hinnant
afcac1ac46 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
/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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160799 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 20:01:13 +00:00
Howard Hinnant
8b5bb3c5af Patch by Andrew C. Morrow: Conditionally include cxxabi.h in new.cpp and typeinfo.cpp. Both new.cpp and typeinfo.cpp have code that is conditionally compiled
based on the LIBCXXRT and _LIBCPPABI_VERSION defines, but those files
do not currently include <cxxabi.h> in the non __APPLE__ case. The
attached patch updates those files so that for non __APPLE__ builds
<cxxabi.h> is included if available or if LIBCXXRT is set. I'm
modeling this on the recent updates to exception.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160790 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 17:42:39 +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
f3d62ea57f locale::id really needs to be constructed at compile time.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160785 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 16:14:37 +00:00
Richard Smith
0405cc4ae0 libc++: switch from using _ATTRIBUTE(noreturn) (which conflicts with a
platform-provided macro on some systems) to _LIBCPP_NORETURN.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160773 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 02:04:22 +00:00
Howard Hinnant
8131a01a9c 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160608 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-21 19:34:12 +00:00
Howard Hinnant
8bf01ddd30 noexcept applied to <future>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160607 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-21 17:46:55 +00:00
Howard Hinnant
6e1d851be8 noexcept applied to <thread>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160606 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-21 16:50:47 +00:00
Howard Hinnant
c8f7413908 noexcept applied to <condition_variable>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@160605 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-21 16:32:53 +00:00