summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-02-01 02:29:58 +0000
committerdim <dim@FreeBSD.org>2015-02-01 02:29:58 +0000
commit2ccbfd1b8e87d9e16738583f1cb19868ea5ad479 (patch)
treea0f122f4b76eb51437a7dd525aaf7fc88d4f887f /contrib
parent111a0cf771f31b0fdae5d6e0e7cbd3277e702172 (diff)
downloadFreeBSD-src-2ccbfd1b8e87d9e16738583f1cb19868ea5ad479.zip
FreeBSD-src-2ccbfd1b8e87d9e16738583f1cb19868ea5ad479.tar.gz
Revert r278017 (MFC of r273381 and r276417) and r278018 (MFC of r273434)
until I can figure out why it leads to link failures in some scenarios.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/libc++/src/new.cpp4
-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.cc135
-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
13 files changed, 135 insertions, 218 deletions
diff --git a/contrib/libc++/src/new.cpp b/contrib/libc++/src/new.cpp
index c179db1..f4998cf 100644
--- a/contrib/libc++/src/new.cpp
+++ b/contrib/libc++/src/new.cpp
@@ -192,6 +192,8 @@ bad_alloc::what() const _NOEXCEPT
#endif // !__GLIBCXX__
+#endif //LIBCXXRT
+
bad_array_new_length::bad_array_new_length() _NOEXCEPT
{
}
@@ -200,8 +202,6 @@ bad_array_new_length::~bad_array_new_length() _NOEXCEPT
{
}
-#endif //LIBCXXRT
-
const char*
bad_array_length::what() const _NOEXCEPT
{
diff --git a/contrib/libcxxrt/atomic.h b/contrib/libcxxrt/atomic.h
index 131ca9f..cfaff3f 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(reinterpret_cast<_Atomic(__typeof__(val))*>(addr), val, __ATOMIC_ACQ_REL)
+ __c11_atomic_exchange((_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(reinterpret_cast<_Atomic(__typeof__(*addr))*>(addr), __ATOMIC_ACQUIRE)
+ __c11_atomic_load((_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 3e98da0..213f8a0 100644
--- a/contrib/libcxxrt/auxhelper.cc
+++ b/contrib/libcxxrt/auxhelper.cc
@@ -75,8 +75,3 @@ 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 411c4c7..7c83360 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;
-#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#ifdef __arm__
/**
* 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 af533b3..d5e1e28 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 static_cast<enum dwarf_data_encoding>(x & 0xf);
+ return (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 static_cast<enum dwarf_data_relative>(x & 0x70);
+ return (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 |= static_cast<int64_t>(-1) << bits;
+ uleb |= ((int64_t)-1) << bits;
}
- return static_cast<int64_t>(uleb);
+ return (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 = static_cast<uint64_t>(*reinterpret_cast<type*>(*data));\
+ v = (uint64_t)(*(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 += reinterpret_cast<uint64_t>(start);
+ v += (uint64_t)start;
break;
case DW_EH_PE_textrel:
- v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetTextRelBase(c)));
+ v += (uint64_t)_Unwind_GetTextRelBase(c);
break;
case DW_EH_PE_datarel:
- v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetDataRelBase(c)));
+ v += (uint64_t)_Unwind_GetDataRelBase(c);
break;
case DW_EH_PE_funcrel:
- v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetRegionStart(c)));
+ v += (uint64_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 = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(*reinterpret_cast<void**>(v)));
+ v = (uint64_t)(uintptr_t)*(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 = reinterpret_cast<dw_eh_ptr_t>(_Unwind_GetRegionStart(context));
+ lsda.region_start = (dw_eh_ptr_t)(uintptr_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 = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(lsda.region_start));
+ uint64_t v = (uint64_t)(uintptr_t)lsda.region_start;
read_value_with_encoding(context, &data, &v);
- lsda.landing_pads = reinterpret_cast<dw_eh_ptr_t>(static_cast<uintptr_t>(v));
+ lsda.landing_pads = (dw_eh_ptr_t)(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 defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#if __arm__
lsda.type_table_encoding = (DW_EH_PE_pcrel | DW_EH_PE_indirect);
#endif
- lsda.callsite_encoding = static_cast<enum dwarf_data_encoding>(*(data++));
+ lsda.callsite_encoding = (enum dwarf_data_encoding)(*(data++));
// Action table is immediately after the call site table
lsda.action_table = data;
- uintptr_t callsite_size = static_cast<uintptr_t>(read_uleb128(&data));
+ uintptr_t callsite_size = (uintptr_t)read_uleb128(&data);
lsda.action_table = data + callsite_size;
// Call site table is immediately after the header
- lsda.call_site_table = static_cast<dw_eh_ptr_t>(data);
+ lsda.call_site_table = (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 = static_cast<unsigned char*>(lsda->call_site_table);
+ unsigned char *callsite_table = (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) \
- ((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)))
+ (((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))
#define GENERIC_EXCEPTION_CLASS(e,f,g,h) \
- (static_cast<uint32_t>(e) << 24) +\
- (static_cast<uint32_t>(f) << 16) +\
- (static_cast<uint32_t>(g) << 8) +\
- (static_cast<uint32_t>(h))
+ ((uint32_t)e << 24) +\
+ ((uint32_t)f << 16) +\
+ ((uint32_t)g << 8) +\
+ ((uint32_t)h)
diff --git a/contrib/libcxxrt/dynamic_cast.cc b/contrib/libcxxrt/dynamic_cast.cc
index 6ae3a40..7a07e4c 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) reinterpret_cast<__typeof__(x)>(reinterpret_cast<char*>(x) + off)
+#define ADD_TO_PTR(x, off) (__typeof__(x))(((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 = *static_cast<ptrdiff_t**>(obj);
+ ptrdiff_t *off = *(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)
{
- const char *vtable_location = *static_cast<const char * const *>(sub);
+ char *vtable_location = *(char**)sub;
const vtable_header *header =
- reinterpret_cast<const vtable_header*>(vtable_location - sizeof(vtable_header));
- void *leaf = ADD_TO_PTR(const_cast<void *>(sub), header->leaf_offset);
+ (const vtable_header*)(vtable_location - sizeof(vtable_header));
+ void *leaf = ADD_TO_PTR((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 d24aa0b..d848905 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)
{
-#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#ifdef __arm__
// 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] = static_cast<uint32_t>(selector);
- ucb->barrier_cache.bitpattern[3] = reinterpret_cast<uint32_t>(landingPad);
+ ucb->barrier_cache.bitpattern[1] = (uint32_t)selector;
+ ucb->barrier_cache.bitpattern[3] = (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)
{
-#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#ifdef __arm__
*selector = ucb->barrier_cache.bitpattern[1];
- *landingPad = reinterpret_cast<dw_eh_ptr_t>(ucb->barrier_cache.bitpattern[3]);
+ *landingPad = (dw_eh_ptr_t)ucb->barrier_cache.bitpattern[3];
return 1;
#else
if (ex)
{
*selector = ex->handlerSwitchValue;
- *landingPad = reinterpret_cast<dw_eh_ptr_t>(ex->catchTemp);
+ *landingPad = (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)
{
-#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#ifdef __arm__
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;
-#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#ifdef __arm__
_Unwind_Exception *nextCleanup;
int cleanupCount;
#endif
@@ -267,13 +267,13 @@ static bool isDependentException(uint64_t cls)
static __cxa_exception *exceptionFromPointer(void *ex)
{
- return reinterpret_cast<__cxa_exception*>(static_cast<char*>(ex) -
+ return (__cxa_exception*)((char*)ex -
offsetof(struct __cxa_exception, unwindHeader));
}
static __cxa_exception *realExceptionFromException(__cxa_exception *ex)
{
if (!isDependentException(ex->unwindHeader.exception_class)) { return ex; }
- return reinterpret_cast<__cxa_exception*>((reinterpret_cast<__cxa_dependent_exception*>(ex))->primaryException)-1;
+ return ((__cxa_exception*)(((__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(static_cast<void*>(ex));
+ __cxa_free_exception((void*)ex);
}
static void dependent_exception_cleanup(_Unwind_Reason_Code reason,
struct _Unwind_Exception *ex)
{
- __cxa_free_dependent_exception(static_cast<void*>(ex));
+ __cxa_free_dependent_exception((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 = static_cast<__cxa_thread_info*>(thread_info);
+ __cxa_thread_info *info = (__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 = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions);
+ _Unwind_Exception *e = (_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, reinterpret_cast<void *>(0x42));
- fakeTLS = (pthread_getspecific(eh_key) != reinterpret_cast<void *>(0x42));
+ pthread_setspecific(eh_key, (void*)0x42);
+ fakeTLS = (pthread_getspecific(eh_key) != (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 = static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key));
+ __cxa_thread_info *info = (__cxa_thread_info*)pthread_getspecific(eh_key);
if (0 == info)
{
- info = static_cast<__cxa_thread_info*>(calloc(1, sizeof(__cxa_thread_info)));
+ info = (__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 static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key));
+ return (__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 static_cast<char*>(m);
+ return (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 == static_cast<void*>(emergency_buffer + (1024 * i)))
+ if (ptr == (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(ptr, 0, 1024);
+ memset((void*)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 = static_cast<char*>(calloc(1, size));
+ char *buffer = (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 = reinterpret_cast<__cxa_exception*>(thrown_exception) - 1;
+ __cxa_exception *ex = ((__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(reinterpret_cast<char*>(ex));
+ free_exception((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 = reinterpret_cast<__cxa_dependent_exception*>(thrown_exception) - 1;
+ __cxa_dependent_exception *ex = ((__cxa_dependent_exception*)thrown_exception) - 1;
assert(isDependentException(ex->unwindHeader.exception_class));
if (ex->primaryException)
{
- releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex)));
+ releaseException(realExceptionFromException((__cxa_exception*)ex));
}
- free_exception(reinterpret_cast<char*>(ex));
+ free_exception((char*)ex);
}
/**
@@ -654,8 +654,8 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c)
{
Dl_info myinfo;
int mylookup =
- dladdr(reinterpret_cast<void *>(__cxa_current_exception_type), &myinfo);
- void *ip = reinterpret_cast<void*>(_Unwind_GetIP(context));
+ dladdr((void*)(uintptr_t)__cxa_current_exception_type, &myinfo);
+ void *ip = (void*)_Unwind_GetIP(context);
Dl_info info;
if (dladdr(ip, &info) != 0)
{
@@ -673,11 +673,6 @@ 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__ > 3 && __GNUC_MINOR__ > 2
-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)
@@ -686,16 +681,14 @@ 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;
-#if !defined(__arm__) || defined(__ARM_DWARF_EH__)
+#ifndef __arm__
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",
- static_cast<void*>(thrown_exception));
+ (void*)thrown_exception);
thrown_exception = realExceptionFromException(thrown_exception);
static const __class_type_info *e_ti =
static_cast<const __class_type_info*>(&typeid(std::exception));
@@ -704,8 +697,8 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce
if (throw_ti)
{
std::exception *e =
- static_cast<std::exception*>(e_ti->cast_to(static_cast<void*>(thrown_exception+1),
- throw_ti));
+ (std::exception*)e_ti->cast_to((void*)(thrown_exception+1),
+ throw_ti);
if (e)
{
fprintf(stderr, " '%s'", e->what());
@@ -713,21 +706,18 @@ static void report_failure(_Unwind_Reason_Code err, __cxa_exception *thrown_exce
}
size_t bufferSize = 128;
- char *demangled = static_cast<char*>(malloc(bufferSize));
+ char *demangled = (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 ? demangled : mangled);
+ status == 0 ? (const char*)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();
@@ -765,7 +755,7 @@ extern "C" void __cxa_throw(void *thrown_exception,
std::type_info *tinfo,
void(*dest)(void*))
{
- __cxa_exception *ex = reinterpret_cast<__cxa_exception*>(thrown_exception) - 1;
+ __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1;
ex->referenceCount = 1;
ex->exceptionType = tinfo;
@@ -783,7 +773,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 = reinterpret_cast<__cxa_dependent_exception*>(__cxa_allocate_dependent_exception())-1;
+ __cxa_dependent_exception *ex = ((__cxa_dependent_exception*)__cxa_allocate_dependent_exception())-1;
ex->primaryException = thrown_exception;
__cxa_increment_exception_refcount(thrown_exception);
@@ -792,7 +782,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(reinterpret_cast<__cxa_exception*>(ex));
+ throw_exception((__cxa_exception*)ex);
}
extern "C" void *__cxa_current_primary_exception(void)
@@ -809,14 +799,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 = static_cast<__cxa_exception*>(thrown_exception) - 1;
+ __cxa_exception *ex = ((__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 = static_cast<__cxa_exception*>(thrown_exception) - 1;
+ __cxa_exception *ex = ((__cxa_exception*)thrown_exception) - 1;
releaseException(ex);
}
@@ -848,7 +838,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 = reinterpret_cast<_Unwind_Exception*>(ex);
+ _Unwind_Exception *e = (_Unwind_Exception*)ex;
_Unwind_Reason_Code err = _Unwind_Resume_or_Rethrow(e);
report_failure(err, ex);
return;
@@ -891,8 +881,8 @@ static std::type_info *get_type_info_entry(_Unwind_Context *context,
if (offset == 0) { return 0; }
// ...so we need to resolve it
- return reinterpret_cast<std::type_info*>(resolve_indirect_value(context,
- lsda->type_table_encoding, offset, start));
+ return (std::type_info*)resolve_indirect_value(context,
+ lsda->type_table_encoding, offset, start);
}
@@ -906,13 +896,13 @@ static bool check_type_signature(__cxa_exception *ex,
const std::type_info *type,
void *&adjustedPtr)
{
- void *exception_ptr = static_cast<void*>(ex+1);
+ void *exception_ptr = (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 = *static_cast<void**>(exception_ptr);
+ exception_ptr = *(void**)exception_ptr;
}
// Always match a catchall, even with a foreign exception
//
@@ -984,7 +974,7 @@ static handler_type check_action_record(_Unwind_Context *context,
{
bool matched = false;
*selector = filter;
-#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#ifdef __arm__
filter++;
std::type_info *handler_type = get_type_info_entry(context, lsda, filter--);
while (handler_type)
@@ -997,7 +987,7 @@ static handler_type check_action_record(_Unwind_Context *context,
handler_type = get_type_info_entry(context, lsda, filter--);
}
#else
- unsigned char *type_index = reinterpret_cast<unsigned char*>(lsda->type_table) - filter - 1;
+ unsigned char *type_index = ((unsigned char*)lsda->type_table - filter - 1);
while (*type_index)
{
std::type_info *handler_type = get_type_info_entry(context, lsda, *(type_index++));
@@ -1029,7 +1019,7 @@ static handler_type check_action_record(_Unwind_Context *context,
static void pushCleanupException(_Unwind_Exception *exceptionObject,
__cxa_exception *ex)
{
-#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#ifdef __arm__
__cxa_thread_info *info = thread_info_fast();
if (ex)
{
@@ -1074,13 +1064,8 @@ 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 =
- reinterpret_cast<unsigned char*>(static_cast<uintptr_t>(_Unwind_GetLanguageSpecificData(context)));
-#endif
+ (unsigned char*)_Unwind_GetLanguageSpecificData(context);
// No LSDA implies no landing pads - try the next frame
if (0 == lsda_addr) { return continueUnwinding(exceptionObject, context); }
@@ -1129,8 +1114,8 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
if (ex)
{
saveLandingPad(context, exceptionObject, ex, selector, action.landing_pad);
- ex->languageSpecificData = reinterpret_cast<const char*>(lsda_addr);
- ex->actionRecord = reinterpret_cast<const char*>(action.action_record);
+ ex->languageSpecificData = (const char*)lsda_addr;
+ ex->actionRecord = (const char*)action.action_record;
// ex->adjustedPtr is set when finding the action record.
}
return _URC_HANDLER_FOUND;
@@ -1176,9 +1161,9 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
}
- _Unwind_SetIP(context, reinterpret_cast<unsigned long>(action.landing_pad));
+ _Unwind_SetIP(context, (unsigned long)action.landing_pad);
_Unwind_SetGR(context, __builtin_eh_return_data_regno(0),
- reinterpret_cast<unsigned long>(exceptionObject));
+ (unsigned long)exceptionObject);
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1), selector);
return _URC_INSTALL_CONTEXT;
@@ -1202,7 +1187,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 = static_cast<_Unwind_Exception*>(e);
+ _Unwind_Exception *exceptionObject = (_Unwind_Exception*)e;
if (isCXXException(exceptionObject->exception_class))
{
@@ -1256,12 +1241,12 @@ extern "C" void *__cxa_begin_catch(void *e)
{
std::terminate();
}
- globals->caughtExceptions = reinterpret_cast<__cxa_exception*>(exceptionObject);
+ globals->caughtExceptions = (__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 (reinterpret_cast<char*>(exceptionObject) + sizeof(_Unwind_Exception));
+ return ((char*)exceptionObject + sizeof(_Unwind_Exception));
}
@@ -1285,7 +1270,7 @@ extern "C" void __cxa_end_catch()
globals->caughtExceptions = 0;
if (ti->foreign_exception_state != __cxa_thread_info::rethrown)
{
- _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions);
+ _Unwind_Exception *e = (_Unwind_Exception*)ti->globals.caughtExceptions;
e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e);
}
ti->foreign_exception_state = __cxa_thread_info::none;
@@ -1347,7 +1332,7 @@ extern "C" std::type_info *__cxa_current_exception_type()
*/
extern "C" void __cxa_call_unexpected(void*exception)
{
- _Unwind_Exception *exceptionObject = static_cast<_Unwind_Exception*>(exception);
+ _Unwind_Exception *exceptionObject = (_Unwind_Exception*)exception;
if (exceptionObject->exception_class == exception_class)
{
__cxa_exception *ex = exceptionFromPointer(exceptionObject);
@@ -1498,7 +1483,7 @@ namespace std
return ATOMIC_LOAD(&terminateHandler);
}
}
-#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#ifdef __arm__
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 f1c4c69..f0c26ab 100644
--- a/contrib/libcxxrt/guard.cc
+++ b/contrib/libcxxrt/guard.cc
@@ -70,45 +70,18 @@
#ifdef __arm__
// ARM ABI - 32-bit guards.
typedef uint32_t guard_t;
-typedef uint32_t guard_lock_t;
-static const uint32_t LOCKED = static_cast<guard_t>(1) << 31;
+static const uint32_t LOCKED = ((guard_t)1) << 31;
static const uint32_t INITIALISED = 1;
-#define LOCK_PART(guard) (guard)
-#define INIT_PART(guard) (guard)
-#elif defined(_LP64)
+#else
typedef uint64_t guard_t;
-typedef uint64_t guard_lock_t;
# if defined(__LITTLE_ENDIAN__)
-static const guard_t LOCKED = static_cast<guard_t>(1) << 63;
+static const guard_t LOCKED = ((guard_t)1) << 63;
static const guard_t INITIALISED = 1;
# else
static const guard_t LOCKED = 1;
-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;
+static const guard_t INITIALISED = ((guard_t)1) << 56;
# 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
@@ -117,49 +90,42 @@ static const guard_lock_t INITIAL = 0;
*/
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 == *INIT_PART(guard_object))
- return 0;
+ if ((INITIALISED == *guard_object)) { return 0; }
// Spin trying to do the initialisation
- for (;;)
+ while (1)
{
// Loop trying to move the value of the guard from 0 (not
// locked, not initialised) to the locked-uninitialised
// position.
- 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))
+ switch (__sync_val_compare_and_swap(guard_object, 0, LOCKED))
+ {
+ // If the old value was 0, we succeeded, so continue
+ // initialising
+ case 0:
return 1;
- 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 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 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;
}
/**
@@ -169,8 +135,7 @@ 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(LOCK_PART(guard_object),
- LOCKED, INITIAL);
+ bool reset = __sync_bool_compare_and_swap(guard_object, LOCKED, 0);
assert(reset);
}
/**
@@ -179,15 +144,9 @@ 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(INIT_PART(guard_object),
- old, INITIALISED);
+ bool reset = __sync_bool_compare_and_swap(guard_object, LOCKED, 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 c1cea39..687fc5e 100644
--- a/contrib/libcxxrt/stdexcept.cc
+++ b/contrib/libcxxrt/stdexcept.cc
@@ -82,18 +82,5 @@ 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 8920393..49eaf55 100644
--- a/contrib/libcxxrt/stdexcept.h
+++ b/contrib/libcxxrt/stdexcept.h
@@ -81,15 +81,6 @@ 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 71de9ae..fda5196 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 = static_cast<char*>(realloc(buf, len+1));
+ buf = (char*)realloc(buf, len+1);
}
if (0 != buf)
{
diff --git a/contrib/libcxxrt/unwind-arm.h b/contrib/libcxxrt/unwind-arm.h
index 52e563e..8c1fa16 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, reinterpret_cast<unsigned long>(exceptionObject));\
+ _Unwind_SetGR (context, 12, (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 130dd6d..e463a2a 100644
--- a/contrib/libcxxrt/unwind.h
+++ b/contrib/libcxxrt/unwind.h
@@ -27,7 +27,7 @@
extern "C" {
#endif
-#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
+#ifdef __arm__
#include "unwind-arm.h"
#else
#include "unwind-itanium.h"
OpenPOWER on IntegriCloud