summaryrefslogtreecommitdiffstats
path: root/libcxx/src
Commit message (Collapse)AuthorAgeFilesLines
* [Chrono][Darwin] Include header for gettimeofdayBruno Cardoso Lopes2017-01-101-1/+1
| | | | | | | Followup on r291466 and include the proper header. This fixes: https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac/builds/12620/steps/gclient%20runhooks/logs/stdio llvm-svn: 291517
* [Chrono][Darwin] Make steady_clock use CLOCK_UPTIME_RAWBruno Cardoso Lopes2017-01-091-3/+45
| | | | | | | | | | | | | | Use CLOCK_UPTIME_RAW in case clock_gettime is available on Darwin. On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able to time functions in the nanosecond range. Thus, they are the only acceptable implementations of steady_clock. Differential Revision: https://reviews.llvm.org/D27429 rdar://problem/29449467 llvm-svn: 291466
* [libc++] Implement terminate(), unexpected() and uncaught_exceptions() on ↵Eric Fiselier2017-01-071-6/+28
| | | | | | | | | | | | | | | | | | | | | | | | | Windows Summary: This patch implements the following functions on Windows by forwarding to the MSVCRT: * `get_terminate()` * `set_terminate()` * `terminate()` * `set_unexpected()` * `get_unexpected()` * `unexpected()` * `uncaught_exception()` * `uncaught_exceptions()` Reviewers: compnerd, rnk, majnemer, smeenai Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28442 llvm-svn: 291343
* Ensure Sleep(...) isn't passed the value 0 on WindowsEric Fiselier2017-01-071-1/+1
| | | | llvm-svn: 291342
* Explicitly specify MSVC mangling of iostream globals. Patch from Dave LeeEric Fiselier2017-01-071-10/+42
| | | | llvm-svn: 291337
* system_error: correct ELAST emulation on WindowsSaleem Abdulrasool2017-01-071-1/+1
| | | | | | | | | | ELAST should point to the last valid error string value. However, `_sys_nerr` provides the number of elements in the errlist array. Since the index is 0-based, this is off-by-one. Adjust it accordingly. Thanks to David Majnemer for catching this! llvm-svn: 291336
* [libc++] Tolerate presence of __deallocate macroEric Fiselier2017-01-071-1/+1
| | | | | | | | | | | | | | | Summary: On Windows the identifier `__deallocate` is defined as a macro by one of the Windows system headers. Previously libc++ worked around this by `#undef __deallocate` and generating a warning. However this causes the WIN32 version of `__threading_support` to always generate a warning on Windows. This is not OK. This patch renames all usages of `__deallocate` internally as to not conflict with the macro. Reviewers: mclow.lists, majnemer, rnk, rsmith, smeenai, compnerd Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28426 llvm-svn: 291332
* thread: implement sleep_for on WindowsSaleem Abdulrasool2017-01-071-0/+7
| | | | | | | | | | Windows does not provide an implementation of `nanosleep`. Round up the time duration to the nearest ms and use `Sleep`. Although this may over-sleep, there is no hard real-time guarantee on the wake, so sleeping a bit more is better than under-sleeping as it within the specification. llvm-svn: 291331
* Add _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] macros.Eric Fiselier2017-01-061-1/+1
| | | | | | | | | | | | This patch refactors the compiler detection done in `__config` by creating a set of `_LIBCPP_COMPILER_<TYPE>` macros. The goal of this patch is to make it easier to detect what compiler is being used outside of `__config`. Additionally this patch removes workarounds for GCC in `__bit_reference`. I tested GCC 4.8 and 4.9 without the workaround and neither seemed to need it anymore. llvm-svn: 291286
* config_elast: fix typo (NFC)Saleem Abdulrasool2017-01-051-1/+1
| | | | | | Missed the original typo which was duplicated. NFC. llvm-svn: 291192
* thread_support: split out {,non-}recursive mutexSaleem Abdulrasool2017-01-051-4/+4
| | | | | | | | Split out the recursive and non-recursive mutex. This split is needed for platforms which may use differing types for the two mutex (e.g. Win32 threads). llvm-svn: 291145
* Fix std::pointer_safety type in ABI v2Eric Fiselier2017-01-051-2/+3
| | | | | | | | | | | | | | | | | | | | In the C++ standard `std::pointer_safety` is defined as a C++11 strongly typed enum. However libc++ currently defines it as a class type which simulates a C++11 enumeration. This can be detected in valid C++ code. This patch introduces an the _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE ABI option. When defined `std::pointer_safety` is implemented as an enum type. Unfortunatly this also means it can no longer be provided as an extension in C++03. Additionally this patch moves the definition for `get_pointer_safety()` out of the dylib, and into the headers. New usages of `get_pointer_safety()` will now use the inline version instead of the dylib version. However in order to keep the dylib ABI compatible the old definition is explicitly compiled into it. llvm-svn: 291046
* [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VISEric Fiselier2017-01-041-3/+3
| | | | | | | | | | | | | The name _LIBCPP_TYPE_VIS_ONLY is no longer accurate because both _LIBCPP_TYPE_VIS and _LIBCPP_TYPE_VIS_ONLY expand to __attribute__((__type_visibility__)) with Clang. The only remaining difference is that _LIBCPP_TYPE_VIS_ONLY can be applied to templates whereas _LIBCPP_TYPE_VIS cannot (due to dllimport/dllexport not being allowed on templates). This patch renames _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS. llvm-svn: 291035
* fix elast configuration on Windows targetsSaleem Abdulrasool2017-01-041-1/+3
| | | | | | | A typo and missing header inclusion was obscured by the litany of user defined literal warnings. This fixes the detection of ELAST on windows. llvm-svn: 290941
* clean up use of _WIN32Saleem Abdulrasool2017-01-036-18/+19
| | | | | | | | | Replace the use of _WIN32 in libc++. Replace most use with a C runtime check _LIBCPP_MSVCRT or the new _LIBCPP_WIN32 to indicate that we are using the Win32 API. Use a new _LIBCPP_WCHAR_IS_UCS2 to indicate that we are on an environment that has a short wchar_t. llvm-svn: 290910
* system_error: provide a thread safe stringification for WindowsSaleem Abdulrasool2017-01-031-2/+10
| | | | | | | Provide a strerror_r replacement for Windows. This is needed to build libc++ for Windows with threading. llvm-svn: 290851
* Recommit r290839 - Fix configuring and building libc++ w/o an ABI library.Eric Fiselier2017-01-034-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch re-commits a previous attempt to support building libc++ w/o an ABI library. That patch was originally reverted because: 1) It forgot to teach the test suite about "default" ABI libraries. 2) Some LLVM builders don't clear the CMake cache between builds. The previous patch caused those builders to fail since their old cache entry for LIBCXX_CXX_ABI="" is no longer valid. The updated patch addresses both issues. It works around (2) by adding a hack to force the builders to update their cache entries. The hack will be removed shortly once all LLVM builders have run. Original commit message ----------------------- Typically libc++ uses libc++abi or libcxxrt to provide the ABI and runtime bits of the C++ STL. However we also support building w/o an ABI library entirely. This patch fixes building libc++ w/o an ABI library (and incorporates the `~type_info()` fix in D28211). The main changes in this patch are: 1) Add `-DLIBCXX_CXX_ABI=default` instead of using the empty string to mean "default". 2) Fix CMake bits which treated "none" as "default" on OS X. 3) Teach the source files to respect `-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY`. 4) Define ~type_info() when _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY is defined. Unfortunately this patch doesn't help clean up the macro mess that we use to configure for different ABI libraries. llvm-svn: 290849
* Revert r290839 - Fix configuring and building libc++ w/o an ABI libraryEric Fiselier2017-01-024-19/+8
| | | | llvm-svn: 290841
* Introduce _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR ABI option.Eric Fiselier2017-01-021-0/+2
| | | | | | | | | | | | | Currently libc++ compiles a special version of error_category() into the dylib. This definition is no longer needed, and doesn't work on Windows due to dllimport/dllexport semantics. For those reasons this patch introduces an option to disable/enable this definition. By default the definition is provided in ABI v1 except on windows. This patch also addresses D28210. llvm-svn: 290840
* Fix configuring and building libc++ w/o an ABI library.Eric Fiselier2017-01-024-8/+19
| | | | | | | | | | | | | | | | | | | Typically libc++ uses libc++abi or libcxxrt to provide the ABI and runtime bits of the C++ STL. However we also support building w/o an ABI library entirely. This patch fixes building libc++ w/o an ABI library (and incorporates the `~type_info()` fix in D28211). The main changes in this patch are: 1) Add `-DLIBCXX_CXX_ABI=default` instead of using the empty string to mean "default". 2) Fix CMake bits which treated "none" as "default" on OS X. 3) Teach the source files to respect `-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY`. 4) Define ~type_info() when _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY is defined. Unfortunately this patch doesn't help clean up the macro mess that we use to configure for different ABI libraries. llvm-svn: 290839
* win32: temporarily disable setting locale on 14+Saleem Abdulrasool2017-01-021-0/+4
| | | | | | | | | | The locale structures have been made opaque in CRT 14+. This currently prevents building libc++ for Windows. We can re-enable this in the future when we have replicated the structure to access the private field for the name (unless there exists a better supported mechanism to query the name of a locale given the locale_t). llvm-svn: 290835
* chrono: correct the units for the epoch biasSaleem Abdulrasool2017-01-021-2/+1
| | | | | | | | As pointed out by Howard, this is actually 134774 days (* 24 * 3600), and therefore seconds, not 100ns units. Adjust the units to reflect reality. llvm-svn: 290824
* locale: update ctype access for MSVC CRT 14+Saleem Abdulrasool2017-01-021-2/+9
| | | | | | | | | | | Visual C++ 14 and newer split msvcrt into msvcrt and ucrt with flavours of the ucrt for different environments. This changed the access to the ctype table by introducing the `__pctype_func` and `__pwctype_func` accessors. Use this rather than directly accessing `_ctype` which allows us to be safer in threaded situations by going through the libc locking. llvm-svn: 290823
* chrono: address post commit comments from HowardSaleem Abdulrasool2017-01-011-13/+17
| | | | | | | | | | | | | | | | | Drawing some inspiration from code from Bill O'Neal as pointed out by Howard, rework the code to avoid an overflow in the duration. Adjust the style to match libc++ style as well. Create a local typedef for the FILETIME duration (100-ns units). Use this to define the difference between the NT and the UNIX epochs (which previously overflowed due to the representation limits due to the bouncing to ns). Return the FILETIME duration biased by the NT-to-UNIX epoch conversion. Use of the custom duration makes it easier to read and reason about the code. llvm-svn: 290806
* chrono: address post-commit comments from majnemerSaleem Abdulrasool2017-01-011-8/+8
| | | | | | | Correct style to match libc++ style as pointed out by David Majnemer on IRC. NFC. llvm-svn: 290805
* chrono: give Windows a steady_clockSaleem Abdulrasool2017-01-011-14/+29
| | | | | | | Provide a definition for a steady monotonic clock by wrapping QueryPerformanceCounter. llvm-svn: 290804
* chrono: implement a Windows version of system_clock::nowSaleem Abdulrasool2017-01-011-0/+32
| | | | | | | | | | | | | | system_clock::now is not entirely straight forward on Windows, which does not have a clock_gettime function. GetSystemTimeAsFileTime gives us the value relative to the NT epoch (Jan 1 1601) rather than the Unix epoch (Jan 1 1970). However, this function has a low resolution (~10ms). Newer versions of Windows provide GetSystemTimePreciseAsFileTime which gives us a much more accurate time (<1us). Unfortunately, the latter is only available on Windows 8+ when targeting desktop apps. llvm-svn: 290803
* system_error: use strerror_r only for threaded codeSaleem Abdulrasool2016-12-311-0/+2
| | | | | | | | When building libc++ without threading, strerror_r is not used. Define the code only when threading is enabled. This allows us to build system_error for Windows, which ATM doesn't build with threading. llvm-svn: 290791
* random: include __config before buildingSaleem Abdulrasool2016-12-311-0/+2
| | | | | | | We need to include __config to ensure that we know what random implementation is being used. Fixes compilation for Windows. llvm-svn: 290775
* Fix debug mode build w/o exceptionsEric Fiselier2016-12-281-0/+4
| | | | llvm-svn: 290652
* Implement a throwing version of _LIBCPP_ASSERT.Eric Fiselier2016-12-281-1/+60
| | | | | | | | | | | | | | | | | | | | | | | | | This patch implements changes to allow _LIBCPP_ASSERT to throw on failure instead of aborting. The main changes needed to do this are: 1. Change _LIBCPP_ASSERT to call a handler via a replacable function pointer instead of calling abort directly. Additionally this patch implements two handler functions, one which aborts and another that throws an exception. 2. Add _NOEXCEPT_DEBUG macro for disabling noexcept spec on function which contain _LIBCPP_ASSERT. This is required in order to prevent assertion failures throwing through a noexcept function. This macro has no effect unless _LIBCPP_DEBUG_USE_EXCEPTIONS is defined. Having a non-aborting _LIBCPP_ASSERT is very important to allow sane testing of debug mode. Currently we can only have one test case per file, since the test case will cause the program to abort. Testing debug mode this way would require thousands of test files, most of which would be 95% boiler plate. I don't think this is a feasible strategy. Fortunately using a throwing debug handler solves these issues. Additionally this patch rewrites the documentation for debug mode. llvm-svn: 290651
* Don't use posix_memalign on Windows platformsEric Fiselier2016-12-231-0/+4
| | | | llvm-svn: 290448
* [libc++] Fix support for multibyte thousands_sep and decimal_point in ↵Eric Fiselier2016-12-111-42/+91
| | | | | | | | | | | | | | | | | | moneypunct_byname and numpunct_byname. Summary: The underlying C locales provide the `thousands_sep` and `decimal_point` as strings, possible with more than one character. We currently don't handle this case even for `wchar_t`. This patch properly converts the mbs -> wide character for `moneypunct_byname<wchar_t>`. For the `moneypunct_byname<char>` case we attempt to narrow the WC and if that fails we also attempt to translate it to some reasonable value. For example we translate U00A0 (non-breaking space) into U0020 (regular space). If none of these conversions succeed then we simply allow the base class to provide a fallback value. Reviewers: mclow.lists, EricWF Subscribers: vangyzen, george.burgess.iv, cfe-commits Differential Revision: https://reviews.llvm.org/D24218 llvm-svn: 289347
* Make variant's index part of the hash valueEric Fiselier2016-12-021-9/+4
| | | | llvm-svn: 288554
* Implement C++17 <variant>. Patch from Michael Park!Eric Fiselier2016-12-021-0/+18
| | | | | | This patch was reviewed as https://reviews.llvm.org/D23263. llvm-svn: 288547
* [libc++] Remove unneeded visibility pragmasShoaib Meenai2016-11-231-4/+0
| | | | | | | | | | The function definitions being guarded by the pragma were all static, so they wouldn't be exported anyway. In any case, we should prefer the visibility macros. No functional change. Differential Revision: https://reviews.llvm.org/D26940 llvm-svn: 287768
* Allow using libsupc++ with LIBCXX_ENABLE_STATIC_ABI_LIBRARY. Patch from ↵Eric Fiselier2016-11-181-5/+13
| | | | | | | | | | | | | | | | | | | | | | Michael Daniels. The code cannot currently link when using libsupc++ with the LIBCXX_ENABLE_STATIC_ABI_LIBRARY option. This change ifdef's out the the destructor and 'what' function for bad_array_length and bad_array_new_length when GLIBCXX is defined. The constructors that are left in are the only functions not being provided by libsupc++ itself, and follows the same pattern that was used to ifdef bad_alloc. Testing was done on a Linux x86_64 host using GCC 5.4 and libc++ from ToT. I see no change to the test results when using libsup++ or libstdc++ without LIBCXX_ENABLE_STATIC_ABI_LIBRARY. When using libsupc++ with LIBCXX_ENABLE_STATIC_ABI_LIBRARY it will now build and test results are the same as those without the option specified. Reviewed as https://reviews.llvm.org/D26186 llvm-svn: 287388
* [libc++] Introduce `_LIBCPP_OVERRIDABLE_FUNC_VIS`Shoaib Meenai2016-11-161-20/+20
| | | | | | | | | | This is a generalization of `_LIBCPP_NEW_DELETE_VIS`; the new macro name captures the semantics better, and also allows us to get rid of the `_WIN32` check in `include/new`. No functional change. Differential Revision: https://reviews.llvm.org/D26702 llvm-svn: 287164
* Improve performance of constructing filesystem::path from strings.Eric Fiselier2016-10-301-8/+1
| | | | | | | | | | | | | This patch fixes a performance bug when constructing or appending to a path from a string or c-string. Previously we called 'push_back' to append every single character. This caused multiple re-allocation and copies when at most one reallocation is necessary. The new behavior is to simply call `string::append` so it can correctly handle reallocation. For large strings this change is a ~4x improvement. This also makes our path faster to construct than libstdc++'s. llvm-svn: 285530
* Rewrite std::filesystem::path iterators and parserEric Fiselier2016-10-301-237/+290
| | | | | | | | | | | | | | | | | | | | | | This patch entirely rewrites the parsing logic for paths. Unlike the previous implementation this one stores information about the current state; For example if we are in a trailing separator or a root separator. This avoids the need for extra lookahead (and extra work) when incrementing or decrementing an iterator. Roughly this gives us a 15% speedup over the previous implementation. Unfortunately this implementation is still a lot slower than libstdc++'s. Because libstdc++ pre-parses and splits the path upon construction their iterators are trivial to increment/decrement. This makes libc++ lazy parsing 100x slower than libstdc++. However the pre-parsing libstdc++ causes a ton of extra and unneeded allocations when constructing the string. For example `path("/foo/bar/")` would require at least 5 allocations with libstdc++ whereas libc++ uses only one. The non-allocating behavior is much preferable when you consider filesystem usages like 'exists("/foo/bar/")'. Even then libc++'s path seems to be twice as slow to simply construct compared to libstdc++. More investigation is needed about this. llvm-svn: 285526
* Remove files missed in r285466Eric Fiselier2016-10-281-14/+0
| | | | llvm-svn: 285469
* Fix Clang 3.6 build errorEric Fiselier2016-10-281-1/+1
| | | | llvm-svn: 285445
* Add __libcpp_version file and __libcpp_library_version function.Eric Fiselier2016-10-281-0/+14
| | | | | | | | | | | | | | | This patch does two seperate things. First it adds a file called "__libcpp_version" which only contains the current libc++ version (currently 4000). This file is not intended for use as a header. This file is used by Clang in order to easily determine the installed libc++ version. This allows Clang to enable/disable certain language features only when the library supports them. The second change is the addition of _LIBCPP_LIBRARY_VERSION macro, which returns the version of the installed dylib since it may be different than the headers. llvm-svn: 285382
* [libc++] Fix modules build - Rework __refstring definition Eric Fiselier2016-10-251-1/+2
| | | | | | | | | | | | | | | Summary: `__libcpp_refstring` currently has two different definitions. First there is the complete definition in `<__refstring>` but there is also a second in `<stdexcept>`. The historical reason for this split is because both libc++ and libc++abi need to see the inline definitions of __libcpp_refstrings methods, but the `<stdexcept>` header doesn't. However this is an ODR violation and breaks the modules build. This patch fixes the issue by creating a single class definition in `<stdexcept>` and changing `<__refstring>` to contain only the inline method definitions. This way both `libcxx/src/stdexcept.cpp` and `libcxxabi/src/stdexcept.cpp` see the same declaration in `<stdexcept>` and definitions in `<__refstring>` Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25603 llvm-svn: 285100
* [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
OpenPOWER on IntegriCloud