Commit Graph

35 Commits

Author SHA1 Message Date
Marshall Clow 04b9853a97 Swap two lines in __mutex_base. On systems with high clock rates, we could mistakenly return no_timeout when a mutex had timed out if we got a tick between these two lines. Thanks to Brian Cain for the bug report.
llvm-svn: 291492
2017-01-09 22:32:11 +00:00
Eric Fiselier e2f2d1edef [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS
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
2017-01-04 23:56:00 +00:00
Eric Fiselier f9980200aa Remove _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
libc++ no longer supports C++11 compilers that don't implement `= default`.
This patch removes all instances of the feature test macro
_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS as well as the potentially dead code it hides.

llvm-svn: 287321
2016-11-18 06:42:17 +00:00
Marshall Clow 816739ca82 Don't use pthread initializers in constexpr constructors. Patch by elram. Reviewed at https://reviews.llvm.org/D21637.
llvm-svn: 275819
2016-07-18 17:23:06 +00:00
Eric Fiselier 48f35e074e Implement variadic lock_guard.
Summary:
This patch implements the variadic `lock_guard` paper. 

Making `lock_guard` variadic is a ABI breaking change because the specialization `lock_guard<_Mutex>` mangles differently then when it was the primary template. This change only provides variadic `lock_guard` in ABI V2 or when `_LIBCPP_ABI_VARIADIC_LOCK_GUARD` is defined.

Note that in ABI V2 `lock_guard` must always be declared as a variadic template, even in C++03, in order to keep the ABI consistent. For this reason `lock_guard` is forward declared as a variadic template in all standard dialects and therefore depends on variadic templates being provided as an extension in C++03. All supported versions of Clang and GCC provide this extension.




Reviewers: mclow.lists

Subscribers: K-ballo, mclow.lists, cfe-commits

Differential Revision: http://reviews.llvm.org/D21260

llvm-svn: 272634
2016-06-14 03:48:09 +00:00
Asiri Rathnayake c7e4239fab Refactor pthread usage of libcxx.
This patch extracts out all the pthread dependencies of libcxx into the
new header __threading_support. The motivation is to make it easy to
re-target libcxx into platforms that do not support pthread.

Original patch from Fulvio Esposito (fulvio.esposito@outlook.com) - D11781

Applied with tweaks - D19412

Change-Id: I301111f0075de93dd8129416e06babc195aa936b
llvm-svn: 268734
2016-05-06 14:06:29 +00:00
Marshall Clow 3126c88137 Qualify calls to addressof to avoid getting ADL. Fixes PR#27254.
llvm-svn: 266209
2016-04-13 17:02:23 +00:00
Eric Fiselier 7865b2e943 Add clang thread safety annotations to mutex and lock_guard. Patch by jamesr@google.com.
This adds clang thread safety annotations to std::mutex and
std::lock_guard so code using these types can use these types directly
instead of having to wrap the types to provide annotations. These checks
when enabled by -Wthread-safety provide simple but useful static
checking to detect potential race conditions.
See http://clang.llvm.org/docs/ThreadSafetyAnalysis.html for details.

This patch was reviewed in http://reviews.llvm.org/D14731.

llvm-svn: 263611
2016-03-16 02:30:06 +00:00
Marshall Clow 0b54e792b7 Implement LWG2577: {shared,unique}_lock</tt> should use std::addressof
llvm-svn: 263506
2016-03-14 23:07:32 +00:00
Evgeniy Stepanov 906c872db9 Cleanup: move visibility/linkage attributes to the first declaration.
This change moves visibility attributes from out-of-class method
definitions to in-class declaration. This is needed for a switch to
attribute((internal_linkage)) (see http://reviews.llvm.org/D13925)
which can only appear on the first declaration.

This change does not touch istream/ostream/streambuf. They are
handled separately in http://reviews.llvm.org/D14409.

llvm-svn: 252385
2015-11-07 01:22:13 +00:00
Jonathan Roelofs 643e0ab8df Do not include pthread.h and sched.h when threads are disabled
Patch by Philippe Daouadi!

http://reviews.llvm.org/D9639

llvm-svn: 246168
2015-08-27 17:47:34 +00:00
Jonathan Roelofs b3fcc67f8f Allow libc++ to be built on systems without POSIX threads
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
2014-09-05 19:45:05 +00:00
Marshall Clow 1641a7c1cb Implement LWG issue #2135. If something goes wrong in condition_variable::wait, call terminate() rather than throwing an error. Do this indirectly, by marking the call as 'noexcept'. This is better than just calling terminate() directly, because it gives a better error message on the console.
llvm-svn: 204778
2014-03-26 02:45:04 +00:00
Marshall Clow ce81aed463 Make cv_status a class enum. Fixes PR18314. Thanks to Andersca for the report and the patch.
llvm-svn: 197921
2013-12-23 22:14:27 +00:00
Howard Hinnant ead6f1699d N3659: Shared locking in C++ Revision 2, c++1y only
llvm-svn: 191127
2013-09-21 01:49:28 +00:00
Howard Hinnant f0544c2086 Nico Rieck: this patch series fixes visibility issues on Windows as explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>.
llvm-svn: 188192
2013-08-12 18:38:34 +00:00
Howard Hinnant 6e41256f68 No functionality change at this time. I've split _LIBCPP_VISIBLE up into two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute.
llvm-svn: 176593
2013-03-06 23:30:19 +00:00
Howard Hinnant 54d333a601 Rename uses of _ and __ because these are getting stepped on by macros from other system code.
llvm-svn: 167038
2012-10-30 19:06:59 +00:00
Howard Hinnant ab303f7e47 Dimitry Andric: FreeBSD porting tweaks for PTHREAD_MUTEX_INITIALIZER and PTHREAD_COND_INITIALIZER
llvm-svn: 163626
2012-09-11 16:10:20 +00:00
Howard Hinnant aad745a024 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.

llvm-svn: 162925
2012-08-30 19:14:33 +00:00
Howard Hinnant 45c663db4e noexcept applied to <condition_variable>.
llvm-svn: 160605
2012-07-21 16:32:53 +00:00
Howard Hinnant 02e610ef34 noexcept and constexpr applied to <mutex>.
llvm-svn: 160604
2012-07-21 16:13:09 +00:00
Howard Hinnant bfa7990b5a Apply constexpr to the mutex constructor. As a conforming extension, apply constexpr to the condition_variable constructor. These are important because it enables the compiler to construct these types at compile time, even though the object will be non-const. Since they are constructed at compile time, there is no chance of a data race before they are constructed.
llvm-svn: 159901
2012-07-07 20:01:52 +00:00
Howard Hinnant f2f2d8b98d Modernize conversion to bool to the explicit bool conversion operator (library wide). This fixes http://llvm.org/bugs/show_bug.cgi?id=12058.
llvm-svn: 151088
2012-02-21 21:46:43 +00:00
Howard Hinnant 073458b1ab Windows support by Ruben Van Boxem.
llvm-svn: 142235
2011-10-17 20:05:10 +00:00
Howard Hinnant ce48a1137d _STD -> _VSTD to avoid macro clash on windows
llvm-svn: 134190
2011-06-30 21:18:19 +00:00
Howard Hinnant ce53420e37 Provide names for template and function parameters in forward declarations. The purpose is to aid automated documentation tools.
llvm-svn: 133008
2011-06-14 19:58:17 +00:00
Howard Hinnant 6fd5c65095 Minor fixup in <ratio> and add optional support for shared_mutex and upgrade_mutex which must be opted into with #define _LIBCPP_SHARED_LOCK
llvm-svn: 120258
2010-11-28 19:41:07 +00:00
Howard Hinnant 3dc6455ff0 N3191: C++ Timeout Specification
llvm-svn: 119909
2010-11-20 19:16:30 +00:00
Howard Hinnant 412dbebe1b license change
llvm-svn: 119395
2010-11-16 22:09:02 +00:00
Howard Hinnant f5ab703f68 visibility-decoration.
llvm-svn: 114470
2010-09-21 20:16:37 +00:00
Howard Hinnant 7609c9b665 Changed __config to react to all of clang's currently documented has_feature flags, and renamed _LIBCPP_MOVE to _LIBCPP_HAS_NO_RVALUE_REFERENCES to be more consistent with the rest of the libc++'s flags, and with clang's nomenclature.
llvm-svn: 113086
2010-09-04 23:28:19 +00:00
Howard Hinnant b3371f6f49 Fixing whitespace problems
llvm-svn: 111750
2010-08-22 00:02:43 +00:00
Howard Hinnant 5b08a8a432 Wiped out some non-ascii characters that snuck into the copyright.
llvm-svn: 103516
2010-05-11 21:36:01 +00:00
Howard Hinnant 3e519524c1 libcxx initial import
llvm-svn: 103490
2010-05-11 19:42:16 +00:00