forked from OSchip/llvm-project
By changing all of the throw() specs to noexcept I've been able to compile and link all of the source files into a dylib. Prior to this substitution the changed functions were calling __cxa_call_unexpected which isn't implemented yet. However in none of these cases do we actaully want __cxa_call_unexpected to be called. Primative buildit script added.
llvm-svn: 148880
This commit is contained in:
parent
1b8e437ab6
commit
abc770690a
|
@ -33,16 +33,16 @@ namespace __cxxabiv1 {
|
|||
extern "C" {
|
||||
|
||||
// 2.4.2 Allocating the Exception Object
|
||||
extern void * __cxa_allocate_exception(size_t thrown_size) throw();
|
||||
extern void __cxa_free_exception(void * thrown_exception) throw();
|
||||
extern void * __cxa_allocate_exception(size_t thrown_size) noexcept;
|
||||
extern void __cxa_free_exception(void * thrown_exception) noexcept;
|
||||
|
||||
// 2.4.3 Throwing the Exception Object
|
||||
extern LIBCXXABI_NORETURN void __cxa_throw(void * thrown_exception,
|
||||
std::type_info * tinfo, void (*dest)(void *));
|
||||
|
||||
// 2.5.3 Exception Handlers
|
||||
extern void * __cxa_get_exception_ptr(void * exceptionObject) throw();
|
||||
extern void * __cxa_begin_catch(void * exceptionObject) throw();
|
||||
extern void * __cxa_get_exception_ptr(void * exceptionObject) noexcept;
|
||||
extern void * __cxa_begin_catch(void * exceptionObject) noexcept;
|
||||
extern void __cxa_end_catch();
|
||||
extern std::type_info * __cxa_current_exception_type();
|
||||
|
||||
|
@ -157,13 +157,13 @@ extern char* __cxa_demangle(const char* mangled_name,
|
|||
|
||||
// Apple additions to support C++ 0x exception_ptr class
|
||||
// These are primitives to wrap a smart pointer around an exception object
|
||||
extern void * __cxa_current_primary_exception() throw();
|
||||
extern void * __cxa_current_primary_exception() noexcept;
|
||||
extern void __cxa_rethrow_primary_exception(void* primary_exception);
|
||||
extern void __cxa_increment_exception_refcount(void* primary_exception) throw();
|
||||
extern void __cxa_decrement_exception_refcount(void* primary_exception) throw();
|
||||
extern void __cxa_increment_exception_refcount(void* primary_exception) noexcept;
|
||||
extern void __cxa_decrement_exception_refcount(void* primary_exception) noexcept;
|
||||
|
||||
// Apple addition to support std::uncaught_exception()
|
||||
extern bool __cxa_uncaught_exception() throw();
|
||||
extern bool __cxa_uncaught_exception() noexcept;
|
||||
|
||||
} // extern "C"
|
||||
} // namespace __cxxabiv1
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# Set the $TRIPLE environment variable to your system's triple before
|
||||
# running this script. If you set $CXX, that will be used to compile
|
||||
# the library. Otherwise we'll use clang++.
|
||||
|
||||
set -e
|
||||
|
||||
if [ `basename $(pwd)` != "lib" ]
|
||||
then
|
||||
echo "current directory must be lib"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$CXX" ]
|
||||
then
|
||||
CXX=clang++
|
||||
fi
|
||||
|
||||
if [ -z "$CC" ]
|
||||
then
|
||||
CC=clang
|
||||
fi
|
||||
|
||||
if [ -z $RC_ProjectSourceVersion ]
|
||||
then
|
||||
RC_ProjectSourceVersion=1
|
||||
fi
|
||||
|
||||
EXTRA_FLAGS="-std=c++0x -stdlib=libc++"
|
||||
|
||||
case $TRIPLE in
|
||||
*-apple-*)
|
||||
if [ -z $RC_XBS ]
|
||||
then
|
||||
RC_CFLAGS="-arch i386 -arch x86_64"
|
||||
fi
|
||||
SOEXT=dylib
|
||||
if [ -n "$SDKROOT" ]
|
||||
then
|
||||
EXTRA_FLAGS+="-isysroot ${SDKROOT}"
|
||||
CXX=`xcrun -sdk "${SDKROOT}" -find clang++`
|
||||
CC=`xcrun -sdk "${SDKROOT}" -find clang`
|
||||
fi
|
||||
LDSHARED_FLAGS="-o libc++abi.dylib \
|
||||
-dynamiclib -nodefaultlibs \
|
||||
-current_version ${RC_ProjectSourceVersion} \
|
||||
-compatibility_version 1 \
|
||||
-install_name /usr/lib/libc++abi.dylib \
|
||||
-lSystem"
|
||||
;;
|
||||
*-*-mingw*)
|
||||
# FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt
|
||||
SOEXT=dll
|
||||
LDSHARED_FLAGS="-o libc++abi.dll \
|
||||
-shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++abi.dll.a \
|
||||
-lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt"
|
||||
;;
|
||||
*)
|
||||
RC_CFLAGS="-fPIC"
|
||||
SOEXT=so
|
||||
LDSHARED_FLAGS="-o libc++abi.so.1.0 \
|
||||
-shared -nodefaultlibs -Wl,-soname,libc++abi.so.1 \
|
||||
-lpthread -lrt -lc -lstdc++"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z $RC_XBS ]
|
||||
then
|
||||
rm -f libc++abi.1.$SOEXT*
|
||||
fi
|
||||
|
||||
set -x
|
||||
|
||||
for FILE in ../src/*.cpp; do
|
||||
$CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE
|
||||
done
|
||||
case $TRIPLE in
|
||||
*-*-mingw*)
|
||||
for FILE in ../src/support/win32/*.cpp; do
|
||||
$CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE
|
||||
done
|
||||
;;
|
||||
esac
|
||||
$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS
|
||||
|
||||
if [ -z $RC_XBS ]
|
||||
then
|
||||
rm *.o
|
||||
fi
|
|
@ -39,7 +39,7 @@ namespace __cxxabiv1 {
|
|||
static
|
||||
inline
|
||||
__cxa_exception*
|
||||
cxa_exception_from_thrown_object(void* thrown_object) throw()
|
||||
cxa_exception_from_thrown_object(void* thrown_object) noexcept
|
||||
{
|
||||
return static_cast<__cxa_exception*>(thrown_object) - 1;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ cxa_exception_from_thrown_object(void* thrown_object) throw()
|
|||
static
|
||||
inline
|
||||
void*
|
||||
thrown_object_from_cxa_exception(__cxa_exception* exception_header) throw()
|
||||
thrown_object_from_cxa_exception(__cxa_exception* exception_header) noexcept
|
||||
{
|
||||
return static_cast<void*>(exception_header + 1);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ thrown_object_from_cxa_exception(__cxa_exception* exception_header) throw()
|
|||
static
|
||||
inline
|
||||
__cxa_exception*
|
||||
cxa_exception_from_exception_unwind_exception(_Unwind_Exception* unwind_exception) throw()
|
||||
cxa_exception_from_exception_unwind_exception(_Unwind_Exception* unwind_exception) noexcept
|
||||
{
|
||||
return cxa_exception_from_thrown_object(unwind_exception + 1 );
|
||||
}
|
||||
|
@ -68,50 +68,50 @@ cxa_exception_from_exception_unwind_exception(_Unwind_Exception* unwind_exceptio
|
|||
static
|
||||
inline
|
||||
size_t
|
||||
cxa_exception_size_from_exception_thrown_size(size_t size) throw()
|
||||
cxa_exception_size_from_exception_thrown_size(size_t size) noexcept
|
||||
{
|
||||
return size + sizeof (__cxa_exception);
|
||||
}
|
||||
|
||||
static void setExceptionClass(_Unwind_Exception* unwind_exception) throw() {
|
||||
static void setExceptionClass(_Unwind_Exception* unwind_exception) noexcept {
|
||||
unwind_exception->exception_class = kOurExceptionClass;
|
||||
}
|
||||
|
||||
static void setDependentExceptionClass(_Unwind_Exception* unwind_exception) throw() {
|
||||
static void setDependentExceptionClass(_Unwind_Exception* unwind_exception) noexcept {
|
||||
unwind_exception->exception_class = kOurDependentExceptionClass;
|
||||
}
|
||||
|
||||
// Is it one of ours?
|
||||
static bool isOurExceptionClass(_Unwind_Exception* unwind_exception) throw() {
|
||||
static bool isOurExceptionClass(_Unwind_Exception* unwind_exception) noexcept {
|
||||
return(unwind_exception->exception_class == kOurExceptionClass)||
|
||||
(unwind_exception->exception_class == kOurDependentExceptionClass);
|
||||
}
|
||||
|
||||
static bool isDependentException(_Unwind_Exception* unwind_exception) throw() {
|
||||
static bool isDependentException(_Unwind_Exception* unwind_exception) noexcept {
|
||||
return (unwind_exception->exception_class & 0xFF) == 0x01;
|
||||
}
|
||||
|
||||
// This does not need to be atomic
|
||||
static inline int incrementHandlerCount(__cxa_exception *exception) throw() {
|
||||
static inline int incrementHandlerCount(__cxa_exception *exception) noexcept {
|
||||
return ++exception->handlerCount;
|
||||
}
|
||||
|
||||
// This does not need to be atomic
|
||||
static inline int decrementHandlerCount(__cxa_exception *exception) throw() {
|
||||
static inline int decrementHandlerCount(__cxa_exception *exception) noexcept {
|
||||
return --exception->handlerCount;
|
||||
}
|
||||
|
||||
#include "fallback_malloc.ipp"
|
||||
|
||||
// Allocate some memory from _somewhere_
|
||||
static void *do_malloc(size_t size) throw() {
|
||||
static void *do_malloc(size_t size) noexcept {
|
||||
void *ptr = std::malloc(size);
|
||||
if (NULL == ptr) // if malloc fails, fall back to emergency stash
|
||||
ptr = fallback_malloc(size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static void do_free(void *ptr) throw() {
|
||||
static void do_free(void *ptr) noexcept {
|
||||
is_fallback_ptr(ptr) ? fallback_free(ptr) : std::free(ptr);
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ exception_cleanup_func(_Unwind_Reason_Code reason, _Unwind_Exception* unwind_exc
|
|||
__cxa_free_exception(thrown_object);
|
||||
}
|
||||
|
||||
static LIBCXXABI_NORETURN void failed_throw(__cxa_exception* exception_header) throw() {
|
||||
static LIBCXXABI_NORETURN void failed_throw(__cxa_exception* exception_header) noexcept {
|
||||
// Section 2.5.3 says:
|
||||
// * For purposes of this ABI, several things are considered exception handlers:
|
||||
// ** A terminate() call due to a throw.
|
||||
|
@ -155,7 +155,7 @@ extern "C" {
|
|||
// object. Zero-fill the object. If memory can't be allocated, call
|
||||
// std::terminate. Return a pointer to the memory to be used for the
|
||||
// user's exception object.
|
||||
void * __cxa_allocate_exception (size_t thrown_size) throw() {
|
||||
void * __cxa_allocate_exception (size_t thrown_size) noexcept {
|
||||
size_t actual_size = cxa_exception_size_from_exception_thrown_size(thrown_size);
|
||||
__cxa_exception* exception_header = static_cast<__cxa_exception*>(do_malloc(actual_size));
|
||||
if (NULL == exception_header)
|
||||
|
@ -166,7 +166,7 @@ void * __cxa_allocate_exception (size_t thrown_size) throw() {
|
|||
|
||||
|
||||
// Free a __cxa_exception object allocated with __cxa_allocate_exception.
|
||||
void __cxa_free_exception (void * thrown_object) throw() {
|
||||
void __cxa_free_exception (void * thrown_object) noexcept {
|
||||
do_free(cxa_exception_from_thrown_object(thrown_object));
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ void __cxa_free_exception (void * thrown_object) throw() {
|
|||
// This function shall allocate a __cxa_dependent_exception and
|
||||
// return a pointer to it. (Really to the object, not past its' end).
|
||||
// Otherwise, it will work like __cxa_allocate_exception.
|
||||
void * __cxa_allocate_dependent_exception () throw() {
|
||||
void * __cxa_allocate_dependent_exception () noexcept {
|
||||
size_t actual_size = sizeof(__cxa_dependent_exception);
|
||||
void *ptr = do_malloc(actual_size);
|
||||
if (NULL == ptr)
|
||||
|
@ -186,7 +186,7 @@ void * __cxa_allocate_dependent_exception () throw() {
|
|||
|
||||
// This function shall free a dependent_exception.
|
||||
// It does not affect the reference count of the primary exception.
|
||||
void __cxa_free_dependent_exception (void * dependent_exception) throw() {
|
||||
void __cxa_free_dependent_exception (void * dependent_exception) noexcept {
|
||||
do_free(dependent_exception);
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ The adjusted pointer is computed by the personality routine during phase 1
|
|||
__cxa_dependent_exception).
|
||||
*/
|
||||
void*
|
||||
__cxa_get_exception_ptr(void* unwind_exception) throw()
|
||||
__cxa_get_exception_ptr(void* unwind_exception) noexcept
|
||||
{
|
||||
return cxa_exception_from_exception_unwind_exception
|
||||
(
|
||||
|
@ -268,7 +268,7 @@ This routine:
|
|||
* Returns the adjusted pointer to the exception object.
|
||||
*/
|
||||
void*
|
||||
__cxa_begin_catch(void* unwind_exception) throw()
|
||||
__cxa_begin_catch(void* unwind_exception) noexcept
|
||||
{
|
||||
__cxa_eh_globals *globals = __cxa_get_globals();
|
||||
__cxa_exception* exception_header =
|
||||
|
@ -396,7 +396,7 @@ extern LIBCXXABI_NORETURN void __cxa_rethrow() {
|
|||
__cxa_exception header associated with the thrown object referred to by p.
|
||||
*/
|
||||
void
|
||||
__cxa_increment_exception_refcount(void* thrown_object) throw()
|
||||
__cxa_increment_exception_refcount(void* thrown_object) noexcept
|
||||
{
|
||||
if (thrown_object != NULL )
|
||||
{
|
||||
|
@ -411,7 +411,7 @@ __cxa_increment_exception_refcount(void* thrown_object) throw()
|
|||
If the referenceCount drops to zero, destroy and deallocate the exception.
|
||||
*/
|
||||
void
|
||||
__cxa_decrement_exception_refcount(void* thrown_object) throw()
|
||||
__cxa_decrement_exception_refcount(void* thrown_object) noexcept
|
||||
{
|
||||
if (thrown_object != NULL )
|
||||
{
|
||||
|
@ -435,7 +435,7 @@ __cxa_decrement_exception_refcount(void* thrown_object) throw()
|
|||
the need to allocate the exception-handling globals.
|
||||
*/
|
||||
void*
|
||||
__cxa_current_primary_exception() throw()
|
||||
__cxa_current_primary_exception() noexcept
|
||||
{
|
||||
// get the current exception
|
||||
__cxa_eh_globals* globals = __cxa_get_globals_fast();
|
||||
|
@ -504,7 +504,7 @@ __cxa_rethrow_primary_exception(void* thrown_object)
|
|||
}
|
||||
|
||||
bool
|
||||
__cxa_uncaught_exception() throw()
|
||||
__cxa_uncaught_exception() noexcept
|
||||
{
|
||||
__cxa_eh_globals* globals = __cxa_get_globals_fast();
|
||||
if (globals == 0)
|
||||
|
|
|
@ -102,10 +102,10 @@ static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC
|
|||
#endif
|
||||
};
|
||||
|
||||
extern "C" __cxa_eh_globals * __cxa_get_globals () throw();
|
||||
extern "C" __cxa_eh_globals * __cxa_get_globals_fast () throw();
|
||||
extern "C" __cxa_eh_globals * __cxa_get_globals () noexcept;
|
||||
extern "C" __cxa_eh_globals * __cxa_get_globals_fast () noexcept;
|
||||
|
||||
extern "C" void * __cxa_allocate_dependent_exception () throw();
|
||||
extern "C" void __cxa_free_dependent_exception (void * dependent_exception) throw();
|
||||
extern "C" void * __cxa_allocate_dependent_exception () noexcept;
|
||||
extern "C" void __cxa_free_dependent_exception (void * dependent_exception) noexcept;
|
||||
|
||||
}
|
|
@ -18,15 +18,15 @@
|
|||
namespace __cxxabiv1 {
|
||||
|
||||
namespace {
|
||||
__cxa_eh_globals * __globals () throw () {
|
||||
__cxa_eh_globals * __globals () noexcept {
|
||||
static thread_local __cxa_eh_globals eh_globals;
|
||||
return &eh_globals;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
__cxa_eh_globals * __cxa_get_globals () throw() { return __globals (); }
|
||||
__cxa_eh_globals * __cxa_get_globals_fast () throw() { return __globals (); }
|
||||
__cxa_eh_globals * __cxa_get_globals () noexcept { return __globals (); }
|
||||
__cxa_eh_globals * __cxa_get_globals_fast () noexcept { return __globals (); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,13 +44,13 @@ namespace __cxxabiv1 {
|
|||
namespace {
|
||||
pthread_key_t key_;
|
||||
|
||||
void destruct_ (void *p) throw () {
|
||||
void destruct_ (void *p) noexcept {
|
||||
std::free ( p );
|
||||
if ( 0 != ::pthread_setspecific ( key_, NULL ) )
|
||||
abort_message("cannot zero out thread value for __cxa_get_globals()");
|
||||
}
|
||||
|
||||
int construct_ () throw () {
|
||||
int construct_ () noexcept {
|
||||
if ( 0 != pthread_key_create ( &key_, destruct_ ) )
|
||||
abort_message("cannot create pthread key for __cxa_get_globals()");
|
||||
return 0;
|
||||
|
@ -58,7 +58,7 @@ namespace {
|
|||
}
|
||||
|
||||
extern "C" {
|
||||
__cxa_eh_globals * __cxa_get_globals () throw () {
|
||||
__cxa_eh_globals * __cxa_get_globals () noexcept {
|
||||
|
||||
// Try to get the globals for this thread
|
||||
__cxa_eh_globals* retVal = __cxa_get_globals_fast ();
|
||||
|
@ -75,7 +75,7 @@ extern "C" {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
__cxa_eh_globals * __cxa_get_globals_fast () throw () {
|
||||
__cxa_eh_globals * __cxa_get_globals_fast () noexcept {
|
||||
// First time through, create the key.
|
||||
static int init = construct_();
|
||||
return static_cast<__cxa_eh_globals*>(::pthread_getspecific(key_));
|
||||
|
|
|
@ -50,26 +50,26 @@ struct heap_node {
|
|||
static const heap_node *list_end = (heap_node *) ( &heap [ HEAP_SIZE ] ); // one past the end of the heap
|
||||
static heap_node *freelist = NULL;
|
||||
|
||||
heap_node *node_from_offset ( const heap_offset offset ) throw()
|
||||
heap_node *node_from_offset ( const heap_offset offset ) noexcept
|
||||
{ return (heap_node *) ( heap + ( offset * sizeof (heap_node))); }
|
||||
|
||||
heap_offset offset_from_node ( const heap_node *ptr ) throw()
|
||||
heap_offset offset_from_node ( const heap_node *ptr ) noexcept
|
||||
{ return (((char *) ptr ) - heap) / sizeof (heap_node); }
|
||||
|
||||
void init_heap () throw() {
|
||||
void init_heap () noexcept {
|
||||
freelist = (heap_node *) heap;
|
||||
freelist->next_node = offset_from_node ( list_end );
|
||||
freelist->len = HEAP_SIZE / sizeof (heap_node);
|
||||
}
|
||||
|
||||
// How big a chunk we allocate
|
||||
size_t alloc_size (size_t len) throw()
|
||||
size_t alloc_size (size_t len) noexcept
|
||||
{ return (len + sizeof(heap_node) - 1) / sizeof(heap_node) + 1; }
|
||||
|
||||
bool is_fallback_ptr ( void *ptr ) throw()
|
||||
bool is_fallback_ptr ( void *ptr ) noexcept
|
||||
{ return ptr >= heap && ptr < ( heap + HEAP_SIZE ); }
|
||||
|
||||
void *fallback_malloc(size_t len) throw() {
|
||||
void *fallback_malloc(size_t len) noexcept {
|
||||
heap_node *p, *prev;
|
||||
const size_t nelems = alloc_size ( len );
|
||||
mutexor mtx ( &heap_mutex );
|
||||
|
@ -104,9 +104,9 @@ void *fallback_malloc(size_t len) throw() {
|
|||
}
|
||||
|
||||
// Return the start of the next block
|
||||
heap_node *after ( struct heap_node *p ) throw() { return p + p->len; }
|
||||
heap_node *after ( struct heap_node *p ) noexcept { return p + p->len; }
|
||||
|
||||
void fallback_free (void *ptr) throw() {
|
||||
void fallback_free (void *ptr) noexcept {
|
||||
struct heap_node *cp = ((struct heap_node *) ptr) - 1; // retrieve the chunk
|
||||
struct heap_node *p, *prev;
|
||||
|
||||
|
|
Loading…
Reference in New Issue