summaryrefslogtreecommitdiffstats
path: root/contrib/libcxxrt
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
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')
-rw-r--r--contrib/libcxxrt/atomic.h4
-rw-r--r--contrib/libcxxrt/auxhelper.cc5
-rw-r--r--contrib/libcxxrt/cxxabi.h2
-rw-r--r--contrib/libcxxrt/dwarf_eh.h60
-rw-r--r--contrib/libcxxrt/dynamic_cast.cc10
-rw-r--r--contrib/libcxxrt/exception.cc137
-rw-r--r--contrib/libcxxrt/guard.cc105
-rw-r--r--contrib/libcxxrt/stdexcept.cc13
-rw-r--r--contrib/libcxxrt/stdexcept.h9
-rw-r--r--contrib/libcxxrt/typeinfo.cc2
-rw-r--r--contrib/libcxxrt/unwind-arm.h2
-rw-r--r--contrib/libcxxrt/unwind.h2
12 files changed, 217 insertions, 134 deletions
diff --git a/contrib/libcxxrt/atomic.h b/contrib/libcxxrt/atomic.h
index cfaff3f..131ca9f 100644
--- a/contrib/libcxxrt/atomic.h
+++ b/contrib/libcxxrt/atomic.h
@@ -11,7 +11,7 @@
*/
#if __has_builtin(__c11_atomic_exchange)
#define ATOMIC_SWAP(addr, val)\
- __c11_atomic_exchange((_Atomic(__typeof__(val))*)addr, val, __ATOMIC_ACQ_REL)
+ __c11_atomic_exchange(reinterpret_cast<_Atomic(__typeof__(val))*>(addr), val, __ATOMIC_ACQ_REL)
#elif __has_builtin(__sync_swap)
#define ATOMIC_SWAP(addr, val)\
__sync_swap(addr, val)
@@ -22,7 +22,7 @@
#if __has_builtin(__c11_atomic_load)
#define ATOMIC_LOAD(addr)\
- __c11_atomic_load((_Atomic(__typeof__(*addr))*)addr, __ATOMIC_ACQUIRE)
+ __c11_atomic_load(reinterpret_cast<_Atomic(__typeof__(*addr))*>(addr), __ATOMIC_ACQUIRE)
#else
#define ATOMIC_LOAD(addr)\
(__sync_synchronize(), *addr)
diff --git a/contrib/libcxxrt/auxhelper.cc b/contrib/libcxxrt/auxhelper.cc
index 213f8a0..3e98da0 100644
--- a/contrib/libcxxrt/auxhelper.cc
+++ b/contrib/libcxxrt/auxhelper.cc
@@ -75,3 +75,8 @@ extern "C" void __cxa_deleted_virtual()
{
abort();
}
+
+extern "C" void __cxa_throw_bad_array_new_length()
+{
+ throw std::bad_array_new_length();
+}
diff --git a/contrib/libcxxrt/cxxabi.h b/contrib/libcxxrt/cxxabi.h
index 7c83360..411c4c7 100644
--- a/contrib/libcxxrt/cxxabi.h
+++ b/contrib/libcxxrt/cxxabi.h
@@ -110,7 +110,7 @@ struct __cxa_exception
* handler count reaches 0 (which it doesn't with the top bit set).
*/
int handlerCount;
-#ifdef __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
/**
* The ARM EH ABI requires the unwind library to keep track of exceptions
* during cleanups. These support nesting, so we need to keep a list of
diff --git a/contrib/libcxxrt/dwarf_eh.h b/contrib/libcxxrt/dwarf_eh.h
index d5e1e28..af533b3 100644
--- a/contrib/libcxxrt/dwarf_eh.h
+++ b/contrib/libcxxrt/dwarf_eh.h
@@ -83,7 +83,7 @@ enum dwarf_data_encoding
*/
static inline enum dwarf_data_encoding get_encoding(unsigned char x)
{
- return (enum dwarf_data_encoding)(x & 0xf);
+ return static_cast<enum dwarf_data_encoding>(x & 0xf);
}
/**
@@ -115,7 +115,7 @@ enum dwarf_data_relative
*/
static inline enum dwarf_data_relative get_base(unsigned char x)
{
- return (enum dwarf_data_relative)(x & 0x70);
+ return static_cast<enum dwarf_data_relative>(x & 0x70);
}
/**
* Returns whether an encoding represents an indirect address.
@@ -206,9 +206,9 @@ static int64_t read_sleb128(dw_eh_ptr_t *data)
if ((uleb >> (bits-1)) == 1)
{
// Sign extend by setting all bits in front of it to 1
- uleb |= ((int64_t)-1) << bits;
+ uleb |= static_cast<int64_t>(-1) << bits;
}
- return (int64_t)uleb;
+ return static_cast<int64_t>(uleb);
}
/**
* Reads a value using the specified encoding from the address pointed to by
@@ -224,7 +224,7 @@ static uint64_t read_value(char encoding, dw_eh_ptr_t *data)
// Read fixed-length types
#define READ(dwarf, type) \
case dwarf:\
- v = (uint64_t)(*(type*)(*data));\
+ v = static_cast<uint64_t>(*reinterpret_cast<type*>(*data));\
*data += sizeof(type);\
break;
READ(DW_EH_PE_udata2, uint16_t)
@@ -263,16 +263,16 @@ static uint64_t resolve_indirect_value(_Unwind_Context *c,
switch (get_base(encoding))
{
case DW_EH_PE_pcrel:
- v += (uint64_t)start;
+ v += reinterpret_cast<uint64_t>(start);
break;
case DW_EH_PE_textrel:
- v += (uint64_t)_Unwind_GetTextRelBase(c);
+ v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetTextRelBase(c)));
break;
case DW_EH_PE_datarel:
- v += (uint64_t)_Unwind_GetDataRelBase(c);
+ v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetDataRelBase(c)));
break;
case DW_EH_PE_funcrel:
- v += (uint64_t)_Unwind_GetRegionStart(c);
+ v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetRegionStart(c)));
default:
break;
}
@@ -282,7 +282,7 @@ static uint64_t resolve_indirect_value(_Unwind_Context *c,
// be a GCC extensions, so not properly documented...
if (is_indirect(encoding))
{
- v = (uint64_t)(uintptr_t)*(void**)v;
+ v = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(*reinterpret_cast<void**>(v)));
}
return v;
}
@@ -342,14 +342,14 @@ static inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context,
{
struct dwarf_eh_lsda lsda;
- lsda.region_start = (dw_eh_ptr_t)(uintptr_t)_Unwind_GetRegionStart(context);
+ lsda.region_start = reinterpret_cast<dw_eh_ptr_t>(_Unwind_GetRegionStart(context));
// If the landing pads are relative to anything other than the start of
// this region, find out where. This is @LPStart in the spec, although the
// encoding that GCC uses does not quite match the spec.
- uint64_t v = (uint64_t)(uintptr_t)lsda.region_start;
+ uint64_t v = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(lsda.region_start));
read_value_with_encoding(context, &data, &v);
- lsda.landing_pads = (dw_eh_ptr_t)(uintptr_t)v;
+ lsda.landing_pads = reinterpret_cast<dw_eh_ptr_t>(static_cast<uintptr_t>(v));
// If there is a type table, find out where it is. This is @TTBase in the
// spec. Note: we find whether there is a type table pointer by checking
@@ -365,18 +365,18 @@ static inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context,
lsda.type_table = type_table;
//lsda.type_table = (uintptr_t*)(data + v);
}
-#if __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
lsda.type_table_encoding = (DW_EH_PE_pcrel | DW_EH_PE_indirect);
#endif
- lsda.callsite_encoding = (enum dwarf_data_encoding)(*(data++));
+ lsda.callsite_encoding = static_cast<enum dwarf_data_encoding>(*(data++));
// Action table is immediately after the call site table
lsda.action_table = data;
- uintptr_t callsite_size = (uintptr_t)read_uleb128(&data);
+ uintptr_t callsite_size = static_cast<uintptr_t>(read_uleb128(&data));
lsda.action_table = data + callsite_size;
// Call site table is immediately after the header
- lsda.call_site_table = (dw_eh_ptr_t)data;
+ lsda.call_site_table = static_cast<dw_eh_ptr_t>(data);
return lsda;
@@ -413,7 +413,7 @@ static bool dwarf_eh_find_callsite(struct _Unwind_Context *context,
result->landing_pad = 0;
// The current instruction pointer offset within the region
uint64_t ip = _Unwind_GetIP(context) - _Unwind_GetRegionStart(context);
- unsigned char *callsite_table = (unsigned char*)lsda->call_site_table;
+ unsigned char *callsite_table = static_cast<unsigned char*>(lsda->call_site_table);
while (callsite_table <= lsda->action_table)
{
@@ -463,17 +463,17 @@ static bool dwarf_eh_find_callsite(struct _Unwind_Context *context,
/// Defines an exception class from 8 bytes (endian independent)
#define EXCEPTION_CLASS(a,b,c,d,e,f,g,h) \
- (((uint64_t)a << 56) +\
- ((uint64_t)b << 48) +\
- ((uint64_t)c << 40) +\
- ((uint64_t)d << 32) +\
- ((uint64_t)e << 24) +\
- ((uint64_t)f << 16) +\
- ((uint64_t)g << 8) +\
- ((uint64_t)h))
+ ((static_cast<uint64_t>(a) << 56) +\
+ (static_cast<uint64_t>(b) << 48) +\
+ (static_cast<uint64_t>(c) << 40) +\
+ (static_cast<uint64_t>(d) << 32) +\
+ (static_cast<uint64_t>(e) << 24) +\
+ (static_cast<uint64_t>(f) << 16) +\
+ (static_cast<uint64_t>(g) << 8) +\
+ (static_cast<uint64_t>(h)))
#define GENERIC_EXCEPTION_CLASS(e,f,g,h) \
- ((uint32_t)e << 24) +\
- ((uint32_t)f << 16) +\
- ((uint32_t)g << 8) +\
- ((uint32_t)h)
+ (static_cast<uint32_t>(e) << 24) +\
+ (static_cast<uint32_t>(f) << 16) +\
+ (static_cast<uint32_t>(g) << 8) +\
+ (static_cast<uint32_t>(h))
diff --git a/contrib/libcxxrt/dynamic_cast.cc b/contrib/libcxxrt/dynamic_cast.cc
index 7a07e4c..6ae3a40 100644
--- a/contrib/libcxxrt/dynamic_cast.cc
+++ b/contrib/libcxxrt/dynamic_cast.cc
@@ -44,7 +44,7 @@ struct vtable_header
* Simple macro that does pointer arithmetic in bytes but returns a value of
* the same type as the original.
*/
-#define ADD_TO_PTR(x, off) (__typeof__(x))(((char*)x) + off)
+#define ADD_TO_PTR(x, off) reinterpret_cast<__typeof__(x)>(reinterpret_cast<char*>(x) + off)
bool std::type_info::__do_catch(std::type_info const *ex_type,
void **exception_object,
@@ -166,7 +166,7 @@ bool __vmi_class_type_info::__do_upcast(const __class_type_info *target,
if (info->isVirtual())
{
// Object's vtable
- ptrdiff_t *off = *(ptrdiff_t**)obj;
+ ptrdiff_t *off = *static_cast<ptrdiff_t**>(obj);
// Offset location in vtable
off = ADD_TO_PTR(off, offset);
offset = *off;
@@ -202,9 +202,9 @@ extern "C" void* __dynamic_cast(const void *sub,
const __class_type_info *dst,
ptrdiff_t src2dst_offset)
{
- char *vtable_location = *(char**)sub;
+ const char *vtable_location = *static_cast<const char * const *>(sub);
const vtable_header *header =
- (const vtable_header*)(vtable_location - sizeof(vtable_header));
- void *leaf = ADD_TO_PTR((void*)sub, header->leaf_offset);
+ reinterpret_cast<const vtable_header*>(vtable_location - sizeof(vtable_header));
+ void *leaf = ADD_TO_PTR(const_cast<void *>(sub), header->leaf_offset);
return header->type->cast_to(leaf, dst);
}
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();
diff --git a/contrib/libcxxrt/guard.cc b/contrib/libcxxrt/guard.cc
index f0c26ab..f1c4c69 100644
--- a/contrib/libcxxrt/guard.cc
+++ b/contrib/libcxxrt/guard.cc
@@ -70,18 +70,45 @@
#ifdef __arm__
// ARM ABI - 32-bit guards.
typedef uint32_t guard_t;
-static const uint32_t LOCKED = ((guard_t)1) << 31;
+typedef uint32_t guard_lock_t;
+static const uint32_t LOCKED = static_cast<guard_t>(1) << 31;
static const uint32_t INITIALISED = 1;
-#else
+#define LOCK_PART(guard) (guard)
+#define INIT_PART(guard) (guard)
+#elif defined(_LP64)
typedef uint64_t guard_t;
+typedef uint64_t guard_lock_t;
# if defined(__LITTLE_ENDIAN__)
-static const guard_t LOCKED = ((guard_t)1) << 63;
+static const guard_t LOCKED = static_cast<guard_t>(1) << 63;
static const guard_t INITIALISED = 1;
# else
static const guard_t LOCKED = 1;
-static const guard_t INITIALISED = ((guard_t)1) << 56;
+static const guard_t INITIALISED = static_cast<guard_t>(1) << 56;
+# endif
+#define LOCK_PART(guard) (guard)
+#define INIT_PART(guard) (guard)
+#else
+typedef uint32_t guard_lock_t;
+# if defined(__LITTLE_ENDIAN__)
+typedef struct {
+ uint32_t init_half;
+ uint32_t lock_half;
+} guard_t;
+static const uint32_t LOCKED = static_cast<guard_lock_t>(1) << 31;
+static const uint32_t INITIALISED = 1;
+# else
+typedef struct {
+ uint32_t init_half;
+ uint32_t lock_half;
+} guard_t;
+_Static_assert(sizeof(guard_t) == sizeof(uint64_t), "");
+static const uint32_t LOCKED = 1;
+static const uint32_t INITIALISED = static_cast<guard_lock_t>(1) << 24;
# endif
+#define LOCK_PART(guard) (&(guard)->lock_half)
+#define INIT_PART(guard) (&(guard)->init_half)
#endif
+static const guard_lock_t INITIAL = 0;
/**
* Acquires a lock on a guard, returning 0 if the object has already been
@@ -90,42 +117,49 @@ static const guard_t INITIALISED = ((guard_t)1) << 56;
*/
extern "C" int __cxa_guard_acquire(volatile guard_t *guard_object)
{
+ guard_lock_t old;
// Not an atomic read, doesn't establish a happens-before relationship, but
// if one is already established and we end up seeing an initialised state
// then it's a fast path, otherwise we'll do something more expensive than
// this test anyway...
- if ((INITIALISED == *guard_object)) { return 0; }
+ if (INITIALISED == *INIT_PART(guard_object))
+ return 0;
// Spin trying to do the initialisation
- while (1)
+ for (;;)
{
// Loop trying to move the value of the guard from 0 (not
// locked, not initialised) to the locked-uninitialised
// position.
- switch (__sync_val_compare_and_swap(guard_object, 0, LOCKED))
- {
- // If the old value was 0, we succeeded, so continue
- // initialising
- case 0:
+ old = __sync_val_compare_and_swap(LOCK_PART(guard_object),
+ INITIAL, LOCKED);
+ if (old == INITIAL) {
+ // Lock obtained. If lock and init bit are
+ // in separate words, check for init race.
+ if (INIT_PART(guard_object) == LOCK_PART(guard_object))
return 1;
- // If this was already initialised, return and let the caller skip
- // initialising it again.
- case INITIALISED:
- return 0;
- // If it is locked by another thread, relinquish the CPU and try
- // again later.
- case LOCKED:
- case LOCKED | INITIALISED:
- sched_yield();
- break;
- // If it is some other value, then something has gone badly wrong.
- // Give up.
- default:
- fprintf(stderr, "Invalid state detected attempting to lock static initialiser.\n");
- abort();
+ if (INITIALISED != *INIT_PART(guard_object))
+ return 1;
+
+ // No need for a memory barrier here,
+ // see first comment.
+ *LOCK_PART(guard_object) = INITIAL;
+ return 0;
}
+ // If lock and init bit are in the same word, check again
+ // if we are done.
+ if (INIT_PART(guard_object) == LOCK_PART(guard_object) &&
+ old == INITIALISED)
+ return 0;
+
+ assert(old == LOCKED);
+ // Another thread holds the lock.
+ // If lock and init bit are in different words, check
+ // if we are done before yielding and looping.
+ if (INIT_PART(guard_object) != LOCK_PART(guard_object) &&
+ INITIALISED == *INIT_PART(guard_object))
+ return 0;
+ sched_yield();
}
- //__builtin_unreachable();
- return 0;
}
/**
@@ -135,7 +169,8 @@ extern "C" int __cxa_guard_acquire(volatile guard_t *guard_object)
extern "C" void __cxa_guard_abort(volatile guard_t *guard_object)
{
__attribute__((unused))
- bool reset = __sync_bool_compare_and_swap(guard_object, LOCKED, 0);
+ bool reset = __sync_bool_compare_and_swap(LOCK_PART(guard_object),
+ LOCKED, INITIAL);
assert(reset);
}
/**
@@ -144,9 +179,15 @@ extern "C" void __cxa_guard_abort(volatile guard_t *guard_object)
*/
extern "C" void __cxa_guard_release(volatile guard_t *guard_object)
{
+ guard_lock_t old;
+ if (INIT_PART(guard_object) == LOCK_PART(guard_object))
+ old = LOCKED;
+ else
+ old = INITIAL;
__attribute__((unused))
- bool reset = __sync_bool_compare_and_swap(guard_object, LOCKED, INITIALISED);
+ bool reset = __sync_bool_compare_and_swap(INIT_PART(guard_object),
+ old, INITIALISED);
assert(reset);
+ if (INIT_PART(guard_object) != LOCK_PART(guard_object))
+ *LOCK_PART(guard_object) = INITIAL;
}
-
-
diff --git a/contrib/libcxxrt/stdexcept.cc b/contrib/libcxxrt/stdexcept.cc
index 687fc5e..c1cea39 100644
--- a/contrib/libcxxrt/stdexcept.cc
+++ b/contrib/libcxxrt/stdexcept.cc
@@ -82,5 +82,18 @@ const char* bad_typeid::what() const throw()
return "std::bad_typeid";
}
+bad_array_new_length::bad_array_new_length() throw() {}
+bad_array_new_length::~bad_array_new_length() {}
+bad_array_new_length::bad_array_new_length(const bad_array_new_length&) throw() {}
+bad_array_new_length& bad_array_new_length::operator=(const bad_array_new_length&) throw()
+{
+ return *this;
+}
+
+const char* bad_array_new_length::what() const throw()
+{
+ return "std::bad_array_new_length";
+}
+
} // namespace std
diff --git a/contrib/libcxxrt/stdexcept.h b/contrib/libcxxrt/stdexcept.h
index 49eaf55..8920393 100644
--- a/contrib/libcxxrt/stdexcept.h
+++ b/contrib/libcxxrt/stdexcept.h
@@ -81,6 +81,15 @@ namespace std
virtual const char* what() const throw();
};
+ class bad_array_new_length: public bad_alloc
+ {
+ public:
+ bad_array_new_length() throw();
+ bad_array_new_length(const bad_array_new_length&) throw();
+ bad_array_new_length& operator=(const bad_array_new_length&) throw();
+ virtual ~bad_array_new_length();
+ virtual const char *what() const throw();
+ };
} // namespace std
diff --git a/contrib/libcxxrt/typeinfo.cc b/contrib/libcxxrt/typeinfo.cc
index fda5196..71de9ae 100644
--- a/contrib/libcxxrt/typeinfo.cc
+++ b/contrib/libcxxrt/typeinfo.cc
@@ -96,7 +96,7 @@ extern "C" char* __cxa_demangle(const char* mangled_name,
}
if (*n < len+1)
{
- buf = (char*)realloc(buf, len+1);
+ buf = static_cast<char*>(realloc(buf, len+1));
}
if (0 != buf)
{
diff --git a/contrib/libcxxrt/unwind-arm.h b/contrib/libcxxrt/unwind-arm.h
index 8c1fa16..52e563e 100644
--- a/contrib/libcxxrt/unwind-arm.h
+++ b/contrib/libcxxrt/unwind-arm.h
@@ -218,6 +218,6 @@ _Unwind_Reason_Code name(_Unwind_State state,\
break;\
}\
}\
- _Unwind_SetGR (context, 12, (unsigned long)exceptionObject);\
+ _Unwind_SetGR (context, 12, reinterpret_cast<unsigned long>(exceptionObject));\
#define CALL_PERSONALITY_FUNCTION(name) name(state,exceptionObject,context)
diff --git a/contrib/libcxxrt/unwind.h b/contrib/libcxxrt/unwind.h
index e463a2a..130dd6d 100644
--- a/contrib/libcxxrt/unwind.h
+++ b/contrib/libcxxrt/unwind.h
@@ -27,7 +27,7 @@
extern "C" {
#endif
-#ifdef __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
#include "unwind-arm.h"
#else
#include "unwind-itanium.h"
OpenPOWER on IntegriCloud