summaryrefslogtreecommitdiff
path: root/libcxx/src/future.cpp
AgeCommit message (Collapse)Author
2025-05-28Revert "[libc++] Introduce ABI sensitive areas to avoid requiring ↵James Y Knight
_LIBCPP_HIDE_FROM_ABI everywhere (#131156)" (#141756) This reverts commit c861fe8a71e64f3d2108c58147e7375cd9314521. Unfortunately, this use of hidden visibility attributes causes user-defined specializations of standard-library types to also be marked hidden by default, which is incorrect. See discussion thread on #131156. ...and also reverts the follow-up commits: Revert "[libc++] Add explicit ABI annotations to functions from the block runtime declared in <__functional/function.h> (#140592)" This reverts commit 3e4c9dc299c35155934688184319d391b298fff7. Revert "[libc++] Make ABI annotations explicit for windows-specific code (#140507)" This reverts commit f73287e623a6c2e4a3485832bc3e10860cd26eb5. Revert "[libc++][NFC] Replace a few "namespace std" with the correct macro (#140510)" This reverts commit 1d411f27c769a32cb22ce50b9dc4421e34fd40dd.
2025-05-18[libc++] Introduce ABI sensitive areas to avoid requiring ↵Nikolas Klauser
_LIBCPP_HIDE_FROM_ABI everywhere (#131156) This patch introduces `_LIBCPP_{BEGIN,END}_EXPLICIT_ABI_ANNOTATIONS`, which allow us to have implicit annotations for most functions, and just where it's not "hide_from_abi everything" we add explicit annotations. This allows us to drop the `_LIBCPP_HIDE_FROM_ABI` macro from most functions in libc++.
2025-02-21[libc++] Qualify calls to nullary functions like __throw_foo (#122465)Louis Dionne
This is technically not necessary in most cases to prevent issues with ADL, but let's be consistent. This allows us to remove the libcpp-qualify-declval clang-tidy check, which is now enforced by the robust-against-adl clang-tidy check.
2024-10-12[libc++][RFC] Always define internal feature test macros (#89178)Nikolas Klauser
Currently, the library-internal feature test macros are only defined if the feature is not available, and always have the prefix `_LIBCPP_HAS_NO_`. This patch changes that, so that they are always defined and have the prefix `_LIBCPP_HAS_` instead. This changes the canonical use of these macros to `#if _LIBCPP_HAS_FEATURE`, which means that using an undefined macro (e.g. due to a missing include) is diagnosed now. While this is rather unlikely currently, a similar change in `<__configuration/availability.h>` caught a few bugs. This also improves readability, since it removes the double-negation of `#ifndef _LIBCPP_HAS_NO_FEATURE`. The current patch only touches the macros defined in `<__config>`. If people are happy with this approach, I'll make a follow-up PR to also change the macros defined in `<__config_site>`.
2023-12-18[libc++] Format the code base (#74334)Louis Dionne
This patch runs clang-format on all of libcxx/include and libcxx/src, in accordance with the RFC discussed at [1]. Follow-up patches will format the benchmarks, the test suite and remaining parts of the code. I'm splitting this one into its own patch so the diff is a bit easier to review. This patch was generated with: find libcxx/include libcxx/src -type f \ | grep -v 'module.modulemap.in' \ | grep -v 'CMakeLists.txt' \ | grep -v 'README.txt' \ | grep -v 'libcxx.imp' \ | grep -v '__config_site.in' \ | xargs clang-format -i A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh to help resolve merge and rebase issues across these formatting changes. [1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
2023-11-05[libc++] Handle threads-related .cpp files like we do all other source files ↵Louis Dionne
(#71100) Source files in libc++ are added to the CMake targets only if they are required by the configuration. We do this pretty consistently for all configurations like no-filesystem, no-random-device, etc. but we didn't do it for no-threads. This patch makes this consistent for no-threads, which is helpful in reducing the amount of work required to port libc++ to some platforms without threads. Indeed, with the previous approach, several threads-related source files would end up including headers that might fail to compile properly on some platforms. This issue is sidestepped entirely by making the approach for no-threads consistent with the other configurations.
2023-10-05[libc++] Make future_error constructor standard-compliantMarek Kurdej
This patch removes the non compliant constructor of std::future_error and adds the standards compliant constructor in C++17 instead. Note that we can't support the constructor as an extension in all standard modes because it uses delegating constructors, which require C++11. We could in theory support the constructor as an extension in C++11 and C++14 only, however I believe it is acceptable not to do that since I expect the breakage from this patch will be minimal. If it turns out that more code than we expect is broken by this, we can reconsider that decision. This was found during D99515. Differential Revision: https://reviews.llvm.org/D99567 Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-09-05[libc++] Avoid destructor call for error_category singletonsChris Bowler
When a handle to an error_category singleton object is used during the termination phase of a program, the destruction of the error_category object may have occurred prior to execution of the current destructor or function registered with atexit, because the singleton object may have been constructed after the corresponding initialization or call to atexit. For example, the updated tests from this patch will fail if using a libc++ built using a compiler that updates the vtable of the object on destruction. This patch attempts to avoid the issue by causing the destructor to not be called in the style of ResourceInitHelper in src/experimental/memory_resource.cpp. This approach might not work if object lifetime is strictly enforced. Differential Revision: https://reviews.llvm.org/D65667 Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2023-02-17[libc++][NFC] Rename _LIBCPP_NO_EXCEPTIONS to _LIBCPP_HAS_NO_EXCEPTIONSNikolas Klauser
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
2022-02-15[libc++] Replace `#include ""` with `<>` in libcxx/src/. NFCI.Arthur O'Dwyer
Our best guess is that the two syntaxes should have exactly equivalent effects, so, let's be consistent with what we do in libcxx/include/. I've left `#include "include/x.h"` and `#include "../y.h"` alone because I'm less sure that they're interchangeable, and they aren't inconsistent with libcxx/include/ because libcxx/include/ never does that kind of thing. Also, use the `_LIBCPP_PUSH_MACROS/POP_MACROS` dance for `<__undef_macros>`, even though it's technically unnecessary in a standalone .cpp file, just so we have consistently one way to do it. Differential Revision: https://reviews.llvm.org/D119561
2022-02-15[libc++] Guard warning pragmasNikolas Klauser
This makes the GCC output even cleaner! Reviewed By: ldionne, #libc Spies: mstorsjo, Quuxplusone, Mordante, libcxx-commits Differential Revision: https://reviews.llvm.org/D119295
2021-11-17[runtimes][NFC] Remove filenames at the top of the license noticeLouis Dionne
We've stopped doing it in libc++ for a while now because these names would end up rotting as we move things around and copy/paste stuff. This cleans up all the existing files so as to stop the spreading as people copy-paste headers around.
2021-03-03[libc++/abi] Replace uses of _NOEXCEPT in src/ by noexceptLouis Dionne
We always build the libraries in a Standard mode that supports noexcept, so there's no need to use the _NOEXCEPT macro. Differential Revision: https://reviews.llvm.org/D97700
2019-01-19Update more file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
2018-08-24[libc++] Remove race condition in std::asyncLouis Dionne
Summary: The state associated to the future was set in one thread (with synchronization) but read in another thread without synchronization, which led to a data race. https://bugs.llvm.org/show_bug.cgi?id=38181 rdar://problem/42548261 Reviewers: mclow.lists, EricWF Subscribers: christof, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D51170 llvm-svn: 340608
2018-07-30Code cleanup - change naked 'throw' expressions to call helpre function ↵Marshall Clow
'__throw_future_error'. The behavior change is that if you build libc++ with exceptions disabled, and then use that in a program that sets the value of the future twice (for example), it will now abort instead of behaving unpredictably. llvm-svn: 338332
2015-11-10Make it possible to build a no-exceptions variant of libcxx.Asiri Rathnayake
Fixes a small omission in libcxx that prevents libcxx being built when -DLIBCXX_ENABLE_EXCEPTIONS=0 is specified. This patch adds XFAILS to all those tests that are currently failing on the new -fno-exceptions library variant. Follow-up patches will update the tests (progressively) to cope with the new library variant. Change-Id: I4b801bd8d8e4fe7193df9e55f39f1f393a8ba81a llvm-svn: 252598
2015-06-12Fix PR23293 - Do not unlock shared state before notifying consumers.Eric Fiselier
Within the shared state methods do not unlock the lock guards manually. This could cause a race condition where the shared state is destroyed before the method is complete. llvm-svn: 239577
2014-09-05Allow libc++ to be built on systems without POSIX threadsJonathan Roelofs
If you're crazy enough to want this sort of thing, then add -D_LIBCPP_HAS_NO_THREADS to your CXXFLAGS and --param=additiona_features=libcpp-has-no-threads to your lit commnad line. http://reviews.llvm.org/D3969 llvm-svn: 217271
2013-12-14Fix GCC unknown pragma warning in libc++.Logan Chien
We should check defined(__clang__) before the usage of the clang diagnostic pragmas. The [-Wswitch] warning in src/future.cpp should be ignored. As the result, the equivalent GCC pragma is added. llvm-svn: 197314
2013-09-14Marshall Clow: LWG Issue 2056: future_errc enums start with value 0 ↵Howard Hinnant
(invalid value for broken_promise). llvm-svn: 190756
2013-01-14Fix a race in the construction of future. This fixes ↵Howard Hinnant
http://llvm.org/bugs/show_bug.cgi?id=14934. llvm-svn: 172456
2012-07-21noexcept applied to <future>.Howard Hinnant
llvm-svn: 160607
2012-02-02Explicitly convert int to future_errc. Fixes ↵Howard Hinnant
http://llvm.org/bugs/show_bug.cgi?id=11428 llvm-svn: 149630
2011-12-01Quash a whole bunch of warningsHoward Hinnant
llvm-svn: 145624
2011-07-13http://llvm.org/bugs/show_bug.cgi?id=10346Howard Hinnant
llvm-svn: 135045
2011-07-08provide ~future_error() definitionHoward Hinnant
llvm-svn: 134663
2011-05-28noexcept for <memory>. I've added a few extension noexcept to: ↵Howard Hinnant
allocator_traits<A>::deallocate, allocaate<T>::deallocate, return_temporary_buffer, and default_delete<T>::operator()(T*) const. My rationale was: If a std-dicated noexcept function needs to call another std-defined function, that called function must be noexcept. We're all a little new to noexcept, so things like this are to be expected. Also included fix for broken __is_swappable trait pointed out by Marc Glisse, thanks Marc|. And fixed a test case for is_nothrow_destructible. Destructors are now noexcept by default| llvm-svn: 132261
2011-05-26Applied noexcept to everything in [diagnostics] (Chapter 19)Howard Hinnant
llvm-svn: 132137
2010-11-30Implemented N3194Howard Hinnant
llvm-svn: 120458
2010-11-16license changeHoward Hinnant
llvm-svn: 119395
2010-10-14Convert __thread_local_data to the singleton patternHoward Hinnant
llvm-svn: 116500
2010-09-04Fix whitespaceHoward Hinnant
llvm-svn: 113089
2010-09-03[futures.atomic_future] and notify_all_at_thread_exit. This completes the ↵Howard Hinnant
header <future> and all of Chapter 30 (for C++0x enabled compilers). llvm-svn: 113017
2010-09-03[futures.shared_future]Howard Hinnant
llvm-svn: 112990
2010-08-30[futures.task] and [futures.async]. Requires variadics and rvalue-ref support.Howard Hinnant
llvm-svn: 112500
2010-08-27future continues ...Howard Hinnant
llvm-svn: 112284
2010-08-25Getting started on <future>Howard Hinnant
llvm-svn: 112061