diff options
author | 2018-09-11 18:18:58 +0000 | |
---|---|---|
committer | 2018-09-11 18:18:58 +0000 | |
commit | 820e1f31efc1d6ed04795ba2e79f3044e1907492 (patch) | |
tree | 815cebb3734784074b661935c33f00bd5eb4d862 /lib/libcxx/src/typeinfo.cpp | |
parent | Nuke unused LIST() ieee80211com_head. (diff) | |
download | wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.tar.xz wireguard-openbsd-820e1f31efc1d6ed04795ba2e79f3044e1907492.zip |
import of libc++ 6.0.0
Diffstat (limited to 'lib/libcxx/src/typeinfo.cpp')
-rw-r--r-- | lib/libcxx/src/typeinfo.cpp | 79 |
1 files changed, 34 insertions, 45 deletions
diff --git a/lib/libcxx/src/typeinfo.cpp b/lib/libcxx/src/typeinfo.cpp index 5c0a609b5e5..0cb193b77d9 100644 --- a/lib/libcxx/src/typeinfo.cpp +++ b/lib/libcxx/src/typeinfo.cpp @@ -6,63 +6,52 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -#include <stdlib.h> - -#if defined(__APPLE__) || defined(LIBCXXRT) || \ - defined(LIBCXX_BUILDING_LIBCXXABI) -#include <cxxabi.h> -#endif #include "typeinfo" -#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) +#if defined(_LIBCPP_ABI_MICROSOFT) +#include <string.h> -std::bad_cast::bad_cast() _NOEXCEPT -{ +int std::type_info::__compare(const type_info &__rhs) const _NOEXCEPT { + if (&__data == &__rhs.__data) + return 0; + return strcmp(&__data.__decorated_name[1], &__rhs.__data.__decorated_name[1]); } -std::bad_typeid::bad_typeid() _NOEXCEPT -{ +const char *std::type_info::name() const _NOEXCEPT { + // TODO(compnerd) cache demangled &__data.__decorated_name[1] + return &__data.__decorated_name[1]; } -#ifndef __GLIBCXX__ +size_t std::type_info::hash_code() const _NOEXCEPT { +#if defined(_WIN64) + constexpr size_t fnv_offset_basis = 14695981039346656037ull; + constexpr size_t fnv_prime = 10995116282110ull; +#else + constexpr size_t fnv_offset_basis = 2166136261ull; + constexpr size_t fnv_prime = 16777619ull; +#endif -std::bad_cast::~bad_cast() _NOEXCEPT -{ -} + size_t value = fnv_offset_basis; + for (const char* c = &__data.__decorated_name[1]; *c; ++c) { + value ^= static_cast<size_t>(static_cast<unsigned char>(*c)); + value *= fnv_prime; + } -const char* -std::bad_cast::what() const _NOEXCEPT -{ - return "std::bad_cast"; -} +#if defined(_WIN64) + value ^= value >> 32; +#endif -std::bad_typeid::~bad_typeid() _NOEXCEPT -{ + return value; } - -const char* -std::bad_typeid::what() const _NOEXCEPT +#endif // _LIBCPP_ABI_MICROSOFT + +// FIXME: Remove __APPLE__ default here once buildit is gone. +// FIXME: Remove the _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY configuration. +#if (!defined(LIBCXX_BUILDING_LIBCXXABI) && !defined(LIBCXXRT) && \ + !defined(__GLIBCXX__) && !defined(__APPLE__)) || \ + defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) +std::type_info::~type_info() { - return "std::bad_typeid"; } - -#ifdef __APPLE__ - // On Darwin, the cxa_bad_* functions cannot be in the lower level library - // because bad_cast and bad_typeid are defined in his higher level library - void __cxxabiv1::__cxa_bad_typeid() - { -#ifndef _LIBCPP_NO_EXCEPTIONS - throw std::bad_typeid(); #endif - } - void __cxxabiv1::__cxa_bad_cast() - { -#ifndef _LIBCPP_NO_EXCEPTIONS - throw std::bad_cast(); -#endif - } -#endif - -#endif // !__GLIBCXX__ -#endif // !LIBCXXRT && !_LIBCPPABI_VERSION |