summaryrefslogtreecommitdiffstats
path: root/libcxx/src
Commit message (Collapse)AuthorAgeFilesLines
* [solaris] Convert the support library to C++ to fix -std=c++11 buildMichal Gorny2016-10-181-0/+3
| | | | | | | | | | | Convert the Solaris xlocale.c compatibility library from plain C to C++ in order to fix the build failures caused by the addition of -std=c++11 to LIBCXX_COMPILE_FLAGS. The additional flag got propagated to the C file, resulting in error with strict compilers. Differential Revision: https://reviews.llvm.org/D25431 llvm-svn: 284494
* [solaris] Fix iswxdigit_l() support function prototypeMichal Gorny2016-10-181-1/+1
| | | | | | | | | Fix the iswxdigit_l() function prototype to take wint_t parameter instead of incorrect wchar_t. Differential Revision: https://reviews.llvm.org/D25431 llvm-svn: 284493
* Implement LWG 2712 and update other issues statusEric Fiselier2016-10-161-0/+6
| | | | llvm-svn: 284318
* Implement LWG 2681 and 2682Eric Fiselier2016-10-161-0/+3
| | | | llvm-svn: 284316
* Implement LWG 2672.Eric Fiselier2016-10-151-5/+17
| | | | llvm-svn: 284314
* Implement modified LWG 2665Eric Fiselier2016-10-151-0/+10
| | | | llvm-svn: 284313
* Implement P0035R4 -- Add C++17 aligned allocation functionsEric Fiselier2016-10-141-8/+118
| | | | | | | | | | | | | | | | Summary: This patch implements the library side of P0035R4. The implementation is thanks to @rsmith. In addition to the C++17 implementation, the library implementation can be explicitly turned on using `-faligned-allocation` in all dialects. Reviewers: mclow.lists, rsmith Subscribers: rsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D25591 llvm-svn: 284206
* Revert r284193 - it is not correct on OS XEric Fiselier2016-10-141-3/+0
| | | | llvm-svn: 284194
* Re-export two previously exported std::string functions.Eric Fiselier2016-10-141-0/+3
| | | | | | | These functions were removed from the dylib sometime between the 3.9 release and now. This patch manually exports them to re-gain ABI compatibility. llvm-svn: 284193
* Revert r282345 - Use __attribute__((internal_linkage)) when available.Eric Fiselier2016-10-131-23/+0
| | | | llvm-svn: 284101
* Implement N4606 optionalEric Fiselier2016-10-121-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adapt implementation of Library Fundamentals TS optional into an implementation of N4606 optional. - Update relational operators per http://wg21.link/P0307 - Update to requirements of http://wg21.link/P0032 - Extension: Implement trivial copy/move construction/assignment for `optional<T>` when `T` is trivially copyable. Audit P/Rs for optional LWG issues: - 2756 "C++ WP optional<T> should 'forward' T's implicit conversions" Implemented, which also resolves 2753 "Optional's constructors and assignments need constraints" (modulo my refusal to explicitly delete the move operations, which is a design error that I'm working on correcting in the 2756 P/R). - 2736 "nullopt_t insufficiently constrained" Already conforming. I've added a test ensuring that `nullopt_t` is not copy-initializable from an empty braced-init-list, which I believe is the root intent of the issue, to avoid regression. - 2740 "constexpr optional<T>::operator->" Already conforming. - 2746 "Inconsistency between requirements for emplace between optional and variant" No P/R, but note that the author's '"suggested resolution" is already implemented. - 2748 "swappable traits for optionals" Already conforming. - 2753 "Optional's constructors and assignments need constraints" Implemented. Most of the work for this patch was done by Casey Carter @ Microsoft. Thank you Casey! Reviewers: mclow.lists, CaseyCarter, EricWF Differential Revision: https://reviews.llvm.org/D22741 llvm-svn: 283980
* Revert Add <optional>. Will recommit with better commit messageEric Fiselier2016-10-121-6/+6
| | | | llvm-svn: 283978
* Add <optional> header.Eric Fiselier2016-10-121-6/+6
| | | | | | | | This patch is largely thanks to Casey Carter @ Microsoft. He did the initial work of porting our experimental implementation and tests over to namespace std. llvm-svn: 283977
* Fix LWG2683 - filesystem::copy() should always clear the user-provided ↵Eric Fiselier2016-10-111-6/+2
| | | | | | error_code llvm-svn: 283951
* [libcxx] Add support for FuchsiaPetr Hosek2016-10-101-0/+2
| | | | | | | | | Fuchsia is a new operating system which uses musl as the standard C library, libc++ and libc++abi as the C++ standard library. Differential Revision: https://reviews.llvm.org/D25414 llvm-svn: 283788
* Workaround missing C++14 constexpr semantics in filesystemEric Fiselier2016-10-101-5/+12
| | | | llvm-svn: 283714
* Remove use of int128_t inside the filesystem implementationEric Fiselier2016-10-101-30/+118
| | | | llvm-svn: 283712
* Partially revert overflow checking in last_write_timeEric Fiselier2016-09-291-5/+7
| | | | llvm-svn: 282660
* Mark libc++ internal globals with _LIBCPP_SAFE_STATIC.Eric Fiselier2016-09-284-14/+12
| | | | | | | | | | | | | This patch applies the _LIBCPP_SAFE_STATIC attribute to internal globals, most of which are locking primitives, in order to ensure that they can safely be used during program startup. This patch also fixes an unsafe static init issue with the global locks used to implement atomic operations on shared pointers. Previously the locks were initialized using a dynamically initialized pointer, so it was possible that the pointer was uninitialized. llvm-svn: 282640
* Improve 'last_write_time(...)' accuracy and detect overflow errors.Eric Fiselier2016-09-281-5/+35
| | | | | | | | | | | | | | | | | The ::stat struct on Linux, FreeBSD, and OS X provides the access and modification times as an instance of 'timespec', which has a nanosecond resolution. The 'st_mtime' and 'st_atime' members simply reference the 'tv_sec' value of the timespec struct. This patch changes 'last_write_time(...)' so that it extracts both the seconds and nanoseconds values of the last modification time, providing a more accurate implementation of 'last_write_time(...)'. Additionally this patch fixes a possible signed integer overflow bug. The 'file_time_type' type cannot represent all possible values returned by the filesystem. Attempting to construct a 'file_time_type' from one of these values is undefined behavior. This patch avoids that UB by detecting possible overflows before the conversion. llvm-svn: 282634
* Fix possible division by zeroEric Fiselier2016-09-271-1/+1
| | | | llvm-svn: 282468
* Use __attribute__((internal_linkage)) when available.Eric Fiselier2016-09-251-0/+23
| | | | | | | | | | | | | | | | | | | | | Summary: This patch has been a long time coming (Thanks @eugenis). It changes `_LIBCPP_INLINE_VISIBILITY` to use `__attribute__((internal_linkage))` instead of `__attribute__((visibility("hidden"), always_inline))`. The point of `_LIBCPP_INLINE_VISIBILITY` is to prevent inline functions from being exported from both the libc++ library and from user libraries. This helps libc++ better manage it's ABI. Previously this was done by forcing inlining and modifying the symbols visibility. However inlining isn't guaranteed and symbol visibility only affects shared libraries making this an imperfect solution. `internal_linkage` improves this situation by making all symbols local to the TU they are emitted in, regardless of inlining or visibility. IIRC the effect of applying `__attribute__((internal_linkage))` to an inline function is the same as applying `static`. For more information about the attribute see: http://lists.llvm.org/pipermail/cfe-dev/2015-October/045580.html Most of the work for this patch was done by @eugenis. Reviewers: mclow.lists, eugenis Subscribers: eugenis, cfe-commits Differential Revision: https://reviews.llvm.org/D24642 llvm-svn: 282345
* [libc++] Fix extern template visibility for WindowsShoaib Meenai2016-09-193-55/+55
| | | | | | | | | | On Windows, marking an `extern template class` declaration as exported actually forces an instantiation, which is not the desired behavior. Instead, the actual explicit instantiations need to be exported. Differential Revision: https://reviews.llvm.org/D24679 llvm-svn: 281925
* Replace __ANDROID__ with __BIONIC__.Dan Albert2016-09-191-1/+1
| | | | | | | | | | | | | | | Summary: None of these checks are specific to Android devices. If libc++ was used with Bionic on a normal Linux system these checks would still be needed. Reviewers: mclow.lists, EricWF Subscribers: compnerd, tberghammer, danalbert, srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D24690 llvm-svn: 281921
* [libc++] Avoid <memory> include in locale_win32.hShoaib Meenai2016-09-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | When `_LIBCPP_NO_EXCEPTIONS` is defined, we end up with compile errors when targeting MSVCRT: * Code includes `<new>` * `<new>` includes `<cstdlib>` in order to get `abort` * `<cstdlib>` includes `<stdlib.h>`, _before_ the `using ::abort` * `<stdlib.h>` includes `locale_win32.h` * `locale_win32.h` includes `<memory>` * `<memory>` includes `<stdexcept>` * `<stdexcept>` includes `<cstdlib` for `abort`, but that inclusion gets (correctly) ignored because of header guards * `<stdexcept>` references `_VSTD::abort`, which isn't declared The easiest solution is to make `locale_win32.h` not include `<memory>`, by removing the use of `unique_ptr` and manually restoring the locale instead. Differential Revision: https://reviews.llvm.org/D24374 llvm-svn: 281641
* [libcxx] Fix a data race in call_onceKuba Brecka2016-09-041-4/+1
| | | | | | | | call_once is using relaxed atomic load to perform double-checked locking, which contains a data race. The fast-path load has to be an acquire atomic load. Differential Revision: https://reviews.llvm.org/D24028 llvm-svn: 280621
* Fix PR30202 - notify_all_at_thread_exit seg faults if run from a raw pthread ↵Eric Fiselier2016-09-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | context. Summary: This patch allows threads not created using `std::thread` to use `std::notify_all_at_thread_exit` by ensuring the TL state has been initialized within `std::notify_all_at_thread_exit`. Additionally this patch "fixes" a potential oddity in `__thread_local_pointer::reset(pointer)`, which would previously delete the old thread local data. However there should *never* be old thread local data because pthread *should* null it out on thread exit. Unfortunately it's possible that pthread failed to do this according to the spec: > > Upon key creation, the value NULL shall be associated with the new key in all active threads. Upon thread creation, the value NULL shall be associated with all defined keys in the new thread. > > An optional destructor function may be associated with each key value. At thread exit, if a key value has a non-NULL destructor pointer, and the thread has a non-NULL value associated with that key, the value of the key is set to NULL, and then the function pointed to is called with the previously associated value as its sole argument. The order of destructor calls is unspecified if more than one destructor exists for a thread when it exits. > > If, after all the destructors have been called for all non-NULL values with associated destructors, there are still some non-NULL values with associated destructors, then the process is repeated. If, after at least {PTHREAD_DESTRUCTOR_ITERATIONS} iterations of destructor calls for outstanding non-NULL values, there are still some non-NULL values with associated destructors, implementations may stop calling destructors, or they may continue calling destructors until no non-NULL values with associated destructors exist, even though this might result in an infinite loop. However if pthread fails to delete the value it is probably incorrect for us to do it. Destroying the value performs all of the "at thread exit" actions registered with it but we are way past "at thread exit". Reviewers: mclow.lists, bcraig, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24159 llvm-svn: 280588
* memory_resource still needs init_priority when built with GCC 4.9Eric Fiselier2016-09-031-3/+1
| | | | llvm-svn: 280585
* Define _LIBCPP_SAFE_STATIC ↵Eric Fiselier2016-09-031-4/+9
| | | | | | __attribute__((require_constant_initialization)), and apply it to memory_resource llvm-svn: 280561
* Fix or suppress GCC warnings during build.Eric Fiselier2016-08-291-0/+3
| | | | | | | | | | | | | | | | | | | | Summary: Currently a number of GCC warnings are emitted when building libc++. This patch fixes or ignores all of them. The primary changes are: * Work around strict aliasing issues in `typeinfo::hash_code()` by using __attribute__((may_alias)). However I think a non-aliasing `hash_code()` implementation is possible. Further investigation needed. * Add `_LIBCPP_UNREACHABLE()` to switch in `strstream.cpp` to avoid -Wpotentially-uninitialized. * Fix -Wunused-value warning in `__all` by adding a void cast. * Ignore -Wattributes for now. There are a number of real attribute issues when using GCC but enabling the warning is too noisy. * Ignore -Wliteral-suffix since it warns about the use of reserved identifiers. Note Only GCC 7.0 supports disabling this warning. * Ignore -Wc++14-compat since it warns about the sized new/delete overloads. Reviewers: EricWF Differential Revision: https://reviews.llvm.org/D24003 llvm-svn: 280007
* Followon to r279744. Find the other exception types and make __throw_XXX ↵Marshall Clow2016-08-252-3/+3
| | | | | | routines (and call them). Remove the generic __libcpp_throw routine, since no one uses it anymore. llvm-svn: 279763
* Add an _LIBCPP_NORETURN inline function named __throw_XXX for each exception ↵Marshall Clow2016-08-258-94/+58
| | | | | | type we define. They either construct and throw the exception, or abort() (if exceptions are disabled). Use these functions everywhere instead of assert()ing when exceptions are disabled. WARNING: This is a behavior change - but only with exceptions disabled. Reviewed as: https://reviews.llvm.org/D23855. llvm-svn: 279744
* [libcxx] Add std::anyEric Fiselier2016-08-111-2/+7
| | | | | | | | | | | | | | | | | | | Summary: This patch adds std::any by moving/adapting <experimental/any>. This patch also implements the std::any parts of p0032r3 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0032r3.pdf) and LWG 2509 (http://cplusplus.github.io/LWG/lwg-defects.html#2509). I plan to push it in a day or two if there are no comments. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D22733 llvm-svn: 278310
* Fixing 'Aquire' typo and libcxx build.Ben Craig2016-08-022-2/+2
| | | | llvm-svn: 277456
* Improve shared_ptr dtor performanceBen Craig2016-08-011-1/+29
| | | | | | | | | | If the last destruction is uncontended, skip the atomic store on __shared_weak_owners_. This shifts some costs from normal shared_ptr usage to weak_ptr uses. https://reviews.llvm.org/D22470 llvm-svn: 277357
* Implement P0392r0. Integrate filesystem::path and string_view.Eric Fiselier2016-07-231-45/+46
| | | | llvm-svn: 276511
* Hide some internal symbols for memory resource.Eric Fiselier2016-07-111-0/+5
| | | | llvm-svn: 275089
* Remove workarounds for C++17 inline variable ABI break. It has been fixed in ↵Eric Fiselier2016-07-022-11/+0
| | | | | | clang. llvm-svn: 274419
* Add another workaround for C++17 inline variable ABI breakage.Eric Fiselier2016-07-011-1/+4
| | | | llvm-svn: 274408
* Remove accidental change committed in r274403.Eric Fiselier2016-07-011-1/+1
| | | | llvm-svn: 274407
* Work around ABI break caused by C++17 inline variables.Eric Fiselier2016-07-011-1/+8
| | | | llvm-svn: 274403
* [libcxx] Fix a bug in strstreambuf::overflow.Akira Hatanaka2016-06-291-2/+1
| | | | | | | | | | | The end pointer should point to one past the end of the newly allocated buffer. rdar://problem/24265174 Differential Revision: http://reviews.llvm.org/D20334 llvm-svn: 274132
* Implement LWG 2488 - Make the placeholders constexpr.Eric Fiselier2016-06-261-10/+11
| | | | | | | | | | | | | | | | | | | This patch makes the bind placeholders in std::placeholders both (1) const and (2) constexpr (See below). This is technically a breaking change for any code using the placeholders outside of std::bind and depending on them being non-const. However I don't think this will break any real world code. (1) Previously the placeholders were non-const extern globals in all dialects. This patch changes these extern globals to be const in all dialects. Since the cv-qualifiers don't participate in name mangling for globals this is an ABI compatible change. (2) Make the placeholders constexpr in C++11 and beyond. Although LWG 2488 only applies to C++17 I don't see any reason not to backport this change. llvm-svn: 273824
* Cleanup filesystem::permissions ever more.Eric Fiselier2016-06-221-20/+15
| | | | llvm-svn: 273392
* Avoid unnecessary stat call in filesystem::permissions implementation.Eric Fiselier2016-06-221-1/+2
| | | | llvm-svn: 273391
* Implement LWG issue 2720. Replace perms::resolve_symlinks with ↵Eric Fiselier2016-06-211-2/+6
| | | | | | | | | | | | | | | perms::symlink_nofollow. This changes how filesystem::permissions(p, perms) handles symlinks. Previously symlinks were not resolved by default instead only getting resolved when "perms::resolve_symlinks" was used. After this change symlinks are resolved by default and perms::symlink_nofollow must be given to change this. This issue has not yet been moved to Ready status, and I will revert if it doesn't get moved at the current meeting. However I feel confident that it will and it's nice to have implementations when moving issues. llvm-svn: 273328
* Fix various undefined behavior found by UBSan.Eric Fiselier2016-06-191-1/+5
| | | | | | | | | | | | | | | | | | | | | | | * Fix non-null violation in strstream.cpp Overflow was calling memcpy with a null parameter and a size of 0. * Fix std/atomics/atomics.flag/ tests: a.test_and_set() was reading from an uninitialized atomic, but wasn't using the value. The tests now clear the flag before performing the first test_and_set. This allows UBSAN to test that clear doesn't read an invalid value. * Fix std/experimental/algorithms/alg.random.sample/sample.pass.cpp The tests were dereferencing a past-the-end pointer to an array so that they could do pointer arithmetic with it. Instead of dereference the iterator I changed the tests to use the special 'base()' test iterator method. * Add -fno-sanitize=float-divide-by-zero to suppress division by zero UBSAN diagnostics. The tests that cause float division by zero are explicitly aware that they are doing that. Since this is well defined for IEEE floats suppress the warnings for now. llvm-svn: 273107
* Fix bugs in last_write_time implementation.Eric Fiselier2016-06-191-17/+56
| | | | | | | | | | | | | | | * Fix passing a negative number as either tv_usec or tv_nsec. When file_time_type is negative and has a non-zero sub-second value we subtract 1 from tv_sec and make the sub-second duration positive. * Detect and report when 'file_time_type' cannot be represented by time_t. This happens when using large/small file_time_type values with a 32 bit time_t. There is more work to be done in the implementation. It should start to use stat's st_mtim or st_mtimeval if it's provided as an extension. That way we can provide a better resolution. llvm-svn: 273103
* Remove Apple specific guard for utimensat. Use !defined(UTIME_OMIT) instead.Eric Fiselier2016-06-181-5/+4
| | | | | | | As pointed out by @majnemer this is a better way to detect utimensat on all platforms. The Apple specific guard is unneeded. llvm-svn: 273093
* Use utimes instead of utimensat when !defined(UTIME_OMIT). Fixes build for ↵Eric Fiselier2016-06-181-1/+3
| | | | | | older GLIBC versions llvm-svn: 273088
OpenPOWER on IntegriCloud