blob: f29253ce1b6cb0ee746c16be8ab6f105fe201959 [file] [log] [blame]
Howard Hinnantd213ffd2011-05-05 15:27:28 +00001//===--------------------------- cxxabi.h ---------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef __CXXABI_H
Dan Albert3cbecdf2015-02-04 21:23:20 +000011#define __CXXABI_H
Howard Hinnantd213ffd2011-05-05 15:27:28 +000012
13/*
14 * This header provides the interface to the C++ ABI as defined at:
15 * http://www.codesourcery.com/cxx-abi/
16 */
17
18#include <stddef.h>
19#include <stdint.h>
20
Dan Albert8414c5a2015-02-05 23:55:15 +000021#include <__cxxabi_config.h>
22
Marshall Clow5013d7c2015-06-02 13:03:17 +000023#define _LIBCPPABI_VERSION 1002
Nick Kledzikf72cdd52011-08-02 05:01:17 +000024#define LIBCXXABI_NORETURN __attribute__((noreturn))
Marshall Clow4c2acbc2011-06-03 02:04:41 +000025
Nick Kledzik15a69282011-08-02 05:15:26 +000026#ifdef __cplusplus
27
Howard Hinnantd213ffd2011-05-05 15:27:28 +000028namespace std {
Dan Albert3cbecdf2015-02-04 21:23:20 +000029class type_info; // forward declaration
Howard Hinnantd213ffd2011-05-05 15:27:28 +000030}
31
32
33// runtime routines use C calling conventions, but are in __cxxabiv1 namespace
Dan Albert3cbecdf2015-02-04 21:23:20 +000034namespace __cxxabiv1 {
35extern "C" {
Howard Hinnantd213ffd2011-05-05 15:27:28 +000036
37// 2.4.2 Allocating the Exception Object
Howard Hinnantca00a4e2012-01-30 16:02:11 +000038extern void * __cxa_allocate_exception(size_t thrown_size) throw();
39extern void __cxa_free_exception(void * thrown_exception) throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +000040
41// 2.4.3 Throwing the Exception Object
Dan Albert3cbecdf2015-02-04 21:23:20 +000042extern LIBCXXABI_NORETURN void __cxa_throw(void * thrown_exception,
Marshall Clow703d1482011-07-20 14:27:46 +000043 std::type_info * tinfo, void (*dest)(void *));
Howard Hinnantd213ffd2011-05-05 15:27:28 +000044
45// 2.5.3 Exception Handlers
Howard Hinnantca00a4e2012-01-30 16:02:11 +000046extern void * __cxa_get_exception_ptr(void * exceptionObject) throw();
47extern void * __cxa_begin_catch(void * exceptionObject) throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +000048extern void __cxa_end_catch();
Nico Weber55d99b72014-06-25 22:49:13 +000049#if LIBCXXABI_ARM_EHABI
Logan Chien05d51bc2014-05-10 00:42:10 +000050extern bool __cxa_begin_cleanup(void * exceptionObject) throw();
51extern void __cxa_end_cleanup();
52#endif
Howard Hinnantd213ffd2011-05-05 15:27:28 +000053extern std::type_info * __cxa_current_exception_type();
54
55// 2.5.4 Rethrowing Exceptions
Marshall Clow703d1482011-07-20 14:27:46 +000056extern LIBCXXABI_NORETURN void __cxa_rethrow();
Howard Hinnantd213ffd2011-05-05 15:27:28 +000057
58
59
60// 2.6 Auxiliary Runtime APIs
Marshall Clow4c2acbc2011-06-03 02:04:41 +000061extern LIBCXXABI_NORETURN void __cxa_bad_cast(void);
62extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
Aaron Ballman68fcfa12014-09-11 17:26:43 +000063extern LIBCXXABI_NORETURN void __cxa_throw_bad_array_new_length(void);
Howard Hinnantd213ffd2011-05-05 15:27:28 +000064
65
66
67// 3.2.6 Pure Virtual Function API
Marshall Clow4c2acbc2011-06-03 02:04:41 +000068extern LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
Howard Hinnantd213ffd2011-05-05 15:27:28 +000069
Howard Hinnant92827182011-05-24 22:01:16 +000070// 3.2.7 Deleted Virtual Function API
Marshall Clow4c2acbc2011-06-03 02:04:41 +000071extern LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
Howard Hinnant92827182011-05-24 22:01:16 +000072
Howard Hinnantd213ffd2011-05-05 15:27:28 +000073// 3.3.2 One-time Construction API
Dan Alberta1fce462015-02-05 01:33:15 +000074#ifdef __arm__
Nick Lewyckyd8cfd652011-06-07 18:46:10 +000075extern int __cxa_guard_acquire(uint32_t*);
76extern void __cxa_guard_release(uint32_t*);
77extern void __cxa_guard_abort(uint32_t*);
78#else
Howard Hinnantd213ffd2011-05-05 15:27:28 +000079extern int __cxa_guard_acquire(uint64_t*);
80extern void __cxa_guard_release(uint64_t*);
81extern void __cxa_guard_abort(uint64_t*);
Nick Lewyckyd8cfd652011-06-07 18:46:10 +000082#endif
Howard Hinnantd213ffd2011-05-05 15:27:28 +000083
84// 3.3.3 Array Construction and Destruction API
Dan Albert3cbecdf2015-02-04 21:23:20 +000085extern void* __cxa_vec_new(size_t element_count,
86 size_t element_size,
87 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +000088 void (*constructor)(void*),
Dan Albert3cbecdf2015-02-04 21:23:20 +000089 void (*destructor)(void*));
Howard Hinnantd213ffd2011-05-05 15:27:28 +000090
91extern void* __cxa_vec_new2(size_t element_count,
Dan Albert3cbecdf2015-02-04 21:23:20 +000092 size_t element_size,
Howard Hinnantd213ffd2011-05-05 15:27:28 +000093 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +000094 void (*constructor)(void*),
95 void (*destructor)(void*),
Dan Albert3cbecdf2015-02-04 21:23:20 +000096 void* (*alloc)(size_t),
97 void (*dealloc)(void*));
Howard Hinnantd213ffd2011-05-05 15:27:28 +000098
99extern void* __cxa_vec_new3(size_t element_count,
Dan Albert3cbecdf2015-02-04 21:23:20 +0000100 size_t element_size,
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000101 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000102 void (*constructor)(void*),
103 void (*destructor)(void*),
Dan Albert3cbecdf2015-02-04 21:23:20 +0000104 void* (*alloc)(size_t),
105 void (*dealloc)(void*, size_t));
106
107extern void __cxa_vec_ctor(void* array_address,
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000108 size_t element_count,
Dan Albert3cbecdf2015-02-04 21:23:20 +0000109 size_t element_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000110 void (*constructor)(void*),
Dan Albert3cbecdf2015-02-04 21:23:20 +0000111 void (*destructor)(void*));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000112
Dan Albert3cbecdf2015-02-04 21:23:20 +0000113extern void __cxa_vec_dtor(void* array_address,
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000114 size_t element_count,
Dan Albert3cbecdf2015-02-04 21:23:20 +0000115 size_t element_size,
116 void (*destructor)(void*));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000117
Dan Albert3cbecdf2015-02-04 21:23:20 +0000118extern void __cxa_vec_cleanup(void* array_address,
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000119 size_t element_count,
Dan Albert3cbecdf2015-02-04 21:23:20 +0000120 size_t element_size,
121 void (*destructor)(void*));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000122
Dan Albert3cbecdf2015-02-04 21:23:20 +0000123extern void __cxa_vec_delete(void* array_address,
124 size_t element_size,
125 size_t padding_size,
126 void (*destructor)(void*));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000127
Dan Albert3cbecdf2015-02-04 21:23:20 +0000128extern void __cxa_vec_delete2(void* array_address,
129 size_t element_size,
130 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000131 void (*destructor)(void*),
Dan Albert3cbecdf2015-02-04 21:23:20 +0000132 void (*dealloc)(void*));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000133
Dan Albert3cbecdf2015-02-04 21:23:20 +0000134extern void __cxa_vec_delete3(void* __array_address,
135 size_t element_size,
136 size_t padding_size,
Howard Hinnant25f18072011-06-07 19:56:49 +0000137 void (*destructor)(void*),
Dan Albert3cbecdf2015-02-04 21:23:20 +0000138 void (*dealloc)(void*, size_t));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000139
Dan Albert3cbecdf2015-02-04 21:23:20 +0000140extern void __cxa_vec_cctor(void* dest_array,
141 void* src_array,
142 size_t element_count,
143 size_t element_size,
144 void (*constructor)(void*, void*),
145 void (*destructor)(void*));
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000146
147// 3.3.5.3 Runtime API
148extern int __cxa_atexit(void (*f)(void*), void* p, void* d);
149extern int __cxa_finalize(void*);
150
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000151// 3.4 Demangler API
Dan Albert3cbecdf2015-02-04 21:23:20 +0000152extern char* __cxa_demangle(const char* mangled_name,
Howard Hinnant25f18072011-06-07 19:56:49 +0000153 char* output_buffer,
Dan Albert3cbecdf2015-02-04 21:23:20 +0000154 size_t* length,
Howard Hinnant25f18072011-06-07 19:56:49 +0000155 int* status);
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000156
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000157// Apple additions to support C++ 0x exception_ptr class
158// These are primitives to wrap a smart pointer around an exception object
Howard Hinnantca00a4e2012-01-30 16:02:11 +0000159extern void * __cxa_current_primary_exception() throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000160extern void __cxa_rethrow_primary_exception(void* primary_exception);
Howard Hinnantca00a4e2012-01-30 16:02:11 +0000161extern void __cxa_increment_exception_refcount(void* primary_exception) throw();
162extern void __cxa_decrement_exception_refcount(void* primary_exception) throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000163
Marshall Clow5013d7c2015-06-02 13:03:17 +0000164// Apple extension to support std::uncaught_exception()
165extern bool __cxa_uncaught_exception () throw();
166extern unsigned int __cxa_uncaught_exceptions() throw();
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000167
Dan Albertefa37d12014-12-18 00:03:57 +0000168#ifdef __linux__
169// Linux TLS support. Not yet an official part of the Itanium ABI.
170// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
171extern int __cxa_thread_atexit(void (*)(void *), void *, void *) throw();
172#endif
173
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000174 } // extern "C"
175} // namespace __cxxabiv1
176
Howard Hinnant3759e452012-02-17 18:45:44 +0000177namespace abi = __cxxabiv1;
Howard Hinnantd213ffd2011-05-05 15:27:28 +0000178
Nico Weber55d99b72014-06-25 22:49:13 +0000179#endif // __cplusplus
180
Dan Albert3cbecdf2015-02-04 21:23:20 +0000181#endif // __CXXABI_H