Index: libcxxabi/trunk/src/cxa_default_handlers.cpp =================================================================== --- libcxxabi/trunk/src/cxa_default_handlers.cpp +++ libcxxabi/trunk/src/cxa_default_handlers.cpp @@ -14,8 +14,8 @@ #include #include "abort_message.h" #include "cxxabi.h" -#include "cxa_handlers.hpp" -#include "cxa_exception.hpp" +#include "cxa_handlers.h" +#include "cxa_exception.h" #include "private_typeinfo.h" #include "include/atomic_support.h" Index: libcxxabi/trunk/src/cxa_exception.h =================================================================== --- libcxxabi/trunk/src/cxa_exception.h +++ libcxxabi/trunk/src/cxa_exception.h @@ -0,0 +1,119 @@ +//===------------------------- cxa_exception.h ----------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// +// This file implements the "Exception Handling APIs" +// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html +// +//===----------------------------------------------------------------------===// + +#ifndef _CXA_EXCEPTION_H +#define _CXA_EXCEPTION_H + +#include // for std::unexpected_handler and std::terminate_handler +#include "cxxabi.h" +#include "unwind.h" + +namespace __cxxabiv1 { + +static const uint64_t kOurExceptionClass = 0x434C4E47432B2B00; // CLNGC++\0 +static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC++\1 +static const uint64_t get_vendor_and_language = 0xFFFFFFFFFFFFFF00; // mask for CLNGC++ + +uint64_t __getExceptionClass (const _Unwind_Exception*); +void __setExceptionClass ( _Unwind_Exception*, uint64_t); +bool __isOurExceptionClass(const _Unwind_Exception*); + +struct _LIBCXXABI_HIDDEN __cxa_exception { +#if defined(__LP64__) || defined(_LIBCXXABI_ARM_EHABI) + // This is a new field to support C++ 0x exception_ptr. + // For binary compatibility it is at the start of this + // struct which is prepended to the object thrown in + // __cxa_allocate_exception. + size_t referenceCount; +#endif + + // Manage the exception object itself. + std::type_info *exceptionType; + void (*exceptionDestructor)(void *); + std::unexpected_handler unexpectedHandler; + std::terminate_handler terminateHandler; + + __cxa_exception *nextException; + + int handlerCount; + +#if defined(_LIBCXXABI_ARM_EHABI) + __cxa_exception* nextPropagatingException; + int propagationCount; +#else + int handlerSwitchValue; + const unsigned char *actionRecord; + const unsigned char *languageSpecificData; + void *catchTemp; + void *adjustedPtr; +#endif + +#if !defined(__LP64__) && !defined(_LIBCXXABI_ARM_EHABI) + // This is a new field to support C++ 0x exception_ptr. + // For binary compatibility it is placed where the compiler + // previously adding padded to 64-bit align unwindHeader. + size_t referenceCount; +#endif + _Unwind_Exception unwindHeader; +}; + +// http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html +// The layout of this structure MUST match the layout of __cxa_exception, with +// primaryException instead of referenceCount. +struct _LIBCXXABI_HIDDEN __cxa_dependent_exception { +#if defined(__LP64__) || defined(_LIBCXXABI_ARM_EHABI) + void* primaryException; +#endif + + std::type_info *exceptionType; + void (*exceptionDestructor)(void *); + std::unexpected_handler unexpectedHandler; + std::terminate_handler terminateHandler; + + __cxa_exception *nextException; + + int handlerCount; + +#if defined(_LIBCXXABI_ARM_EHABI) + __cxa_exception* nextPropagatingException; + int propagationCount; +#else + int handlerSwitchValue; + const unsigned char *actionRecord; + const unsigned char *languageSpecificData; + void * catchTemp; + void *adjustedPtr; +#endif + +#if !defined(__LP64__) && !defined(_LIBCXXABI_ARM_EHABI) + void* primaryException; +#endif + _Unwind_Exception unwindHeader; +}; + +struct _LIBCXXABI_HIDDEN __cxa_eh_globals { + __cxa_exception * caughtExceptions; + unsigned int uncaughtExceptions; +#if defined(_LIBCXXABI_ARM_EHABI) + __cxa_exception* propagatingExceptions; +#endif +}; + +extern "C" _LIBCXXABI_FUNC_VIS __cxa_eh_globals * __cxa_get_globals (); +extern "C" _LIBCXXABI_FUNC_VIS __cxa_eh_globals * __cxa_get_globals_fast (); + +extern "C" _LIBCXXABI_FUNC_VIS void * __cxa_allocate_dependent_exception (); +extern "C" _LIBCXXABI_FUNC_VIS void __cxa_free_dependent_exception (void * dependent_exception); + +} // namespace __cxxabiv1 + +#endif // _CXA_EXCEPTION_H Index: libcxxabi/trunk/src/cxa_exception.hpp =================================================================== --- libcxxabi/trunk/src/cxa_exception.hpp +++ libcxxabi/trunk/src/cxa_exception.hpp @@ -1,119 +0,0 @@ -//===------------------------- cxa_exception.hpp --------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// -// This file implements the "Exception Handling APIs" -// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html -// -//===----------------------------------------------------------------------===// - -#ifndef _CXA_EXCEPTION_H -#define _CXA_EXCEPTION_H - -#include // for std::unexpected_handler and std::terminate_handler -#include "cxxabi.h" -#include "unwind.h" - -namespace __cxxabiv1 { - -static const uint64_t kOurExceptionClass = 0x434C4E47432B2B00; // CLNGC++\0 -static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC++\1 -static const uint64_t get_vendor_and_language = 0xFFFFFFFFFFFFFF00; // mask for CLNGC++ - -uint64_t __getExceptionClass (const _Unwind_Exception*); -void __setExceptionClass ( _Unwind_Exception*, uint64_t); -bool __isOurExceptionClass(const _Unwind_Exception*); - -struct _LIBCXXABI_HIDDEN __cxa_exception { -#if defined(__LP64__) || defined(_LIBCXXABI_ARM_EHABI) - // This is a new field to support C++ 0x exception_ptr. - // For binary compatibility it is at the start of this - // struct which is prepended to the object thrown in - // __cxa_allocate_exception. - size_t referenceCount; -#endif - - // Manage the exception object itself. - std::type_info *exceptionType; - void (*exceptionDestructor)(void *); - std::unexpected_handler unexpectedHandler; - std::terminate_handler terminateHandler; - - __cxa_exception *nextException; - - int handlerCount; - -#if defined(_LIBCXXABI_ARM_EHABI) - __cxa_exception* nextPropagatingException; - int propagationCount; -#else - int handlerSwitchValue; - const unsigned char *actionRecord; - const unsigned char *languageSpecificData; - void *catchTemp; - void *adjustedPtr; -#endif - -#if !defined(__LP64__) && !defined(_LIBCXXABI_ARM_EHABI) - // This is a new field to support C++ 0x exception_ptr. - // For binary compatibility it is placed where the compiler - // previously adding padded to 64-bit align unwindHeader. - size_t referenceCount; -#endif - _Unwind_Exception unwindHeader; -}; - -// http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html -// The layout of this structure MUST match the layout of __cxa_exception, with -// primaryException instead of referenceCount. -struct _LIBCXXABI_HIDDEN __cxa_dependent_exception { -#if defined(__LP64__) || defined(_LIBCXXABI_ARM_EHABI) - void* primaryException; -#endif - - std::type_info *exceptionType; - void (*exceptionDestructor)(void *); - std::unexpected_handler unexpectedHandler; - std::terminate_handler terminateHandler; - - __cxa_exception *nextException; - - int handlerCount; - -#if defined(_LIBCXXABI_ARM_EHABI) - __cxa_exception* nextPropagatingException; - int propagationCount; -#else - int handlerSwitchValue; - const unsigned char *actionRecord; - const unsigned char *languageSpecificData; - void * catchTemp; - void *adjustedPtr; -#endif - -#if !defined(__LP64__) && !defined(_LIBCXXABI_ARM_EHABI) - void* primaryException; -#endif - _Unwind_Exception unwindHeader; -}; - -struct _LIBCXXABI_HIDDEN __cxa_eh_globals { - __cxa_exception * caughtExceptions; - unsigned int uncaughtExceptions; -#if defined(_LIBCXXABI_ARM_EHABI) - __cxa_exception* propagatingExceptions; -#endif -}; - -extern "C" _LIBCXXABI_FUNC_VIS __cxa_eh_globals * __cxa_get_globals (); -extern "C" _LIBCXXABI_FUNC_VIS __cxa_eh_globals * __cxa_get_globals_fast (); - -extern "C" _LIBCXXABI_FUNC_VIS void * __cxa_allocate_dependent_exception (); -extern "C" _LIBCXXABI_FUNC_VIS void __cxa_free_dependent_exception (void * dependent_exception); - -} // namespace __cxxabiv1 - -#endif // _CXA_EXCEPTION_H Index: libcxxabi/trunk/src/cxa_exception.cpp =================================================================== --- libcxxabi/trunk/src/cxa_exception.cpp +++ libcxxabi/trunk/src/cxa_exception.cpp @@ -14,8 +14,8 @@ #include // for std::terminate #include // for memset -#include "cxa_exception.hpp" -#include "cxa_handlers.hpp" +#include "cxa_exception.h" +#include "cxa_handlers.h" #include "fallback_malloc.h" #include "include/atomic_support.h" Index: libcxxabi/trunk/src/cxa_exception_storage.cpp =================================================================== --- libcxxabi/trunk/src/cxa_exception_storage.cpp +++ libcxxabi/trunk/src/cxa_exception_storage.cpp @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "cxa_exception.hpp" +#include "cxa_exception.h" #include <__threading_support> Index: libcxxabi/trunk/src/cxa_handlers.h =================================================================== --- libcxxabi/trunk/src/cxa_handlers.h +++ libcxxabi/trunk/src/cxa_handlers.h @@ -0,0 +1,55 @@ +//===------------------------- cxa_handlers.h -----------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// +// This file implements the functionality associated with the terminate_handler, +// unexpected_handler, and new_handler. +//===----------------------------------------------------------------------===// + +#ifndef _CXA_HANDLERS_H +#define _CXA_HANDLERS_H + +#include <__cxxabi_config.h> + +#include + +namespace std +{ + +_LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN +void +__unexpected(unexpected_handler func); + +_LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN +void +__terminate(terminate_handler func) _NOEXCEPT; + +} // std + +extern "C" +{ + +_LIBCXXABI_DATA_VIS extern void (*__cxa_terminate_handler)(); +_LIBCXXABI_DATA_VIS extern void (*__cxa_unexpected_handler)(); +_LIBCXXABI_DATA_VIS extern void (*__cxa_new_handler)(); + +/* + + At some point in the future these three symbols will become + C++11 atomic variables: + + extern std::atomic __cxa_terminate_handler; + extern std::atomic __cxa_unexpected_handler; + extern std::atomic __cxa_new_handler; + + This change will not impact their ABI. But it will allow for a + portable performance optimization. + +*/ + +} // extern "C" + +#endif // _CXA_HANDLERS_H Index: libcxxabi/trunk/src/cxa_handlers.hpp =================================================================== --- libcxxabi/trunk/src/cxa_handlers.hpp +++ libcxxabi/trunk/src/cxa_handlers.hpp @@ -1,55 +0,0 @@ -//===------------------------- cxa_handlers.cpp ---------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// -// This file implements the functionality associated with the terminate_handler, -// unexpected_handler, and new_handler. -//===----------------------------------------------------------------------===// - -#ifndef _CXA_HANDLERS_H -#define _CXA_HANDLERS_H - -#include <__cxxabi_config.h> - -#include - -namespace std -{ - -_LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN -void -__unexpected(unexpected_handler func); - -_LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN -void -__terminate(terminate_handler func) _NOEXCEPT; - -} // std - -extern "C" -{ - -_LIBCXXABI_DATA_VIS extern void (*__cxa_terminate_handler)(); -_LIBCXXABI_DATA_VIS extern void (*__cxa_unexpected_handler)(); -_LIBCXXABI_DATA_VIS extern void (*__cxa_new_handler)(); - -/* - - At some point in the future these three symbols will become - C++11 atomic variables: - - extern std::atomic __cxa_terminate_handler; - extern std::atomic __cxa_unexpected_handler; - extern std::atomic __cxa_new_handler; - - This change will not impact their ABI. But it will allow for a - portable performance optimization. - -*/ - -} // extern "C" - -#endif // _CXA_HANDLERS_H Index: libcxxabi/trunk/src/cxa_handlers.cpp =================================================================== --- libcxxabi/trunk/src/cxa_handlers.cpp +++ libcxxabi/trunk/src/cxa_handlers.cpp @@ -14,8 +14,8 @@ #include #include "abort_message.h" #include "cxxabi.h" -#include "cxa_handlers.hpp" -#include "cxa_exception.hpp" +#include "cxa_handlers.h" +#include "cxa_exception.h" #include "private_typeinfo.h" #include "include/atomic_support.h" Index: libcxxabi/trunk/src/cxa_noexception.cpp =================================================================== --- libcxxabi/trunk/src/cxa_noexception.cpp +++ libcxxabi/trunk/src/cxa_noexception.cpp @@ -15,8 +15,8 @@ #include "cxxabi.h" #include // for std::terminate -#include "cxa_exception.hpp" -#include "cxa_handlers.hpp" +#include "cxa_exception.h" +#include "cxa_handlers.h" namespace __cxxabiv1 { Index: libcxxabi/trunk/src/cxa_personality.cpp =================================================================== --- libcxxabi/trunk/src/cxa_personality.cpp +++ libcxxabi/trunk/src/cxa_personality.cpp @@ -17,8 +17,8 @@ #include #include "__cxxabi_config.h" -#include "cxa_exception.hpp" -#include "cxa_handlers.hpp" +#include "cxa_exception.h" +#include "cxa_handlers.h" #include "private_typeinfo.h" #include "unwind.h" Index: libcxxabi/trunk/src/cxa_unexpected.cpp =================================================================== --- libcxxabi/trunk/src/cxa_unexpected.cpp +++ libcxxabi/trunk/src/cxa_unexpected.cpp @@ -8,7 +8,7 @@ #include #include "cxxabi.h" -#include "cxa_exception.hpp" +#include "cxa_exception.h" namespace __cxxabiv1 { Index: libcxxabi/trunk/test/dynamic_cast14.pass.cpp =================================================================== --- libcxxabi/trunk/test/dynamic_cast14.pass.cpp +++ libcxxabi/trunk/test/dynamic_cast14.pass.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include -#include "support/timer.hpp" +#include "support/timer.h" namespace t1 { Index: libcxxabi/trunk/test/dynamic_cast3.pass.cpp =================================================================== --- libcxxabi/trunk/test/dynamic_cast3.pass.cpp +++ libcxxabi/trunk/test/dynamic_cast3.pass.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include -#include "support/timer.hpp" +#include "support/timer.h" // This test explicitly tests dynamic cast with types that have inaccessible // bases. Index: libcxxabi/trunk/test/dynamic_cast5.pass.cpp =================================================================== --- libcxxabi/trunk/test/dynamic_cast5.pass.cpp +++ libcxxabi/trunk/test/dynamic_cast5.pass.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include -#include "support/timer.hpp" +#include "support/timer.h" // This test explicitly tests dynamic cast with types that have inaccessible // bases. Index: libcxxabi/trunk/test/dynamic_cast_stress.pass.cpp =================================================================== --- libcxxabi/trunk/test/dynamic_cast_stress.pass.cpp +++ libcxxabi/trunk/test/dynamic_cast_stress.pass.cpp @@ -10,7 +10,7 @@ #include #include -#include "support/timer.hpp" +#include "support/timer.h" template struct C Index: libcxxabi/trunk/test/support/timer.h =================================================================== --- libcxxabi/trunk/test/support/timer.h +++ libcxxabi/trunk/test/support/timer.h @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===//// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===//// + +#ifndef TIMER_HPP +#define TIMER_HPP + +// Define LIBCXXABI_NO_TIMER to disable testing with a timer. +#ifndef LIBCXXABI_NO_TIMER + +#include +#include + +class timer +{ + typedef std::chrono::high_resolution_clock Clock; + typedef Clock::time_point TimePoint; + typedef std::chrono::microseconds MicroSeconds; +public: + timer() : m_start(Clock::now()) {} + + timer(timer const &) = delete; + timer & operator=(timer const &) = delete; + + ~timer() + { + using std::chrono::duration_cast; + TimePoint end = Clock::now(); + MicroSeconds us = duration_cast(end - m_start); + std::cout << us.count() << " microseconds\n"; + } + +private: + TimePoint m_start; +}; + +#else /* LIBCXXABI_NO_TIMER */ + +class timer +{ +public: + timer() {} + timer(timer const &) = delete; + timer & operator=(timer const &) = delete; + ~timer() {} +}; + +#endif /* LIBCXXABI_NO_TIMER */ + +#endif /* TIMER_HPP */ Index: libcxxabi/trunk/test/support/timer.hpp =================================================================== --- libcxxabi/trunk/test/support/timer.hpp +++ libcxxabi/trunk/test/support/timer.hpp @@ -1,54 +0,0 @@ -//===----------------------------------------------------------------------===//// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===//// - -#ifndef TIMER_HPP -#define TIMER_HPP - -// Define LIBCXXABI_NO_TIMER to disable testing with a timer. -#ifndef LIBCXXABI_NO_TIMER - -#include -#include - -class timer -{ - typedef std::chrono::high_resolution_clock Clock; - typedef Clock::time_point TimePoint; - typedef std::chrono::microseconds MicroSeconds; -public: - timer() : m_start(Clock::now()) {} - - timer(timer const &) = delete; - timer & operator=(timer const &) = delete; - - ~timer() - { - using std::chrono::duration_cast; - TimePoint end = Clock::now(); - MicroSeconds us = duration_cast(end - m_start); - std::cout << us.count() << " microseconds\n"; - } - -private: - TimePoint m_start; -}; - -#else /* LIBCXXABI_NO_TIMER */ - -class timer -{ -public: - timer() {} - timer(timer const &) = delete; - timer & operator=(timer const &) = delete; - ~timer() {} -}; - -#endif /* LIBCXXABI_NO_TIMER */ - -#endif /* TIMER_HPP */ Index: libcxxabi/trunk/test/test_demangle.pass.cpp =================================================================== --- libcxxabi/trunk/test/test_demangle.pass.cpp +++ libcxxabi/trunk/test/test_demangle.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "support/timer.hpp" +#include "support/timer.h" #include #include #include Index: libcxxabi/trunk/test/test_exception_storage.pass.cpp =================================================================== --- libcxxabi/trunk/test/test_exception_storage.pass.cpp +++ libcxxabi/trunk/test/test_exception_storage.pass.cpp @@ -12,7 +12,7 @@ #include <__threading_support> #include -#include "../src/cxa_exception.hpp" +#include "../src/cxa_exception.h" typedef __cxxabiv1::__cxa_eh_globals globals_t ;