mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-04 00:06:50 +00:00
I had originally made the handler function pointers a static internal detail, not accessible to the outside world. I did this because they must be accessed in a thread-safe manner, and the library provides thread-safe getters and setters for these. However I am at least temporarily making them public and giving them the Apple-extension names. In the future these may disappear again, and I think that would probably be a good idea.
llvm-svn: 151256
This commit is contained in:
parent
91c6b6a933
commit
49f28b5a47
@ -172,4 +172,21 @@ extern bool __cxa_uncaught_exception() throw();
|
||||
|
||||
namespace abi = __cxxabiv1;
|
||||
|
||||
// Below are Apple extensions to support implementing C++ ABI in a seperate dylib
|
||||
namespace __cxxabiapple
|
||||
{
|
||||
extern "C"
|
||||
{
|
||||
|
||||
// Apple additions to support multiple STL stacks that share common
|
||||
// terminate, unexpected, and new handlers
|
||||
// But touching these is a bad idea. It is not thread safe.
|
||||
// Use get_terminate, set_terminate, etc. instead.
|
||||
extern void (*__cxa_terminate_handler)();
|
||||
extern void (*__cxa_unexpected_handler)();
|
||||
extern void (*__cxa_new_handler)();
|
||||
|
||||
} // extern "C"
|
||||
} // namespace __cxxabiv1
|
||||
|
||||
#endif // __CXXABI_H
|
||||
|
@ -85,22 +85,22 @@ static void default_unexpected_handler()
|
||||
terminate();
|
||||
}
|
||||
|
||||
static terminate_handler __terminate_handler = default_terminate_handler;
|
||||
static unexpected_handler __unexpected_handler = default_unexpected_handler;
|
||||
static new_handler __new_handler = 0;
|
||||
terminate_handler __cxa_terminate_handler = default_terminate_handler;
|
||||
unexpected_handler __cxa_unexpected_handler = default_unexpected_handler;
|
||||
new_handler __cxa_new_handler = 0;
|
||||
|
||||
unexpected_handler
|
||||
set_unexpected(unexpected_handler func) _NOEXCEPT
|
||||
{
|
||||
if (func == 0)
|
||||
func = default_unexpected_handler;
|
||||
return __sync_lock_test_and_set(&__unexpected_handler, func);
|
||||
return __sync_lock_test_and_set(&__cxa_unexpected_handler, func);
|
||||
}
|
||||
|
||||
unexpected_handler
|
||||
get_unexpected() _NOEXCEPT
|
||||
{
|
||||
return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0);
|
||||
return __sync_fetch_and_add(&__cxa_unexpected_handler, (unexpected_handler)0);
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"), noreturn))
|
||||
@ -124,13 +124,13 @@ set_terminate(terminate_handler func) _NOEXCEPT
|
||||
{
|
||||
if (func == 0)
|
||||
func = default_terminate_handler;
|
||||
return __sync_lock_test_and_set(&__terminate_handler, func);
|
||||
return __sync_lock_test_and_set(&__cxa_terminate_handler, func);
|
||||
}
|
||||
|
||||
terminate_handler
|
||||
get_terminate() _NOEXCEPT
|
||||
{
|
||||
return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0);
|
||||
return __sync_fetch_and_add(&__cxa_terminate_handler, (terminate_handler)0);
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"), noreturn))
|
||||
@ -184,13 +184,13 @@ terminate() _NOEXCEPT
|
||||
new_handler
|
||||
set_new_handler(new_handler handler) _NOEXCEPT
|
||||
{
|
||||
return __sync_lock_test_and_set(&__new_handler, handler);
|
||||
return __sync_lock_test_and_set(&__cxa_new_handler, handler);
|
||||
}
|
||||
|
||||
new_handler
|
||||
get_new_handler() _NOEXCEPT
|
||||
{
|
||||
return __sync_fetch_and_add(&__new_handler, (new_handler)0);
|
||||
return __sync_fetch_and_add(&__cxa_new_handler, (new_handler)0);
|
||||
}
|
||||
|
||||
} // std
|
||||
|
@ -1,41 +0,0 @@
|
||||
//===---------------------------- temporary.cpp ---------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "abort_message.h"
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
static
|
||||
void f1()
|
||||
{
|
||||
abort_message("__cxa_new_handler shouldn't be called");
|
||||
}
|
||||
|
||||
static
|
||||
void f2()
|
||||
{
|
||||
abort_message("__cxa_terminate_handler shouldn't be called");
|
||||
}
|
||||
|
||||
static
|
||||
void f3()
|
||||
{
|
||||
abort_message("__cxa_unexpected_handler shouldn't be called");
|
||||
}
|
||||
|
||||
void (*__cxa_new_handler)() = f1;
|
||||
void (*__cxa_terminate_handler)() = f2;
|
||||
void (*__cxa_unexpected_handler)() = f3;
|
||||
|
||||
}
|
||||
|
||||
#pragma GCC visibility pop
|
Loading…
x
Reference in New Issue
Block a user