]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / src / c++11 / compatibility-thread-c++0x.cc
CommitLineData
0b284728
BK
1// Compatibility symbols for previous versions, C++0x bits -*- C++ -*-
2
8d9254fc 3// Copyright (C) 2009-2020 Free Software Foundation, Inc.
0b284728
BK
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
3dd808fe 25#include <bits/c++config.h>
f2f08be7 26#if defined(_GLIBCXX_SHARED)
3dd808fe
JW
27#define _GLIBCXX_ASYNC_ABI_COMPAT
28#endif
29
0b284728
BK
30#include <future>
31#include <mutex>
c05986b9 32#include <functional>
0b284728 33
734f5023 34#if __cplusplus < 201103L
3dd808fe 35# error "compatibility-thread-c++0x.cc must be compiled with -std=gnu++0x"
0b284728
BK
36#endif
37
38#define _GLIBCXX_ASM_SYMVER(cur, old, version) \
39 asm (".symver " #cur "," #old "@@@" #version);
40
41// XXX GLIBCXX_ABI Deprecated
42// gcc-4.6.0
43// <future> export changes
ac6d1200 44#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
0b284728
BK
45 && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE) \
46 && defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
47
48namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
49{
50 const std::error_category* future_category = &std::future_category();
51}
52
53_GLIBCXX_ASM_SYMVER(_ZN9__gnu_cxx15future_categoryE, _ZSt15future_category, GLIBCXX_3.4.14)
54
55#endif
56
57// XXX GLIBCXX_ABI Deprecated
58// gcc-4.6.0
59// <mutex> export changes
60#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
ac6d1200 61#if defined(_GLIBCXX_SYMVER_GNU) && defined(_GLIBCXX_SHARED) \
0b284728
BK
62 && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE) \
63 && defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
64
65namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
66{
67 std::defer_lock_t defer_lock;
68 std::try_to_lock_t try_to_lock;
69 std::adopt_lock_t adopt_lock;
70}
71
72_GLIBCXX_ASM_SYMVER(_ZN9__gnu_cxx10adopt_lockE, _ZSt10adopt_lock, GLIBCXX_3.4.11)
73_GLIBCXX_ASM_SYMVER(_ZN9__gnu_cxx10defer_lockE, _ZSt10defer_lock, GLIBCXX_3.4.11)
74_GLIBCXX_ASM_SYMVER(_ZN9__gnu_cxx11try_to_lockE, _ZSt11try_to_lock, GLIBCXX_3.4.11)
75
76
77#endif
78#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
3dd808fe
JW
79
80
81// XXX GLIBCXX_ABI Deprecated
f2f08be7 82// gcc-4.7.0, gcc-4.9.0
3dd808fe
JW
83// <future> export changes
84#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
85 && (ATOMIC_INT_LOCK_FREE > 1)
f2f08be7 86#if defined(_GLIBCXX_SHARED)
3dd808fe
JW
87namespace std _GLIBCXX_VISIBILITY(default)
88{
89_GLIBCXX_BEGIN_NAMESPACE_VERSION
f2f08be7
JW
90 // Replaced by _State_baseV2 in gcc-4.9.0
91 class __future_base::_State_base
92 {
93 typedef _Ptr<_Result_base> _Ptr_type;
94
95 _Ptr_type _M_result;
96 mutex _M_mutex;
97 condition_variable _M_cond;
98 atomic_flag _M_retrieved;
99 once_flag _M_once;
100 public:
101 virtual ~_State_base();
102 virtual void _M_run_deferred() { }
103 };
104 __future_base::_State_base::~_State_base() { }
105
106 // Replaced by _Async_state_commonV2 in gcc-4.9.0
107 class __future_base::_Async_state_common : public __future_base::_State_base
108 {
109 protected:
110 ~_Async_state_common();
111 virtual void _M_run_deferred() { _M_join(); }
79a88477 112 void _M_join() { std::call_once(_M_once, &thread::join, &_M_thread); }
f2f08be7
JW
113 thread _M_thread;
114 once_flag _M_once;
115 };
116#if defined(_GLIBCXX_HAVE_TLS)
117 // Replaced with inline definition in gcc-4.8.0
3dd808fe
JW
118 __future_base::_Async_state_common::~_Async_state_common() { _M_join(); }
119
79a88477
JW
120 // Explicit instantiation due to -fno-implicit-templates.
121 template void call_once(once_flag&, void (thread::*&&)(), thread*&&);
f2f08be7 122#endif // _GLIBCXX_HAVE_TLS
3dd808fe
JW
123_GLIBCXX_END_NAMESPACE_VERSION
124} // namespace std
f2f08be7 125#endif // _GLIBCXX_SHARED
3dd808fe 126#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1