cxxabi.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. // ABI Support -*- C++ -*-
  2. // Copyright (C) 2000-2022 Free Software Foundation, Inc.
  3. //
  4. // This file is part of GCC.
  5. //
  6. // GCC is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation; either version 3, or (at your option)
  9. // any later version.
  10. //
  11. // GCC 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. // You should have received a copy of the GNU General Public License and
  20. // a copy of the GCC Runtime Library Exception along with this program;
  21. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  22. // <http://www.gnu.org/licenses/>.
  23. // Written by Nathan Sidwell, Codesourcery LLC, <nathan@codesourcery.com>
  24. /* This file declares the new abi entry points into the runtime. It is not
  25. normally necessary for user programs to include this header, or use the
  26. entry points directly. However, this header is available should that be
  27. needed.
  28. Some of the entry points are intended for both C and C++, thus this header
  29. is includable from both C and C++. Though the C++ specific parts are not
  30. available in C, naturally enough. */
  31. /** @file cxxabi.h
  32. * The header provides an interface to the C++ ABI.
  33. */
  34. #ifndef _CXXABI_H
  35. #define _CXXABI_H 1
  36. #pragma GCC system_header
  37. #pragma GCC visibility push(default)
  38. #include <stddef.h>
  39. #include <bits/c++config.h>
  40. #include <bits/cxxabi_tweaks.h>
  41. #include <bits/cxxabi_forced.h>
  42. #include <bits/cxxabi_init_exception.h>
  43. #ifdef __cplusplus
  44. namespace __cxxabiv1
  45. {
  46. extern "C"
  47. {
  48. #endif
  49. typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *);
  50. // Allocate array.
  51. void*
  52. __cxa_vec_new(size_t __element_count, size_t __element_size,
  53. size_t __padding_size, __cxa_cdtor_type __constructor,
  54. __cxa_cdtor_type __destructor);
  55. void*
  56. __cxa_vec_new2(size_t __element_count, size_t __element_size,
  57. size_t __padding_size, __cxa_cdtor_type __constructor,
  58. __cxa_cdtor_type __destructor, void *(*__alloc) (size_t),
  59. void (*__dealloc) (void*));
  60. void*
  61. __cxa_vec_new3(size_t __element_count, size_t __element_size,
  62. size_t __padding_size, __cxa_cdtor_type __constructor,
  63. __cxa_cdtor_type __destructor, void *(*__alloc) (size_t),
  64. void (*__dealloc) (void*, size_t));
  65. // Construct array.
  66. __cxa_vec_ctor_return_type
  67. __cxa_vec_ctor(void* __array_address, size_t __element_count,
  68. size_t __element_size, __cxa_cdtor_type __constructor,
  69. __cxa_cdtor_type __destructor);
  70. __cxa_vec_ctor_return_type
  71. __cxa_vec_cctor(void* __dest_array, void* __src_array,
  72. size_t __element_count, size_t __element_size,
  73. __cxa_cdtor_return_type (*__constructor) (void*, void*),
  74. __cxa_cdtor_type __destructor);
  75. // Destruct array.
  76. void
  77. __cxa_vec_dtor(void* __array_address, size_t __element_count,
  78. size_t __element_size, __cxa_cdtor_type __destructor);
  79. void
  80. __cxa_vec_cleanup(void* __array_address, size_t __element_count, size_t __s,
  81. __cxa_cdtor_type __destructor) _GLIBCXX_NOTHROW;
  82. // Destruct and release array.
  83. void
  84. __cxa_vec_delete(void* __array_address, size_t __element_size,
  85. size_t __padding_size, __cxa_cdtor_type __destructor);
  86. void
  87. __cxa_vec_delete2(void* __array_address, size_t __element_size,
  88. size_t __padding_size, __cxa_cdtor_type __destructor,
  89. void (*__dealloc) (void*));
  90. void
  91. __cxa_vec_delete3(void* __array_address, size_t __element_size,
  92. size_t __padding_size, __cxa_cdtor_type __destructor,
  93. void (*__dealloc) (void*, size_t));
  94. int
  95. __cxa_guard_acquire(__guard*);
  96. void
  97. __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW;
  98. void
  99. __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW;
  100. // DSO destruction.
  101. int
  102. #ifdef _GLIBCXX_CDTOR_CALLABI
  103. __cxa_atexit(void (_GLIBCXX_CDTOR_CALLABI *)(void*), void*, void*) _GLIBCXX_NOTHROW;
  104. #else
  105. __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
  106. #endif
  107. void
  108. __cxa_finalize(void*);
  109. // TLS destruction.
  110. int
  111. #ifdef _GLIBCXX_CDTOR_CALLABI
  112. __cxa_thread_atexit(void (_GLIBCXX_CDTOR_CALLABI *)(void*), void*, void *) _GLIBCXX_NOTHROW;
  113. #else
  114. __cxa_thread_atexit(void (*)(void*), void*, void *) _GLIBCXX_NOTHROW;
  115. #endif
  116. // Pure virtual functions.
  117. void
  118. __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
  119. void
  120. __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
  121. // Exception handling auxiliary.
  122. void
  123. __cxa_bad_cast() __attribute__((__noreturn__));
  124. void
  125. __cxa_bad_typeid() __attribute__((__noreturn__));
  126. void
  127. __cxa_throw_bad_array_new_length() __attribute__((__noreturn__));
  128. /**
  129. * @brief Demangling routine.
  130. * ABI-mandated entry point in the C++ runtime library for demangling.
  131. *
  132. * @param __mangled_name A NUL-terminated character string
  133. * containing the name to be demangled.
  134. *
  135. * @param __output_buffer A region of memory, allocated with
  136. * malloc, of @a *__length bytes, into which the demangled name is
  137. * stored. If @a __output_buffer is not long enough, it is
  138. * expanded using realloc. @a __output_buffer may instead be NULL;
  139. * in that case, the demangled name is placed in a region of memory
  140. * allocated with malloc.
  141. *
  142. * @param __length If @a __length is non-null, the length of the
  143. * buffer containing the demangled name is placed in @a *__length.
  144. *
  145. * @param __status If @a __status is non-null, @a *__status is set to
  146. * one of the following values:
  147. * 0: The demangling operation succeeded.
  148. * -1: A memory allocation failure occurred.
  149. * -2: @a mangled_name is not a valid name under the C++ ABI mangling rules.
  150. * -3: One of the arguments is invalid.
  151. *
  152. * @return A pointer to the start of the NUL-terminated demangled
  153. * name, or NULL if the demangling fails. The caller is
  154. * responsible for deallocating this memory using @c free.
  155. *
  156. * The demangling is performed using the C++ ABI mangling rules,
  157. * with GNU extensions. For example, this function is used in
  158. * __gnu_cxx::__verbose_terminate_handler.
  159. *
  160. * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html
  161. * for other examples of use.
  162. *
  163. * @note The same demangling functionality is available via
  164. * libiberty (@c <libiberty/demangle.h> and @c libiberty.a) in GCC
  165. * 3.1 and later, but that requires explicit installation (@c
  166. * --enable-install-libiberty) and uses a different API, although
  167. * the ABI is unchanged.
  168. */
  169. char*
  170. __cxa_demangle(const char* __mangled_name, char* __output_buffer,
  171. size_t* __length, int* __status);
  172. #ifdef __cplusplus
  173. }
  174. } // namespace __cxxabiv1
  175. #endif
  176. #ifdef __cplusplus
  177. #include <typeinfo>
  178. namespace __cxxabiv1
  179. {
  180. // Type information for int, float etc.
  181. class __fundamental_type_info : public std::type_info
  182. {
  183. public:
  184. explicit
  185. __fundamental_type_info(const char* __n) : std::type_info(__n) { }
  186. virtual
  187. ~__fundamental_type_info();
  188. };
  189. // Type information for array objects.
  190. class __array_type_info : public std::type_info
  191. {
  192. public:
  193. explicit
  194. __array_type_info(const char* __n) : std::type_info(__n) { }
  195. virtual
  196. ~__array_type_info();
  197. };
  198. // Type information for functions (both member and non-member).
  199. class __function_type_info : public std::type_info
  200. {
  201. public:
  202. explicit
  203. __function_type_info(const char* __n) : std::type_info(__n) { }
  204. virtual
  205. ~__function_type_info();
  206. protected:
  207. // Implementation defined member function.
  208. virtual bool
  209. __is_function_p() const;
  210. };
  211. // Type information for enumerations.
  212. class __enum_type_info : public std::type_info
  213. {
  214. public:
  215. explicit
  216. __enum_type_info(const char* __n) : std::type_info(__n) { }
  217. virtual
  218. ~__enum_type_info();
  219. };
  220. // Common type information for simple pointers and pointers to member.
  221. class __pbase_type_info : public std::type_info
  222. {
  223. public:
  224. unsigned int __flags; // Qualification of the target object.
  225. const std::type_info* __pointee; // Type of pointed to object.
  226. explicit
  227. __pbase_type_info(const char* __n, int __quals,
  228. const std::type_info* __type)
  229. : std::type_info(__n), __flags(__quals), __pointee(__type)
  230. { }
  231. virtual
  232. ~__pbase_type_info();
  233. // Implementation defined type.
  234. enum __masks
  235. {
  236. __const_mask = 0x1,
  237. __volatile_mask = 0x2,
  238. __restrict_mask = 0x4,
  239. __incomplete_mask = 0x8,
  240. __incomplete_class_mask = 0x10,
  241. __transaction_safe_mask = 0x20,
  242. __noexcept_mask = 0x40
  243. };
  244. protected:
  245. __pbase_type_info(const __pbase_type_info&);
  246. __pbase_type_info&
  247. operator=(const __pbase_type_info&);
  248. // Implementation defined member functions.
  249. virtual bool
  250. __do_catch(const std::type_info* __thr_type, void** __thr_obj,
  251. unsigned int __outer) const;
  252. inline virtual bool
  253. __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
  254. unsigned __outer) const;
  255. };
  256. inline bool __pbase_type_info::
  257. __pointer_catch (const __pbase_type_info *thrown_type,
  258. void **thr_obj,
  259. unsigned outer) const
  260. {
  261. return __pointee->__do_catch (thrown_type->__pointee, thr_obj, outer + 2);
  262. }
  263. // Type information for simple pointers.
  264. class __pointer_type_info : public __pbase_type_info
  265. {
  266. public:
  267. explicit
  268. __pointer_type_info(const char* __n, int __quals,
  269. const std::type_info* __type)
  270. : __pbase_type_info (__n, __quals, __type) { }
  271. virtual
  272. ~__pointer_type_info();
  273. protected:
  274. // Implementation defined member functions.
  275. virtual bool
  276. __is_pointer_p() const;
  277. virtual bool
  278. __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
  279. unsigned __outer) const;
  280. };
  281. class __class_type_info;
  282. // Type information for a pointer to member variable.
  283. class __pointer_to_member_type_info : public __pbase_type_info
  284. {
  285. public:
  286. __class_type_info* __context; // Class of the member.
  287. explicit
  288. __pointer_to_member_type_info(const char* __n, int __quals,
  289. const std::type_info* __type,
  290. __class_type_info* __klass)
  291. : __pbase_type_info(__n, __quals, __type), __context(__klass) { }
  292. virtual
  293. ~__pointer_to_member_type_info();
  294. protected:
  295. __pointer_to_member_type_info(const __pointer_to_member_type_info&);
  296. __pointer_to_member_type_info&
  297. operator=(const __pointer_to_member_type_info&);
  298. // Implementation defined member function.
  299. virtual bool
  300. __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj,
  301. unsigned __outer) const;
  302. };
  303. // Helper class for __vmi_class_type.
  304. class __base_class_type_info
  305. {
  306. public:
  307. const __class_type_info* __base_type; // Base class type.
  308. #ifdef _GLIBCXX_LLP64
  309. long long __offset_flags; // Offset and info.
  310. #else
  311. long __offset_flags; // Offset and info.
  312. #endif
  313. enum __offset_flags_masks
  314. {
  315. __virtual_mask = 0x1,
  316. __public_mask = 0x2,
  317. __hwm_bit = 2,
  318. __offset_shift = 8 // Bits to shift offset.
  319. };
  320. // Implementation defined member functions.
  321. bool
  322. __is_virtual_p() const
  323. { return __offset_flags & __virtual_mask; }
  324. bool
  325. __is_public_p() const
  326. { return __offset_flags & __public_mask; }
  327. ptrdiff_t
  328. __offset() const
  329. {
  330. // This shift, being of a signed type, is implementation
  331. // defined. GCC implements such shifts as arithmetic, which is
  332. // what we want.
  333. return static_cast<ptrdiff_t>(__offset_flags) >> __offset_shift;
  334. }
  335. };
  336. // Type information for a class.
  337. class __class_type_info : public std::type_info
  338. {
  339. public:
  340. explicit
  341. __class_type_info (const char *__n) : type_info(__n) { }
  342. virtual
  343. ~__class_type_info ();
  344. // Implementation defined types.
  345. // The type sub_kind tells us about how a base object is contained
  346. // within a derived object. We often do this lazily, hence the
  347. // UNKNOWN value. At other times we may use NOT_CONTAINED to mean
  348. // not publicly contained.
  349. enum __sub_kind
  350. {
  351. // We have no idea.
  352. __unknown = 0,
  353. // Not contained within us (in some circumstances this might
  354. // mean not contained publicly)
  355. __not_contained,
  356. // Contained ambiguously.
  357. __contained_ambig,
  358. // Via a virtual path.
  359. __contained_virtual_mask = __base_class_type_info::__virtual_mask,
  360. // Via a public path.
  361. __contained_public_mask = __base_class_type_info::__public_mask,
  362. // Contained within us.
  363. __contained_mask = 1 << __base_class_type_info::__hwm_bit,
  364. __contained_private = __contained_mask,
  365. __contained_public = __contained_mask | __contained_public_mask
  366. };
  367. struct __upcast_result;
  368. struct __dyncast_result;
  369. protected:
  370. // Implementation defined member functions.
  371. virtual bool
  372. __do_upcast(const __class_type_info* __dst_type, void**__obj_ptr) const;
  373. virtual bool
  374. __do_catch(const type_info* __thr_type, void** __thr_obj,
  375. unsigned __outer) const;
  376. public:
  377. // Helper for upcast. See if DST is us, or one of our bases.
  378. // Return false if not found, true if found.
  379. virtual bool
  380. __do_upcast(const __class_type_info* __dst, const void* __obj,
  381. __upcast_result& __restrict __result) const;
  382. // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly
  383. // within OBJ_PTR. OBJ_PTR points to a base object of our type,
  384. // which is the destination type. SRC2DST indicates how SRC
  385. // objects might be contained within this type. If SRC_PTR is one
  386. // of our SRC_TYPE bases, indicate the virtuality. Returns
  387. // not_contained for non containment or private containment.
  388. inline __sub_kind
  389. __find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
  390. const __class_type_info* __src_type,
  391. const void* __src_ptr) const;
  392. // Helper for dynamic cast. ACCESS_PATH gives the access from the
  393. // most derived object to this base. DST_TYPE indicates the
  394. // desired type we want. OBJ_PTR points to a base of our type
  395. // within the complete object. SRC_TYPE indicates the static type
  396. // started from and SRC_PTR points to that base within the most
  397. // derived object. Fill in RESULT with what we find. Return true
  398. // if we have located an ambiguous match.
  399. virtual bool
  400. __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
  401. const __class_type_info* __dst_type, const void* __obj_ptr,
  402. const __class_type_info* __src_type, const void* __src_ptr,
  403. __dyncast_result& __result) const;
  404. // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE
  405. // bases are inherited by the type started from -- which is not
  406. // necessarily the current type. The current type will be a base
  407. // of the destination type. OBJ_PTR points to the current base.
  408. virtual __sub_kind
  409. __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
  410. const __class_type_info* __src_type,
  411. const void* __src_ptr) const;
  412. };
  413. // Type information for a class with a single non-virtual base.
  414. class __si_class_type_info : public __class_type_info
  415. {
  416. public:
  417. const __class_type_info* __base_type;
  418. explicit
  419. __si_class_type_info(const char *__n, const __class_type_info *__base)
  420. : __class_type_info(__n), __base_type(__base) { }
  421. virtual
  422. ~__si_class_type_info();
  423. protected:
  424. __si_class_type_info(const __si_class_type_info&);
  425. __si_class_type_info&
  426. operator=(const __si_class_type_info&);
  427. // Implementation defined member functions.
  428. virtual bool
  429. __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
  430. const __class_type_info* __dst_type, const void* __obj_ptr,
  431. const __class_type_info* __src_type, const void* __src_ptr,
  432. __dyncast_result& __result) const;
  433. virtual __sub_kind
  434. __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
  435. const __class_type_info* __src_type,
  436. const void* __sub_ptr) const;
  437. virtual bool
  438. __do_upcast(const __class_type_info*__dst, const void*__obj,
  439. __upcast_result& __restrict __result) const;
  440. };
  441. // Type information for a class with multiple and/or virtual bases.
  442. class __vmi_class_type_info : public __class_type_info
  443. {
  444. public:
  445. unsigned int __flags; // Details about the class hierarchy.
  446. unsigned int __base_count; // Number of direct bases.
  447. // The array of bases uses the trailing array struct hack so this
  448. // class is not constructable with a normal constructor. It is
  449. // internally generated by the compiler.
  450. __base_class_type_info __base_info[1]; // Array of bases.
  451. explicit
  452. __vmi_class_type_info(const char* __n, int ___flags)
  453. : __class_type_info(__n), __flags(___flags), __base_count(0) { }
  454. virtual
  455. ~__vmi_class_type_info();
  456. // Implementation defined types.
  457. enum __flags_masks
  458. {
  459. __non_diamond_repeat_mask = 0x1, // Distinct instance of repeated base.
  460. __diamond_shaped_mask = 0x2, // Diamond shaped multiple inheritance.
  461. __flags_unknown_mask = 0x10
  462. };
  463. protected:
  464. // Implementation defined member functions.
  465. virtual bool
  466. __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path,
  467. const __class_type_info* __dst_type, const void* __obj_ptr,
  468. const __class_type_info* __src_type, const void* __src_ptr,
  469. __dyncast_result& __result) const;
  470. virtual __sub_kind
  471. __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr,
  472. const __class_type_info* __src_type,
  473. const void* __src_ptr) const;
  474. virtual bool
  475. __do_upcast(const __class_type_info* __dst, const void* __obj,
  476. __upcast_result& __restrict __result) const;
  477. };
  478. // Exception handling forward declarations.
  479. struct __cxa_exception;
  480. struct __cxa_refcounted_exception;
  481. struct __cxa_dependent_exception;
  482. struct __cxa_eh_globals;
  483. extern "C"
  484. {
  485. // Dynamic cast runtime.
  486. // src2dst has the following possible values
  487. // >-1: src_type is a unique public non-virtual base of dst_type
  488. // dst_ptr + src2dst == src_ptr
  489. // -1: unspecified relationship
  490. // -2: src_type is not a public base of dst_type
  491. // -3: src_type is a multiple public non-virtual base of dst_type
  492. void*
  493. __dynamic_cast(const void* __src_ptr, // Starting object.
  494. const __class_type_info* __src_type, // Static type of object.
  495. const __class_type_info* __dst_type, // Desired target type.
  496. ptrdiff_t __src2dst); // How src and dst are related.
  497. // Exception handling runtime.
  498. // The __cxa_eh_globals for the current thread can be obtained by using
  499. // either of the following functions. The "fast" version assumes at least
  500. // one prior call of __cxa_get_globals has been made from the current
  501. // thread, so no initialization is necessary.
  502. __cxa_eh_globals*
  503. __cxa_get_globals() _GLIBCXX_NOTHROW __attribute__ ((__const__));
  504. __cxa_eh_globals*
  505. __cxa_get_globals_fast() _GLIBCXX_NOTHROW __attribute__ ((__const__));
  506. // Free the space allocated for the primary exception.
  507. void
  508. __cxa_free_exception(void*) _GLIBCXX_NOTHROW;
  509. // Throw the exception.
  510. void
  511. __cxa_throw(void*, std::type_info*, void (_GLIBCXX_CDTOR_CALLABI *) (void *))
  512. __attribute__((__noreturn__));
  513. // Used to implement exception handlers.
  514. void*
  515. __cxa_get_exception_ptr(void*) _GLIBCXX_NOTHROW __attribute__ ((__pure__));
  516. void*
  517. __cxa_begin_catch(void*) _GLIBCXX_NOTHROW;
  518. void
  519. __cxa_end_catch();
  520. void
  521. __cxa_rethrow() __attribute__((__noreturn__));
  522. // Returns the type_info for the currently handled exception [15.3/8], or
  523. // null if there is none.
  524. std::type_info*
  525. __cxa_current_exception_type() _GLIBCXX_NOTHROW __attribute__ ((__pure__));
  526. // GNU Extensions.
  527. // Allocate memory for a dependent exception.
  528. __cxa_dependent_exception*
  529. __cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW;
  530. // Free the space allocated for the dependent exception.
  531. void
  532. __cxa_free_dependent_exception(__cxa_dependent_exception*) _GLIBCXX_NOTHROW;
  533. } // extern "C"
  534. // A magic placeholder class that can be caught by reference
  535. // to recognize foreign exceptions.
  536. class __foreign_exception
  537. {
  538. virtual ~__foreign_exception() throw();
  539. virtual void __pure_dummy() = 0; // prevent catch by value
  540. };
  541. } // namespace __cxxabiv1
  542. /** @namespace abi
  543. * @brief The cross-vendor C++ Application Binary Interface. A
  544. * namespace alias to __cxxabiv1, but user programs should use the
  545. * alias 'abi'.
  546. *
  547. * A brief overview of an ABI is given in the libstdc++ FAQ, question
  548. * 5.8 (you may have a copy of the FAQ locally, or you can view the online
  549. * version at http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#5_8 ).
  550. *
  551. * GCC subscribes to a cross-vendor ABI for C++, sometimes
  552. * called the IA64 ABI because it happens to be the native ABI for that
  553. * platform. It is summarized at http://www.codesourcery.com/cxx-abi/
  554. * along with the current specification.
  555. *
  556. * For users of GCC greater than or equal to 3.x, entry points are
  557. * available in <cxxabi.h>, which notes, <em>'It is not normally
  558. * necessary for user programs to include this header, or use the
  559. * entry points directly. However, this header is available should
  560. * that be needed.'</em>
  561. */
  562. namespace abi = __cxxabiv1;
  563. namespace __gnu_cxx
  564. {
  565. /**
  566. * @brief Exception thrown by __cxa_guard_acquire.
  567. * @ingroup exceptions
  568. *
  569. * C++ 2011 6.7 [stmt.dcl]/4: If control re-enters the declaration
  570. * recursively while the variable is being initialized, the behavior
  571. * is undefined.
  572. *
  573. * Since we already have a library function to handle locking, we might
  574. * as well check for this situation and throw an exception.
  575. * We use the second byte of the guard variable to remember that we're
  576. * in the middle of an initialization.
  577. */
  578. class recursive_init_error: public std::exception
  579. {
  580. public:
  581. recursive_init_error() _GLIBCXX_NOTHROW;
  582. virtual ~recursive_init_error() _GLIBCXX_NOTHROW;
  583. };
  584. }
  585. #endif // __cplusplus
  586. #pragma GCC visibility pop
  587. #endif // __CXXABI_H