mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-27 09:12:44 +00:00
Merge libcxxrt master 03c83f5a57be8c5b1a29a68de5638744f17d28ba
Interesting fixes (* were already cherry-picked):
- 03c83f5 add __cxa_init_primary_exception (#23)
* 5d8a158 Fix two bugs in __cxa_end_cleanup()
* b00c6c5 Insert padding in __cxa_dependent_exception
* 45ca8b1 Insert padding in __cxa_exception struct for compatibility
* f2e5509 Fix unlock in two-word version and add missing comment.
- 6229590 Add an option for disabling emergency buffers. (#14)
MFC after: 2 weeks
(cherry picked from commit ecf4106237
)
This commit is contained in:
parent
d5d6b3938d
commit
134580c103
@ -203,6 +203,14 @@ __cxa_eh_globals *__cxa_get_globals_fast(void);
|
||||
|
||||
std::type_info * __cxa_current_exception_type();
|
||||
|
||||
|
||||
void *__cxa_allocate_exception(size_t thrown_size);
|
||||
|
||||
void __cxa_free_exception(void* thrown_exception);
|
||||
|
||||
__cxa_exception *__cxa_init_primary_exception(
|
||||
void *object, std::type_info* tinfo, void (*dest)(void *));
|
||||
|
||||
/**
|
||||
* Throws an exception returned by __cxa_current_primary_exception(). This
|
||||
* exception may have been caught in another thread.
|
||||
|
@ -162,6 +162,7 @@ struct __cxa_thread_info
|
||||
terminate_handler terminateHandler;
|
||||
/** The unexpected exception handler for this thread. */
|
||||
unexpected_handler unexpectedHandler;
|
||||
#ifndef LIBCXXRT_NO_EMERGENCY_MALLOC
|
||||
/**
|
||||
* The number of emergency buffers held by this thread. This is 0 in
|
||||
* normal operation - the emergency buffers are only used when malloc()
|
||||
@ -170,6 +171,7 @@ struct __cxa_thread_info
|
||||
* in ABI spec [3.3.1]).
|
||||
*/
|
||||
int emergencyBuffersHeld;
|
||||
#endif
|
||||
/**
|
||||
* The exception currently running in a cleanup.
|
||||
*/
|
||||
@ -445,6 +447,23 @@ extern "C" __cxa_eh_globals *ABI_NAMESPACE::__cxa_get_globals_fast(void)
|
||||
return &(thread_info_fast()->globals);
|
||||
}
|
||||
|
||||
#ifdef LIBCXXRT_NO_EMERGENCY_MALLOC
|
||||
static char *alloc_or_die(size_t size)
|
||||
{
|
||||
char *buffer = static_cast<char*>(calloc(1, size));
|
||||
|
||||
if (buffer == nullptr)
|
||||
{
|
||||
fputs("Out of memory attempting to allocate exception\n", stderr);
|
||||
std::terminate();
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
static void free_exception(char *e)
|
||||
{
|
||||
free(e);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* An emergency allocation reserved for when malloc fails. This is treated as
|
||||
* 16 buffers of 1KB each.
|
||||
@ -584,6 +603,7 @@ static void free_exception(char *e)
|
||||
free(e);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Allocates an exception structure. Returns a pointer to the space that can
|
||||
@ -773,6 +793,21 @@ static void throw_exception(__cxa_exception *ex)
|
||||
report_failure(err, ex);
|
||||
}
|
||||
|
||||
extern "C" __cxa_exception *__cxa_init_primary_exception(
|
||||
void *object, std::type_info* tinfo, void (*dest)(void *)) {
|
||||
__cxa_exception *ex = reinterpret_cast<__cxa_exception*>(object) - 1;
|
||||
|
||||
ex->referenceCount = 0;
|
||||
ex->exceptionType = tinfo;
|
||||
|
||||
ex->exceptionDestructor = dest;
|
||||
|
||||
ex->unwindHeader.exception_class = exception_class;
|
||||
ex->unwindHeader.exception_cleanup = exception_cleanup;
|
||||
|
||||
return ex;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ABI function for throwing an exception. Takes the object to be thrown (the
|
||||
@ -783,15 +818,8 @@ 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_init_primary_exception(thrown_exception, tinfo, dest);
|
||||
ex->referenceCount = 1;
|
||||
ex->exceptionType = tinfo;
|
||||
|
||||
ex->exceptionDestructor = dest;
|
||||
|
||||
ex->unwindHeader.exception_class = exception_class;
|
||||
ex->unwindHeader.exception_cleanup = exception_cleanup;
|
||||
|
||||
throw_exception(ex);
|
||||
}
|
||||
|
@ -283,6 +283,10 @@ CXXABI_1.3.9 {
|
||||
};
|
||||
} CXXABI_1.3.6;
|
||||
|
||||
CXXABI_1.3.11 {
|
||||
__cxa_init_primary_exception;
|
||||
} CXXABI_1.3.9;
|
||||
|
||||
CXXRT_1.0 {
|
||||
|
||||
extern "C++" {
|
||||
|
Loading…
Reference in New Issue
Block a user