aboutsummaryrefslogtreecommitdiff
path: root/libcxx/src
AgeCommit message (Collapse)AuthorFilesLines
2023-06-15[libc++] Move the definition of std::new_handler out of new.cppLouis Dionne3-20/+24
This reduces the difference between libc++'s new.cpp and libc++abi's stdlib_new_delete.cpp files, which are essentially copies of each other. Differential Revision: https://reviews.llvm.org/D152956
2023-06-12[libc++] Android temp dir is /data/local/tmp, enable Windows testRyan Prichard1-1/+6
[libc++] Android temp dir is /data/local/tmp, enable Windows test On Android, std::filesystem::temp_directory_path() should fall back to /data/local/tmp when no environment variable is set. There is no /tmp directory. Most apps can't access /data/local/tmp, but they do have a "cache dir" (Context#getCacheDir()) that is usable for temporary files. However, there is no obvious and reliable way for libc++ to query this directory in contexts where it is available. The global fallback /data/local/tmp is available for "adb shell", making it useful for test suites. On Windows, temp_directory_path falls back to the Windows directory (e.g. "C:\Windows"), so call GetWindowsDirectoryW to do the test. Reviewed By: ldionne, #libc, enh Differential Revision: https://reviews.llvm.org/D137131
2023-06-07[libc++] Roll up fstream support into filesystem supportLouis Dionne1-1/+1
LIBCXX_ENABLE_FILESYSTEM should represent whether the platform has support for a filesystem, not just whether we support <filesystem>. This patch slightly generalizes the setting to also encompass whether we provide <fstream>, since that only makes sense when a filesystem is supported. Differential Revision: https://reviews.llvm.org/D152168
2023-06-06[libc++] Refactor __lessNikolas Klauser1-2/+3
This simplifies the usage of `__less` by making the class not depend on the types compared, but instead the `operator()`. We can't remove the template completely because we explicitly instantiate `std::__sort` with `__less<T>`. Reviewed By: ldionne, #libc Spies: arichardson, EricWF, libcxx-commits, mgrang Differential Revision: https://reviews.llvm.org/D145285
2023-06-03[libcxx] Fix using std::wcout/wcin on Windows with streams configured in ↵Martin Storsjö1-35/+121
wide mode On Windows, the underlying file descriptors for stdout/stdin/stderr can be reconfigured to wide mode. In the default (narrow) mode, the charset usually isn't utf8 (as libcxx assumes), but normally a locale specific codepage (where each codepage only can represent a small subset of unicode characters). By configuring the stdout file descriptor to wide mode, the user can output wchar_t based strings without convesion to the narrow charset. Within libcxx, don't try to use codecvt to convert this to a narrow character encoding, but output these strings as such with fputwc. In wide mode, such strings could be output directly with fwrite too, but if the file descriptor hasn't been configured in wide mode, that breaks the output (which currently works reasonably). By always outputting one character at a time with fputwc, it works regardless of mode of the stdout file descriptor. For the narrow output stream, std::cout, outputting (via fwrite) does fail when the file descriptor is set to wide mode. This matches how it behaves with both MS STL and GNU libstdc++ too, so this is probably acceptable. This fixes https://github.com/llvm/llvm-project/issues/46646, and the downstream bugs https://github.com/mstorsjo/llvm-mingw/issues/145 and https://github.com/mstorsjo/llvm-mingw/issues/222. Differential Revision: https://reviews.llvm.org/D146398
2023-05-16[libc++][format] Removes format sources.Mark de Wever2-18/+0
The source file is used to anchor the destructor of format_error. When format is moved from experimental to stable this code would move to the dylib. One issue with code in the dylib is that it can't be used in constexpr context. There is a proposal to make format work during constant evaluation P2758 Emitting messages at compile time This paper has initially been received favourable by EWG. Therefore move the code to the header. This also avoids possible availability issues on Mac back deployment targets. Note it is expected that format will no longer be experimental with the next LLVM release. Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D150073
2023-05-05[libc++] Remove Solaris related codeLouis Dionne8-262/+0
This was contributed ~10 years ago, but we don't officially support it and I am not aware of any bot testing it, so this has likely rotten to the point where it is unusable. Differential Revision: https://reviews.llvm.org/D138680
2023-04-21[libc++] Make bsd_locale_fallbacks.h modular and move it into ↵Nikolas Klauser2-0/+6
__locale/locale_base_api/ This is a first step towards granularizing `<locale>`. Reviewed By: ldionne, #libc Spies: arichardson, libcxx-commits, mikhail.ramalho Differential Revision: https://reviews.llvm.org/D146397
2023-04-21[libc++][PSTL] Remove current integrationNikolas Klauser1-17/+0
We decided to go a different route. To make the switch easier, rip out the old integration first and build on a clean base. Reviewed By: ldionne, #libc, #libc_abi Spies: arichardson, libcxx-commits Differential Revision: https://reviews.llvm.org/D148480
2023-04-19[libc++] Remove symbols for a std::allocator_arg & friends from the dylibLouis Dionne4-22/+0
This patch removes the symbols defined in the library for std::allocator_arg, std::defer_lock, std::try_to_lock, std::adopt_lock, and std::piecewise_construct. Those were defined in the library because we provided them in C++03 as an extension, and in C++03 it was impossible to define them as `constexpr` variables, like in the spec. This is technically an ABI break since we are removing symbols from the library. However, in practice, only programs compiled in C++03 mode who take the address of those objects (or pass them as a reference) will have an undefined ref to those symbols. In practice, this is expected to be rare. First, those are C++11 features that we happen to provide in C++03, and only the C++03 definition can potentially lead to code referencing the dylib definition. So any code that is using these objects but compiling in C++11 mode (as they should) is not at risk. Second, all uses of these types in the library is done by passing those types by value to a function that can get inlined. Since they are empty types, the compiler won't generate an undefined reference if passed by value, since there's nothing to pass anyway. Long story short, the risk for code actually containing an undefined reference to one of these types is rather small (but non-zero). I also couldn't find any app on the App Store that referenced these symbols, which supports my impression that this won't be an issue in practice. Differential Revision: https://reviews.llvm.org/D145587
2023-04-13[libcxx] Rename the now fully private header __std_stream to std_stream.hMartin Storsjö2-4/+4
When this header now is a fully regular header within the src tree, give it a more regular name. Differential Revision: https://reviews.llvm.org/D148072
2023-04-12[libcxx] Move the private header __std_stream into the src subdirMartin Storsjö2-1/+362
This header isn't used by any public header, so there shouldn't be any need to install it or treat it as a heder. Once it's part of the src subdirectory, I guess one could consider giving it a more traditional name too. Differential Revision: https://reviews.llvm.org/D147855
2023-04-10[libc++] Move __errc to __system_error/errc.hNikolas Klauser2-1/+2
This file was added before we started granularizing the headers, but is essentially just a granularized header. This moves the header to the correct place. Reviewed By: #libc, EricWF Spies: libcxx-commits, arichardson, mikhail.ramalho Differential Revision: https://reviews.llvm.org/D146395
2023-04-09[libc++] Granularize system_error.Mark de Wever7-8/+4
Reviewed By: #libc, philnik Differential Revision: https://reviews.llvm.org/D147853
2023-03-22[libc++] Granularize __mutex_baseNikolas Klauser1-0/+1
This also updates the moved code to the current style. (i.e. `_VSTD` -> `std`, `_LIBCPP_INLINE_VISIBILITY` -> `_LIBCPP_HIDE_FROM_ABI`, clang-format). Reviewed By: Mordante, #libc, EricWF Spies: arichardson, libcxx-commits, mikhail.ramalho Differential Revision: https://reviews.llvm.org/D146228
2023-03-10[libc++] Clean up old macOS back-deployment workaroundsLouis Dionne3-80/+2
This patch bumps the minimum macOS version for building the dylib or back-deploying a statically-linked libc++ from macOS 10.11 to macOS 10.13. AFAICT, Chrome was the last one to require macOS 10.11, but since then they have bumped their minimal supported version to macOS 10.13. Differential Revision: https://reviews.llvm.org/D145012
2023-03-08[libc++] Enable -Wunused-templateNikolas Klauser1-0/+2
Clang wants to enable this flag by default, but libc++ isn't working with it yet. Reviewed By: Mordante, #libc, #libc_abi, EricWF Spies: libcxx-commits, arichardson Differential Revision: https://reviews.llvm.org/D144667
2023-03-01[libc++] [FreeBSD] correct 64-bit testEd Maste1-1/+1
Using __SIZEOF_LONG__ == 8 rather than __LP64__ is needed so we use umtx on CHERI. I accidentally landed an older diff. Fixes: 17ecbb3ea6ff0ae716dd524c0e2bf75a4815c95b
2023-03-01[libc++] [FreeBSD] only use _umtx_op(2) on 64bit archesKonstantin Belousov1-3/+8
Only 64bit architectures can be supported this way, because libcxx defines __cxx_contention_t to be int64_t for FreeBSD, and 32bit arches do not have a kind of UMTX_OP_WAIT_INT64_PRIVATE operation. Fixes: 83387dbc18e7998f87aa4a2d35320bcb2ed5c392 Reviewed by: arichardson, ldionne, emaste, Mordante Differential Revision: https://reviews.llvm.org/D142422
2023-02-21[libc++] Move constexpr <cstring> functions into their own headers and ↵Nikolas Klauser1-1/+2
remove unused <cstring> includes Reviewed By: ldionne, Mordante, #libc, #libc_abi Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D143329
2023-02-17[libc++][CI] Switches to clang-format-16.Mark de Wever1-1/+1
Uses an absolute path to the selected binary. Updates the formatting of two files to match clang-format-16 style. Depends on D144126 Reviewed By: #libc, philnik Differential Revision: https://reviews.llvm.org/D144132
2023-02-17[libc++] Improve the format ignorelist generation.Mark de Wever1-0/+0
Several improvements - Only add files that we actually want to format. - Sort according to a fixed locale. Some drive-by fixes - Rename a text file, this avoids a filter exception. - Adds a some missing source files extensions. - Removes unused extensions hh, hxx, cc, and cxx from clang-format. Reviewed By: philnik, #libc Differential Revision: https://reviews.llvm.org/D144126
2023-02-17[libc++][NFC] Rename _LIBCPP_NO_EXCEPTIONS to _LIBCPP_HAS_NO_EXCEPTIONSNikolas Klauser10-69/+69
Other macros that disable parts of the library are named `_LIBCPP_HAS_NO_WHATEVER`. Reviewed By: ldionne, Mordante, #libc Spies: libcxx-commits, smeenai Differential Revision: https://reviews.llvm.org/D143163
2023-02-06[libc++][NFC] _VSTD -> std in ryuLouis Dionne4-56/+56
Those ones are extremely mechanical and since that's not libc++ code in the first place, there's even more of an incentive to do the rename.
2023-02-01[libc++] Forward ranges::sort to instantiations in the dylibNikolas Klauser1-1/+15
This patch removes `_WrapAlgPolicy` and related functionality. Instead, we explicitly forward to `__sort` now if we have an instantiation inside the dylib. If we don't we just call `__introsort`. Reviewed By: ldionne, #libc Spies: sstefan1, libcxx-commits Differential Revision: https://reviews.llvm.org/D140824
2023-02-01[libc++] Remove explicit instantiations of __insertion_sort_incomplete and ↵Nikolas Klauser1-20/+0
__sort5 from the dylib These instantiations were never visible, because they are only used in `__sort`, which is also explicitly instantiated in the dylib. Reviewed By: ldionne, #libc Spies: #libc_vendors, emaste, nemanjai, libcxx-commits Differential Revision: https://reviews.llvm.org/D142185
2023-01-26[libc++] Move the definition of aligned allocation helpers outside of <new>Louis Dionne1-0/+1
They are not needed in <new> -- in fact they are only needed in .cpp files. Getting those out of the way makes the headers smaller and also makes it easier to use the library on platforms where aligned allocation is not available. Differential Revision: https://reviews.llvm.org/D139231
2023-01-20[libc++] add FreeBSD atomic wait supportKonstantin Belousov1-0/+21
Reviewed By: philnik Differential Revision: https://reviews.llvm.org/D142134
2023-01-12[libc++] Make pmr::monotonic_buffer_resource bump downNikolas Klauser1-8/+25
Bumping down is significantly faster than bumping up. This is ABI breaking, but the ABI of `pmr::monotonic_buffer_resource` was only stabilized in this release cycle, so we can still change it. For a more detailed explanation why bumping down is better, see https://fitzgeraldnick.com/2019/11/01/always-bump-downwards.html. Reviewed By: ldionne, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D141435
2023-01-11[libc++] Hold mutex lock while notify_all is called at notify_all_at_thread_exitArthur O'Dwyer1-1/+1
Releasing the mutex before the call to notify_all is an optimization. This optimization cannot be used here. The thread waiting on the condition might destroy the associated resources — mutex + condition variable — and the notifier thread will access an destroyed variable — the condition variable. In fact, notify_all_at_thread_exit is meant exactly to join on detached threads, and the waiting thread doesn't expect for the notifier thread to access any further shared resources, making this scenario very likely to happen. The waiting thread might awake spuriously on the release of the mutex lock. The reorder is necessary to prevent this race. Further details can be found at https://cplusplus.github.io/LWG/issue3343. Differential Revision: https://reviews.llvm.org/D105758
2022-11-25[libc++][NFC] Consistently use newline between license and include guardLouis Dionne1-0/+1
2022-11-20[libc++] Introduce a setting to remove fstream from the libraryLouis Dionne1-0/+3
This allows porting the library to platforms that are able to support <iostream> but that do not have a notion of a filesystem, and where it hence doesn't make sense to support std::fstream (and never will). Also, remove reliance on <fstream> in various tests that didn't actually need it. Differential Revision: https://reviews.llvm.org/D138327
2022-11-01[libc++][PMR] Deprecate the implementation in std::experimentalNikolas Klauser1-0/+2
This commit deprecates <experimental/memory_resource> since we now ship the non-experimental version of it. Per the libc++ policy [1], we are deprecating the experimental feature in upcoming LLVM 16 and will remove it entirely in LLVM 18. [1]: https://libcxx.llvm.org/DesignDocs/ExperimentalFeatures.html#id4 Reviewed By: ldionne, #libc Spies: EricWF, libcxx-commits Differential Revision: https://reviews.llvm.org/D136245
2022-11-01[libc++][PMR] Move the pmr::memory_resource destructor into the dylibNikolas Klauser1-1/+1
This avoids emitting the VTable of `pmr::memory_resource` in every TU. Reviewed By: ldionne Spies: EricWF, nemanjai, libcxx-commits Differential Revision: https://reviews.llvm.org/D136196
2022-10-12Revert "[runtimes] Always define cxx_shared, cxx_static & other targets"Haowei Wu1-116/+113
This reverts commit 79ee0342dbf025bc70f237bdfe9ccb4e10a592ce which breaks the LLVM TSan bots.
2022-10-12[libc++] Implements constexpr <charconv>.Mark de Wever1-1/+1
Implements: - P2291R3 Add Constexpr Modifiers to Functions to_chars and from_chars for Integral Types in <charconv> Header Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D131317
2022-10-12[runtimes] Always define cxx_shared, cxx_static & other targetsLouis Dionne1-113/+116
However, mark them as EXCLUDE_FROM_ALL when we don't want to build them. Simply declaring the targets should be of no harm, and it allows other projects to mention these targets regardless of whether they end up being built or not. While the diff may not make that obvious, this patch basically moves the definition of e.g. `cxx_shared` out of the `if (LIBCXX_ENABLE_SHARED)` and instead marks it as `EXCLUDE_FROM_ALL` conditionally on whether LIBCXX_ENABLE_SHARED is passed. It then does the same for libunwind and libc++abi targets. Differential Revision: https://reviews.llvm.org/D134221
2022-10-11[runtimes] Add the ability to customize the output name of libc++, libc++abi ↵Louis Dionne1-1/+1
and libunwind We already had the ability to do that for libc++.dylib, so this only adds consistency for all the runtime libraries. This should allow working around difficulties on AIX as described in https://llvm.org/D134221. Differential Revision: https://reviews.llvm.org/D135669
2022-10-11[libc++] Add the C++17 <memory_resource> header (mono-patch)Arthur O'Dwyer3-0/+482
This patch is the rebase and squash of three earlier patches. It supersedes all three of them. - D47111: experimental monotonic_buffer_resource. - D47358: experimental pool resources. - D47360: Copy std::experimental::pmr to std::pmr. The significant difference between this patch and the-sum-of-those-three is that this patch does not add `std::experimental::pmr::monotonic_buffer_resource` and so on. This patch simply adds the C++17 standard facilities, and leaves the `std::experimental` namespace entirely alone. Differential Revision: https://reviews.llvm.org/D89057
2022-10-03[SystemZ][z/OS] Add ASCII and 32-bit variants for libc++.Zibi Sarbinowski1-1/+11
This patch enables libc++ build as shared library in all combinations of ASCII/EBCDIC and 32-bit/64-bit variants. In particular it introduces: # ASCII version of libc++ named as libc++_a.so # Script to rename DLL name inside the generated side deck # Various names for dataset members where DLL libraries and their side decks will reside # Add the following options: - LIBCXX_SHARED_OUTPUT_NAME - LIBCXX_ADDITIONAL_COMPILE_FLAGS - LIBCXX_ADDITIONAL_LIBRARIES - LIBCXXABI_ADDITIONAL_COMPILE_FLAGS - LIBCXXABI_ADDITIONAL_LIBRARIES **Background and rational of this patch** The linker on z/OS creates a list of exported symbols in a file called side deck. The list contains the symbol name as well as the name of the DLL which implements the symbol. The name of the DLL depends on what is specified in the -o command line option. If it points to a USS file, than the DLL name in the side deck will be the USS file name. If it points to a member of a dataset then the DLL name in the side deck is the member name. If CMake could deal with z/OS datasets we could use -o that points to a dataset member name, but this does not seem to work so we have to produce a USS file as the DLL and then copy the content of the produced side deck to a dataset as well as rename the USS file name in the side deck to a dataset member name that corresponds to that DLL. Reviewed By: muiez, SeanP, ldionne, #libc, #libc_abi Differential Revision: https://reviews.llvm.org/D118503
2022-10-03[libc++] Suppress -Wctad-maybe-unsupported on types w/o deduction guidesLouis Dionne1-0/+1
There are a handful of standard library types that are intended to support CTAD but don't need any explicit deduction guides to do so. This patch adds a dummy deduction guide to those types to suppress -Wctad-maybe-unsupported (which gets emitted in user code). This is a re-application of the original patch by Eric Fiselier in fcd549a7d828 which had been reverted due to reasons lost at this point. I also added the macro to a few more types. Reviving this patch was prompted by the discussion on https://llvm.org/D133425. Differential Revision: https://reviews.llvm.org/D133535
2022-10-03[libc++] Avoid relying on non-portable behaviour in std::alignAlex Richardson1-1/+1
Round-tripping pointers via size_t is not portable, the C/C++ standards only require this to be valid when using (u)intptr_t. Originally committed to the CHERI fork of LLVM as https://github.com/CTSRD-CHERI/llvm-project/commit/dd01245185ab9e71b70b418bee8f11ea0199e1a3, but I forgot to upstream the change. I rediscovered this issue due to a compiler warning when building libc++ on a Arm Morello system. Reviewed By: #libc, ldionne, philnik Differential Revision: https://reviews.llvm.org/D134363
2022-09-20[libc++] Remove MSVC codeNikolas Klauser1-7/+0
It's been one and a half months now and nobody said anything, so I guess this code can be removed. Reviewed By: ldionne, #libc Spies: Mordante, libcxx-commits, mgorny, mstorsjo Differential Revision: https://reviews.llvm.org/D132943
2022-09-16[SystemZ][z/OS] define REMOVE_ALL_USE_DIRECTORY_ITERATOR (libc++)Muiez Ahmed1-1/+1
This patch fixes the z/OS build by using the first implementation of __remove_all since we don't have access to the openat() family of POSIX functions. Differential Revision: https://reviews.llvm.org/D132948
2022-09-06[libc++] Avoid instantiating type_trait classesNikolas Klauser1-2/+2
Use `using` aliases to avoid instantiating lots of types Reviewed By: ldionne, #libc Spies: libcxx-commits, miyuki Differential Revision: https://reviews.llvm.org/D132785
2022-09-02[libc++] Make the naming of private member variables consistent and enforce ↵Nikolas Klauser3-167/+167
it through readability-identifier-naming Reviewed By: ldionne, #libc Spies: aheejin, sstefan1, libcxx-commits Differential Revision: https://reviews.llvm.org/D129386
2022-08-31[libc++] Inlines format_error for clang-cl DLL.Mark de Wever1-0/+2
This version is build without support for the experimental library but the code still wants to link this function. Inlining the function solves the issue. Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D132667
2022-08-23[libc++] Extend check for non-ASCII characters to src/, test/ and benchmarks/Louis Dionne6-19/+19
Differential Revision: https://reviews.llvm.org/D132180
2022-08-23[libc++] Remove trailing whitespace from libcxx includes, source, tests and ↵Louis Dionne1-1/+1
benchmarks Differential Revision: https://reviews.llvm.org/D132175
2022-08-19[libc++][NFC] Rename the constexpr macrosNikolas Klauser2-11/+11
This was discussed on Discord with the consensus that we should rename the macros. Reviewed By: ldionne, Mordante, var-const, avogelsgesang, jloser, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D131498