From owner-svn-src-all@freebsd.org Thu May 5 22:40:09 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 17001B2E2C7; Thu, 5 May 2016 22:40:09 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E3EE81C80; Thu, 5 May 2016 22:40:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u45Me8h0096872; Thu, 5 May 2016 22:40:08 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u45Me8OK096870; Thu, 5 May 2016 22:40:08 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201605052240.u45Me8OK096870@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Thu, 5 May 2016 22:40:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299144 - head/contrib/libcxxrt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2016 22:40:09 -0000 Author: dim Date: Thu May 5 22:40:07 2016 New Revision: 299144 URL: https://svnweb.freebsd.org/changeset/base/299144 Log: Import libcxxrt master 516a65c109eb0a01e5e95fbef455eb3215135cef. Interesting fixes: 3adaa2e Fix _Unwind_Exception cleanup functions 286776c Check exception cleanup function ptr before calling edda626 Correct exception specifications on new and delete operators Modified: head/contrib/libcxxrt/exception.cc head/contrib/libcxxrt/memory.cc Directory Properties: head/contrib/libcxxrt/ (props changed) Modified: head/contrib/libcxxrt/exception.cc ============================================================================== --- head/contrib/libcxxrt/exception.cc Thu May 5 22:30:00 2016 (r299143) +++ head/contrib/libcxxrt/exception.cc Thu May 5 22:40:07 2016 (r299144) @@ -304,13 +304,17 @@ static pthread_key_t eh_key; static void exception_cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { - __cxa_free_exception(static_cast(ex)); + // Exception layout: + // [__cxa_exception [_Unwind_Exception]] [exception object] + // + // __cxa_free_exception expects a pointer to the exception object + __cxa_free_exception(static_cast(ex + 1)); } static void dependent_exception_cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { - __cxa_free_dependent_exception(static_cast(ex)); + __cxa_free_dependent_exception(static_cast(ex + 1)); } /** @@ -340,7 +344,8 @@ static void thread_cleanup(void* thread_ if (info->foreign_exception_state != __cxa_thread_info::none) { _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions); - e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); + if (e->exception_cleanup) + e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); } else { @@ -1282,12 +1287,13 @@ extern "C" void __cxa_end_catch() if (ti->foreign_exception_state != __cxa_thread_info::none) { - globals->caughtExceptions = 0; if (ti->foreign_exception_state != __cxa_thread_info::rethrown) { _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions); - e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); + if (e->exception_cleanup) + e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); } + globals->caughtExceptions = 0; ti->foreign_exception_state = __cxa_thread_info::none; return; } Modified: head/contrib/libcxxrt/memory.cc ============================================================================== --- head/contrib/libcxxrt/memory.cc Thu May 5 22:30:00 2016 (r299143) +++ head/contrib/libcxxrt/memory.cc Thu May 5 22:40:07 2016 (r299144) @@ -71,8 +71,17 @@ namespace std } +#if __cplusplus < 201103L +#define NOEXCEPT throw() +#define BADALLOC throw(std::bad_alloc) +#else +#define NOEXCEPT noexcept +#define BADALLOC +#endif + + __attribute__((weak)) -void* operator new(size_t size) +void* operator new(size_t size) BADALLOC { if (0 == size) { @@ -97,7 +106,7 @@ void* operator new(size_t size) } __attribute__((weak)) -void* operator new(size_t size, const std::nothrow_t &) throw() +void* operator new(size_t size, const std::nothrow_t &) NOEXCEPT { try { return :: operator new(size); @@ -110,27 +119,21 @@ void* operator new(size_t size, const st __attribute__((weak)) -void operator delete(void * ptr) -#if __cplusplus < 201000L -throw() -#endif +void operator delete(void * ptr) NOEXCEPT { free(ptr); } __attribute__((weak)) -void * operator new[](size_t size) -#if __cplusplus < 201000L -throw(std::bad_alloc) -#endif +void * operator new[](size_t size) BADALLOC { return ::operator new(size); } __attribute__((weak)) -void * operator new[](size_t size, const std::nothrow_t &) throw() +void * operator new[](size_t size, const std::nothrow_t &) NOEXCEPT { try { return ::operator new[](size); @@ -143,10 +146,7 @@ void * operator new[](size_t size, const __attribute__((weak)) -void operator delete[](void * ptr) -#if __cplusplus < 201000L -throw() -#endif +void operator delete[](void * ptr) NOEXCEPT { ::operator delete(ptr); }