[cfe-commits] [libcxxabi] r146072 - in /libcxxabi/trunk: src/cxa_exception.cpp src/cxa_handlers.cpp src/cxa_handlers.hpp www/spec.html
Howard Hinnant
hhinnant at apple.com
Wed Dec 7 13:16:40 PST 2011
Author: hhinnant
Date: Wed Dec 7 15:16:40 2011
New Revision: 146072
URL: http://llvm.org/viewvc/llvm-project?rev=146072&view=rev
Log:
Reviewing cxa_exception.cpp and marking as implemented as I go. Not marking as implemented on arm when I'm not sure about that platform.
Added:
libcxxabi/trunk/src/cxa_handlers.hpp
Modified:
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_handlers.cpp
libcxxabi/trunk/www/spec.html
Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=146072&r1=146071&r2=146072&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Wed Dec 7 15:16:40 2011
@@ -19,21 +19,22 @@
#include <pthread.h>
#include "cxa_exception.hpp"
+#include "cxa_handlers.hpp"
namespace __cxxabiv1 {
static const uint64_t kOurExceptionClass = 0x434C4E47432B2B00; // CLNGC++\0
static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC++\1
// Utility routines
-static __cxa_exception *exception_from_thrown_object(void *p) throw() {
+static inline __cxa_exception *exception_from_thrown_object(void *p) throw() {
return ((__cxa_exception *) p) - 1;
}
-static void * thrown_object_from_exception(void *p) throw() {
+static inline void * thrown_object_from_exception(void *p) throw() {
return (void *) (((__cxa_exception *) p) + 1 );
}
-static size_t object_size_from_exception_size(size_t size) throw() {
+static inline size_t object_size_from_exception_size(size_t size) throw() {
return size + sizeof (__cxa_exception);
}
@@ -90,7 +91,7 @@
return is_fallback_ptr(ptr) ? fallback_free(ptr) : std::free(ptr);
}
-/* Howard says:
+/*
If reason isn't _URC_FOREIGN_EXCEPTION_CAUGHT, then the terminateHandler
stored in exc is called. Otherwise the exceptionDestructor stored in
exc is called, and then the memory for the exception is deallocated.
@@ -98,7 +99,7 @@
static void exception_cleanup_func(_Unwind_Reason_Code reason, struct _Unwind_Exception* exc) {
__cxa_exception *exception = exception_from_exception_object(exc);
if (_URC_FOREIGN_EXCEPTION_CAUGHT != reason)
- exception->terminateHandler ();
+ std::__terminate(exception->terminateHandler);
void * thrown_object = thrown_object_from_exception(exception);
if (NULL != exception->exceptionDestructor)
@@ -115,7 +116,7 @@
// a handler must call:
// * void *__cxa_begin_catch(void *exceptionObject );
(void) __cxa_begin_catch(&exception->unwindHeader);
- std::terminate();
+ std::__terminate(exception->terminateHandler);
}
extern "C" {
@@ -150,7 +151,6 @@
if (NULL == ptr)
std::terminate();
std::memset(ptr, 0, actual_size);
-// bookkeeping here ?
return ptr;
}
@@ -158,7 +158,6 @@
// 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() {
-// I'm pretty sure there's no bookkeeping here
do_free(dependent_exception);
}
@@ -228,11 +227,7 @@
__cxa_eh_globals *globals = __cxa_get_globals();
__cxa_exception *exception = exception_from_exception_object(exceptionObject);
-// TODO add stuff for dependent exceptions.
-
-// TODO - should this be atomic?
// Increment the handler count, removing the flag about being rethrown
-// assert(exception->handlerCount != 0);
exception->handlerCount = exception->handlerCount < 0 ?
-exception->handlerCount + 1 : exception->handlerCount + 1;
Modified: libcxxabi/trunk/src/cxa_handlers.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.cpp?rev=146072&r1=146071&r2=146072&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_handlers.cpp Wed Dec 7 15:16:40 2011
@@ -14,6 +14,7 @@
#include <new>
#include <exception>
#include "abort_message.h"
+#include "cxa_handlers.hpp"
namespace std
{
Added: libcxxabi/trunk/src/cxa_handlers.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.hpp?rev=146072&view=auto
==============================================================================
--- libcxxabi/trunk/src/cxa_handlers.hpp (added)
+++ libcxxabi/trunk/src/cxa_handlers.hpp Wed Dec 7 15:16:40 2011
@@ -0,0 +1,28 @@
+//===------------------------- cxa_handlers.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.
+//
+//
+// This file implements the functionality associated with the terminate_handler,
+// unexpected_handler, and new_handler.
+//===----------------------------------------------------------------------===//
+
+#include <exception>
+
+namespace std
+{
+
+_LIBCPP_HIDDEN
+_ATTRIBUTE(noreturn)
+void
+__unexpected(unexpected_handler func);
+
+_LIBCPP_HIDDEN
+_ATTRIBUTE(noreturn)
+void
+__terminate(terminate_handler func) _NOEXCEPT;
+
+} // std
Modified: libcxxabi/trunk/www/spec.html
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/www/spec.html?rev=146072&r1=146071&r2=146072&view=diff
==============================================================================
--- libcxxabi/trunk/www/spec.html (original)
+++ libcxxabi/trunk/www/spec.html Wed Dec 7 15:16:40 2011
@@ -112,8 +112,8 @@
</p>
</blockquote>
</td>
-<td></td>
-<td></td>
+<td>✓</td>
+<td>✓</td>
<td></td>
</tr>
@@ -130,9 +130,9 @@
</p>
</blockquote>
</td>
-<td></td>
-<td></td>
-<td></td>
+<td>✓</td>
+<td>✓</td>
+<td>✓</td>
</tr>
<tr>
@@ -166,8 +166,8 @@
</p>
</blockquote>
</td>
-<td></td>
-<td></td>
+<td>✓</td>
+<td>✓</td>
<td></td>
</tr>
More information about the cfe-commits
mailing list