summaryrefslogtreecommitdiffstats
path: root/contrib/libcxxrt/exception.cc
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-02-13 22:05:54 +0000
committerdim <dim@FreeBSD.org>2015-02-13 22:05:54 +0000
commit3678f64ad386927abc67f2fa9c29e9d841865db8 (patch)
tree3f1fe901534b9de961c0c7ea660ae37c69fea14b /contrib/libcxxrt/exception.cc
parentd8b2164f70a462483fbb9be8e8edadf15b5c13a3 (diff)
downloadFreeBSD-src-3678f64ad386927abc67f2fa9c29e9d841865db8.zip
FreeBSD-src-3678f64ad386927abc67f2fa9c29e9d841865db8.tar.gz
Synchronize the default C++ stack in stable/10 with head, by merging
almost all recent changes to libc++ and libcxxrt. MFC r256642: Since C++ typeinfo objects are currently not guaranteed to be merged at runtime by the dynamic linker, check for their equality in libcxxrt by not only comparing the typeinfo's name pointers, but also comparing the full names, if necessary. (This is similar to what GNU libstdc++ does in its default configuration.) The 'deep' check can be turned off again by defining LIBCXXRT_MERGED_TYPEINFO, and recompiling libcxxrt. Reviewed by: theraven MFC r270522 (by rdivacky): The standard we compile libc++ with is called c++11 not c++0x. MFC r273066 (by bapt): Import patch from libc++ r197313 which allows using libc++ headers with gcc Differential Revision: https://reviews.freebsd.org/D942 Reviewed by: imp MFC r273381 (by bapt): Add support for __cxa_throw_bad_array_new_length in libcxxrt It is required for use with newer g++49 Differential Revision: https://reviews.freebsd.org/D982 Reviewed by: theraven Approved by: theraven MFC r273382 (by bapt): Fix build by marking the new functions as weak This is a temporary fix MFC r273407 (by bapt): When using an external gcc 4.8+ and not building libstdc++ then create in the objectdir a fake libstdc++.so and libstdc++.a which is a symlink on libc++ that allow g++ to satisfy its links dependencies in the least hackish way. Please note that this hacky libstds++ never get installed on the final system Reviewed by: imp MFC r273434 (by bapt): Do not define bad_array_new_length::bad_array_new_length in libc++ anymore when used in combinaison with libcxxrt since it is now defined there already. This fixes building world MFC r276417: Import libcxxrt master 00bc29eb6513624824a6d7db2ebc768a4216a604. Interesting fixes: 76584a0 Reorganize code to use only 32bit atomic ops for 32bit platforms 30d2ae5 Implement __cxa_throw_bad_array_new_length Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D1390 MFC r277217: Import libc++ trunk r224926. This fixes a number of bugs, completes C++14 support[1], adds more C++1z features[2], and fixes the following LWG issues[3]: 1450: Contradiction in regex_constants 2003: String exception inconsistency in erase. 2075: Progress guarantees, lock-free property, and scheduling assumptions 2104: unique_lock move-assignment should not be noexcept 2112: User-defined classes that cannot be derived from 2132: std::function ambiguity 2135: Unclear requirement for exceptions thrown in condition_variable::wait() 2142: packaged_task::operator() synchronization too broad? 2182: Container::[const_]reference types are misleadingly specified 2186: Incomplete action on async/launch::deferred 2188: Reverse iterator does not fully support targets that overload operator& 2193: Default constructors for standard library containers are explicit 2205: Problematic postconditions of regex_match and regex_search 2213: Return value of std::regex_replace 2240: Probable misuse of term "function scope" in [thread.condition] 2252: Strong guarantee on vector::push_back() still broken with C++11? 2257: Simplify container requirements with the new algorithms 2258: a.erase(q1, q2) unable to directly return q2 2263: Comparing iterators and allocator pointers with different const-character 2268: Setting a default argument in the declaration of a member function assign of std::basic_string 2271: regex_traits::lookup_classname specification unclear 2272: quoted should use char_traits::eq for character comparison 2278: User-defined literals for Standard Library types 2280: begin / end for arrays should be constexpr and noexcept 2285: make_reverse_iterator 2288: Inconsistent requirements for shared mutexes 2291: std::hash is vulnerable to collision DoS attack 2293: Wrong facet used by num_put::do_put 2299: Effects of inaccessible key_compare::is_transparent type are not clear 2301: Why is std::tie not constexpr? 2304: Complexity of count in unordered associative containers 2306: match_results::reference should be value_type&, not const value_type& 2308: Clarify container destructor requirements w.r.t. std::array 2313: tuple_size should always derive from integral_constant<size_t, N> 2314: apply() should return decltype(auto) and use decay_t before tuple_size 2315: weak_ptr should be movable 2316: weak_ptr::lock() should be atomic 2317: The type property queries should be UnaryTypeTraits returning size_t 2320: select_on_container_copy_construction() takes allocators, not containers 2322: Associative(initializer_list, stuff) constructors are underspecified 2323: vector::resize(n, t)'s specification should be simplified 2324: Insert iterator constructors should use addressof() 2329: regex_match()/regex_search() with match_results should forbid temporary strings 2330: regex("meow", regex::icase) is technically forbidden but should be permitted 2332: regex_iterator/regex_token_iterator should forbid temporary regexes 2339: Wording issue in nth_element 2341: Inconsistency between basic_ostream::seekp(pos) and basic_ostream::seekp(off, dir) 2344: quoted()'s interaction with padding is unclear 2346: integral_constant's member functions should be marked noexcept 2350: min, max, and minmax should be constexpr 2356: Stability of erasure in unordered associative containers 2357: Remaining "Assignable" requirement 2359: How does regex_constants::nosubs affect basic_regex::mark_count()? 2360: reverse_iterator::operator*() is unimplementable [1] http://libcxx.llvm.org/cxx1y_status.html [2] http://libcxx.llvm.org/cxx1z_status.html [3] http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html Exp-run: antoine MFC r277944: Partially revert r273382, to reduce diffs against upstream. This was a temporary fix to solve a conflict with an older version of libc++, and it is no longer relevant. MFC r278010: Revert r256642, not only to reduce diffs against upstream libcxxrt, but also because it is the wrong approach: comparing typeinfo names deeply causes trouble if two loaded DSOs use independent types of the same name. In addition, this particular change was never merged to FreeBSD 10.x and 9.x, so let's get rid of it before it ends up in an 11.x release. Discussed with: theraven, joerg@netbsd MFC r278016: Import libcxxrt master 1cb607e89f6135bbc10f3d3b6fba1f983e258dcc. Interesting fixes: 1cb607e Correct gcc version check for __cxa_begin_catch() declaration with or without throw()
Diffstat (limited to 'contrib/libcxxrt/exception.cc')
-rw-r--r--contrib/libcxxrt/exception.cc137
1 files changed, 76 insertions, 61 deletions
diff --git a/contrib/libcxxrt/exception.cc b/contrib/libcxxrt/exception.cc
index d848905..e428773 100644
--- a/contrib/libcxxrt/exception.cc
+++ b/contrib/libcxxrt/exception.cc
@@ -71,11 +71,11 @@ static void saveLandingPad(struct _Unwind_Context *context,
int selector,
dw_eh_ptr_t landingPad)
{
-#ifdef __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
// On ARM, we store the saved exception in the generic part of the structure
ucb->barrier_cache.sp = _Unwind_GetGR(context, 13);
- ucb->barrier_cache.bitpattern[1] = (uint32_t)selector;
- ucb->barrier_cache.bitpattern[3] = (uint32_t)landingPad;
+ ucb->barrier_cache.bitpattern[1] = static_cast<uint32_t>(selector);
+ ucb->barrier_cache.bitpattern[3] = reinterpret_cast<uint32_t>(landingPad);
#endif
// Cache the results for the phase 2 unwind, if we found a handler
// and this is not a foreign exception.
@@ -95,15 +95,15 @@ static int loadLandingPad(struct _Unwind_Context *context,
unsigned long *selector,
dw_eh_ptr_t *landingPad)
{
-#ifdef __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
*selector = ucb->barrier_cache.bitpattern[1];
- *landingPad = (dw_eh_ptr_t)ucb->barrier_cache.bitpattern[3];
+ *landingPad = reinterpret_cast<dw_eh_ptr_t>(ucb->barrier_cache.bitpattern[3]);
return 1;
#else
if (ex)
{
*selector = ex->handlerSwitchValue;
- *landingPad = (dw_eh_ptr_t)ex->catchTemp;
+ *landingPad = reinterpret_cast<dw_eh_ptr_t>(ex->catchTemp);
return 0;
}
return 0;
@@ -113,7 +113,7 @@ static int loadLandingPad(struct _Unwind_Context *context,
static inline _Unwind_Reason_Code continueUnwinding(struct _Unwind_Exception *ex,
struct _Unwind_Context *context)
{
-#ifdef __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
if (__gnu_unwind_frame(ex, context) != _URC_OK) { return _URC_FAILURE; }
#endif
return _URC_CONTINUE_UNWIND;
@@ -204,7 +204,7 @@ struct __cxa_dependent_exception
terminate_handler terminateHandler;
__cxa_exception *nextException;
int handlerCount;
-#ifdef __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
_Unwind_Exception *nextCleanup;
int cleanupCount;
#endif
@@ -267,13 +267,13 @@ static bool isDependentException(uint64_t cls)
static __cxa_exception *exceptionFromPointer(void *ex)
{
- return (__cxa_exception*)((char*)ex -
+ return reinterpret_cast<__cxa_exception*>(static_cast<char*>(ex) -
offsetof(struct __cxa_exception, unwindHeader));
}
static __cxa_exception *realExceptionFromException(__cxa_exception *ex)
{
if (!isDependentException(ex->unwindHeader.exception_class)) { return ex; }
- return ((__cxa_exception*)(((__cxa_dependent_exception*)ex)->primaryException))-1;
+ return reinterpret_cast<__cxa_exception*>((reinterpret_cast<__cxa_dependent_exception*>(ex))->primaryException)-1;
}
@@ -304,13 +304,13 @@ static pthread_key_t eh_key;
static void exception_cleanup(_Unwind_Reason_Code reason,
struct _Unwind_Exception *ex)
{
- __cxa_free_exception((void*)ex);
+ __cxa_free_exception(static_cast<void*>(ex));
}
static void dependent_exception_cleanup(_Unwind_Reason_Code reason,
struct _Unwind_Exception *ex)
{
- __cxa_free_dependent_exception((void*)ex);
+ __cxa_free_dependent_exception(static_cast<void*>(ex));
}
/**
@@ -333,13 +333,13 @@ static void free_exception_list(__cxa_exception *ex)
*/
static void thread_cleanup(void* thread_info)
{
- __cxa_thread_info *info = (__cxa_thread_info*)thread_info;
+ __cxa_thread_info *info = static_cast<__cxa_thread_info*>(thread_info);
if (info->globals.caughtExceptions)
{
// If this is a foreign exception, ask it to clean itself up.
if (info->foreign_exception_state != __cxa_thread_info::none)
{
- _Unwind_Exception *e = (_Unwind_Exception*)info->globals.caughtExceptions;
+ _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions);
e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
}
else
@@ -379,8 +379,8 @@ static void init_key(void)
return;
}
pthread_key_create(&eh_key, thread_cleanup);
- pthread_setspecific(eh_key, (void*)0x42);
- fakeTLS = (pthread_getspecific(eh_key) != (void*)0x42);
+ pthread_setspecific(eh_key, reinterpret_cast<void *>(0x42));
+ fakeTLS = (pthread_getspecific(eh_key) != reinterpret_cast<void *>(0x42));
pthread_setspecific(eh_key, 0);
}
@@ -394,10 +394,10 @@ static __cxa_thread_info *thread_info()
fakeTLS = true;
}
if (fakeTLS) { return &singleThreadInfo; }
- __cxa_thread_info *info = (__cxa_thread_info*)pthread_getspecific(eh_key);
+ __cxa_thread_info *info = static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key));
if (0 == info)
{
- info = (__cxa_thread_info*)calloc(1, sizeof(__cxa_thread_info));
+ info = static_cast<__cxa_thread_info*>(calloc(1, sizeof(__cxa_thread_info)));
pthread_setspecific(eh_key, info);
}
return info;
@@ -409,7 +409,7 @@ static __cxa_thread_info *thread_info()
static __cxa_thread_info *thread_info_fast()
{
if (fakeTLS) { return &singleThreadInfo; }
- return (__cxa_thread_info*)pthread_getspecific(eh_key);
+ return static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key));
}
/**
* ABI function returning the __cxa_eh_globals structure.
@@ -472,7 +472,7 @@ static char *emergency_malloc(size_t size)
if (0 != m)
{
pthread_mutex_unlock(&emergency_malloc_lock);
- return (char*)m;
+ return static_cast<char*>(m);
}
for (int i=0 ; i<16 ; i++)
{
@@ -510,7 +510,7 @@ static void emergency_malloc_free(char *ptr)
// Find the buffer corresponding to this pointer.
for (int i=0 ; i<16 ; i++)
{
- if (ptr == (void*)(emergency_buffer + (1024 * i)))
+ if (ptr == static_cast<void*>(emergency_buffer + (1024 * i)))
{
buffer = i;
break;
@@ -521,7 +521,7 @@ static void emergency_malloc_free(char *ptr)
// emergency_malloc() is expected to return 0-initialized data. We don't
// zero the buffer when allocating it, because the static buffers will
// begin life containing 0 values.
- memset((void*)ptr, 0, 1024);
+ memset(ptr, 0, 1024);
// Signal the condition variable to wake up any threads that are blocking
// waiting for some space in the emergency buffer
pthread_mutex_lock(&emergency_malloc_lock);
@@ -535,7 +535,7 @@ static void emergency_malloc_free(char *ptr)
static char *alloc_or_die(size_t size)
{
- char *buffer = (char*)calloc(1, size);
+ char *buffer = static_cast<char*>(calloc(1, size));
// If calloc() doesn't want to give us any memory, try using an emergency
// buffer.
@@ -597,7 +597,7 @@ extern "C" void *__cxa_allocate_dependent_exception(void)
*/
extern "C" void __cxa_free_exception(void *thrown_exception)
{
- __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1;
+ __cxa_exception *ex = reinterpret_cast<__cxa_exception*>(thrown_exception) - 1;
// Free the object that was thrown, calling its destructor
if (0 != ex->exceptionDestructor)
{
@@ -612,7 +612,7 @@ extern "C" void __cxa_free_exception(void *thrown_exception)
}
}
- free_exception((char*)ex);
+ free_exception(reinterpret_cast<char*>(ex));
}
static void releaseException(__cxa_exception *exception)
@@ -633,13 +633,13 @@ static void releaseException(__cxa_exception *exception)
void __cxa_free_dependent_exception(void *thrown_exception)
{
- __cxa_dependent_exception *ex = ((__cxa_dependent_exception*)thrown_exception) - 1;
+ __cxa_dependent_exception *ex = reinterpret_cast<__cxa_dependent_exception*>(thrown_exception) - 1;
assert(isDependentException(ex->unwindHeader.exception_class));
if (ex->primaryException)
{
- releaseException(realExceptionFromException((__cxa_exception*)ex));
+ releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex)));
}
- free_exception((char*)ex);
+ free_exception(reinterpret_cast<char*>(ex));
}
/**
@@ -654,8 +654,8 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c)
{
Dl_info myinfo;
int mylookup =
- dladdr((void*)(uintptr_t)__cxa_current_exception_type, &myinfo);
- void *ip = (void*)_Unwind_GetIP(context);
+ dladdr(reinterpret_cast<void *>(__cxa_current_exception_type), &myinfo);
+ void *ip = reinterpret_cast<void*>(_Unwind_GetIP(context));
Dl_info info;
if (dladdr(ip, &info) != 0)
{
@@ -673,6 +673,11 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c)
* If the failure happened by falling off the end of the stack without finding
* a handler, prints a back trace before aborting.
*/
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+extern "C" void *__cxa_begin_catch(void *e) throw();
+#else
+extern "C" void *__cxa_begin_catch(void *e);
+#endif
static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exception)
{
switch (err)
@@ -681,14 +686,16 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce
case _URC_FATAL_PHASE1_ERROR:
fprintf(stderr, "Fatal error during phase 1 unwinding\n");
break;
-#ifndef __arm__
+#if !defined(__arm__) || defined(__ARM_DWARF_EH__)
case _URC_FATAL_PHASE2_ERROR:
fprintf(stderr, "Fatal error during phase 2 unwinding\n");
break;
#endif
case _URC_END_OF_STACK:
+ __cxa_begin_catch (&(thrown_exception->unwindHeader));
+ std::terminate();
fprintf(stderr, "Terminating due to uncaught exception %p",
- (void*)thrown_exception);
+ static_cast<void*>(thrown_exception));
thrown_exception = realExceptionFromException(thrown_exception);
static const __class_type_info *e_ti =
static_cast<const __class_type_info*>(&typeid(std::exception));
@@ -697,8 +704,8 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce
if (throw_ti)
{
std::exception *e =
- (std::exception*)e_ti->cast_to((void*)(thrown_exception+1),
- throw_ti);
+ static_cast<std::exception*>(e_ti->cast_to(static_cast<void*>(thrown_exception+1),
+ throw_ti));
if (e)
{
fprintf(stderr, " '%s'", e->what());
@@ -706,18 +713,21 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce
}
size_t bufferSize = 128;
- char *demangled = (char*)malloc(bufferSize);
+ char *demangled = static_cast<char*>(malloc(bufferSize));
const char *mangled = thrown_exception->exceptionType->name();
int status;
demangled = __cxa_demangle(mangled, demangled, &bufferSize, &status);
fprintf(stderr, " of type %s\n",
- status == 0 ? (const char*)demangled : mangled);
+ status == 0 ? demangled : mangled);
if (status == 0) { free(demangled); }
// Print a back trace if no handler is found.
// TODO: Make this optional
#ifndef __arm__
_Unwind_Backtrace(trace, 0);
#endif
+
+ // Just abort. No need to call std::terminate for the second time
+ abort();
break;
}
std::terminate();
@@ -755,7 +765,7 @@ extern "C" void __cxa_throw(void *thrown_exception,
std::type_info *tinfo,
void(*dest)(void*))
{
- __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1;
+ __cxa_exception *ex = reinterpret_cast<__cxa_exception*>(thrown_exception) - 1;
ex->referenceCount = 1;
ex->exceptionType = tinfo;
@@ -773,7 +783,7 @@ extern "C" void __cxa_rethrow_primary_exception(void* thrown_exception)
if (NULL == thrown_exception) { return; }
__cxa_exception *original = exceptionFromPointer(thrown_exception);
- __cxa_dependent_exception *ex = ((__cxa_dependent_exception*)__cxa_allocate_dependent_exception())-1;
+ __cxa_dependent_exception *ex = reinterpret_cast<__cxa_dependent_exception*>(__cxa_allocate_dependent_exception())-1;
ex->primaryException = thrown_exception;
__cxa_increment_exception_refcount(thrown_exception);
@@ -782,7 +792,7 @@ extern "C" void __cxa_rethrow_primary_exception(void* thrown_exception)
ex->unwindHeader.exception_class = dependent_exception_class;
ex->unwindHeader.exception_cleanup = dependent_exception_cleanup;
- throw_exception((__cxa_exception*)ex);
+ throw_exception(reinterpret_cast<__cxa_exception*>(ex));
}
extern "C" void *__cxa_current_primary_exception(void)
@@ -799,14 +809,14 @@ extern "C" void *__cxa_current_primary_exception(void)
extern "C" void __cxa_increment_exception_refcount(void* thrown_exception)
{
if (NULL == thrown_exception) { return; }
- __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1;
+ __cxa_exception *ex = static_cast<__cxa_exception*>(thrown_exception) - 1;
if (isDependentException(ex->unwindHeader.exception_class)) { return; }
__sync_fetch_and_add(&ex->referenceCount, 1);
}
extern "C" void __cxa_decrement_exception_refcount(void* thrown_exception)
{
if (NULL == thrown_exception) { return; }
- __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1;
+ __cxa_exception *ex = static_cast<__cxa_exception*>(thrown_exception) - 1;
releaseException(ex);
}
@@ -838,7 +848,7 @@ extern "C" void __cxa_rethrow()
if (ti->foreign_exception_state != __cxa_thread_info::none)
{
ti->foreign_exception_state = __cxa_thread_info::rethrown;
- _Unwind_Exception *e = (_Unwind_Exception*)ex;
+ _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ex);
_Unwind_Reason_Code err = _Unwind_Resume_or_Rethrow(e);
report_failure(err, ex);
return;
@@ -881,8 +891,8 @@ static std::type_info *get_type_info_entry(_Unwind_Context *context,
if (offset == 0) { return 0; }
// ...so we need to resolve it
- return (std::type_info*)resolve_indirect_value(context,
- lsda->type_table_encoding, offset, start);
+ return reinterpret_cast<std::type_info*>(resolve_indirect_value(context,
+ lsda->type_table_encoding, offset, start));
}
@@ -896,13 +906,13 @@ static bool check_type_signature(__cxa_exception *ex,
const std::type_info *type,
void *&adjustedPtr)
{
- void *exception_ptr = (void*)(ex+1);
+ void *exception_ptr = static_cast<void*>(ex+1);
const std::type_info *ex_type = ex ? ex->exceptionType : 0;
bool is_ptr = ex ? ex_type->__is_pointer_p() : false;
if (is_ptr)
{
- exception_ptr = *(void**)exception_ptr;
+ exception_ptr = *static_cast<void**>(exception_ptr);
}
// Always match a catchall, even with a foreign exception
//
@@ -974,7 +984,7 @@ static handler_type check_action_record(_Unwind_Context *context,
{
bool matched = false;
*selector = filter;
-#ifdef __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
filter++;
std::type_info *handler_type = get_type_info_entry(context, lsda, filter--);
while (handler_type)
@@ -987,7 +997,7 @@ static handler_type check_action_record(_Unwind_Context *context,
handler_type = get_type_info_entry(context, lsda, filter--);
}
#else
- unsigned char *type_index = ((unsigned char*)lsda->type_table - filter - 1);
+ unsigned char *type_index = reinterpret_cast<unsigned char*>(lsda->type_table) - filter - 1;
while (*type_index)
{
std::type_info *handler_type = get_type_info_entry(context, lsda, *(type_index++));
@@ -1019,7 +1029,7 @@ static handler_type check_action_record(_Unwind_Context *context,
static void pushCleanupException(_Unwind_Exception *exceptionObject,
__cxa_exception *ex)
{
-#ifdef __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
__cxa_thread_info *info = thread_info_fast();
if (ex)
{
@@ -1064,8 +1074,13 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
realEx = realExceptionFromException(ex);
}
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+ unsigned char *lsda_addr =
+ static_cast<unsigned char*>(_Unwind_GetLanguageSpecificData(context));
+#else
unsigned char *lsda_addr =
- (unsigned char*)_Unwind_GetLanguageSpecificData(context);
+ reinterpret_cast<unsigned char*>(static_cast<uintptr_t>(_Unwind_GetLanguageSpecificData(context)));
+#endif
// No LSDA implies no landing pads - try the next frame
if (0 == lsda_addr) { return continueUnwinding(exceptionObject, context); }
@@ -1114,8 +1129,8 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
if (ex)
{
saveLandingPad(context, exceptionObject, ex, selector, action.landing_pad);
- ex->languageSpecificData = (const char*)lsda_addr;
- ex->actionRecord = (const char*)action.action_record;
+ ex->languageSpecificData = reinterpret_cast<const char*>(lsda_addr);
+ ex->actionRecord = reinterpret_cast<const char*>(action.action_record);
// ex->adjustedPtr is set when finding the action record.
}
return _URC_HANDLER_FOUND;
@@ -1161,9 +1176,9 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
}
- _Unwind_SetIP(context, (unsigned long)action.landing_pad);
+ _Unwind_SetIP(context, reinterpret_cast<unsigned long>(action.landing_pad));
_Unwind_SetGR(context, __builtin_eh_return_data_regno(0),
- (unsigned long)exceptionObject);
+ reinterpret_cast<unsigned long>(exceptionObject));
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1), selector);
return _URC_INSTALL_CONTEXT;
@@ -1176,7 +1191,7 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
* pointer to the caught exception, which is either the adjusted pointer (for
* C++ exceptions) of the unadjusted pointer (for foreign exceptions).
*/
-#if __GNUC__ > 3 && __GNUC_MINOR__ > 2
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
extern "C" void *__cxa_begin_catch(void *e) throw()
#else
extern "C" void *__cxa_begin_catch(void *e)
@@ -1187,7 +1202,7 @@ extern "C" void *__cxa_begin_catch(void *e)
__cxa_thread_info *ti = thread_info();
__cxa_eh_globals *globals = &ti->globals;
globals->uncaughtExceptions--;
- _Unwind_Exception *exceptionObject = (_Unwind_Exception*)e;
+ _Unwind_Exception *exceptionObject = static_cast<_Unwind_Exception*>(e);
if (isCXXException(exceptionObject->exception_class))
{
@@ -1241,12 +1256,12 @@ extern "C" void *__cxa_begin_catch(void *e)
{
std::terminate();
}
- globals->caughtExceptions = (__cxa_exception*)exceptionObject;
+ globals->caughtExceptions = reinterpret_cast<__cxa_exception*>(exceptionObject);
ti->foreign_exception_state = __cxa_thread_info::caught;
}
// exceptionObject is the pointer to the _Unwind_Exception within the
// __cxa_exception. The throw object is after this
- return ((char*)exceptionObject + sizeof(_Unwind_Exception));
+ return (reinterpret_cast<char*>(exceptionObject) + sizeof(_Unwind_Exception));
}
@@ -1270,7 +1285,7 @@ extern "C" void __cxa_end_catch()
globals->caughtExceptions = 0;
if (ti->foreign_exception_state != __cxa_thread_info::rethrown)
{
- _Unwind_Exception *e = (_Unwind_Exception*)ti->globals.caughtExceptions;
+ _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions);
e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
}
ti->foreign_exception_state = __cxa_thread_info::none;
@@ -1332,7 +1347,7 @@ extern "C" std::type_info *__cxa_current_exception_type()
*/
extern "C" void __cxa_call_unexpected(void*exception)
{
- _Unwind_Exception *exceptionObject = (_Unwind_Exception*)exception;
+ _Unwind_Exception *exceptionObject = static_cast<_Unwind_Exception*>(exception);
if (exceptionObject->exception_class == exception_class)
{
__cxa_exception *ex = exceptionFromPointer(exceptionObject);
@@ -1483,7 +1498,7 @@ namespace std
return ATOMIC_LOAD(&terminateHandler);
}
}
-#ifdef __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
extern "C" _Unwind_Exception *__cxa_get_cleanup(void)
{
__cxa_thread_info *info = thread_info_fast();
OpenPOWER on IntegriCloud