]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/src/future.cc
Change export code to use the backend interface.
[thirdparty/gcc.git] / libstdc++-v3 / src / future.cc
CommitLineData
c910ceff
JW
1// future -*- C++ -*-
2
a14dd08a 3// Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
c910ceff
JW
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
25#include <future>
26
c910ceff
JW
27namespace
28{
29 struct future_error_category : public std::error_category
30 {
6ad86a5b
FC
31 future_error_category() {}
32
c910ceff
JW
33 virtual const char*
34 name() const
35 { return "future"; }
36
37 virtual std::string message(int __ec) const
38 {
39 std::string __msg;
40 switch (std::future_errc(__ec))
41 {
42 case std::future_errc::broken_promise:
43 __msg = "Broken promise";
44 break;
45 case std::future_errc::future_already_retrieved:
46 __msg = "Future already retrieved";
47 break;
48 case std::future_errc::promise_already_satisfied:
49 __msg = "Promise already satisfied";
50 break;
a14dd08a
JW
51 case std::future_errc::no_state:
52 __msg = "No associated state";
53 break;
c910ceff
JW
54 default:
55 __msg = "Unknown error";
56 break;
57 }
58 return __msg;
59 }
60 };
61
62 const future_error_category&
63 __future_category_instance()
64 {
65 static const future_error_category __fec;
66 return __fec;
67 }
68}
69
12ffa228
BK
70namespace std _GLIBCXX_VISIBILITY(default)
71{
72_GLIBCXX_BEGIN_NAMESPACE_VERSION
53dc5044 73
94a86be0
BK
74 const error_category& future_category()
75 { return __future_category_instance(); }
8d1b99e2
BK
76
77 future_error::~future_error() throw() { }
78
79 const char*
80 future_error::what() const throw() { return _M_code.message().c_str(); }
53dc5044 81
0d2e205e
BK
82#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
83 && defined(_GLIBCXX_ATOMIC_BUILTINS_4)
e9599233
BK
84 __future_base::_Result_base::_Result_base() = default;
85
86 __future_base::_Result_base::~_Result_base() = default;
87
88 __future_base::_State_base::~_State_base() = default;
0d2e205e 89#endif
e9599233 90
12ffa228 91_GLIBCXX_END_NAMESPACE_VERSION
e9599233 92} // namespace std
5b824b76
JW
93
94// XXX GLIBCXX_ABI Deprecated
95// gcc-4.6.0
96// <future> export changes
97#if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC) \
98 && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE) \
99 && defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
100
12ffa228 101namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
5b824b76
JW
102{
103 const std::error_category* future_category = &__future_category_instance();
104}
105
106#define _GLIBCXX_ASM_SYMVER(cur, old, version) \
107 asm (".symver " #cur "," #old "@@@" #version);
108
109_GLIBCXX_ASM_SYMVER(_ZN9__gnu_cxx15future_categoryE, _ZSt15future_category, GLIBCXX_3.4.14)
110
111#endif
112