[cfe-commits] [libcxxabi] r151256 - in /libcxxabi/trunk: include/cxxabi.h src/cxa_handlers.cpp src/temporary.cpp
Howard Hinnant
hhinnant at apple.com
Thu Feb 23 07:32:07 PST 2012
Author: hhinnant
Date: Thu Feb 23 09:32:07 2012
New Revision: 151256
URL: http://llvm.org/viewvc/llvm-project?rev=151256&view=rev
Log:
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.
Removed:
libcxxabi/trunk/src/temporary.cpp
Modified:
libcxxabi/trunk/include/cxxabi.h
libcxxabi/trunk/src/cxa_handlers.cpp
Modified: libcxxabi/trunk/include/cxxabi.h
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/cxxabi.h?rev=151256&r1=151255&r2=151256&view=diff
==============================================================================
--- libcxxabi/trunk/include/cxxabi.h (original)
+++ libcxxabi/trunk/include/cxxabi.h Thu Feb 23 09:32:07 2012
@@ -172,4 +172,21 @@
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
Modified: libcxxabi/trunk/src/cxa_handlers.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.cpp?rev=151256&r1=151255&r2=151256&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_handlers.cpp Thu Feb 23 09:32:07 2012
@@ -85,22 +85,22 @@
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 @@
{
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 @@
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
Removed: libcxxabi/trunk/src/temporary.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/temporary.cpp?rev=151255&view=auto
==============================================================================
--- libcxxabi/trunk/src/temporary.cpp (original)
+++ libcxxabi/trunk/src/temporary.cpp (removed)
@@ -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
More information about the cfe-commits
mailing list