diff options
author | Robert Nagy <robert@cvs.openbsd.org> | 2018-09-11 18:12:07 +0000 |
---|---|---|
committer | Robert Nagy <robert@cvs.openbsd.org> | 2018-09-11 18:12:07 +0000 |
commit | fcc7823d118c7714b983b20aeb010f1590a98eb7 (patch) | |
tree | b120faa5e211330a71b654b552da60c6c56df77d /lib | |
parent | 0ad7e27fc619908386a28d66d104e7d285e13b2a (diff) |
merge libc++abi 6.0.0 and bump lib minor; ok patrick@, kettenis@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcxxabi/Makefile | 52 | ||||
-rw-r--r-- | lib/libcxxabi/shlib_version | 2 | ||||
-rw-r--r-- | lib/libcxxabi/src/config.h | 31 | ||||
-rw-r--r-- | lib/libcxxabi/src/cxa_new_delete.cpp | 274 | ||||
-rw-r--r-- | lib/libcxxabi/src/exception.cpp | 41 | ||||
-rw-r--r-- | lib/libcxxabi/src/fallback_malloc.ipp | 188 | ||||
-rw-r--r-- | lib/libcxxabi/src/stdexcept.cpp | 48 | ||||
-rw-r--r-- | lib/libcxxabi/src/typeinfo.cpp | 53 |
8 files changed, 28 insertions, 661 deletions
diff --git a/lib/libcxxabi/Makefile b/lib/libcxxabi/Makefile index 6203cc34b91..d54dc99eb82 100644 --- a/lib/libcxxabi/Makefile +++ b/lib/libcxxabi/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.8 2017/04/17 15:53:21 kettenis Exp $ +# $OpenBSD: Makefile,v 1.9 2018/09/11 18:12:06 robert Exp $ .include <bsd.own.mk> @@ -19,30 +19,32 @@ CXXINCLUDEDIR= /usr/include/c++/v1 LIB= c++abi -SRCS+= abort_message.cpp\ - cxa_aux_runtime.cpp\ - cxa_default_handlers.cpp\ - cxa_demangle.cpp\ - cxa_exception.cpp\ - cxa_exception_storage.cpp\ - cxa_guard.cpp\ - cxa_handlers.cpp\ - cxa_new_delete.cpp\ - cxa_personality.cpp\ - cxa_thread_atexit.cpp\ - cxa_unexpected.cpp\ - cxa_vector.cpp\ - cxa_virtual.cpp\ - exception.cpp\ - private_typeinfo.cpp\ - stdexcept.cpp\ - typeinfo.cpp\ - Unwind-EHABI.cpp\ - Unwind-sjlj.c\ - UnwindLevel1-gcc-ext.c\ - UnwindLevel1.c\ - UnwindRegistersRestore.S\ - UnwindRegistersSave.S\ + +SRCS+= abort_message.cpp \ + cxa_aux_runtime.cpp \ + cxa_default_handlers.cpp \ + cxa_demangle.cpp \ + cxa_exception.cpp \ + cxa_exception_storage.cpp \ + cxa_guard.cpp \ + cxa_handlers.cpp \ + cxa_personality.cpp \ + cxa_thread_atexit.cpp \ + cxa_unexpected.cpp \ + cxa_vector.cpp \ + cxa_virtual.cpp \ + fallback_malloc.cpp \ + private_typeinfo.cpp \ + stdlib_exception.cpp \ + stdlib_new_delete.cpp \ + stdlib_stdexcept.cpp \ + stdlib_typeinfo.cpp \ + Unwind-EHABI.cpp \ + Unwind-sjlj.c \ + UnwindLevel1-gcc-ext.c \ + UnwindLevel1.c \ + UnwindRegistersRestore.S \ + UnwindRegistersSave.S \ libunwind.cpp CPPFLAGS+= -I${SHDRDIR} -I${HDRDIR} -I${UHDRDIR} diff --git a/lib/libcxxabi/shlib_version b/lib/libcxxabi/shlib_version index 97c9f92d6b8..3d7c908e43d 100644 --- a/lib/libcxxabi/shlib_version +++ b/lib/libcxxabi/shlib_version @@ -1,2 +1,2 @@ major=0 -minor=0 +minor=1 diff --git a/lib/libcxxabi/src/config.h b/lib/libcxxabi/src/config.h deleted file mode 100644 index ac6d297d113..00000000000 --- a/lib/libcxxabi/src/config.h +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------- config.h -------------------------------===// -// -// 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. -// -// -// Defines macros used within the libc++abi project. -// -//===----------------------------------------------------------------------===// - - -#ifndef LIBCXXABI_CONFIG_H -#define LIBCXXABI_CONFIG_H - -#include <unistd.h> - -// Set this in the CXXFLAGS when you need it -#if !defined(LIBCXXABI_HAS_NO_THREADS) -# define LIBCXXABI_HAS_NO_THREADS 0 -#endif - -// Set this in the CXXFLAGS when you need it, because otherwise we'd have to -// #if !defined(__linux__) && !defined(__APPLE__) && ... -// and so-on for *every* platform. -#ifndef LIBCXXABI_BAREMETAL -# define LIBCXXABI_BAREMETAL 0 -#endif - -#endif // LIBCXXABI_CONFIG_H diff --git a/lib/libcxxabi/src/cxa_new_delete.cpp b/lib/libcxxabi/src/cxa_new_delete.cpp deleted file mode 100644 index 7a2c864c311..00000000000 --- a/lib/libcxxabi/src/cxa_new_delete.cpp +++ /dev/null @@ -1,274 +0,0 @@ -//===------------------------ cxa_new_delete.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 new and delete operators. -//===----------------------------------------------------------------------===// - -#define _LIBCPP_BUILDING_NEW - -#include <new> -#include <cstdlib> - -/* -[new.delete.single] - -* Executes a loop: Within the loop, the function first attempts to allocate - the requested storage. Whether the attempt involves a call to the Standard C - library function malloc is unspecified. - -* Returns a pointer to the allocated storage if the attempt is successful. - Otherwise, if the current new_handler (18.6.2.5) is a null pointer value, - throws bad_alloc. - -* Otherwise, the function calls the current new_handler function (18.6.2.3). - If the called function returns, the loop repeats. - -* The loop terminates when an attempt to allocate the requested storage is - successful or when a called new_handler function does not return. -*/ -__attribute__((__weak__, __visibility__("default"))) -void * -operator new(std::size_t size) -#if !__has_feature(cxx_noexcept) - throw(std::bad_alloc) -#endif -{ - if (size == 0) - size = 1; - void* p; - while ((p = std::malloc(size)) == 0) - { - std::new_handler nh = std::get_new_handler(); - if (nh) - nh(); - else -#ifndef _LIBCXXABI_NO_EXCEPTIONS - throw std::bad_alloc(); -#else - break; -#endif - } - return p; -} - -/* -Note: The relationships among these operators is both carefully considered -and standard in C++11. Please do not change them without fully understanding -the consequences of doing so. Reference: -http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2158.html -*/ -/* -[new.delete.single] - -Calls operator new(size). If the call returns normally, returns the result of -that call. Otherwise, returns a null pointer. -*/ -__attribute__((__weak__, __visibility__("default"))) -void* -operator new(size_t size, const std::nothrow_t&) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif -{ - void* p = 0; -#ifndef _LIBCXXABI_NO_EXCEPTIONS - try - { -#endif - p = ::operator new(size); -#ifndef _LIBCXXABI_NO_EXCEPTIONS - } - catch (...) - { - } -#endif - return p; -} - -/* -[new.delete.array] - -Returns operator new(size). -*/ -__attribute__((__weak__, __visibility__("default"))) -void* -operator new[](size_t size) -#if !__has_feature(cxx_noexcept) - throw(std::bad_alloc) -#endif -{ - return ::operator new(size); -} - -/* -[new.delete.array] - -Calls operator new[](size). If the call returns normally, returns the result -of that call. Otherwise, returns a null pointer. -*/ -__attribute__((__weak__, __visibility__("default"))) -void* -operator new[](size_t size, const std::nothrow_t&) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif -{ - void* p = 0; -#ifndef _LIBCXXABI_NO_EXCEPTIONS - try - { -#endif - p = ::operator new[](size); -#ifndef _LIBCXXABI_NO_EXCEPTIONS - } - catch (...) - { - } -#endif - return p; -} - -/* -[new.delete.single] - -If ptr is null, does nothing. Otherwise, reclaims the storage allocated by the -earlier call to operator new. -*/ -__attribute__((__weak__, __visibility__("default"))) -void -operator delete(void* ptr) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif -{ - if (ptr) - std::free(ptr); -} - -/* -[new.delete.single] - -calls operator delete(ptr) -*/ -__attribute__((__weak__, __visibility__("default"))) -void -operator delete(void* ptr, const std::nothrow_t&) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif -{ - ::operator delete(ptr); -} - -/* -[new.delete.array] - -Calls operator delete(ptr) -*/ -__attribute__((__weak__, __visibility__("default"))) -void -operator delete[] (void* ptr) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif -{ - ::operator delete(ptr); -} - -/* -[new.delete.array] - -calls operator delete[](ptr) -*/ -__attribute__((__weak__, __visibility__("default"))) -void -operator delete[] (void* ptr, const std::nothrow_t&) -#if __has_feature(cxx_noexcept) - noexcept -#else - throw() -#endif -{ - ::operator delete[](ptr); -} - -namespace std -{ - -// bad_alloc - -bad_alloc::bad_alloc() _NOEXCEPT -{ -} - -bad_alloc::~bad_alloc() _NOEXCEPT -{ -} - -const char* -bad_alloc::what() const _NOEXCEPT -{ - return "std::bad_alloc"; -} - -// bad_array_new_length - -bad_array_new_length::bad_array_new_length() _NOEXCEPT -{ -} - -bad_array_new_length::~bad_array_new_length() _NOEXCEPT -{ -} - -const char* -bad_array_new_length::what() const _NOEXCEPT -{ - return "bad_array_new_length"; -} - -// bad_array_length - -#ifndef _LIBCPP_BAD_ARRAY_LENGTH_DEFINED - -class _LIBCPP_EXCEPTION_ABI bad_array_length - : public bad_alloc -{ -public: - bad_array_length() _NOEXCEPT; - virtual ~bad_array_length() _NOEXCEPT; - virtual const char* what() const _NOEXCEPT; -}; - -#endif // _LIBCPP_BAD_ARRAY_LENGTH_DEFINED - -bad_array_length::bad_array_length() _NOEXCEPT -{ -} - -bad_array_length::~bad_array_length() _NOEXCEPT -{ -} - -const char* -bad_array_length::what() const _NOEXCEPT -{ - return "bad_array_length"; -} - -} // std diff --git a/lib/libcxxabi/src/exception.cpp b/lib/libcxxabi/src/exception.cpp deleted file mode 100644 index c47a9b76266..00000000000 --- a/lib/libcxxabi/src/exception.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===---------------------------- exception.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 <exception> - -#pragma GCC visibility push(default) - -namespace std -{ - -// exception - -exception::~exception() _NOEXCEPT -{ -} - -const char* exception::what() const _NOEXCEPT -{ - return "std::exception"; -} - -// bad_exception - -bad_exception::~bad_exception() _NOEXCEPT -{ -} - -const char* bad_exception::what() const _NOEXCEPT -{ - return "std::bad_exception"; -} - -} // std - -#pragma GCC visibility pop diff --git a/lib/libcxxabi/src/fallback_malloc.ipp b/lib/libcxxabi/src/fallback_malloc.ipp deleted file mode 100644 index 71b65bed888..00000000000 --- a/lib/libcxxabi/src/fallback_malloc.ipp +++ /dev/null @@ -1,188 +0,0 @@ -//===------------------------ fallback_malloc.ipp -------------------------===// -// -// 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 "Exception Handling APIs" -// http://mentorembedded.github.io/cxx-abi/abi-eh.html -// -//===----------------------------------------------------------------------===// - -#include "config.h" - -// A small, simple heap manager based (loosely) on -// the startup heap manager from FreeBSD, optimized for space. -// -// Manages a fixed-size memory pool, supports malloc and free only. -// No support for realloc. -// -// Allocates chunks in multiples of four bytes, with a four byte header -// for each chunk. The overhead of each chunk is kept low by keeping pointers -// as two byte offsets within the heap, rather than (4 or 8 byte) pointers. - -namespace { - -// When POSIX threads are not available, make the mutex operations a nop -#if LIBCXXABI_HAS_NO_THREADS -static void * heap_mutex = 0; -#else -static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif - -class mutexor { -public: -#if LIBCXXABI_HAS_NO_THREADS - mutexor ( void * ) {} - ~mutexor () {} -#else - mutexor ( pthread_mutex_t *m ) : mtx_(m) { pthread_mutex_lock ( mtx_ ); } - ~mutexor () { pthread_mutex_unlock ( mtx_ ); } -#endif -private: - mutexor ( const mutexor &rhs ); - mutexor & operator = ( const mutexor &rhs ); -#if !LIBCXXABI_HAS_NO_THREADS - pthread_mutex_t *mtx_; -#endif - }; - - -#define HEAP_SIZE 512 -char heap [ HEAP_SIZE ]; - -typedef unsigned short heap_offset; -typedef unsigned short heap_size; - -struct heap_node { - heap_offset next_node; // offset into heap - heap_size len; // size in units of "sizeof(heap_node)" -}; - -static const heap_node *list_end = (heap_node *) ( &heap [ HEAP_SIZE ] ); // one past the end of the heap -static heap_node *freelist = NULL; - -heap_node *node_from_offset ( const heap_offset offset ) - { return (heap_node *) ( heap + ( offset * sizeof (heap_node))); } - -heap_offset offset_from_node ( const heap_node *ptr ) - { return static_cast<heap_offset>(static_cast<size_t>(reinterpret_cast<const char *>(ptr) - heap) / sizeof (heap_node)); } - -void init_heap () { - freelist = (heap_node *) heap; - freelist->next_node = offset_from_node ( list_end ); - freelist->len = HEAP_SIZE / sizeof (heap_node); - } - -// How big a chunk we allocate -size_t alloc_size (size_t len) - { return (len + sizeof(heap_node) - 1) / sizeof(heap_node) + 1; } - -bool is_fallback_ptr ( void *ptr ) - { return ptr >= heap && ptr < ( heap + HEAP_SIZE ); } - -void *fallback_malloc(size_t len) { - heap_node *p, *prev; - const size_t nelems = alloc_size ( len ); - mutexor mtx ( &heap_mutex ); - - if ( NULL == freelist ) - init_heap (); - -// Walk the free list, looking for a "big enough" chunk - for (p = freelist, prev = 0; - p && p != list_end; prev = p, p = node_from_offset ( p->next_node)) { - - if (p->len > nelems) { // chunk is larger, shorten, and return the tail - heap_node *q; - - p->len = static_cast<heap_size>(p->len - nelems); - q = p + p->len; - q->next_node = 0; - q->len = static_cast<heap_size>(nelems); - return (void *) (q + 1); - } - - if (p->len == nelems) { // exact size match - if (prev == 0) - freelist = node_from_offset(p->next_node); - else - prev->next_node = p->next_node; - p->next_node = 0; - return (void *) (p + 1); - } - } - return NULL; // couldn't find a spot big enough -} - -// Return the start of the next block -heap_node *after ( struct heap_node *p ) { return p + p->len; } - -void fallback_free (void *ptr) { - struct heap_node *cp = ((struct heap_node *) ptr) - 1; // retrieve the chunk - struct heap_node *p, *prev; - - mutexor mtx ( &heap_mutex ); - -#ifdef DEBUG_FALLBACK_MALLOC - std::cout << "Freeing item at " << offset_from_node ( cp ) << " of size " << cp->len << std::endl; -#endif - - for (p = freelist, prev = 0; - p && p != list_end; prev = p, p = node_from_offset (p->next_node)) { -#ifdef DEBUG_FALLBACK_MALLOC - std::cout << " p, cp, after (p), after(cp) " - << offset_from_node ( p ) << ' ' - << offset_from_node ( cp ) << ' ' - << offset_from_node ( after ( p )) << ' ' - << offset_from_node ( after ( cp )) << std::endl; -#endif - if ( after ( p ) == cp ) { -#ifdef DEBUG_FALLBACK_MALLOC - std::cout << " Appending onto chunk at " << offset_from_node ( p ) << std::endl; -#endif - p->len = static_cast<heap_size>(p->len + cp->len); // make the free heap_node larger - return; - } - else if ( after ( cp ) == p ) { // there's a free heap_node right after -#ifdef DEBUG_FALLBACK_MALLOC - std::cout << " Appending free chunk at " << offset_from_node ( p ) << std::endl; -#endif - cp->len = static_cast<heap_size>(cp->len + p->len); - if ( prev == 0 ) { - freelist = cp; - cp->next_node = p->next_node; - } - else - prev->next_node = offset_from_node(cp); - return; - } - } -// Nothing to merge with, add it to the start of the free list -#ifdef DEBUG_FALLBACK_MALLOC - std::cout << " Making new free list entry " << offset_from_node ( cp ) << std::endl; -#endif - cp->next_node = offset_from_node ( freelist ); - freelist = cp; -} - -#ifdef INSTRUMENT_FALLBACK_MALLOC -size_t print_free_list () { - struct heap_node *p, *prev; - heap_size total_free = 0; - if ( NULL == freelist ) - init_heap (); - - for (p = freelist, prev = 0; - p && p != list_end; prev = p, p = node_from_offset (p->next_node)) { - std::cout << ( prev == 0 ? "" : " ") << "Offset: " << offset_from_node ( p ) - << "\tsize: " << p->len << " Next: " << p->next_node << std::endl; - total_free += p->len; - } - std::cout << "Total Free space: " << total_free << std::endl; - return total_free; - } -#endif -} // end unnamed namespace diff --git a/lib/libcxxabi/src/stdexcept.cpp b/lib/libcxxabi/src/stdexcept.cpp deleted file mode 100644 index bd6789ef227..00000000000 --- a/lib/libcxxabi/src/stdexcept.cpp +++ /dev/null @@ -1,48 +0,0 @@ -//===------------------------ stdexcept.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 "__refstring" -#include "stdexcept" -#include "new" -#include <cstdlib> -#include <cstring> -#include <cstdint> -#include <cstddef> - -static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), ""); - -namespace std // purposefully not using versioning namespace -{ - -logic_error::~logic_error() _NOEXCEPT {} - -const char* -logic_error::what() const _NOEXCEPT -{ - return __imp_.c_str(); -} - -runtime_error::~runtime_error() _NOEXCEPT {} - -const char* -runtime_error::what() const _NOEXCEPT -{ - return __imp_.c_str(); -} - -domain_error::~domain_error() _NOEXCEPT {} -invalid_argument::~invalid_argument() _NOEXCEPT {} -length_error::~length_error() _NOEXCEPT {} -out_of_range::~out_of_range() _NOEXCEPT {} - -range_error::~range_error() _NOEXCEPT {} -overflow_error::~overflow_error() _NOEXCEPT {} -underflow_error::~underflow_error() _NOEXCEPT {} - -} // std diff --git a/lib/libcxxabi/src/typeinfo.cpp b/lib/libcxxabi/src/typeinfo.cpp deleted file mode 100644 index 9313be04a39..00000000000 --- a/lib/libcxxabi/src/typeinfo.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//===----------------------------- typeinfo.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 <typeinfo> - -namespace std -{ - -// type_info - -type_info::~type_info() -{ -} - -// bad_cast - -bad_cast::bad_cast() _NOEXCEPT -{ -} - -bad_cast::~bad_cast() _NOEXCEPT -{ -} - -const char* -bad_cast::what() const _NOEXCEPT -{ - return "std::bad_cast"; -} - -// bad_typeid - -bad_typeid::bad_typeid() _NOEXCEPT -{ -} - -bad_typeid::~bad_typeid() _NOEXCEPT -{ -} - -const char* -bad_typeid::what() const _NOEXCEPT -{ - return "std::bad_typeid"; -} - -} // std |