annotate libstdc++-v3/libsupc++/exception_ptr.h @ 120:f93fa5091070

fix conv1.c
author mir3636
date Thu, 08 Mar 2018 14:53:42 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Exception Handling support header (exception_ptr class) for -*- C++ -*-
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 // Copyright (C) 2008-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
4 //
kono
parents:
diff changeset
5 // This file is part of GCC.
kono
parents:
diff changeset
6 //
kono
parents:
diff changeset
7 // GCC is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
8 // it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
9 // the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
10 // any later version.
kono
parents:
diff changeset
11 //
kono
parents:
diff changeset
12 // GCC is distributed in the hope that it will be useful,
kono
parents:
diff changeset
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
15 // GNU General Public License for more details.
kono
parents:
diff changeset
16 //
kono
parents:
diff changeset
17 // Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
18 // permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
19 // 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 // You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
22 // a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
24 // <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 /** @file bits/exception_ptr.h
kono
parents:
diff changeset
27 * This is an internal header file, included by other library headers.
kono
parents:
diff changeset
28 * Do not attempt to use it directly. @headername{exception}
kono
parents:
diff changeset
29 */
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 #ifndef _EXCEPTION_PTR_H
kono
parents:
diff changeset
32 #define _EXCEPTION_PTR_H
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 #pragma GCC visibility push(default)
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 #include <bits/c++config.h>
kono
parents:
diff changeset
37 #include <bits/exception_defines.h>
kono
parents:
diff changeset
38 #include <bits/cxxabi_init_exception.h>
kono
parents:
diff changeset
39 #include <typeinfo>
kono
parents:
diff changeset
40 #include <new>
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 extern "C++" {
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 namespace std
kono
parents:
diff changeset
45 {
kono
parents:
diff changeset
46 class type_info;
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 /**
kono
parents:
diff changeset
49 * @addtogroup exceptions
kono
parents:
diff changeset
50 * @{
kono
parents:
diff changeset
51 */
kono
parents:
diff changeset
52 namespace __exception_ptr
kono
parents:
diff changeset
53 {
kono
parents:
diff changeset
54 class exception_ptr;
kono
parents:
diff changeset
55 }
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 using __exception_ptr::exception_ptr;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 /** Obtain an exception_ptr to the currently handled exception. If there
kono
parents:
diff changeset
60 * is none, or the currently handled exception is foreign, return the null
kono
parents:
diff changeset
61 * value.
kono
parents:
diff changeset
62 */
kono
parents:
diff changeset
63 exception_ptr current_exception() _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 template<typename _Ex>
kono
parents:
diff changeset
66 exception_ptr make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 /// Throw the object pointed to by the exception_ptr.
kono
parents:
diff changeset
69 void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__));
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 namespace __exception_ptr
kono
parents:
diff changeset
72 {
kono
parents:
diff changeset
73 using std::rethrow_exception;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 /**
kono
parents:
diff changeset
76 * @brief An opaque pointer to an arbitrary exception.
kono
parents:
diff changeset
77 * @ingroup exceptions
kono
parents:
diff changeset
78 */
kono
parents:
diff changeset
79 class exception_ptr
kono
parents:
diff changeset
80 {
kono
parents:
diff changeset
81 void* _M_exception_object;
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 explicit exception_ptr(void* __e) _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 void _M_addref() _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
86 void _M_release() _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 void *_M_get() const _GLIBCXX_NOEXCEPT __attribute__ ((__pure__));
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 friend exception_ptr std::current_exception() _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
91 friend void std::rethrow_exception(exception_ptr);
kono
parents:
diff changeset
92 template<typename _Ex>
kono
parents:
diff changeset
93 friend exception_ptr std::make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 public:
kono
parents:
diff changeset
96 exception_ptr() _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 exception_ptr(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 #if __cplusplus >= 201103L
kono
parents:
diff changeset
101 exception_ptr(nullptr_t) noexcept
kono
parents:
diff changeset
102 : _M_exception_object(0)
kono
parents:
diff changeset
103 { }
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 exception_ptr(exception_ptr&& __o) noexcept
kono
parents:
diff changeset
106 : _M_exception_object(__o._M_exception_object)
kono
parents:
diff changeset
107 { __o._M_exception_object = 0; }
kono
parents:
diff changeset
108 #endif
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 #if (__cplusplus < 201103L) || defined (_GLIBCXX_EH_PTR_COMPAT)
kono
parents:
diff changeset
111 typedef void (exception_ptr::*__safe_bool)();
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 // For construction from nullptr or 0.
kono
parents:
diff changeset
114 exception_ptr(__safe_bool) _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
115 #endif
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 exception_ptr&
kono
parents:
diff changeset
118 operator=(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 #if __cplusplus >= 201103L
kono
parents:
diff changeset
121 exception_ptr&
kono
parents:
diff changeset
122 operator=(exception_ptr&& __o) noexcept
kono
parents:
diff changeset
123 {
kono
parents:
diff changeset
124 exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*this);
kono
parents:
diff changeset
125 return *this;
kono
parents:
diff changeset
126 }
kono
parents:
diff changeset
127 #endif
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 ~exception_ptr() _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 void
kono
parents:
diff changeset
132 swap(exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 #ifdef _GLIBCXX_EH_PTR_COMPAT
kono
parents:
diff changeset
135 // Retained for compatibility with CXXABI_1.3.
kono
parents:
diff changeset
136 void _M_safe_bool_dummy() _GLIBCXX_USE_NOEXCEPT
kono
parents:
diff changeset
137 __attribute__ ((__const__));
kono
parents:
diff changeset
138 bool operator!() const _GLIBCXX_USE_NOEXCEPT
kono
parents:
diff changeset
139 __attribute__ ((__pure__));
kono
parents:
diff changeset
140 operator __safe_bool() const _GLIBCXX_USE_NOEXCEPT;
kono
parents:
diff changeset
141 #endif
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 #if __cplusplus >= 201103L
kono
parents:
diff changeset
144 explicit operator bool() const
kono
parents:
diff changeset
145 { return _M_exception_object; }
kono
parents:
diff changeset
146 #endif
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 friend bool
kono
parents:
diff changeset
149 operator==(const exception_ptr&, const exception_ptr&)
kono
parents:
diff changeset
150 _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 const class std::type_info*
kono
parents:
diff changeset
153 __cxa_exception_type() const _GLIBCXX_USE_NOEXCEPT
kono
parents:
diff changeset
154 __attribute__ ((__pure__));
kono
parents:
diff changeset
155 };
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 bool
kono
parents:
diff changeset
158 operator==(const exception_ptr&, const exception_ptr&)
kono
parents:
diff changeset
159 _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 bool
kono
parents:
diff changeset
162 operator!=(const exception_ptr&, const exception_ptr&)
kono
parents:
diff changeset
163 _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 inline void
kono
parents:
diff changeset
166 swap(exception_ptr& __lhs, exception_ptr& __rhs)
kono
parents:
diff changeset
167 { __lhs.swap(__rhs); }
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 template<typename _Ex>
kono
parents:
diff changeset
170 inline void
kono
parents:
diff changeset
171 __dest_thunk(void* __x)
kono
parents:
diff changeset
172 { static_cast<_Ex*>(__x)->~_Ex(); }
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 } // namespace __exception_ptr
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 /// Obtain an exception_ptr pointing to a copy of the supplied object.
kono
parents:
diff changeset
177 template<typename _Ex>
kono
parents:
diff changeset
178 exception_ptr
kono
parents:
diff changeset
179 make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT
kono
parents:
diff changeset
180 {
kono
parents:
diff changeset
181 #if __cpp_exceptions
kono
parents:
diff changeset
182 try
kono
parents:
diff changeset
183 {
kono
parents:
diff changeset
184 #if __cpp_rtti && !_GLIBCXX_HAVE_CDTOR_CALLABI
kono
parents:
diff changeset
185 void *__e = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ex));
kono
parents:
diff changeset
186 (void)__cxxabiv1::__cxa_init_primary_exception(
kono
parents:
diff changeset
187 __e, const_cast<std::type_info*>(&typeid(__ex)),
kono
parents:
diff changeset
188 __exception_ptr::__dest_thunk<_Ex>);
kono
parents:
diff changeset
189 ::new (__e) _Ex(__ex);
kono
parents:
diff changeset
190 return exception_ptr(__e);
kono
parents:
diff changeset
191 #else
kono
parents:
diff changeset
192 throw __ex;
kono
parents:
diff changeset
193 #endif
kono
parents:
diff changeset
194 }
kono
parents:
diff changeset
195 catch(...)
kono
parents:
diff changeset
196 {
kono
parents:
diff changeset
197 return current_exception();
kono
parents:
diff changeset
198 }
kono
parents:
diff changeset
199 #else
kono
parents:
diff changeset
200 return exception_ptr();
kono
parents:
diff changeset
201 #endif
kono
parents:
diff changeset
202 }
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 // @} group exceptions
kono
parents:
diff changeset
205 } // namespace std
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 } // extern "C++"
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 #pragma GCC visibility pop
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 #endif