From owner-svn-src-vendor@FreeBSD.ORG Tue Nov 22 17:30:41 2011 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C9341065670; Tue, 22 Nov 2011 17:30:41 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 884D18FC1C; Tue, 22 Nov 2011 17:30:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAMHUfZw002171; Tue, 22 Nov 2011 17:30:41 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAMHUfDc002168; Tue, 22 Nov 2011 17:30:41 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201111221730.pAMHUfDc002168@svn.freebsd.org> From: David Chisnall Date: Tue, 22 Nov 2011 17:30:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227825 - in vendor: libc++ libc++/dist libc++/dist/include libc++/dist/include/ext libc++/dist/include/support libc++/dist/include/support/win32 libc++/dist/src libc++/dist/src/support... X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Nov 2011 17:30:41 -0000 Author: theraven Date: Tue Nov 22 17:30:41 2011 New Revision: 227825 URL: http://svn.freebsd.org/changeset/base/227825 Log: Import libcxxrt / libc++ into a vendor branch. Approved by: dim (mentor) Added: vendor/libc++/ vendor/libc++/dist/ vendor/libc++/dist/include/ vendor/libc++/dist/include/__bit_reference vendor/libc++/dist/include/__config vendor/libc++/dist/include/__debug vendor/libc++/dist/include/__functional_03 vendor/libc++/dist/include/__functional_base vendor/libc++/dist/include/__functional_base_03 vendor/libc++/dist/include/__hash_table vendor/libc++/dist/include/__locale vendor/libc++/dist/include/__mutex_base vendor/libc++/dist/include/__split_buffer vendor/libc++/dist/include/__sso_allocator vendor/libc++/dist/include/__std_stream vendor/libc++/dist/include/__tree vendor/libc++/dist/include/__tuple vendor/libc++/dist/include/__tuple_03 vendor/libc++/dist/include/algorithm vendor/libc++/dist/include/array vendor/libc++/dist/include/atomic vendor/libc++/dist/include/bitset vendor/libc++/dist/include/cassert vendor/libc++/dist/include/ccomplex vendor/libc++/dist/include/cctype vendor/libc++/dist/include/cerrno vendor/libc++/dist/include/cfenv vendor/libc++/dist/include/cfloat vendor/libc++/dist/include/chrono vendor/libc++/dist/include/cinttypes vendor/libc++/dist/include/ciso646 vendor/libc++/dist/include/climits vendor/libc++/dist/include/clocale vendor/libc++/dist/include/cmath vendor/libc++/dist/include/codecvt vendor/libc++/dist/include/complex vendor/libc++/dist/include/complex.h (contents, props changed) vendor/libc++/dist/include/condition_variable vendor/libc++/dist/include/csetjmp vendor/libc++/dist/include/csignal vendor/libc++/dist/include/cstdarg vendor/libc++/dist/include/cstdbool vendor/libc++/dist/include/cstddef vendor/libc++/dist/include/cstdint vendor/libc++/dist/include/cstdio vendor/libc++/dist/include/cstdlib vendor/libc++/dist/include/cstring vendor/libc++/dist/include/ctgmath vendor/libc++/dist/include/ctime vendor/libc++/dist/include/cwchar vendor/libc++/dist/include/cwctype vendor/libc++/dist/include/deque vendor/libc++/dist/include/exception vendor/libc++/dist/include/ext/ vendor/libc++/dist/include/ext/__hash vendor/libc++/dist/include/ext/hash_map vendor/libc++/dist/include/ext/hash_set vendor/libc++/dist/include/forward_list vendor/libc++/dist/include/fstream vendor/libc++/dist/include/functional vendor/libc++/dist/include/future vendor/libc++/dist/include/initializer_list vendor/libc++/dist/include/iomanip vendor/libc++/dist/include/ios vendor/libc++/dist/include/iosfwd vendor/libc++/dist/include/iostream vendor/libc++/dist/include/istream vendor/libc++/dist/include/iterator vendor/libc++/dist/include/limits vendor/libc++/dist/include/list vendor/libc++/dist/include/locale vendor/libc++/dist/include/map vendor/libc++/dist/include/memory vendor/libc++/dist/include/mutex vendor/libc++/dist/include/new vendor/libc++/dist/include/numeric vendor/libc++/dist/include/ostream vendor/libc++/dist/include/queue vendor/libc++/dist/include/random vendor/libc++/dist/include/ratio vendor/libc++/dist/include/regex vendor/libc++/dist/include/scoped_allocator vendor/libc++/dist/include/set vendor/libc++/dist/include/sstream vendor/libc++/dist/include/stack vendor/libc++/dist/include/stdexcept vendor/libc++/dist/include/streambuf vendor/libc++/dist/include/string vendor/libc++/dist/include/strstream vendor/libc++/dist/include/support/ vendor/libc++/dist/include/support/win32/ vendor/libc++/dist/include/support/win32/limits_win32.h (contents, props changed) vendor/libc++/dist/include/support/win32/locale_win32.h (contents, props changed) vendor/libc++/dist/include/support/win32/math_win32.h (contents, props changed) vendor/libc++/dist/include/support/win32/support.h (contents, props changed) vendor/libc++/dist/include/system_error vendor/libc++/dist/include/tgmath.h (contents, props changed) vendor/libc++/dist/include/thread vendor/libc++/dist/include/tuple vendor/libc++/dist/include/type_traits vendor/libc++/dist/include/typeindex vendor/libc++/dist/include/typeinfo vendor/libc++/dist/include/unordered_map vendor/libc++/dist/include/unordered_set vendor/libc++/dist/include/utility vendor/libc++/dist/include/valarray vendor/libc++/dist/include/vector vendor/libc++/dist/src/ vendor/libc++/dist/src/algorithm.cpp (contents, props changed) vendor/libc++/dist/src/bind.cpp (contents, props changed) vendor/libc++/dist/src/chrono.cpp (contents, props changed) vendor/libc++/dist/src/condition_variable.cpp (contents, props changed) vendor/libc++/dist/src/debug.cpp (contents, props changed) vendor/libc++/dist/src/exception.cpp (contents, props changed) vendor/libc++/dist/src/future.cpp (contents, props changed) vendor/libc++/dist/src/hash.cpp (contents, props changed) vendor/libc++/dist/src/ios.cpp (contents, props changed) vendor/libc++/dist/src/iostream.cpp (contents, props changed) vendor/libc++/dist/src/locale.cpp (contents, props changed) vendor/libc++/dist/src/memory.cpp (contents, props changed) vendor/libc++/dist/src/mutex.cpp (contents, props changed) vendor/libc++/dist/src/new.cpp (contents, props changed) vendor/libc++/dist/src/random.cpp (contents, props changed) vendor/libc++/dist/src/regex.cpp (contents, props changed) vendor/libc++/dist/src/stdexcept.cpp (contents, props changed) vendor/libc++/dist/src/string.cpp (contents, props changed) vendor/libc++/dist/src/strstream.cpp (contents, props changed) vendor/libc++/dist/src/support/ vendor/libc++/dist/src/support/win32/ vendor/libc++/dist/src/support/win32/locale_win32.cpp (contents, props changed) vendor/libc++/dist/src/support/win32/support.cpp (contents, props changed) vendor/libc++/dist/src/system_error.cpp (contents, props changed) vendor/libc++/dist/src/thread.cpp (contents, props changed) vendor/libc++/dist/src/typeinfo.cpp (contents, props changed) vendor/libc++/dist/src/utility.cpp (contents, props changed) vendor/libc++/dist/src/valarray.cpp (contents, props changed) vendor/libcxxrt/ vendor/libcxxrt/dist/ vendor/libcxxrt/dist/CMakeLists.txt (contents, props changed) vendor/libcxxrt/dist/abi_namespace.h (contents, props changed) vendor/libcxxrt/dist/auxhelper.cc (contents, props changed) vendor/libcxxrt/dist/cxxabi.h (contents, props changed) vendor/libcxxrt/dist/doxygen_config vendor/libcxxrt/dist/dwarf_eh.h (contents, props changed) vendor/libcxxrt/dist/dynamic_cast.cc (contents, props changed) vendor/libcxxrt/dist/exception.cc (contents, props changed) vendor/libcxxrt/dist/guard.cc (contents, props changed) vendor/libcxxrt/dist/libelftc_dem_gnu3.c (contents, props changed) vendor/libcxxrt/dist/memory.cc (contents, props changed) vendor/libcxxrt/dist/stdexcept.cc (contents, props changed) vendor/libcxxrt/dist/stdexcept.h (contents, props changed) vendor/libcxxrt/dist/terminate.cc (contents, props changed) vendor/libcxxrt/dist/typeinfo vendor/libcxxrt/dist/typeinfo.cc (contents, props changed) vendor/libcxxrt/dist/typeinfo.h (contents, props changed) Added: vendor/libc++/dist/include/__bit_reference ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libc++/dist/include/__bit_reference Tue Nov 22 17:30:41 2011 (r227825) @@ -0,0 +1,1247 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___BIT_REFERENCE +#define _LIBCPP___BIT_REFERENCE + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template class __bit_iterator; +template class __bit_const_reference; + +template +struct __has_storage_type +{ + static const bool value = false; +}; + +template ::value> +class __bit_reference +{ + typedef typename _C::__storage_type __storage_type; + typedef typename _C::__storage_pointer __storage_pointer; + + __storage_pointer __seg_; + __storage_type __mask_; + +#if defined(__clang__) + friend typename _C::__self; +#else + friend class _C::__self; +#endif + friend class __bit_const_reference<_C>; + friend class __bit_iterator<_C, false>; +public: + _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT + {return static_cast(*__seg_ & __mask_);} + _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT + {return !static_cast(*this);} + + _LIBCPP_INLINE_VISIBILITY + __bit_reference& operator=(bool __x) _NOEXCEPT + { + if (__x) + *__seg_ |= __mask_; + else + *__seg_ &= ~__mask_; + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT + {return operator=(static_cast(__x));} + + _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;} + _LIBCPP_INLINE_VISIBILITY __bit_iterator<_C, false> operator&() const _NOEXCEPT + {return __bit_iterator<_C, false>(__seg_, static_cast(__ctz(__mask_)));} +private: + _LIBCPP_INLINE_VISIBILITY + __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT + : __seg_(__s), __mask_(__m) {} +}; + +template +class __bit_reference<_C, false> +{ +}; + +template +_LIBCPP_INLINE_VISIBILITY inline +void +swap(__bit_reference<_C> __x, __bit_reference<_D> __y) _NOEXCEPT +{ + bool __t = __x; + __x = __y; + __y = __t; +} + +template +_LIBCPP_INLINE_VISIBILITY inline +void +swap(__bit_reference<_C> __x, bool& __y) _NOEXCEPT +{ + bool __t = __x; + __x = __y; + __y = __t; +} + +template +_LIBCPP_INLINE_VISIBILITY inline +void +swap(bool& __x, __bit_reference<_C> __y) _NOEXCEPT +{ + bool __t = __x; + __x = __y; + __y = __t; +} + +template +class __bit_const_reference +{ + typedef typename _C::__storage_type __storage_type; + typedef typename _C::__const_storage_pointer __storage_pointer; + + __storage_pointer __seg_; + __storage_type __mask_; + +#if defined(__clang__) + friend typename _C::__self; +#else + friend class _C::__self; +#endif + friend class __bit_iterator<_C, true>; +public: + _LIBCPP_INLINE_VISIBILITY + __bit_const_reference(const __bit_reference<_C>& __x) _NOEXCEPT + : __seg_(__x.__seg_), __mask_(__x.__mask_) {} + + _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT + {return static_cast(*__seg_ & __mask_);} + + _LIBCPP_INLINE_VISIBILITY __bit_iterator<_C, true> operator&() const _NOEXCEPT + {return __bit_iterator<_C, true>(__seg_, static_cast(__ctz(__mask_)));} +private: + _LIBCPP_INLINE_VISIBILITY + __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT + : __seg_(__s), __mask_(__m) {} + + __bit_const_reference& operator=(const __bit_const_reference& __x); +}; + +// find + +template +__bit_iterator<_C, false> +__find_bool_true(__bit_iterator<_C, false> __first, typename _C::size_type __n) +{ + typedef __bit_iterator<_C, false> _It; + typedef typename _It::__storage_type __storage_type; + static const unsigned __bits_per_word = _It::__bits_per_word; + // do first partial word + if (__first.__ctz_ != 0) + { + __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); + __storage_type __dn = _VSTD::min(__clz_f, __n); + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __storage_type __b = *__first.__seg_ & __m; + if (__b) + return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); + __n -= __dn; + ++__first.__seg_; + } + // do middle whole words + for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) + if (*__first.__seg_) + return _It(__first.__seg_, static_cast(_VSTD::__ctz(*__first.__seg_))); + // do last partial word + if (__n > 0) + { + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b = *__first.__seg_ & __m; + if (__b) + return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); + } + return _It(__first.__seg_, static_cast(__n)); +} + +template +__bit_iterator<_C, false> +__find_bool_false(__bit_iterator<_C, false> __first, typename _C::size_type __n) +{ + typedef __bit_iterator<_C, false> _It; + typedef typename _It::__storage_type __storage_type; + static const unsigned __bits_per_word = _It::__bits_per_word; + // do first partial word + if (__first.__ctz_ != 0) + { + __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); + __storage_type __dn = _VSTD::min(__clz_f, __n); + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __storage_type __b = ~(*__first.__seg_ & __m); + if (__b) + return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); + __n -= __dn; + ++__first.__seg_; + } + // do middle whole words + for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) + { + __storage_type __b = ~*__first.__seg_; + if (__b) + return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); + } + // do last partial word + if (__n > 0) + { + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b = ~(*__first.__seg_ & __m); + if (__b) + return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); + } + return _It(__first.__seg_, static_cast(__n)); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +__bit_iterator<_C, false> +find(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, const _Tp& __value_) +{ + if (static_cast(__value_)) + return __find_bool_true(__first, static_cast(__last - __first)); + return __find_bool_false(__first, static_cast(__last - __first)); +} + +// count + +template +typename __bit_iterator<_C, false>::difference_type +__count_bool_true(__bit_iterator<_C, false> __first, typename _C::size_type __n) +{ + typedef __bit_iterator<_C, false> _It; + typedef typename _It::__storage_type __storage_type; + typedef typename _It::difference_type difference_type; + static const unsigned __bits_per_word = _It::__bits_per_word; + difference_type __r = 0; + // do first partial word + if (__first.__ctz_ != 0) + { + __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); + __storage_type __dn = _VSTD::min(__clz_f, __n); + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __r = _VSTD::__pop_count(*__first.__seg_ & __m); + __n -= __dn; + ++__first.__seg_; + } + // do middle whole words + for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) + __r += _VSTD::__pop_count(*__first.__seg_); + // do last partial word + if (__n > 0) + { + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + __r += _VSTD::__pop_count(*__first.__seg_ & __m); + } + return __r; +} + +template +typename __bit_iterator<_C, false>::difference_type +__count_bool_false(__bit_iterator<_C, false> __first, typename _C::size_type __n) +{ + typedef __bit_iterator<_C, false> _It; + typedef typename _It::__storage_type __storage_type; + typedef typename _It::difference_type difference_type; + static const unsigned __bits_per_word = _It::__bits_per_word; + difference_type __r = 0; + // do first partial word + if (__first.__ctz_ != 0) + { + __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); + __storage_type __dn = _VSTD::min(__clz_f, __n); + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __r = _VSTD::__pop_count(~(*__first.__seg_ & __m)); + __n -= __dn; + ++__first.__seg_; + } + // do middle whole words + for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) + __r += _VSTD::__pop_count(~*__first.__seg_); + // do last partial word + if (__n > 0) + { + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + __r += _VSTD::__pop_count(~(*__first.__seg_ & __m)); + } + return __r; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __bit_iterator<_C, false>::difference_type +count(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, const _Tp& __value_) +{ + if (static_cast(__value_)) + return __count_bool_true(__first, static_cast(__last - __first)); + return __count_bool_false(__first, static_cast(__last - __first)); +} + +// fill_n + +template +void +__fill_n_false(__bit_iterator<_C, false> __first, typename _C::size_type __n) +{ + typedef __bit_iterator<_C, false> _It; + typedef typename _It::__storage_type __storage_type; + static const unsigned __bits_per_word = _It::__bits_per_word; + // do first partial word + if (__first.__ctz_ != 0) + { + __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); + __storage_type __dn = _VSTD::min(__clz_f, __n); + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + *__first.__seg_ &= ~__m; + __n -= __dn; + ++__first.__seg_; + } + // do middle whole words + __storage_type __nw = __n / __bits_per_word; + _VSTD::memset(__first.__seg_, 0, __nw * sizeof(__storage_type)); + __n -= __nw * __bits_per_word; + // do last partial word + if (__n > 0) + { + __first.__seg_ += __nw; + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + *__first.__seg_ &= ~__m; + } +} + +template +void +__fill_n_true(__bit_iterator<_C, false> __first, typename _C::size_type __n) +{ + typedef __bit_iterator<_C, false> _It; + typedef typename _It::__storage_type __storage_type; + static const unsigned __bits_per_word = _It::__bits_per_word; + // do first partial word + if (__first.__ctz_ != 0) + { + __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); + __storage_type __dn = _VSTD::min(__clz_f, __n); + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + *__first.__seg_ |= __m; + __n -= __dn; + ++__first.__seg_; + } + // do middle whole words + __storage_type __nw = __n / __bits_per_word; + _VSTD::memset(__first.__seg_, -1, __nw * sizeof(__storage_type)); + __n -= __nw * __bits_per_word; + // do last partial word + if (__n > 0) + { + __first.__seg_ += __nw; + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + *__first.__seg_ |= __m; + } +} + +template +_LIBCPP_INLINE_VISIBILITY inline +void +fill_n(__bit_iterator<_C, false> __first, typename _C::size_type __n, bool __value_) +{ + if (__n > 0) + { + if (__value_) + __fill_n_true(__first, __n); + else + __fill_n_false(__first, __n); + } +} + +// fill + +template +inline _LIBCPP_INLINE_VISIBILITY +void +fill(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __last, bool __value_) +{ + _VSTD::fill_n(__first, static_cast(__last - __first), __value_); +} + +// copy + +template +__bit_iterator<_C, false> +__copy_aligned(__bit_iterator<_C, _IsConst> __first, __bit_iterator<_C, _IsConst> __last, + __bit_iterator<_C, false> __result) +{ + typedef __bit_iterator<_C, _IsConst> _In; + typedef typename _In::difference_type difference_type; + typedef typename _In::__storage_type __storage_type; + static const unsigned __bits_per_word = _In::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) + { + // do first word + if (__first.__ctz_ != 0) + { + unsigned __clz = __bits_per_word - __first.__ctz_; + difference_type __dn = _VSTD::min(static_cast(__clz), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); + __storage_type __b = *__first.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b; + __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); + ++__first.__seg_; + // __first.__ctz_ = 0; + } + // __first.__ctz_ == 0; + // do middle words + __storage_type __nw = __n / __bits_per_word; + _VSTD::memmove(__result.__seg_, __first.__seg_, __nw * sizeof(__storage_type)); + __n -= __nw * __bits_per_word; + __result.__seg_ += __nw; + // do last word + if (__n > 0) + { + __first.__seg_ += __nw; + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b = *__first.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b; + __result.__ctz_ = static_cast(__n); + } + } + return __result; +} + +template +__bit_iterator<_C, false> +__copy_unaligned(__bit_iterator<_C, _IsConst> __first, __bit_iterator<_C, _IsConst> __last, + __bit_iterator<_C, false> __result) +{ + typedef __bit_iterator<_C, _IsConst> _In; + typedef typename _In::difference_type difference_type; + typedef typename _In::__storage_type __storage_type; + static const unsigned __bits_per_word = _In::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) + { + // do first word + if (__first.__ctz_ != 0) + { + unsigned __clz_f = __bits_per_word - __first.__ctz_; + difference_type __dn = _VSTD::min(static_cast(__clz_f), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __storage_type __b = *__first.__seg_ & __m; + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); + __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); + *__result.__seg_ &= ~__m; + if (__result.__ctz_ > __first.__ctz_) + *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_); + else + *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_); + __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast((__ddn + __result.__ctz_) % __bits_per_word); + __dn -= __ddn; + if (__dn > 0) + { + __m = ~__storage_type(0) >> (__bits_per_word - __dn); + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn); + __result.__ctz_ = static_cast(__dn); + } + ++__first.__seg_; + // __first.__ctz_ = 0; + } + // __first.__ctz_ == 0; + // do middle words + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __m = ~__storage_type(0) << __result.__ctz_; + for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) + { + __storage_type __b = *__first.__seg_; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b << __result.__ctz_; + ++__result.__seg_; + *__result.__seg_ &= __m; + *__result.__seg_ |= __b >> __clz_r; + } + // do last word + if (__n > 0) + { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b = *__first.__seg_ & __m; + __storage_type __dn = _VSTD::min(__n, static_cast(__clz_r)); + __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b << __result.__ctz_; + __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); + __n -= __dn; + if (__n > 0) + { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b >> __dn; + __result.__ctz_ = static_cast(__n); + } + } + } + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +__bit_iterator<_C, false> +copy(__bit_iterator<_C, _IsConst> __first, __bit_iterator<_C, _IsConst> __last, __bit_iterator<_C, false> __result) +{ + if (__first.__ctz_ == __result.__ctz_) + return __copy_aligned(__first, __last, __result); + return __copy_unaligned(__first, __last, __result); +} + +// copy_backward + +template +__bit_iterator<_C, false> +__copy_backward_aligned(__bit_iterator<_C, _IsConst> __first, __bit_iterator<_C, _IsConst> __last, + __bit_iterator<_C, false> __result) +{ + typedef __bit_iterator<_C, _IsConst> _In; + typedef typename _In::difference_type difference_type; + typedef typename _In::__storage_type __storage_type; + static const unsigned __bits_per_word = _In::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) + { + // do first word + if (__last.__ctz_ != 0) + { + difference_type __dn = _VSTD::min(static_cast(__last.__ctz_), __n); + __n -= __dn; + unsigned __clz = __bits_per_word - __last.__ctz_; + __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz); + __storage_type __b = *__last.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b; + __result.__ctz_ = static_cast(((-__dn & (__bits_per_word - 1)) + + __result.__ctz_) % __bits_per_word); + // __last.__ctz_ = 0 + } + // __last.__ctz_ == 0 || __n == 0 + // __result.__ctz_ == 0 || __n == 0 + // do middle words + __storage_type __nw = __n / __bits_per_word; + __result.__seg_ -= __nw; + __last.__seg_ -= __nw; + _VSTD::memmove(__result.__seg_, __last.__seg_, __nw * sizeof(__storage_type)); + __n -= __nw * __bits_per_word; + // do last word + if (__n > 0) + { + __storage_type __m = ~__storage_type(0) << (__bits_per_word - __n); + __storage_type __b = *--__last.__seg_ & __m; + *--__result.__seg_ &= ~__m; + *__result.__seg_ |= __b; + __result.__ctz_ = static_cast(-__n & (__bits_per_word - 1)); + } + } + return __result; +} + +template +__bit_iterator<_C, false> +__copy_backward_unaligned(__bit_iterator<_C, _IsConst> __first, __bit_iterator<_C, _IsConst> __last, + __bit_iterator<_C, false> __result) +{ + typedef __bit_iterator<_C, _IsConst> _In; + typedef typename _In::difference_type difference_type; + typedef typename _In::__storage_type __storage_type; + static const unsigned __bits_per_word = _In::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) + { + // do first word + if (__last.__ctz_ != 0) + { + difference_type __dn = _VSTD::min(static_cast(__last.__ctz_), __n); + __n -= __dn; + unsigned __clz_l = __bits_per_word - __last.__ctz_; + __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_l); + __storage_type __b = *__last.__seg_ & __m; + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __ddn = _VSTD::min(__dn, static_cast(__result.__ctz_)); + if (__ddn > 0) + { + __m = (~__storage_type(0) << (__result.__ctz_ - __ddn)) & (~__storage_type(0) >> __clz_r); + *__result.__seg_ &= ~__m; + if (__result.__ctz_ > __last.__ctz_) + *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); + else + *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_); + __result.__ctz_ = static_cast(((-__ddn & (__bits_per_word - 1)) + + __result.__ctz_) % __bits_per_word); + __dn -= __ddn; + } + if (__dn > 0) + { + // __result.__ctz_ == 0 + --__result.__seg_; + __result.__ctz_ = static_cast(-__dn & (__bits_per_word - 1)); + __m = ~__storage_type(0) << __result.__ctz_; + *__result.__seg_ &= ~__m; + __last.__ctz_ -= __dn + __ddn; + *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); + } + // __last.__ctz_ = 0 + } + // __last.__ctz_ == 0 || __n == 0 + // __result.__ctz_ != 0 || __n == 0 + // do middle words + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __m = ~__storage_type(0) >> __clz_r; + for (; __n >= __bits_per_word; __n -= __bits_per_word) + { + __storage_type __b = *--__last.__seg_; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b >> __clz_r; + *--__result.__seg_ &= __m; + *__result.__seg_ |= __b << __result.__ctz_; + } + // do last word + if (__n > 0) + { + __m = ~__storage_type(0) << (__bits_per_word - __n); + __storage_type __b = *--__last.__seg_ & __m; + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __dn = _VSTD::min(__n, static_cast(__result.__ctz_)); + __m = (~__storage_type(0) << (__result.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_r); + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_); + __result.__ctz_ = static_cast(((-__dn & (__bits_per_word - 1)) + + __result.__ctz_) % __bits_per_word); + __n -= __dn; + if (__n > 0) + { + // __result.__ctz_ == 0 + --__result.__seg_; + __result.__ctz_ = static_cast(-__n & (__bits_per_word - 1)); + __m = ~__storage_type(0) << __result.__ctz_; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn)); + } + } + } + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +__bit_iterator<_C, false> +copy_backward(__bit_iterator<_C, _IsConst> __first, __bit_iterator<_C, _IsConst> __last, __bit_iterator<_C, false> __result) +{ + if (__last.__ctz_ == __result.__ctz_) + return __copy_backward_aligned(__first, __last, __result); + return __copy_backward_unaligned(__first, __last, __result); +} + +// move + +template +inline _LIBCPP_INLINE_VISIBILITY +__bit_iterator<_C, false> +move(__bit_iterator<_C, _IsConst> __first, __bit_iterator<_C, _IsConst> __last, __bit_iterator<_C, false> __result) +{ + return _VSTD::copy(__first, __last, __result); +} + +// move_backward + +template +inline _LIBCPP_INLINE_VISIBILITY +__bit_iterator<_C, false> +move_backward(__bit_iterator<_C, _IsConst> __first, __bit_iterator<_C, _IsConst> __last, __bit_iterator<_C, false> __result) +{ + return _VSTD::copy(__first, __last, __result); +} + +// swap_ranges + +template +__bit_iterator<__C2, false> +__swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last, + __bit_iterator<__C2, false> __result) +{ + typedef __bit_iterator<__C1, false> _I1; + typedef typename _I1::difference_type difference_type; + typedef typename _I1::__storage_type __storage_type; + static const unsigned __bits_per_word = _I1::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) + { + // do first word + if (__first.__ctz_ != 0) + { + unsigned __clz = __bits_per_word - __first.__ctz_; + difference_type __dn = _VSTD::min(static_cast(__clz), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); + __storage_type __b1 = *__first.__seg_ & __m; + *__first.__seg_ &= ~__m; + __storage_type __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b1; + *__first.__seg_ |= __b2; + __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); + ++__first.__seg_; + // __first.__ctz_ = 0; + } + // __first.__ctz_ == 0; + // do middle words + for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_) + swap(*__first.__seg_, *__result.__seg_); + // do last word + if (__n > 0) + { + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b1 = *__first.__seg_ & __m; + *__first.__seg_ &= ~__m; + __storage_type __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b1; + *__first.__seg_ |= __b2; + __result.__ctz_ = static_cast(__n); + } + } + return __result; +} + +template +__bit_iterator<__C2, false> +__swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last, + __bit_iterator<__C2, false> __result) +{ + typedef __bit_iterator<__C1, false> _I1; + typedef typename _I1::difference_type difference_type; + typedef typename _I1::__storage_type __storage_type; + static const unsigned __bits_per_word = _I1::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) + { + // do first word + if (__first.__ctz_ != 0) + { + unsigned __clz_f = __bits_per_word - __first.__ctz_; + difference_type __dn = _VSTD::min(static_cast(__clz_f), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __storage_type __b1 = *__first.__seg_ & __m; + *__first.__seg_ &= ~__m; + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); + __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); + __storage_type __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + if (__result.__ctz_ > __first.__ctz_) + { + unsigned __s = __result.__ctz_ - __first.__ctz_; + *__result.__seg_ |= __b1 << __s; + *__first.__seg_ |= __b2 >> __s; + } + else + { + unsigned __s = __first.__ctz_ - __result.__ctz_; + *__result.__seg_ |= __b1 >> __s; + *__first.__seg_ |= __b2 << __s; + } + __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast((__ddn + __result.__ctz_) % __bits_per_word); + __dn -= __ddn; + if (__dn > 0) + { + __m = ~__storage_type(0) >> (__bits_per_word - __dn); + __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + unsigned __s = __first.__ctz_ + __ddn; + *__result.__seg_ |= __b1 >> __s; + *__first.__seg_ |= __b2 << __s; + __result.__ctz_ = static_cast(__dn); + } + ++__first.__seg_; + // __first.__ctz_ = 0; + } + // __first.__ctz_ == 0; + // do middle words + __storage_type __m = ~__storage_type(0) << __result.__ctz_; + unsigned __clz_r = __bits_per_word - __result.__ctz_; + for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) + { + __storage_type __b1 = *__first.__seg_; + __storage_type __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b1 << __result.__ctz_; + *__first.__seg_ = __b2 >> __result.__ctz_; + ++__result.__seg_; + __b2 = *__result.__seg_ & ~__m; + *__result.__seg_ &= __m; + *__result.__seg_ |= __b1 >> __clz_r; + *__first.__seg_ |= __b2 << __clz_r; + } + // do last word + if (__n > 0) + { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b1 = *__first.__seg_ & __m; + *__first.__seg_ &= ~__m; + __storage_type __dn = _VSTD::min<__storage_type>(__n, __clz_r); + __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); + __storage_type __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b1 << __result.__ctz_; + *__first.__seg_ |= __b2 >> __result.__ctz_; + __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); + __n -= __dn; + if (__n > 0) + { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b1 >> __dn; + *__first.__seg_ |= __b2 << __dn; + __result.__ctz_ = static_cast(__n); + } + } + } + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +__bit_iterator<__C2, false> +swap_ranges(__bit_iterator<__C1, false> __first1, __bit_iterator<__C1, false> __last1, + __bit_iterator<__C2, false> __first2) +{ + if (__first1.__ctz_ == __first2.__ctz_) + return __swap_ranges_aligned(__first1, __last1, __first2); + return __swap_ranges_unaligned(__first1, __last1, __first2); +} + +// rotate + +template +struct __bit_array +{ + typedef typename _C::difference_type difference_type; + typedef typename _C::__storage_type __storage_type; + typedef typename _C::iterator iterator; + static const unsigned __bits_per_word = _C::__bits_per_word; + static const unsigned _N = 4; + + difference_type __size_; + __storage_type __word_[_N]; + + _LIBCPP_INLINE_VISIBILITY static difference_type capacity() + {return static_cast(_N * __bits_per_word);} + _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {} + _LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(__word_, 0);} + _LIBCPP_INLINE_VISIBILITY iterator end() {return iterator(__word_ + __size_ / __bits_per_word, + static_cast(__size_ % __bits_per_word));} +}; + +template +__bit_iterator<_C, false> +rotate(__bit_iterator<_C, false> __first, __bit_iterator<_C, false> __middle, __bit_iterator<_C, false> __last) +{ + typedef __bit_iterator<_C, false> _I1; + typedef typename _I1::difference_type difference_type; + typedef typename _I1::__storage_type __storage_type; + static const unsigned __bits_per_word = _I1::__bits_per_word; + difference_type __d1 = __middle - __first; + difference_type __d2 = __last - __middle; + _I1 __r = __first + __d2; + while (__d1 != 0 && __d2 != 0) + { + if (__d1 <= __d2) + { + if (__d1 <= __bit_array<_C>::capacity()) + { + __bit_array<_C> __b(__d1); + _VSTD::copy(__first, __middle, __b.begin()); + _VSTD::copy(__b.begin(), __b.end(), _VSTD::copy(__middle, __last, __first)); + break; + } + else + { + __bit_iterator<_C, false> __mp = _VSTD::swap_ranges(__first, __middle, __middle); + __first = __middle; + __middle = __mp; + __d2 -= __d1; + } + } + else + { + if (__d2 <= __bit_array<_C>::capacity()) + { + __bit_array<_C> __b(__d2); + _VSTD::copy(__middle, __last, __b.begin()); + _VSTD::copy_backward(__b.begin(), __b.end(), _VSTD::copy_backward(__first, __middle, __last)); + break; + } + else + { + __bit_iterator<_C, false> __mp = __first + __d2; + _VSTD::swap_ranges(__first, __mp, __middle); + __first = __mp; + __d1 -= __d2; + } + } + } + return __r; +} + +// equal + +template +bool +__equal_unaligned(__bit_iterator<_C, true> __first1, __bit_iterator<_C, true> __last1, + __bit_iterator<_C, true> __first2) +{ + typedef __bit_iterator<_C, true> _It; + typedef typename _It::difference_type difference_type; + typedef typename _It::__storage_type __storage_type; + static const unsigned __bits_per_word = _It::__bits_per_word; + difference_type __n = __last1 - __first1; + if (__n > 0) + { + // do first word + if (__first1.__ctz_ != 0) + { + unsigned __clz_f = __bits_per_word - __first1.__ctz_; + difference_type __dn = _VSTD::min(static_cast(__clz_f), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __storage_type __b = *__first1.__seg_ & __m; + unsigned __clz_r = __bits_per_word - __first2.__ctz_; + __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); + __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); + if (__first2.__ctz_ > __first1.__ctz_) + if ((*__first2.__seg_ & __m) != (__b << (__first2.__ctz_ - __first1.__ctz_))) + return false; + else + if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ - __first2.__ctz_))) + return false; + __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word; + __first2.__ctz_ = static_cast((__ddn + __first2.__ctz_) % __bits_per_word); + __dn -= __ddn; + if (__dn > 0) + { + __m = ~__storage_type(0) >> (__bits_per_word - __dn); + if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ + __ddn))) + return false; + __first2.__ctz_ = static_cast(__dn); + } + ++__first1.__seg_; + // __first1.__ctz_ = 0; + } + // __first1.__ctz_ == 0; + // do middle words + unsigned __clz_r = __bits_per_word - __first2.__ctz_; + __storage_type __m = ~__storage_type(0) << __first2.__ctz_; + for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_) + { + __storage_type __b = *__first1.__seg_; + if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) + return false; + ++__first2.__seg_; + if ((*__first2.__seg_ & ~__m) != (__b >> __clz_r)) + return false; + } + // do last word + if (__n > 0) + { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b = *__first1.__seg_ & __m; + __storage_type __dn = _VSTD::min(__n, static_cast(__clz_r)); + __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); + if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) + return false; + __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word; + __first2.__ctz_ = static_cast((__dn + __first2.__ctz_) % __bits_per_word); + __n -= __dn; + if (__n > 0) + { + __m = ~__storage_type(0) >> (__bits_per_word - __n); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-vendor@FreeBSD.ORG Tue Nov 22 17:33:09 2011 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 328661065679; Tue, 22 Nov 2011 17:33:09 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 089228FC0C; Tue, 22 Nov 2011 17:33:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAMHX83F002290; Tue, 22 Nov 2011 17:33:08 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAMHX8Td002289; Tue, 22 Nov 2011 17:33:08 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201111221733.pAMHX8Td002289@svn.freebsd.org> From: David Chisnall Date: Tue, 22 Nov 2011 17:33:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227826 - in vendor: libc++/r145065 libcxxrt/9802a7e430e08b90bf0e92d24abff095fa72ec21 X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Nov 2011 17:33:09 -0000 Author: theraven Date: Tue Nov 22 17:33:08 2011 New Revision: 227826 URL: http://svn.freebsd.org/changeset/base/227826 Log: Create versioned copies of the vendor branches.. Approved by: dim (mentor) Added: vendor/libc++/r145065/ - copied from r227825, vendor/libc++/dist/ vendor/libcxxrt/9802a7e430e08b90bf0e92d24abff095fa72ec21/ - copied from r227825, vendor/libcxxrt/dist/ From owner-svn-src-vendor@FreeBSD.ORG Wed Nov 23 18:05:38 2011 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C4F51065678; Wed, 23 Nov 2011 18:05:38 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 17B2D8FC1B; Wed, 23 Nov 2011 18:05:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pANI5cFm056757; Wed, 23 Nov 2011 18:05:38 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pANI5b0L056749; Wed, 23 Nov 2011 18:05:37 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201111231805.pANI5b0L056749@svn.freebsd.org> From: Jung-uk Kim Date: Wed, 23 Nov 2011 18:05:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor-sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227896 - in vendor-sys/acpica/dist: . common compiler debugger disassembler dispatcher events executer generate/unix generate/unix/acpibin generate/unix/acpiexec generate/unix/acpihelp... X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Nov 2011 18:05:38 -0000 Author: jkim Date: Wed Nov 23 18:05:37 2011 New Revision: 227896 URL: http://svn.freebsd.org/changeset/base/227896 Log: Import ACPICA 20111123. Added: vendor-sys/acpica/dist/compiler/aslrestype2s.c (contents, props changed) vendor-sys/acpica/dist/disassembler/dmresrcl2.c (contents, props changed) vendor-sys/acpica/dist/include/actbl3.h (contents, props changed) vendor-sys/acpica/dist/resources/rsserial.c (contents, props changed) vendor-sys/acpica/dist/utilities/utxfmutex.c (contents, props changed) Modified: vendor-sys/acpica/dist/changes.txt vendor-sys/acpica/dist/common/adisasm.c vendor-sys/acpica/dist/common/adwalk.c vendor-sys/acpica/dist/common/dmrestag.c vendor-sys/acpica/dist/common/dmtable.c vendor-sys/acpica/dist/common/dmtbdump.c vendor-sys/acpica/dist/common/dmtbinfo.c vendor-sys/acpica/dist/compiler/Makefile vendor-sys/acpica/dist/compiler/aslanalyze.c vendor-sys/acpica/dist/compiler/aslcodegen.c vendor-sys/acpica/dist/compiler/aslcompiler.h vendor-sys/acpica/dist/compiler/aslcompiler.l vendor-sys/acpica/dist/compiler/aslcompiler.y vendor-sys/acpica/dist/compiler/asldefine.h vendor-sys/acpica/dist/compiler/aslerror.c vendor-sys/acpica/dist/compiler/aslload.c vendor-sys/acpica/dist/compiler/asllookup.c vendor-sys/acpica/dist/compiler/aslmain.c vendor-sys/acpica/dist/compiler/aslmap.c vendor-sys/acpica/dist/compiler/aslmessages.h vendor-sys/acpica/dist/compiler/aslopcodes.c vendor-sys/acpica/dist/compiler/aslpredef.c vendor-sys/acpica/dist/compiler/aslresource.c vendor-sys/acpica/dist/compiler/aslrestype1i.c vendor-sys/acpica/dist/compiler/aslrestype2.c vendor-sys/acpica/dist/compiler/asltransform.c vendor-sys/acpica/dist/compiler/asltree.c vendor-sys/acpica/dist/compiler/aslwalks.c vendor-sys/acpica/dist/compiler/dtcompile.c vendor-sys/acpica/dist/compiler/dtcompiler.h vendor-sys/acpica/dist/compiler/dtfield.c vendor-sys/acpica/dist/compiler/dtsubtable.c vendor-sys/acpica/dist/compiler/dttable.c vendor-sys/acpica/dist/compiler/dttemplate.h vendor-sys/acpica/dist/compiler/dtutils.c vendor-sys/acpica/dist/debugger/dbcmds.c vendor-sys/acpica/dist/debugger/dbdisply.c vendor-sys/acpica/dist/debugger/dbfileio.c vendor-sys/acpica/dist/debugger/dbinput.c vendor-sys/acpica/dist/debugger/dbutils.c vendor-sys/acpica/dist/disassembler/dmbuffer.c vendor-sys/acpica/dist/disassembler/dmopcode.c vendor-sys/acpica/dist/disassembler/dmresrc.c vendor-sys/acpica/dist/disassembler/dmresrcl.c vendor-sys/acpica/dist/disassembler/dmresrcs.c vendor-sys/acpica/dist/disassembler/dmutils.c vendor-sys/acpica/dist/disassembler/dmwalk.c vendor-sys/acpica/dist/dispatcher/dsargs.c vendor-sys/acpica/dist/dispatcher/dsfield.c vendor-sys/acpica/dist/events/evevent.c vendor-sys/acpica/dist/events/evglock.c vendor-sys/acpica/dist/events/evregion.c vendor-sys/acpica/dist/executer/exconfig.c vendor-sys/acpica/dist/executer/excreate.c vendor-sys/acpica/dist/executer/exdump.c vendor-sys/acpica/dist/executer/exfield.c vendor-sys/acpica/dist/executer/exfldio.c vendor-sys/acpica/dist/executer/exprep.c vendor-sys/acpica/dist/executer/exutils.c vendor-sys/acpica/dist/generate/unix/Makefile vendor-sys/acpica/dist/generate/unix/Makefile.config vendor-sys/acpica/dist/generate/unix/acpibin/Makefile vendor-sys/acpica/dist/generate/unix/acpiexec/Makefile vendor-sys/acpica/dist/generate/unix/acpihelp/Makefile vendor-sys/acpica/dist/generate/unix/acpinames/Makefile vendor-sys/acpica/dist/generate/unix/acpisrc/Makefile vendor-sys/acpica/dist/generate/unix/acpixtract/Makefile vendor-sys/acpica/dist/generate/unix/iasl/Makefile vendor-sys/acpica/dist/hardware/hwvalid.c vendor-sys/acpica/dist/include/acconfig.h vendor-sys/acpica/dist/include/acdebug.h vendor-sys/acpica/dist/include/acdisasm.h vendor-sys/acpica/dist/include/acevents.h vendor-sys/acpica/dist/include/acglobal.h vendor-sys/acpica/dist/include/acinterp.h vendor-sys/acpica/dist/include/aclocal.h vendor-sys/acpica/dist/include/acnames.h vendor-sys/acpica/dist/include/acobject.h vendor-sys/acpica/dist/include/acopcode.h vendor-sys/acpica/dist/include/acpixf.h vendor-sys/acpica/dist/include/acpredef.h vendor-sys/acpica/dist/include/acresrc.h vendor-sys/acpica/dist/include/acrestyp.h vendor-sys/acpica/dist/include/actbl.h vendor-sys/acpica/dist/include/actbl1.h vendor-sys/acpica/dist/include/actypes.h vendor-sys/acpica/dist/include/acutils.h vendor-sys/acpica/dist/include/amlcode.h vendor-sys/acpica/dist/include/amlresrc.h vendor-sys/acpica/dist/namespace/nspredef.c vendor-sys/acpica/dist/namespace/nsrepair.c vendor-sys/acpica/dist/namespace/nsrepair2.c vendor-sys/acpica/dist/os_specific/service_layers/osunixxf.c vendor-sys/acpica/dist/os_specific/service_layers/oswinxf.c vendor-sys/acpica/dist/parser/psargs.c vendor-sys/acpica/dist/parser/psopcode.c vendor-sys/acpica/dist/parser/pstree.c vendor-sys/acpica/dist/resources/rscalc.c vendor-sys/acpica/dist/resources/rscreate.c vendor-sys/acpica/dist/resources/rsdump.c vendor-sys/acpica/dist/resources/rsinfo.c vendor-sys/acpica/dist/resources/rsirq.c vendor-sys/acpica/dist/resources/rslist.c vendor-sys/acpica/dist/resources/rsmisc.c vendor-sys/acpica/dist/resources/rsutils.c vendor-sys/acpica/dist/resources/rsxface.c vendor-sys/acpica/dist/tables/tbfadt.c vendor-sys/acpica/dist/tables/tbutils.c vendor-sys/acpica/dist/tests/misc/badcode.asl vendor-sys/acpica/dist/tools/acpiexec/Makefile vendor-sys/acpica/dist/tools/acpiexec/aecommon.h vendor-sys/acpica/dist/tools/acpiexec/aeexec.c vendor-sys/acpica/dist/tools/acpiexec/aehandlers.c vendor-sys/acpica/dist/tools/acpiexec/aemain.c vendor-sys/acpica/dist/tools/acpiexec/aetables.c vendor-sys/acpica/dist/tools/acpiexec/aetables.h vendor-sys/acpica/dist/tools/acpihelp/acpihelp.h vendor-sys/acpica/dist/tools/acpihelp/ahaslkey.c vendor-sys/acpica/dist/tools/acpihelp/ahaslops.c vendor-sys/acpica/dist/tools/acpihelp/ahdecode.c vendor-sys/acpica/dist/tools/acpihelp/ahpredef.c vendor-sys/acpica/dist/tools/acpisrc/asconvrt.c vendor-sys/acpica/dist/tools/acpisrc/astable.c vendor-sys/acpica/dist/utilities/utdecode.c vendor-sys/acpica/dist/utilities/utmutex.c vendor-sys/acpica/dist/utilities/utresrc.c Modified: vendor-sys/acpica/dist/changes.txt ============================================================================== --- vendor-sys/acpica/dist/changes.txt Wed Nov 23 18:04:53 2011 (r227895) +++ vendor-sys/acpica/dist/changes.txt Wed Nov 23 18:05:37 2011 (r227896) @@ -1,7 +1,214 @@ ---------------------------------------- -22 September 2011. Summary of changes for version 20110922: +23 November 2011. Summary of changes for version 20111123: This release is available at www.acpica.org/downloads +The ACPI 5.0 specification is available at www.acpi.info + +0) ACPI 5.0 Support: + +This release contains full support for the ACPI 5.0 specification, as +summarized below. + +Reduced Hardware Support: +------------------------- + +This support allows for ACPI systems without the usual ACPI hardware. This +support is enabled by a flag in the revision 5 FADT. If it is set, ACPICA will +not attempt to initialize or use any of the usual ACPI hardware. Note, when +this flag is set, all of the following ACPI hardware is assumed to be not +present and is not initialized or accessed: + + General Purpose Events (GPEs) + Fixed Events (PM1a/PM1b and PM Control) + Power Management Timer and Console Buttons (power/sleep) + Real-time Clock Alarm + Global Lock + System Control Interrupt (SCI) + The FACS is assumed to be non-existent + +ACPI Tables: +------------ + +All new tables and updates to existing tables are fully supported in the +ACPICA headers (for use by device drivers), the disassembler, and the iASL +Data Table Compiler. ACPI 5.0 defines these new tables: + + BGRT /* Boot Graphics Resource Table */ + DRTM /* Dynamic Root of Trust for Measurement table */ + FPDT /* Firmware Performance Data Table */ + GTDT /* Generic Timer Description Table */ + MPST /* Memory Power State Table */ + PCCT /* Platform Communications Channel Table */ + PMTT /* Platform Memory Topology Table */ + RASF /* RAS Feature table */ + +Operation Regions/SpaceIDs: +--------------------------- + +All new operation regions are fully supported by the iASL compiler, the +disassembler, and the ACPICA runtime code (for dispatch to region handlers.) +The new operation region Space IDs are: + + GeneralPurposeIo + GenericSerialBus + +Resource Descriptors: +--------------------- + +All new ASL resource descriptors are fully supported by the iASL compiler, the +ASL/AML disassembler, and the ACPICA runtime Resource Manager code (including +all new predefined resource tags). New descriptors are: + + FixedDma + GpioIo + GpioInt + I2cSerialBus + SpiSerialBus + UartSerialBus + +ASL/AML Operators, New and Modified: +------------------------------------ + +One new operator is added, the Connection operator, which is used to associate +a GeneralPurposeIo or GenericSerialBus resource descriptor with individual +field objects within an operation region. Several new protocols are associated +with the AccessAs operator. All are fully supported by the iASL compiler, +disassembler, and runtime ACPICA AML interpreter: + + Connection // Declare Field Connection attributes + AccessAs: AttribBytes (n) // Read/Write N-Bytes Protocol + AccessAs: AttribRawBytes (n) // Raw Read/Write N-Bytes Protocol + AccessAs: AttribRawProcessBytes (n) // Raw Process Call Protocol + RawDataBuffer // Data type for Vendor Data fields + +Predefined ASL/AML Objects: +--------------------------- + +All new predefined objects/control-methods are supported by the iASL compiler +and the ACPICA runtime validation/repair (arguments and return values.) New +predefined names include the following: + +Standard Predefined Names (Objects or Control Methods): + _AEI, _CLS, _CPC, _CWS, _DEP, + _DLM, _EVT, _GCP, _CRT, _GWS, + _HRV, _PRE, _PSE, _SRT, _SUB. + +Resource Tags (Names used to access individual fields within resource +descriptors): + _DBT, _DPL, _DRS, _END, _FLC, + _IOR, _LIN, _MOD, _PAR, _PHA, + _PIN, _PPI, _POL, _RXL, _SLV, + _SPE, _STB, _TXL, _VEN. + +ACPICA External Interfaces: +--------------------------- + +Several new interfaces have been defined for use by ACPI-related device +drivers and other host OS services: + +AcpiAcquireMutex and AcpiReleaseMutex: These interfaces allow the host OS to +acquire and release AML mutexes that are defined in the DSDT/SSDT tables +provided by the BIOS. They are intended to be used in conjunction with the +ACPI 5.0 _DLM (Device Lock Method) in order to provide transaction-level +mutual exclusion with the AML code/interpreter. + +AcpiGetEventResources: Returns the (formatted) resource descriptors as defined +by the ACPI 5.0 _AEI object (ACPI Event Information). This object provides +resource descriptors associated with hardware-reduced platform events, similar +to the AcpiGetCurrentResources interface. + +Operation Region Handlers: For General Purpose IO and Generic Serial Bus +operation regions, information about the Connection() object and any optional +length information is passed to the region handler within the Context +parameter. + +AcpiBufferToResource: This interface converts a raw AML buffer containing a +resource template or resource descriptor to the ACPI_RESOURCE internal format +suitable for use by device drivers. Can be used by an operation region handler +to convert the Connection() buffer object into a ACPI_RESOURCE. + +Miscellaneous/Tools/TestSuites: +------------------------------- + +Support for extended _HID names (Four alpha characters instead of three). +Support for ACPI 5.0 features in the AcpiExec and AcpiHelp utilities. +Support for ACPI 5.0 features in the ASLTS test suite. +Fully updated documentation (ACPICA and iASL reference documents.) + +ACPI Table Definition Language: +------------------------------- + +Support for this language was implemented and released as a subsystem of the +iASL compiler in 2010. (See the iASL compiler User Guide.) + + +Non-ACPI 5.0 changes for this release: +-------------------------------------- + +1) ACPICA Core Subsystem: + +Fix a problem with operation region declarations where a failure can occur if +the region name and an argument that evaluates to an object (such as the +region address) are in different namespace scopes. Lin Ming, ACPICA BZ 937. + +Do not abort an ACPI table load if an invalid space ID is found within. This +will be caught later if the offending method is executed. ACPICA BZ 925. + +Fixed an issue with the FFixedHW space ID where the ID was not always +recognized properly (Both ACPICA and iASL). ACPICA BZ 926. + +Fixed a problem with the 32-bit generation of the unix-specific OSL +(osunixxf.c). Lin Ming, ACPICA BZ 936. + +Several changes made to enable generation with the GCC 4.6 compiler. ACPICA BZ +935. + +New error messages: Unsupported I/O requests (not 8/16/32 bit), and Index/Bank +field registers out-of-range. + +2) iASL Compiler/Disassembler and Tools: + +iASL: Implemented the __PATH__ operator, which returns the full pathname of +the current source file. + +AcpiHelp: Automatically display expanded keyword information for all ASL +operators. + +Debugger: Add "Template" command to disassemble/dump resource template +buffers. + +Added a new master script to generate and execute the ASLTS test suite. +Automatically handles 32- and 64-bit generation. See tests/aslts.sh + +iASL: Fix problem with listing generation during processing of the Switch() +operator where AML listing was disabled until the entire Switch block was +completed. + +iASL: Improve support for semicolon statement terminators. Fix "invalid +character" message for some cases when the semicolon is used. Semicolons are +now allowed after every grammar element. ACPICA BZ 927. + +iASL: Fixed some possible aliasing warnings during generation. ACPICA BZ 923. + +Disassembler: Fix problem with disassembly of the DataTableRegion operator +where an inadvertent "Unhandled deferred opcode" message could be generated. + +3) Example Code and Data Size + +These are the sizes for the OS-independent acpica.lib produced by the +Microsoft Visual C++ 9.0 32-bit compiler. The debug version of the code +includes the debug output trace mechanism and has a much larger code and data +size. + + Previous Release: + Non-Debug Version: 90.2K Code, 23.9K Data, 114.1K Total + Debug Version: 165.6K Code, 68.4K Data, 234.0K Total + Current Release: + Non-Debug Version: 92.3K Code, 24.9K Data, 117.2K Total + Debug Version: 170.8K Code, 72.6K Data, 243.4K Total + +---------------------------------------- +22 September 2011. Summary of changes for version 20110922: 0) ACPI 5.0 News: Modified: vendor-sys/acpica/dist/common/adisasm.c ============================================================================== --- vendor-sys/acpica/dist/common/adisasm.c Wed Nov 23 18:04:53 2011 (r227895) +++ vendor-sys/acpica/dist/common/adisasm.c Wed Nov 23 18:05:37 2011 (r227896) @@ -868,6 +868,7 @@ AdParseDeferredOps ( break; case AML_REGION_OP: + case AML_DATA_REGION_OP: case AML_CREATE_QWORD_FIELD_OP: case AML_CREATE_DWORD_FIELD_OP: case AML_CREATE_WORD_FIELD_OP: Modified: vendor-sys/acpica/dist/common/adwalk.c ============================================================================== --- vendor-sys/acpica/dist/common/adwalk.c Wed Nov 23 18:04:53 2011 (r227895) +++ vendor-sys/acpica/dist/common/adwalk.c Wed Nov 23 18:05:37 2011 (r227896) @@ -378,6 +378,10 @@ AcpiDmDumpDescending ( AcpiOsPrintf ("%X", (UINT32) Op->Common.Value.Integer); break; + case AML_QWORD_OP: + AcpiOsPrintf ("%8.8X%8.8X", ACPI_FORMAT_UINT64 (Op->Common.Value.Integer)); + break; + case AML_INT_NAMEPATH_OP: if (Op->Common.Value.String) { Modified: vendor-sys/acpica/dist/common/dmrestag.c ============================================================================== --- vendor-sys/acpica/dist/common/dmrestag.c Wed Nov 23 18:04:53 2011 (r227895) +++ vendor-sys/acpica/dist/common/dmrestag.c Wed Nov 23 18:05:37 2011 (r227896) @@ -63,7 +63,7 @@ AcpiDmUpdateResourceName ( static char * AcpiDmSearchTagList ( UINT32 BitIndex, - ACPI_RESOURCE_TAG *TagList); + const ACPI_RESOURCE_TAG *TagList); static char * AcpiDmGetResourceTag ( @@ -108,7 +108,7 @@ AcpiDmAddResourcesToNamespace ( * ******************************************************************************/ -static ACPI_RESOURCE_TAG AcpiDmIrqTags[] = +static const ACPI_RESOURCE_TAG AcpiDmIrqTags[] = { {( 1 * 8), ACPI_RESTAG_INTERRUPT}, {( 3 * 8) + 0, ACPI_RESTAG_INTERRUPTTYPE}, @@ -117,7 +117,7 @@ static ACPI_RESOURCE_TAG AcpiDmIr {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmDmaTags[] = +static const ACPI_RESOURCE_TAG AcpiDmDmaTags[] = { {( 1 * 8), ACPI_RESTAG_DMA}, {( 2 * 8) + 0, ACPI_RESTAG_XFERTYPE}, @@ -126,7 +126,7 @@ static ACPI_RESOURCE_TAG AcpiDmDm {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmIoTags[] = +static const ACPI_RESOURCE_TAG AcpiDmIoTags[] = { {( 1 * 8) + 0, ACPI_RESTAG_DECODE}, {( 2 * 8), ACPI_RESTAG_MINADDR}, @@ -136,14 +136,22 @@ static ACPI_RESOURCE_TAG AcpiDmIo {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmFixedIoTags[] = +static const ACPI_RESOURCE_TAG AcpiDmFixedIoTags[] = { {( 1 * 8), ACPI_RESTAG_BASEADDRESS}, {( 3 * 8), ACPI_RESTAG_LENGTH}, {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmMemory24Tags[] = +static const ACPI_RESOURCE_TAG AcpiDmFixedDmaTags[] = +{ + {( 1 * 8), ACPI_RESTAG_DMA}, + {( 3 * 8), ACPI_RESTAG_DMATYPE}, + {( 5 * 8), ACPI_RESTAG_XFERTYPE}, + {0, NULL} +}; + +static const ACPI_RESOURCE_TAG AcpiDmMemory24Tags[] = { {( 3 * 8) + 0, ACPI_RESTAG_READWRITETYPE}, {( 4 * 8), ACPI_RESTAG_MINADDR}, @@ -153,7 +161,7 @@ static ACPI_RESOURCE_TAG AcpiDmMe {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmRegisterTags[] = +static const ACPI_RESOURCE_TAG AcpiDmRegisterTags[] = { {( 3 * 8), ACPI_RESTAG_ADDRESSSPACE}, {( 4 * 8), ACPI_RESTAG_REGISTERBITWIDTH}, @@ -163,7 +171,7 @@ static ACPI_RESOURCE_TAG AcpiDmRe {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmMemory32Tags[] = +static const ACPI_RESOURCE_TAG AcpiDmMemory32Tags[] = { {( 3 * 8) + 0, ACPI_RESTAG_READWRITETYPE}, {( 4 * 8), ACPI_RESTAG_MINADDR}, @@ -173,7 +181,7 @@ static ACPI_RESOURCE_TAG AcpiDmMe {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmFixedMemory32Tags[] = +static const ACPI_RESOURCE_TAG AcpiDmFixedMemory32Tags[] = { {( 3 * 8) + 0, ACPI_RESTAG_READWRITETYPE}, {( 4 * 8), ACPI_RESTAG_BASEADDRESS}, @@ -181,7 +189,7 @@ static ACPI_RESOURCE_TAG AcpiDmFi {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmInterruptTags[] = +static const ACPI_RESOURCE_TAG AcpiDmInterruptTags[] = { {( 3 * 8) + 1, ACPI_RESTAG_INTERRUPTTYPE}, {( 3 * 8) + 2, ACPI_RESTAG_INTERRUPTLEVEL}, @@ -190,7 +198,7 @@ static ACPI_RESOURCE_TAG AcpiDmIn {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmAddress16Tags[] = +static const ACPI_RESOURCE_TAG AcpiDmAddress16Tags[] = { {( 4 * 8) + 1, ACPI_RESTAG_DECODE}, {( 4 * 8) + 2, ACPI_RESTAG_MINTYPE}, @@ -203,7 +211,7 @@ static ACPI_RESOURCE_TAG AcpiDmAd {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmAddress32Tags[] = +static const ACPI_RESOURCE_TAG AcpiDmAddress32Tags[] = { {( 4 * 8) + 1, ACPI_RESTAG_DECODE}, {( 4 * 8) + 2, ACPI_RESTAG_MINTYPE}, @@ -216,7 +224,7 @@ static ACPI_RESOURCE_TAG AcpiDmAd {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmAddress64Tags[] = +static const ACPI_RESOURCE_TAG AcpiDmAddress64Tags[] = { {( 4 * 8) + 1, ACPI_RESTAG_DECODE}, {( 4 * 8) + 2, ACPI_RESTAG_MINTYPE}, @@ -229,7 +237,7 @@ static ACPI_RESOURCE_TAG AcpiDmAd {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmExtendedAddressTags[] = +static const ACPI_RESOURCE_TAG AcpiDmExtendedAddressTags[] = { {( 4 * 8) + 1, ACPI_RESTAG_DECODE}, {( 4 * 8) + 2, ACPI_RESTAG_MINTYPE}, @@ -243,9 +251,71 @@ static ACPI_RESOURCE_TAG AcpiDmEx {0, NULL} }; -/* Special-case tables for the type-specific flags */ +/* Subtype tables for GPIO descriptors */ + +static const ACPI_RESOURCE_TAG AcpiDmGpioIntTags[] = +{ + {( 7 * 8) + 0, ACPI_RESTAG_MODE}, + {( 7 * 8) + 1, ACPI_RESTAG_POLARITY}, + {( 7 * 8) + 3, ACPI_RESTAG_INTERRUPTSHARE}, + {( 9 * 8), ACPI_RESTAG_PINCONFIG}, + {(10 * 8), ACPI_RESTAG_DRIVESTRENGTH}, + {(12 * 8), ACPI_RESTAG_DEBOUNCETIME}, + {0, NULL} +}; + +static const ACPI_RESOURCE_TAG AcpiDmGpioIoTags[] = +{ + {( 7 * 8) + 0, ACPI_RESTAG_IORESTRICTION}, + {( 7 * 8) + 3, ACPI_RESTAG_INTERRUPTSHARE}, + {( 9 * 8), ACPI_RESTAG_PINCONFIG}, + {(10 * 8), ACPI_RESTAG_DRIVESTRENGTH}, + {(12 * 8), ACPI_RESTAG_DEBOUNCETIME}, + {0, NULL} +}; + +/* Subtype tables for SerialBus descriptors */ + +static const ACPI_RESOURCE_TAG AcpiDmI2cSerialBusTags[] = +{ + {( 6 * 8) + 0, ACPI_RESTAG_SLAVEMODE}, + {( 7 * 8) + 0, ACPI_RESTAG_MODE}, + {(12 * 8), ACPI_RESTAG_SPEED}, + {(16 * 8), ACPI_RESTAG_ADDRESS}, + {0, NULL} +}; + +static const ACPI_RESOURCE_TAG AcpiDmSpiSerialBusTags[] = +{ + {( 6 * 8) + 0, ACPI_RESTAG_SLAVEMODE}, + {( 7 * 8) + 0, ACPI_RESTAG_MODE}, + {( 7 * 8) + 1, ACPI_RESTAG_DEVICEPOLARITY}, + {(12 * 8), ACPI_RESTAG_SPEED}, + {(16 * 8), ACPI_RESTAG_LENGTH}, + {(17 * 8), ACPI_RESTAG_PHASE}, + {(18 * 8), ACPI_RESTAG_POLARITY}, + {(19 * 8), ACPI_RESTAG_ADDRESS}, + {0, NULL} +}; + +static const ACPI_RESOURCE_TAG AcpiDmUartSerialBusTags[] = +{ + {( 6 * 8) + 0, ACPI_RESTAG_SLAVEMODE}, /* Note: not part of original macro */ + {( 7 * 8) + 0, ACPI_RESTAG_FLOWCONTROL}, + {( 7 * 8) + 2, ACPI_RESTAG_STOPBITS}, + {( 7 * 8) + 4, ACPI_RESTAG_LENGTH}, + {( 7 * 8) + 7, ACPI_RESTAG_ENDIANNESS}, + {(12 * 8), ACPI_RESTAG_SPEED}, + {(16 * 8), ACPI_RESTAG_LENGTH_RX}, + {(18 * 8), ACPI_RESTAG_LENGTH_TX}, + {(20 * 8), ACPI_RESTAG_PARITY}, + {(21 * 8), ACPI_RESTAG_LINE}, + {0, NULL} +}; + +/* Subtype tables for Address descriptor type-specific flags */ -static ACPI_RESOURCE_TAG AcpiDmMemoryFlagTags[] = +static const ACPI_RESOURCE_TAG AcpiDmMemoryFlagTags[] = { {( 5 * 8) + 0, ACPI_RESTAG_READWRITETYPE}, {( 5 * 8) + 1, ACPI_RESTAG_MEMTYPE}, @@ -254,7 +324,7 @@ static ACPI_RESOURCE_TAG AcpiDmMe {0, NULL} }; -static ACPI_RESOURCE_TAG AcpiDmIoFlagTags[] = +static const ACPI_RESOURCE_TAG AcpiDmIoFlagTags[] = { {( 5 * 8) + 0, ACPI_RESTAG_RANGETYPE}, {( 5 * 8) + 4, ACPI_RESTAG_TYPE}, @@ -263,9 +333,15 @@ static ACPI_RESOURCE_TAG AcpiDmIo }; -/* Dispatch table used to obtain the correct tag table for a descriptor */ - -static ACPI_RESOURCE_TAG *AcpiGbl_ResourceTags [] = +/* + * Dispatch table used to obtain the correct tag table for a descriptor. + * + * A NULL in this table means one of three things: + * 1) The descriptor ID is reserved and invalid + * 2) The descriptor has no tags associated with it + * 3) The descriptor has subtypes and a separate table will be used. + */ +static const ACPI_RESOURCE_TAG *AcpiGbl_ResourceTags[] = { /* Small descriptors */ @@ -279,7 +355,7 @@ static ACPI_RESOURCE_TAG *AcpiGbl NULL, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ AcpiDmIoTags, /* 0x08, ACPI_RESOURCE_NAME_IO_PORT */ AcpiDmFixedIoTags, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO_PORT */ - NULL, /* 0x0A, Reserved */ + AcpiDmFixedDmaTags, /* 0x0A, ACPI_RESOURCE_NAME_FIXED_DMA */ NULL, /* 0x0B, Reserved */ NULL, /* 0x0C, Reserved */ NULL, /* 0x0D, Reserved */ @@ -299,9 +375,29 @@ static ACPI_RESOURCE_TAG *AcpiGbl AcpiDmAddress16Tags, /* 0x08, ACPI_RESOURCE_NAME_WORD_ADDRESS_SPACE */ AcpiDmInterruptTags, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_XRUPT */ AcpiDmAddress64Tags, /* 0x0A, ACPI_RESOURCE_NAME_QWORD_ADDRESS_SPACE */ - AcpiDmExtendedAddressTags /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS_SPACE */ + AcpiDmExtendedAddressTags, /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS_SPACE */ + NULL, /* 0x0C, ACPI_RESOURCE_NAME_GPIO - Use Subtype table below */ + NULL, /* 0x0D, Reserved */ + NULL /* 0x0E, ACPI_RESOURCE_NAME_SERIAL_BUS - Use Subtype table below */ +}; + +/* GPIO Subtypes */ + +static const ACPI_RESOURCE_TAG *AcpiGbl_GpioResourceTags[] = +{ + AcpiDmGpioIntTags, /* 0x00 Interrupt Connection */ + AcpiDmGpioIoTags /* 0x01 I/O Connection */ }; +/* Serial Bus Subtypes */ + +static const ACPI_RESOURCE_TAG *AcpiGbl_SerialResourceTags[] = +{ + NULL, /* 0x00 Reserved */ + AcpiDmI2cSerialBusTags, /* 0x01 I2C SerialBus */ + AcpiDmSpiSerialBusTags, /* 0x02 SPI SerialBus */ + AcpiDmUartSerialBusTags /* 0x03 UART SerialBus */ +}; /* * Globals used to generate unique resource descriptor names. We use names that @@ -666,6 +762,9 @@ AcpiDmUpdateResourceName ( * * DESCRIPTION: Convert a BitIndex into a symbolic resource tag. * + * Note: ResourceIndex should be previously validated and guaranteed to ve + * valid. + * ******************************************************************************/ static char * @@ -674,23 +773,16 @@ AcpiDmGetResourceTag ( AML_RESOURCE *Resource, UINT8 ResourceIndex) { - ACPI_RESOURCE_TAG *TagList; + const ACPI_RESOURCE_TAG *TagList; char *Tag = NULL; /* Get the tag list for this resource descriptor type */ TagList = AcpiGbl_ResourceTags[ResourceIndex]; - if (!TagList) - { - /* There are no tags for this resource type */ - - return (NULL); - } /* - * Handle the type-specific flags field for the address descriptors. - * Kindof brute force, but just blindly search for an index match. + * Handle descriptors that have multiple subtypes */ switch (Resource->DescriptorType) { @@ -699,6 +791,10 @@ AcpiDmGetResourceTag ( case ACPI_RESOURCE_NAME_ADDRESS64: case ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64: + /* + * Subtype differentiation is the flags. + * Kindof brute force, but just blindly search for an index match + */ if (Resource->Address.ResourceType == ACPI_ADDRESS_TYPE_MEMORY_RANGE) { Tag = AcpiDmSearchTagList (BitIndex, AcpiDmMemoryFlagTags); @@ -716,13 +812,42 @@ AcpiDmGetResourceTag ( } break; + case ACPI_RESOURCE_NAME_GPIO: + + /* GPIO connection has 2 subtypes: Interrupt and I/O */ + + if (Resource->Gpio.ConnectionType > AML_RESOURCE_MAX_GPIOTYPE) + { + return (NULL); + } + + TagList = AcpiGbl_GpioResourceTags[Resource->Gpio.ConnectionType]; + break; + + case ACPI_RESOURCE_NAME_SERIAL_BUS: + + /* SerialBus has 3 subtypes: I2C, SPI, and UART */ + + if ((Resource->CommonSerialBus.Type == 0) || + (Resource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE)) + { + return (NULL); + } + + TagList = AcpiGbl_SerialResourceTags[Resource->CommonSerialBus.Type]; + break; + default: break; } - /* Search the tag list for this descriptor type */ + /* Search for a match against the BitIndex */ + + if (TagList) + { + Tag = AcpiDmSearchTagList (BitIndex, TagList); + } - Tag = AcpiDmSearchTagList (BitIndex, TagList); return (Tag); } @@ -744,7 +869,7 @@ AcpiDmGetResourceTag ( static char * AcpiDmSearchTagList ( UINT32 BitIndex, - ACPI_RESOURCE_TAG *TagList) + const ACPI_RESOURCE_TAG *TagList) { /* Modified: vendor-sys/acpica/dist/common/dmtable.c ============================================================================== --- vendor-sys/acpica/dist/common/dmtable.c Wed Nov 23 18:04:53 2011 (r227895) +++ vendor-sys/acpica/dist/common/dmtable.c Wed Nov 23 18:05:37 2011 (r227896) @@ -196,6 +196,16 @@ static const char *AcpiDmMadtS "Platform Interrupt Sources", /* ACPI_MADT_TYPE_INTERRUPT_SOURCE */ "Processor Local x2APIC", /* ACPI_MADT_TYPE_LOCAL_X2APIC */ "Local x2APIC NMI", /* ACPI_MADT_TYPE_LOCAL_X2APIC_NMI */ + "Generic Interrupt Controller", /* ACPI_MADT_GENERIC_INTERRUPT */ + "Generic Interrupt Distributor",/* ACPI_MADT_GENERIC_DISTRIBUTOR */ + "Unknown SubTable Type" /* Reserved */ +}; + +static const char *AcpiDmPmttSubnames[] = +{ + "Socket", /* ACPI_PMTT_TYPE_SOCKET */ + "Memory Controller", /* ACPI_PMTT_TYPE_CONTROLLER */ + "Physical Component (DIMM)", /* ACPI_PMTT_TYPE_DIMM */ "Unknown SubTable Type" /* Reserved */ }; @@ -268,6 +278,7 @@ ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_ASF, NULL, AcpiDmDumpAsf, DtCompileAsf, TemplateAsf, "Alert Standard Format table"}, {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, NULL, TemplateBoot, "Simple Boot Flag Table"}, {ACPI_SIG_BERT, AcpiDmTableInfoBert, NULL, NULL, TemplateBert, "Boot Error Record Table"}, + {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt, NULL, NULL, TemplateBgrt, "Boot Graphics Resource Table"}, {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, DtCompileCpep, TemplateCpep, "Corrected Platform Error Polling table"}, {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, NULL, TemplateDbgp, "Debug Port table"}, {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, DtCompileDmar, TemplateDmar, "DMA Remapping table"}, @@ -275,14 +286,20 @@ ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_EINJ, NULL, AcpiDmDumpEinj, DtCompileEinj, TemplateEinj, "Error Injection table"}, {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, DtCompileErst, TemplateErst, "Error Record Serialization Table"}, {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, DtCompileFadt, TemplateFadt, "Fixed ACPI Description Table"}, + {ACPI_SIG_FPDT, NULL, AcpiDmDumpFpdt, DtCompileFpdt, TemplateFpdt, "Firmware Performance Data Table"}, + {ACPI_SIG_GTDT, AcpiDmTableInfoGtdt, NULL, NULL, TemplateGtdt, "Generic Timer Description Table"}, {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, DtCompileHest, TemplateHest, "Hardware Error Source Table"}, {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, NULL, TemplateHpet, "High Precision Event Timer table"}, {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, DtCompileIvrs, TemplateIvrs, "I/O Virtualization Reporting Structure"}, {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, DtCompileMadt, TemplateMadt, "Multiple APIC Description Table"}, {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, DtCompileMcfg, TemplateMcfg, "Memory Mapped Configuration table"}, {ACPI_SIG_MCHI, AcpiDmTableInfoMchi, NULL, NULL, TemplateMchi, "Management Controller Host Interface table"}, + {ACPI_SIG_MPST, AcpiDmTableInfoMpst, AcpiDmDumpMpst, DtCompileMpst, TemplateMpst, "Memory Power State Table"}, {ACPI_SIG_MSCT, NULL, AcpiDmDumpMsct, DtCompileMsct, TemplateMsct, "Maximum System Characteristics Table"}, + {ACPI_SIG_PCCT, NULL, AcpiDmDumpPcct, NULL, NULL, "Platform Communications Channel Table"}, + {ACPI_SIG_PMTT, NULL, AcpiDmDumpPmtt, DtCompilePmtt, TemplatePmtt, "Platform Memory Topology Table"}, {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, DtCompileRsdt, TemplateRsdt, "Root System Description Table"}, + {ACPI_SIG_S3PT, NULL, NULL, NULL, TemplateS3pt, "S3 Performance Table"}, {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, NULL, TemplateSbst, "Smart Battery Specification Table"}, {ACPI_SIG_SLIC, NULL, AcpiDmDumpSlic, DtCompileSlic, TemplateSlic, "Software Licensing Description Table"}, {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, DtCompileSlit, TemplateSlit, "System Locality Information Table"}, @@ -400,7 +417,7 @@ AcpiDmDumpDataTable ( /* * Handle tables that don't use the common ACPI table header structure. - * Currently, these are the FACS and RSDP. + * Currently, these are the FACS, RSDP, and S3PT. */ if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS)) { @@ -411,6 +428,10 @@ AcpiDmDumpDataTable ( { Length = AcpiDmDumpRsdp (Table); } + else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_S3PT)) + { + Length = AcpiDmDumpS3pt (Table); + } else { /* @@ -646,6 +667,7 @@ AcpiDmDumpTable ( case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: case ACPI_DMT_MADT: + case ACPI_DMT_PMTT: case ACPI_DMT_SRAT: case ACPI_DMT_ASF: case ACPI_DMT_HESTNTYP: @@ -670,6 +692,10 @@ AcpiDmDumpTable ( case ACPI_DMT_SLIC: ByteLength = 4; break; + case ACPI_DMT_UINT40: + ByteLength = 5; + break; + case ACPI_DMT_UINT48: case ACPI_DMT_NAME6: ByteLength = 6; break; @@ -718,6 +744,12 @@ AcpiDmDumpTable ( return (AE_BAD_DATA); } + if (Info->Opcode == ACPI_DMT_EXTRA_TEXT) + { + AcpiOsPrintf ("%s", Info->Name); + continue; + } + /* Start a new line and decode the opcode */ AcpiDmLineHeader (CurrentOffset, ByteLength, Info->Name); @@ -745,17 +777,29 @@ AcpiDmDumpTable ( AcpiOsPrintf ("%1.1X\n", *Target & 0x03); break; + case ACPI_DMT_FLAGS1: + + AcpiOsPrintf ("%1.1X\n", (*Target >> 1) & 0x03); + break; + case ACPI_DMT_FLAGS2: AcpiOsPrintf ("%1.1X\n", (*Target >> 2) & 0x03); break; + case ACPI_DMT_FLAGS4: + + AcpiOsPrintf ("%1.1X\n", (*Target >> 4) & 0x03); + break; + /* Integer Data Types */ case ACPI_DMT_UINT8: case ACPI_DMT_UINT16: case ACPI_DMT_UINT24: case ACPI_DMT_UINT32: + case ACPI_DMT_UINT40: + case ACPI_DMT_UINT48: case ACPI_DMT_UINT56: case ACPI_DMT_UINT64: /* @@ -1021,6 +1065,19 @@ AcpiDmDumpTable ( AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmMadtSubnames[Temp8]); break; + case ACPI_DMT_PMTT: + + /* PMTT subtable types */ + + Temp8 = *Target; + if (Temp8 > ACPI_PMTT_TYPE_RESERVED) + { + Temp8 = ACPI_PMTT_TYPE_RESERVED; + } + + AcpiOsPrintf (UINT8_FORMAT, *Target, AcpiDmPmttSubnames[Temp8]); + break; + case ACPI_DMT_SLIC: /* SLIC subtable types */ Modified: vendor-sys/acpica/dist/common/dmtbdump.c ============================================================================== --- vendor-sys/acpica/dist/common/dmtbdump.c Wed Nov 23 18:04:53 2011 (r227895) +++ vendor-sys/acpica/dist/common/dmtbdump.c Wed Nov 23 18:05:37 2011 (r227896) @@ -230,11 +230,18 @@ AcpiDmDumpFadt ( AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt2); } - /* Check for FADT revision 3 fields and up (ACPI 2.0+ extended data) */ + /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */ else if (Table->Length > ACPI_FADT_V2_SIZE) { AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt3); + + /* Check for FADT revision 5 fields and up (ACPI 5.0+) */ + + if (Table->Length > ACPI_FADT_V3_SIZE) + { + AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt5); + } } /* Validate various fields in the FADT, including length */ @@ -290,6 +297,10 @@ AcpiDmValidateFadtLength ( ExpectedLength = ACPI_FADT_V3_SIZE; break; + case 5: + ExpectedLength = ACPI_FADT_V5_SIZE; + break; + default: return; } @@ -751,6 +762,84 @@ AcpiDmDumpErst ( /******************************************************************************* * + * FUNCTION: AcpiDmDumpFpdt + * + * PARAMETERS: Table - A FPDT table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a FPDT. This table type consists + * of an open-ended number of subtables. + * + ******************************************************************************/ + +void +AcpiDmDumpFpdt ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + ACPI_FPDT_HEADER *SubTable; + UINT32 Length = Table->Length; + UINT32 Offset = sizeof (ACPI_TABLE_FPDT); + ACPI_DMTABLE_INFO *InfoTable; + + + /* There is no main table (other than the standard ACPI header) */ + + /* Sub-tables */ + + SubTable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, Table, Offset); + while (Offset < Table->Length) + { + /* Common sub-table header */ + + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTable->Length, AcpiDmTableInfoFpdtHdr); + if (ACPI_FAILURE (Status)) + { + return; + } + + switch (SubTable->Type) + { + case ACPI_FPDT_TYPE_BOOT: + InfoTable = AcpiDmTableInfoFpdt0; + break; + case ACPI_FPDT_TYPE_S3PERF: + InfoTable = AcpiDmTableInfoFpdt1; + break; + default: + AcpiOsPrintf ("\n**** Unknown FPDT sub-table type 0x%X\n\n", SubTable->Type); + + /* Attempt to continue */ + + if (!SubTable->Length) + { + AcpiOsPrintf ("Invalid zero length subtable\n"); + return; + } + goto NextSubTable; + } + + Status = AcpiDmDumpTable (Length, Offset, SubTable, + SubTable->Length, InfoTable); + if (ACPI_FAILURE (Status)) + { + return; + } + +NextSubTable: + /* Point to next sub-table */ + + Offset += SubTable->Length; + SubTable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, SubTable, SubTable->Length); + } +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmDumpHest * * PARAMETERS: Table - A HEST table @@ -1134,6 +1223,12 @@ AcpiDmDumpMadt ( case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI: InfoTable = AcpiDmTableInfoMadt10; break; + case ACPI_MADT_TYPE_GENERIC_INTERRUPT: + InfoTable = AcpiDmTableInfoMadt11; + break; + case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR: + InfoTable = AcpiDmTableInfoMadt12; + break; default: AcpiOsPrintf ("\n**** Unknown MADT sub-table type 0x%X\n\n", SubTable->Type); @@ -1223,6 +1318,150 @@ AcpiDmDumpMcfg ( /******************************************************************************* * + * FUNCTION: AcpiDmDumpMpst + * + * PARAMETERS: Table - A MPST Table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a MPST table + * + ******************************************************************************/ + +void +AcpiDmDumpMpst ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + UINT32 Offset = sizeof (ACPI_TABLE_MPST); + ACPI_MPST_POWER_NODE *SubTable0; + ACPI_MPST_POWER_STATE *SubTable0A; + ACPI_MPST_COMPONENT *SubTable0B; + ACPI_MPST_DATA_HDR *SubTable1; + ACPI_MPST_POWER_DATA *SubTable2; + UINT16 SubtableCount; + UINT8 PowerStateCount; + UINT8 ComponentCount; + + + /* Main table */ + + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoMpst); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Subtable: Memory Power Node(s) */ + + SubtableCount = (ACPI_CAST_PTR (ACPI_TABLE_MPST, Table))->PowerNodeCount; + SubTable0 = ACPI_ADD_PTR (ACPI_MPST_POWER_NODE, Table, Offset); + + while ((Offset < Table->Length) && SubtableCount) + { + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable0, + sizeof (ACPI_MPST_POWER_NODE), AcpiDmTableInfoMpst0); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Extract the sub-subtable counts */ + + PowerStateCount = SubTable0->NumPowerStates; + ComponentCount = SubTable0->NumPhysicalComponents; + Offset += sizeof (ACPI_MPST_POWER_NODE); + + /* Sub-subtables - Memory Power State Structure(s) */ + + SubTable0A = ACPI_ADD_PTR (ACPI_MPST_POWER_STATE, SubTable0, + sizeof (ACPI_MPST_POWER_NODE)); + + while (PowerStateCount) + { + AcpiOsPrintf ("\n"); + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable0A, + sizeof (ACPI_MPST_POWER_STATE), AcpiDmTableInfoMpst0A); + if (ACPI_FAILURE (Status)) + { + return; + } + + SubTable0A++; + PowerStateCount--; + Offset += sizeof (ACPI_MPST_POWER_STATE); + } + + /* Sub-subtables - Physical Component ID Structure(s) */ + + SubTable0B = ACPI_CAST_PTR (ACPI_MPST_COMPONENT, SubTable0A); + + if (ComponentCount) + { + AcpiOsPrintf ("\n"); + } + + while (ComponentCount) + { + Status = AcpiDmDumpTable (Table->Length, Offset, SubTable0B, + sizeof (ACPI_MPST_COMPONENT), AcpiDmTableInfoMpst0B); + if (ACPI_FAILURE (Status)) + { + return; + } + + SubTable0B++; + ComponentCount--; + Offset += sizeof (ACPI_MPST_COMPONENT); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-vendor@FreeBSD.ORG Wed Nov 23 18:06:50 2011 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 876DB106564A; Wed, 23 Nov 2011 18:06:50 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5DA2E8FC16; Wed, 23 Nov 2011 18:06:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pANI6otS056864; Wed, 23 Nov 2011 18:06:50 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pANI6omp056863; Wed, 23 Nov 2011 18:06:50 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201111231806.pANI6omp056863@svn.freebsd.org> From: Jung-uk Kim Date: Wed, 23 Nov 2011 18:06:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor-sys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227897 - vendor-sys/acpica/20111123 X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Nov 2011 18:06:50 -0000 Author: jkim Date: Wed Nov 23 18:06:50 2011 New Revision: 227897 URL: http://svn.freebsd.org/changeset/base/227897 Log: Tag ACPICA 20111123. Added: vendor-sys/acpica/20111123/ - copied from r227896, vendor-sys/acpica/dist/ From owner-svn-src-vendor@FreeBSD.ORG Fri Nov 25 15:46:25 2011 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8553A1065670; Fri, 25 Nov 2011 15:46:25 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 73DD58FC0A; Fri, 25 Nov 2011 15:46:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAPFkPg9049396; Fri, 25 Nov 2011 15:46:25 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAPFkPmF049388; Fri, 25 Nov 2011 15:46:25 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201111251546.pAPFkPmF049388@svn.freebsd.org> From: David Chisnall Date: Fri, 25 Nov 2011 15:46:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227972 - vendor/libcxxrt/dist X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Nov 2011 15:46:25 -0000 Author: theraven Date: Fri Nov 25 15:46:25 2011 New Revision: 227972 URL: http://svn.freebsd.org/changeset/base/227972 Log: Import the new version of libcxxrt, which grew an extra ARM. Approved by: dim (mentor) Added: vendor/libcxxrt/dist/unwind-arm.h vendor/libcxxrt/dist/unwind-itanium.h vendor/libcxxrt/dist/unwind.h Modified: vendor/libcxxrt/dist/cxxabi.h vendor/libcxxrt/dist/dwarf_eh.h vendor/libcxxrt/dist/exception.cc vendor/libcxxrt/dist/guard.cc Modified: vendor/libcxxrt/dist/cxxabi.h ============================================================================== --- vendor/libcxxrt/dist/cxxabi.h Fri Nov 25 13:34:27 2011 (r227971) +++ vendor/libcxxrt/dist/cxxabi.h Fri Nov 25 15:46:25 2011 (r227972) @@ -1,7 +1,7 @@ #ifndef __CXXABI_H_ #define __CXXABI_H_ #include -#include +#include "unwind.h" namespace std { class type_info; @@ -87,6 +87,18 @@ struct __cxa_exception * handler count reaches 0 (which it doesn't with the top bit set). */ int handlerCount; +#ifdef __arm__ + /** + * The ARM EH ABI requires the unwind library to keep track of exceptions + * during cleanups. These support nesting, so we need to keep a list of + * them. + */ + _Unwind_Exception *nextCleanup; + /** + * The number of cleanups that are currently being run on this exception. + */ + int cleanupCount; +#endif /** * The selector value to be returned when installing the catch handler. * Used at the call site to determine which catch() block should execute. Modified: vendor/libcxxrt/dist/dwarf_eh.h ============================================================================== --- vendor/libcxxrt/dist/dwarf_eh.h Fri Nov 25 13:34:27 2011 (r227971) +++ vendor/libcxxrt/dist/dwarf_eh.h Fri Nov 25 15:46:25 2011 (r227972) @@ -16,10 +16,10 @@ // that it doesn't impact the rest of the program. #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 -# include +# include "unwind.h" # undef _GNU_SOURCE #else -# include +# include "unwind.h" #endif #include @@ -340,6 +340,9 @@ static inline struct dwarf_eh_lsda parse lsda.type_table = type_table; //lsda.type_table = (uintptr_t*)(data + v); } +#if __arm__ + lsda.type_table_encoding = (DW_EH_PE_pcrel | DW_EH_PE_indirect); +#endif lsda.callsite_encoding = (enum dwarf_data_encoding)(*(data++)); Modified: vendor/libcxxrt/dist/exception.cc ============================================================================== --- vendor/libcxxrt/dist/exception.cc Fri Nov 25 13:34:27 2011 (r227971) +++ vendor/libcxxrt/dist/exception.cc Fri Nov 25 15:46:25 2011 (r227972) @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "typeinfo.h" #include "dwarf_eh.h" @@ -9,6 +10,66 @@ using namespace ABI_NAMESPACE; +/** + * Saves the result of the landing pad that we have found. For ARM, this is + * stored in the generic unwind structure, while on other platforms it is + * stored in the C++ exception. + */ +static void saveLandingPad(struct _Unwind_Context *context, + struct _Unwind_Exception *ucb, + struct __cxa_exception *ex, + int selector, + dw_eh_ptr_t landingPad) +{ +#ifdef __arm__ + // On ARM, we store the saved exception in the generic part of the structure + ucb->barrier_cache.sp = _Unwind_GetGR(context, 13); + ucb->barrier_cache.bitpattern[1] = (uint32_t)selector; + ucb->barrier_cache.bitpattern[3] = (uint32_t)landingPad; +#endif + // Cache the results for the phase 2 unwind, if we found a handler + // and this is not a foreign exception. + if (ex) + { + ex->handlerSwitchValue = selector; + ex->catchTemp = landingPad; + } +} + +/** + * Loads the saved landing pad. Returns 1 on success, 0 on failure. + */ +static int loadLandingPad(struct _Unwind_Context *context, + struct _Unwind_Exception *ucb, + struct __cxa_exception *ex, + unsigned long *selector, + dw_eh_ptr_t *landingPad) +{ +#ifdef __arm__ + *selector = ucb->barrier_cache.bitpattern[1]; + *landingPad = (dw_eh_ptr_t)ucb->barrier_cache.bitpattern[3]; + return 1; +#else + if (ex) + { + *selector = ex->handlerSwitchValue; + *landingPad = (dw_eh_ptr_t)ex->catchTemp; + return 0; + } + return 0; +#endif +} + +static inline _Unwind_Reason_Code continueUnwinding(struct _Unwind_Exception *ex, + struct _Unwind_Context *context) +{ +#ifdef __arm__ + if (__gnu_unwind_frame(ex, context) != _URC_OK) { return _URC_FAILURE; } +#endif + return _URC_CONTINUE_UNWIND; +} + + extern "C" void __cxa_free_exception(void *thrown_exception); extern "C" void __cxa_free_dependent_exception(void *thrown_exception); extern "C" void* __dynamic_cast(const void *sub, @@ -59,6 +120,10 @@ struct __cxa_thread_info */ int emergencyBuffersHeld; /** + * The exception currently running in a cleanup. + */ + _Unwind_Exception *currentCleanup; + /** * The public part of this structure, accessible from outside of this * module. */ @@ -78,6 +143,10 @@ struct __cxa_dependent_exception terminate_handler terminateHandler; __cxa_exception *nextException; int handlerCount; +#ifdef __arm__ + _Unwind_Exception *nextCleanup; + int cleanupCount; +#endif int handlerSwitchValue; const char *actionRecord; const char *languageSpecificData; @@ -519,9 +588,11 @@ static void report_failure(_Unwind_Reaso case _URC_FATAL_PHASE1_ERROR: fprintf(stderr, "Fatal error during phase 1 unwinding\n"); break; +#ifndef __arm__ case _URC_FATAL_PHASE2_ERROR: fprintf(stderr, "Fatal error during phase 2 unwinding\n"); break; +#endif case _URC_END_OF_STACK: fprintf(stderr, "Terminating due to uncaught exception %p", (void*)thrown_exception); @@ -696,6 +767,7 @@ static std::type_info *get_type_info_ent // Get the address of the record in the table. dw_eh_ptr_t record = lsda->type_table - dwarf_size_of_fixed_size_field(lsda->type_table_encoding)*filter; + //record -= 4; dw_eh_ptr_t start = record; // Read the value, but it's probably an indirect reference... int64_t offset = read_value(lsda->type_table_encoding, &record); @@ -709,6 +781,7 @@ static std::type_info *get_type_info_ent } + /** * Checks the type signature found in a handler against the type of the thrown * object. If ex is 0 then it is assumed to be a foreign exception and only @@ -829,9 +902,22 @@ static handler_type check_action_record( } else if (filter < 0 && 0 != ex) { - unsigned char *type_index = ((unsigned char*)lsda->type_table - filter - 1); bool matched = false; *selector = filter; +#ifdef __arm__ + filter++; + std::type_info *handler_type = get_type_info_entry(context, lsda, filter--); + while (handler_type) + { + if (check_type_signature(ex, handler_type, adjustedPtr)) + { + matched = true; + break; + } + handler_type = get_type_info_entry(context, lsda, filter--); + } +#else + unsigned char *type_index = ((unsigned char*)lsda->type_table - filter - 1); while (*type_index) { std::type_info *handler_type = get_type_info_entry(context, lsda, *(type_index++)); @@ -844,6 +930,7 @@ static handler_type check_action_record( break; } } +#endif if (matched) { continue; } // If we don't find an allowed exception spec, we need to install // the context for this action. The landing pad will then call the @@ -859,17 +946,32 @@ static handler_type check_action_record( return found; } +static void pushCleanupException(_Unwind_Exception *exceptionObject, + __cxa_exception *ex) +{ +#ifdef __arm__ + __cxa_thread_info *info = thread_info_fast(); + if (ex) + { + ex->cleanupCount++; + if (ex->cleanupCount > 1) + { + assert(exceptionObject == info->currentCleanup); + return; + } + ex->nextCleanup = info->currentCleanup; + } + info->currentCleanup = exceptionObject; +#endif +} + /** * The exception personality function. This is referenced in the unwinding * DWARF metadata and is called by the unwind library for each C++ stack frame * containing catch or cleanup code. */ -extern "C" _Unwind_Reason_Code __gxx_personality_v0(int version, - _Unwind_Action actions, - uint64_t exceptionClass, - struct _Unwind_Exception *exceptionObject, - struct _Unwind_Context *context) -{ +extern "C" +BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0) // This personality function is for version 1 of the ABI. If you use it // with a future version of the ABI, it won't know what to do, so it // reports a fatal error and give up before it breaks anything. @@ -896,7 +998,7 @@ extern "C" _Unwind_Reason_Code __gxx_pe (unsigned char*)_Unwind_GetLanguageSpecificData(context); // No LSDA implies no landing pads - try the next frame - if (0 == lsda_addr) { return _URC_CONTINUE_UNWIND; } + if (0 == lsda_addr) { return continueUnwinding(exceptionObject, context); } // These two variables define how the exception will be handled. dwarf_eh_action action = {0}; @@ -941,15 +1043,14 @@ extern "C" _Unwind_Reason_Code __gxx_pe // and this is not a foreign exception. if (ex) { - ex->handlerSwitchValue = selector; - ex->actionRecord = (const char*)action.action_record; + saveLandingPad(context, exceptionObject, ex, selector, action.landing_pad); ex->languageSpecificData = (const char*)lsda_addr; - ex->catchTemp = action.landing_pad; + ex->actionRecord = (const char*)action.action_record; // ex->adjustedPtr is set when finding the action record. } return _URC_HANDLER_FOUND; } - return _URC_CONTINUE_UNWIND; + return continueUnwinding(exceptionObject, context); } @@ -962,11 +1063,12 @@ extern "C" _Unwind_Reason_Code __gxx_pe // cleanup struct dwarf_eh_lsda lsda = parse_lsda(context, lsda_addr); dwarf_eh_find_callsite(context, &lsda, &action); - if (0 == action.landing_pad) { return _URC_CONTINUE_UNWIND; } + if (0 == action.landing_pad) { return continueUnwinding(exceptionObject, context); } handler_type found_handler = check_action_record(context, &lsda, action.action_record, realEx, &selector, ex->adjustedPtr); // Ignore handlers this time. - if (found_handler != handler_cleanup) { return _URC_CONTINUE_UNWIND; } + if (found_handler != handler_cleanup) { return continueUnwinding(exceptionObject, context); } + pushCleanupException(exceptionObject, ex); } else if (foreignException) { @@ -983,9 +1085,8 @@ extern "C" _Unwind_Reason_Code __gxx_pe else { // Restore the saved info if we saved some last time. - action.landing_pad = (dw_eh_ptr_t)ex->catchTemp; + loadLandingPad(context, exceptionObject, ex, &selector, &action.landing_pad); ex->catchTemp = 0; - selector = (unsigned long)ex->handlerSwitchValue; ex->handlerSwitchValue = 0; } @@ -1063,6 +1164,8 @@ extern "C" void *__cxa_begin_catch(void return ((char*)exceptionObject + sizeof(_Unwind_Exception)); } + + /** * ABI function called when exiting a catch block. This will free the current * exception if it is no longer referenced in other catch blocks. @@ -1281,3 +1384,38 @@ namespace std return terminateHandler; } } +#ifdef __arm__ +extern "C" _Unwind_Exception *__cxa_get_cleanup(void) +{ + __cxa_thread_info *info = thread_info_fast(); + _Unwind_Exception *exceptionObject = info->currentCleanup; + if (isCXXException(exceptionObject->exception_class)) + { + __cxa_exception *ex = exceptionFromPointer(exceptionObject); + ex->cleanupCount--; + if (ex->cleanupCount == 0) + { + info->currentCleanup = ex->nextCleanup; + ex->nextCleanup = 0; + } + } + else + { + info->currentCleanup = 0; + } + return exceptionObject; +} + +asm ( +".pushsection .text.__cxa_end_cleanup \n" +".global __cxa_end_cleanup \n" +".type __cxa_end_cleanup, \"function\" \n" +"__cxa_end_cleanup: \n" +" push {r1, r2, r3, r4} \n" +" bl __cxa_get_cleanup \n" +" push {r1, r2, r3, r4} \n" +" b _Unwind_Resume \n" +" bl abort \n" +".popsection \n" +); +#endif Modified: vendor/libcxxrt/dist/guard.cc ============================================================================== --- vendor/libcxxrt/dist/guard.cc Fri Nov 25 13:34:27 2011 (r227971) +++ vendor/libcxxrt/dist/guard.cc Fri Nov 25 15:46:25 2011 (r227972) @@ -16,6 +16,59 @@ */ #include #include +#include + +#ifdef __arm__ +// ARM ABI - 32-bit guards. + +/** + * Acquires a lock on a guard, returning 0 if the object has already been + * initialised, and 1 if it has not. If the object is already constructed then + * this function just needs to read a byte from memory and return. + */ +extern "C" int __cxa_guard_acquire(volatile int32_t *guard_object) +{ + if ((1<<31) == *guard_object) { return 0; } + // If we can atomically move the value from 0 -> 1, then this is + // uninitialised. + if (__sync_bool_compare_and_swap(guard_object, 0, 1)) + { + return 1; + } + // If the value is not 0, some other thread was initialising this. Spin + // until it's finished. + while (__sync_bool_compare_and_swap(guard_object, (1<<31), (1<<31))) + { + // If the other thread aborted, then we grab the lock + if (__sync_bool_compare_and_swap(guard_object, 0, 1)) + { + return 1; + } + sched_yield(); + } + return 0; +} + +/** + * Releases the lock without marking the object as initialised. This function + * is called if initialising a static causes an exception to be thrown. + */ +extern "C" void __cxa_guard_abort(int32_t *guard_object) +{ + assert(__sync_bool_compare_and_swap(guard_object, 1, 0)); +} +/** + * Releases the guard and marks the object as initialised. This function is + * called after successful initialisation of a static. + */ +extern "C" void __cxa_guard_release(int32_t *guard_object) +{ + assert(__sync_bool_compare_and_swap(guard_object, 1, (1<<31))); +} + + +#else +// Itanium ABI: 64-bit guards /** * Returns a pointer to the low 32 bits in a 64-bit value, respecting the @@ -78,3 +131,4 @@ extern "C" void __cxa_guard_release(int6 __cxa_guard_abort(guard_object); } +#endif Added: vendor/libcxxrt/dist/unwind-arm.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libcxxrt/dist/unwind-arm.h Fri Nov 25 15:46:25 2011 (r227972) @@ -0,0 +1,201 @@ +/** + * ARM-specific unwind definitions. These are taken from the ARM EHABI + * specification. + */ + typedef enum +{ + _URC_OK = 0, /* operation completed successfully */ + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8, + _URC_FAILURE = 9, /* unspecified failure of some kind */ + _URC_FATAL_PHASE1_ERROR = _URC_FAILURE +} _Unwind_Reason_Code; + +typedef uint32_t _Unwind_State; +#ifdef __clang__ +static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME = 0; +static const _Unwind_State _US_UNWIND_FRAME_STARTING = 1; +static const _Unwind_State _US_UNWIND_FRAME_RESUME = 2; +#else // GCC fails at knowing what a constant expression is +# define _US_VIRTUAL_UNWIND_FRAME 0 +# define _US_UNWIND_FRAME_STARTING 1 +# define _US_UNWIND_FRAME_RESUME 2 +#endif + +typedef struct _Unwind_Context _Unwind_Context; + +typedef uint32_t _Unwind_EHT_Header; + +struct _Unwind_Exception +{ + uint64_t exception_class; + void (*exception_cleanup)(_Unwind_Reason_Code, struct _Unwind_Exception *); + /* Unwinder cache, private fields for the unwinder's use */ + struct + { + uint32_t reserved1; + uint32_t reserved2; + uint32_t reserved3; + uint32_t reserved4; + uint32_t reserved5; + /* init reserved1 to 0, then don't touch */ + } unwinder_cache; + /* Propagation barrier cache (valid after phase 1): */ + struct + { + uint32_t sp; + uint32_t bitpattern[5]; + } barrier_cache; + /* Cleanup cache (preserved over cleanup): */ + struct + { + uint32_t bitpattern[4]; + } cleanup_cache; + /* Pr cache (for pr's benefit): */ + struct + { + /** function start address */ + uint32_t fnstart; + /** pointer to EHT entry header word */ + _Unwind_EHT_Header *ehtp; + /** additional data */ + uint32_t additional; + uint32_t reserved1; + } pr_cache; + /** Force alignment of next item to 8-byte boundary */ + long long int :0; +}; + +/* Unwinding functions */ +_Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *ucbp); +void _Unwind_Resume(struct _Unwind_Exception *ucbp); +void _Unwind_Complete(struct _Unwind_Exception *ucbp); +void _Unwind_DeleteException(struct _Unwind_Exception *ucbp); +void *_Unwind_GetLanguageSpecificData(struct _Unwind_Context*); + +typedef enum +{ + _UVRSR_OK = 0, + _UVRSR_NOT_IMPLEMENTED = 1, + _UVRSR_FAILED = 2 +} _Unwind_VRS_Result; +typedef enum +{ + _UVRSC_CORE = 0, + _UVRSC_VFP = 1, + _UVRSC_WMMXD = 3, + _UVRSC_WMMXC = 4 +} _Unwind_VRS_RegClass; +typedef enum +{ + _UVRSD_UINT32 = 0, + _UVRSD_VFPX = 1, + _UVRSD_UINT64 = 3, + _UVRSD_FLOAT = 4, + _UVRSD_DOUBLE = 5 +} _Unwind_VRS_DataRepresentation; + +_Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *context, + _Unwind_VRS_RegClass regclass, + uint32_t regno, + _Unwind_VRS_DataRepresentation representation, + void *valuep); +_Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *context, + _Unwind_VRS_RegClass regclass, + uint32_t regno, + _Unwind_VRS_DataRepresentation representation, + void *valuep); + +/* Return the base-address for data references. */ +extern unsigned long _Unwind_GetDataRelBase(struct _Unwind_Context *); + +/* Return the base-address for text references. */ +extern unsigned long _Unwind_GetTextRelBase(struct _Unwind_Context *); +extern unsigned long _Unwind_GetRegionStart(struct _Unwind_Context *); + +typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (struct _Unwind_Context *, + void *); +extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *); +extern _Unwind_Reason_Code + _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *); + +/** + * The next set of functions are compatibility extensions, implementing Itanium + * ABI functions on top of ARM ones. + */ + +#define _UA_SEARCH_PHASE 1 +#define _UA_CLEANUP_PHASE 2 +#define _UA_HANDLER_FRAME 4 +#define _UA_FORCE_UNWIND 8 + +static inline unsigned long _Unwind_GetGR(struct _Unwind_Context *context, int reg) +{ + unsigned long val; + _Unwind_VRS_Get(context, _UVRSC_CORE, reg, _UVRSD_UINT32, &val); + return val; +} +static inline void _Unwind_SetGR(struct _Unwind_Context *context, int reg, unsigned long val) +{ + _Unwind_VRS_Set(context, _UVRSC_CORE, reg, _UVRSD_UINT32, &val); +} +static inline unsigned long _Unwind_GetIP(_Unwind_Context *context) +{ + // Low bit store the thumb state - discard it + return _Unwind_GetGR(context, 15) & ~1; +} +static inline void _Unwind_SetIP(_Unwind_Context *context, unsigned long val) +{ + // The lowest bit of the instruction pointer indicates whether we're in + // thumb or ARM mode. This is assumed to be fixed throughout a function, + // so must be propagated when setting the program counter. + unsigned long thumbState = _Unwind_GetGR(context, 15) & 1; + _Unwind_SetGR(context, 15, (val | thumbState)); +} + +/** GNU API function that unwinds the frame */ +_Unwind_Reason_Code __gnu_unwind_frame(struct _Unwind_Exception*, struct _Unwind_Context*); + + +#define DECLARE_PERSONALITY_FUNCTION(name) \ +_Unwind_Reason_Code name(_Unwind_State state,\ + struct _Unwind_Exception *exceptionObject,\ + struct _Unwind_Context *context); + +#define BEGIN_PERSONALITY_FUNCTION(name) \ +_Unwind_Reason_Code name(_Unwind_State state,\ + struct _Unwind_Exception *exceptionObject,\ + struct _Unwind_Context *context)\ +{\ + int version = 1;\ + uint64_t exceptionClass = exceptionObject->exception_class;\ + int actions;\ + switch (state)\ + {\ + default: return _URC_FAILURE;\ + case _US_VIRTUAL_UNWIND_FRAME:\ + {\ + actions = _UA_SEARCH_PHASE;\ + break;\ + }\ + case _US_UNWIND_FRAME_STARTING:\ + {\ + actions = _UA_CLEANUP_PHASE;\ + if (exceptionObject->barrier_cache.sp == _Unwind_GetGR(context, 13))\ + {\ + actions |= _UA_HANDLER_FRAME;\ + }\ + break;\ + }\ + case _US_UNWIND_FRAME_RESUME:\ + {\ + return continueUnwinding(exceptionObject, context);\ + break;\ + }\ + }\ + _Unwind_SetGR (context, 12, (unsigned long)exceptionObject);\ + +#define CALL_PERSONALITY_FUNCTION(name) name(state,exceptionObject,context) Added: vendor/libcxxrt/dist/unwind-itanium.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libcxxrt/dist/unwind-itanium.h Fri Nov 25 15:46:25 2011 (r227972) @@ -0,0 +1,170 @@ +/* libunwind - a platform-independent unwind library + Copyright (C) 2003 Hewlett-Packard Co + Contributed by David Mosberger-Tang + +This file is part of libunwind. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#ifndef _UNWIND_H +#define _UNWIND_H + +/* For uint64_t */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Minimal interface as per C++ ABI draft standard: + + http://www.codesourcery.com/cxx-abi/abi-eh.html */ + +typedef enum + { + _URC_NO_REASON = 0, + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8 + } +_Unwind_Reason_Code; + +typedef int _Unwind_Action; + +#define _UA_SEARCH_PHASE 1 +#define _UA_CLEANUP_PHASE 2 +#define _UA_HANDLER_FRAME 4 +#define _UA_FORCE_UNWIND 8 + +struct _Unwind_Context; /* opaque data-structure */ +struct _Unwind_Exception; /* forward-declaration */ + +typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, + struct _Unwind_Exception *); + +typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) (int, _Unwind_Action, + uint64_t, + struct _Unwind_Exception *, + struct _Unwind_Context *, + void *); + +/* The C++ ABI requires exception_class, private_1, and private_2 to + be of type uint64 and the entire structure to be + double-word-aligned. Please note that exception_class stays 64-bit + even on 32-bit machines for gcc compatibility. */ +struct _Unwind_Exception + { + uint64_t exception_class; + _Unwind_Exception_Cleanup_Fn exception_cleanup; + unsigned long private_1; + unsigned long private_2; + } __attribute__((__aligned__)); + +extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *); +extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *, + _Unwind_Stop_Fn, void *); +extern void _Unwind_Resume (struct _Unwind_Exception *); +extern void _Unwind_DeleteException (struct _Unwind_Exception *); +extern unsigned long _Unwind_GetGR (struct _Unwind_Context *, int); +extern void _Unwind_SetGR (struct _Unwind_Context *, int, unsigned long); +extern unsigned long _Unwind_GetIP (struct _Unwind_Context *); +extern unsigned long _Unwind_GetIPInfo (struct _Unwind_Context *, int *); +extern void _Unwind_SetIP (struct _Unwind_Context *, unsigned long); +extern unsigned long _Unwind_GetLanguageSpecificData (struct _Unwind_Context*); +extern unsigned long _Unwind_GetRegionStart (struct _Unwind_Context *); + +#ifdef _GNU_SOURCE + +/* Callback for _Unwind_Backtrace(). The backtrace stops immediately + if the callback returns any value other than _URC_NO_REASON. */ +typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (struct _Unwind_Context *, + void *); + +/* See http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00082.html for why + _UA_END_OF_STACK exists. */ +# define _UA_END_OF_STACK 16 + +/* If the unwind was initiated due to a forced unwind, resume that + operation, else re-raise the exception. This is used by + __cxa_rethrow(). */ +extern _Unwind_Reason_Code + _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *); + +/* See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00154.html for why + _Unwind_GetBSP() exists. */ +extern unsigned long _Unwind_GetBSP (struct _Unwind_Context *); + +/* Return the "canonical frame address" for the given context. + This is used by NPTL... */ +extern unsigned long _Unwind_GetCFA (struct _Unwind_Context *); + +/* Return the base-address for data references. */ +extern unsigned long _Unwind_GetDataRelBase (struct _Unwind_Context *); + +/* Return the base-address for text references. */ +extern unsigned long _Unwind_GetTextRelBase (struct _Unwind_Context *); + +/* Call _Unwind_Trace_Fn once for each stack-frame, without doing any + cleanup. The first frame for which the callback is invoked is the + one for the caller of _Unwind_Backtrace(). _Unwind_Backtrace() + returns _URC_END_OF_STACK when the backtrace stopped due to + reaching the end of the call-chain or _URC_FATAL_PHASE1_ERROR if it + stops for any other reason. */ +extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *); + +/* Find the start-address of the procedure containing the specified IP + or NULL if it cannot be found (e.g., because the function has no + unwind info). Note: there is not necessarily a one-to-one + correspondence between source-level functions and procedures: some + functions don't have unwind-info and others are split into multiple + procedures. */ +extern void *_Unwind_FindEnclosingFunction (void *); + +/* See also Linux Standard Base Spec: + http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/libgcc-s.html */ + +#endif /* _GNU_SOURCE */ + +#define DECLARE_PERSONALITY_FUNCTION(name) \ +_Unwind_Reason_Code name(int version,\ + _Unwind_Action actions,\ + uint64_t exceptionClass,\ + struct _Unwind_Exception *exceptionObject,\ + struct _Unwind_Context *context); +#define BEGIN_PERSONALITY_FUNCTION(name) \ +_Unwind_Reason_Code name(int version,\ + _Unwind_Action actions,\ + uint64_t exceptionClass,\ + struct _Unwind_Exception *exceptionObject,\ + struct _Unwind_Context *context)\ +{ + +#define CALL_PERSONALITY_FUNCTION(name) name(version, actions, exceptionClass, exceptionObject, context) + +#ifdef __cplusplus +} +#endif + +#endif /* _UNWIND_H */ Added: vendor/libcxxrt/dist/unwind.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libcxxrt/dist/unwind.h Fri Nov 25 15:46:25 2011 (r227972) @@ -0,0 +1,18 @@ +#ifndef UNWIND_H_INCLUDED +#define UNWIND_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __arm__ +#include "unwind-arm.h" +#else +#include "unwind-itanium.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif From owner-svn-src-vendor@FreeBSD.ORG Fri Nov 25 15:48:31 2011 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27D9F1065677; Fri, 25 Nov 2011 15:48:31 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1576C8FC12; Fri, 25 Nov 2011 15:48:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAPFmVH8049494; Fri, 25 Nov 2011 15:48:31 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAPFmVqs049490; Fri, 25 Nov 2011 15:48:31 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201111251548.pAPFmVqs049490@svn.freebsd.org> From: David Chisnall Date: Fri, 25 Nov 2011 15:48:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227973 - vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4 X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Nov 2011 15:48:31 -0000 Author: theraven Date: Fri Nov 25 15:48:30 2011 New Revision: 227973 URL: http://svn.freebsd.org/changeset/base/227973 Log: libcxxrt version snapshot created. Approved by: dim (mentor) Added: vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/ - copied from r227971, vendor/libcxxrt/dist/ vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/unwind-arm.h - copied unchanged from r227972, vendor/libcxxrt/dist/unwind-arm.h vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/unwind-itanium.h - copied unchanged from r227972, vendor/libcxxrt/dist/unwind-itanium.h vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/unwind.h - copied unchanged from r227972, vendor/libcxxrt/dist/unwind.h Replaced: vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/cxxabi.h - copied unchanged from r227972, vendor/libcxxrt/dist/cxxabi.h vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/dwarf_eh.h - copied unchanged from r227972, vendor/libcxxrt/dist/dwarf_eh.h vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/exception.cc - copied unchanged from r227972, vendor/libcxxrt/dist/exception.cc vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/guard.cc - copied unchanged from r227972, vendor/libcxxrt/dist/guard.cc Copied: vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/cxxabi.h (from r227972, vendor/libcxxrt/dist/cxxabi.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/cxxabi.h Fri Nov 25 15:48:30 2011 (r227973, copy of r227972, vendor/libcxxrt/dist/cxxabi.h) @@ -0,0 +1,219 @@ +#ifndef __CXXABI_H_ +#define __CXXABI_H_ +#include +#include "unwind.h" +namespace std +{ + class type_info; +} +/* + * The cxxabi.h header provides a set of public definitions for types and + * functions defined by the Itanium C++ ABI specification. For reference, see + * the ABI specification here: + * + * http://sourcery.mentor.com/public/cxx-abi/abi.html + * + * All deviations from this specification, unless otherwise noted, are + * accidental. + */ + +#ifdef __cplusplus +namespace __cxxabiv1 { +extern "C" { +#endif +/** + * Function type to call when an unexpected exception is encountered. + */ +typedef void (*unexpected_handler)(); +/** + * Function type to call when an unrecoverable condition is encountered. + */ +typedef void (*terminate_handler)(); + + +/** + * Structure used as a header on thrown exceptions. This is the same layout as + * defined by the Itanium ABI spec, so should be interoperable with any other + * implementation of this spec, such as GNU libsupc++. + * + * This structure is allocated when an exception is thrown. Unwinding happens + * in two phases, the first looks for a handler and the second installs the + * context. This structure stores a cache of the handler location between + * phase 1 and phase 2. Unfortunately, cleanup information is not cached, so + * must be looked up in both phases. This happens for two reasons. The first + * is that we don't know how many frames containing cleanups there will be, and + * we should avoid dynamic allocation during unwinding (the exception may be + * reporting that we've run out of memory). The second is that finding + * cleanups is much cheaper than finding handlers, because we don't have to + * look at the type table at all. + * + * Note: Several fields of this structure have not-very-informative names. + * These are taken from the ABI spec and have not been changed to make it + * easier for people referring to to the spec while reading this code. + */ +struct __cxa_exception +{ +#if __LP64__ + /** + * Reference count. Used to support the C++11 exception_ptr class. This + * is prepended to the structure in 64-bit mode and squeezed in to the + * padding left before the 64-bit aligned _Unwind_Exception at the end in + * 32-bit mode. + * + * Note that it is safe to extend this structure at the beginning, rather + * than the end, because the public API for creating it returns the address + * of the end (where the exception object can be stored). + */ + uintptr_t referenceCount; +#endif + /** Type info for the thrown object. */ + std::type_info *exceptionType; + /** Destructor for the object, if one exists. */ + void (*exceptionDestructor) (void *); + /** Handler called when an exception specification is violated. */ + unexpected_handler unexpectedHandler; + /** Hander called to terminate. */ + terminate_handler terminateHandler; + /** + * Next exception in the list. If an exception is thrown inside a catch + * block and caught in a nested catch, this points to the exception that + * will be handled after the inner catch block completes. + */ + __cxa_exception *nextException; + /** + * The number of handlers that currently have references to this + * exception. The top (non-sign) bit of this is used as a flag to indicate + * that the exception is being rethrown, so should not be deleted when its + * handler count reaches 0 (which it doesn't with the top bit set). + */ + int handlerCount; +#ifdef __arm__ + /** + * The ARM EH ABI requires the unwind library to keep track of exceptions + * during cleanups. These support nesting, so we need to keep a list of + * them. + */ + _Unwind_Exception *nextCleanup; + /** + * The number of cleanups that are currently being run on this exception. + */ + int cleanupCount; +#endif + /** + * The selector value to be returned when installing the catch handler. + * Used at the call site to determine which catch() block should execute. + * This is found in phase 1 of unwinding then installed in phase 2. + */ + int handlerSwitchValue; + /** + * The action record for the catch. This is cached during phase 1 + * unwinding. + */ + const char *actionRecord; + /** + * Pointer to the language-specific data area (LSDA) for the handler + * frame. This is unused in this implementation, but set for ABI + * compatibility in case we want to mix code in very weird ways. + */ + const char *languageSpecificData; + /** The cached landing pad for the catch handler.*/ + void *catchTemp; + /** + * The pointer that will be returned as the pointer to the object. When + * throwing a class and catching a virtual superclass (for example), we + * need to adjust the thrown pointer to make it all work correctly. + */ + void *adjustedPtr; +#if !__LP64__ + /** + * Reference count. Used to support the C++11 exception_ptr class. This + * is prepended to the structure in 64-bit mode and squeezed in to the + * padding left before the 64-bit aligned _Unwind_Exception at the end in + * 32-bit mode. + * + * Note that it is safe to extend this structure at the beginning, rather + * than the end, because the public API for creating it returns the address + * of the end (where the exception object can be stored) + */ + uintptr_t referenceCount; +#endif + /** The language-agnostic part of the exception header. */ + _Unwind_Exception unwindHeader; +}; + +/** + * ABI-specified globals structure. Returned by the __cxa_get_globals() + * function and its fast variant. This is a per-thread structure - every + * thread will have one lazily allocated. + * + * This structure is defined by the ABI, so may be used outside of this + * library. + */ +struct __cxa_eh_globals +{ + /** + * A linked list of exceptions that are currently caught. There may be + * several of these in nested catch() blocks. + */ + __cxa_exception *caughtExceptions; + /** + * The number of uncaught exceptions. + */ + unsigned int uncaughtExceptions; +}; +/** + * ABI function returning the __cxa_eh_globals structure. + */ +__cxa_eh_globals *__cxa_get_globals(void); +/** + * Version of __cxa_get_globals() assuming that __cxa_get_globals() has already + * been called at least once by this thread. + */ +__cxa_eh_globals *__cxa_get_globals_fast(void); + +/** + * Throws an exception returned by __cxa_current_primary_exception(). This + * exception may have been caught in another thread. + */ +void __cxa_rethrow_primary_exception(void* thrown_exception); +/** + * Returns the current exception in a form that can be stored in an + * exception_ptr object and then rethrown by a call to + * __cxa_rethrow_primary_exception(). + */ +void *__cxa_current_primary_exception(void); +/** + * Increments the reference count of an exception. Called when an + * exception_ptr is copied. + */ +void __cxa_increment_exception_refcount(void* thrown_exception); +/** + * Decrements the reference count of an exception. Called when an + * exception_ptr is deleted. + */ +void __cxa_decrement_exception_refcount(void* thrown_exception); +/** + * Demangles a C++ symbol or type name. The buffer, if non-NULL, must be + * allocated with malloc() and must be *n bytes or more long. This function + * may call realloc() on the value pointed to by buf, and will return the + * length of the string via *n. + * + * The value pointed to by status is set to one of the following: + * + * 0: success + * -1: memory allocation failure + * -2: invalid mangled name + * -3: invalid arguments + */ +char* __cxa_demangle(const char* mangled_name, + char* buf, + size_t* n, + int* status); +#ifdef __cplusplus +} // extern "C" +} // namespace + +namespace abi = __cxxabiv1; + +#endif /* __cplusplus */ +#endif /* __CXXABI_H_ */ Copied: vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/dwarf_eh.h (from r227972, vendor/libcxxrt/dist/dwarf_eh.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/dwarf_eh.h Fri Nov 25 15:48:30 2011 (r227973, copy of r227972, vendor/libcxxrt/dist/dwarf_eh.h) @@ -0,0 +1,454 @@ +/** + * dwarf_eh.h - Defines some helper functions for parsing DWARF exception + * handling tables. + * + * This file contains various helper functions that are independent of the + * language-specific code. It can be used in any personality function for the + * Itanium ABI. + */ +#include + +// TODO: Factor out Itanium / ARM differences. We probably want an itanium.h +// and arm.h that can be included by this file depending on the target ABI. + +// _GNU_SOURCE must be defined for unwind.h to expose some of the functions +// that we want. If it isn't, then we define it and undefine it to make sure +// that it doesn't impact the rest of the program. +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +# include "unwind.h" +# undef _GNU_SOURCE +#else +# include "unwind.h" +#endif + +#include + +/// Type used for pointers into DWARF data +typedef unsigned char *dw_eh_ptr_t; + +// Flag indicating a signed quantity +#define DW_EH_PE_signed 0x08 +/// DWARF data encoding types. +enum dwarf_data_encoding +{ + /// Unsigned, little-endian, base 128-encoded (variable length). + DW_EH_PE_uleb128 = 0x01, + /// Unsigned 16-bit integer. + DW_EH_PE_udata2 = 0x02, + /// Unsigned 32-bit integer. + DW_EH_PE_udata4 = 0x03, + /// Unsigned 64-bit integer. + DW_EH_PE_udata8 = 0x04, + /// Signed, little-endian, base 128-encoded (variable length) + DW_EH_PE_sleb128 = DW_EH_PE_uleb128 | DW_EH_PE_signed, + /// Signed 16-bit integer. + DW_EH_PE_sdata2 = DW_EH_PE_udata2 | DW_EH_PE_signed, + /// Signed 32-bit integer. + DW_EH_PE_sdata4 = DW_EH_PE_udata4 | DW_EH_PE_signed, + /// Signed 32-bit integer. + DW_EH_PE_sdata8 = DW_EH_PE_udata8 | DW_EH_PE_signed +}; + +/** + * Returns the encoding for a DWARF EH table entry. The encoding is stored in + * the low four of an octet. The high four bits store the addressing mode. + */ +static inline enum dwarf_data_encoding get_encoding(unsigned char x) +{ + return (enum dwarf_data_encoding)(x & 0xf); +} + +/** + * DWARF addressing mode constants. When reading a pointer value from a DWARF + * exception table, you must know how it is stored and what the addressing mode + * is. The low four bits tell you the encoding, allowing you to decode a + * number. The high four bits tell you the addressing mode, allowing you to + * turn that number into an address in memory. + */ +enum dwarf_data_relative +{ + /// Value is omitted + DW_EH_PE_omit = 0xff, + /// Absolute pointer value + DW_EH_PE_absptr = 0x00, + /// Value relative to program counter + DW_EH_PE_pcrel = 0x10, + /// Value relative to the text segment + DW_EH_PE_textrel = 0x20, + /// Value relative to the data segment + DW_EH_PE_datarel = 0x30, + /// Value relative to the start of the function + DW_EH_PE_funcrel = 0x40, + /// Aligned pointer (Not supported yet - are they actually used?) + DW_EH_PE_aligned = 0x50, + /// Pointer points to address of real value + DW_EH_PE_indirect = 0x80 +}; +/** + * Returns the addressing mode component of this encoding. + */ +static inline enum dwarf_data_relative get_base(unsigned char x) +{ + return (enum dwarf_data_relative)(x & 0x70); +} +/** + * Returns whether an encoding represents an indirect address. + */ +static int is_indirect(unsigned char x) +{ + return ((x & DW_EH_PE_indirect) == DW_EH_PE_indirect); +} + +/** + * Returns the size of a fixed-size encoding. This function will abort if + * called with a value that is not a fixed-size encoding. + */ +static inline int dwarf_size_of_fixed_size_field(unsigned char type) +{ + switch (get_encoding(type)) + { + default: abort(); + case DW_EH_PE_sdata2: + case DW_EH_PE_udata2: return 2; + case DW_EH_PE_sdata4: + case DW_EH_PE_udata4: return 4; + case DW_EH_PE_sdata8: + case DW_EH_PE_udata8: return 8; + case DW_EH_PE_absptr: return sizeof(void*); + } +} + +/** + * Read an unsigned, little-endian, base-128, DWARF value. Updates *data to + * point to the end of the value. Stores the number of bits read in the value + * pointed to by b, allowing you to determine the value of the highest bit, and + * therefore the sign of a signed value. + * + * This function is not intended to be called directly. Use read_sleb128() or + * read_uleb128() for reading signed and unsigned versions, respectively. + */ +static uint64_t read_leb128(dw_eh_ptr_t *data, int *b) +{ + uint64_t uleb = 0; + unsigned int bit = 0; + unsigned char digit = 0; + // We have to read at least one octet, and keep reading until we get to one + // with the high bit unset + do + { + // This check is a bit too strict - we should also check the highest + // bit of the digit. + assert(bit < sizeof(uint64_t) * 8); + // Get the base 128 digit + digit = (**data) & 0x7f; + // Add it to the current value + uleb += digit << bit; + // Increase the shift value + bit += 7; + // Proceed to the next octet + (*data)++; + // Terminate when we reach a value that does not have the high bit set + // (i.e. which was not modified when we mask it with 0x7f) + } while ((*(*data - 1)) != digit); + *b = bit; + + return uleb; +} + +/** + * Reads an unsigned little-endian base-128 value starting at the address + * pointed to by *data. Updates *data to point to the next byte after the end + * of the variable-length value. + */ +static int64_t read_uleb128(dw_eh_ptr_t *data) +{ + int b; + return read_leb128(data, &b); +} + +/** + * Reads a signed little-endian base-128 value starting at the address pointed + * to by *data. Updates *data to point to the next byte after the end of the + * variable-length value. + */ +static int64_t read_sleb128(dw_eh_ptr_t *data) +{ + int bits; + // Read as if it's signed + uint64_t uleb = read_leb128(data, &bits); + // If the most significant bit read is 1, then we need to sign extend it + if ((uleb >> (bits-1)) == 1) + { + // Sign extend by setting all bits in front of it to 1 + uleb |= ((int64_t)-1) << bits; + } + return (int64_t)uleb; +} +/** + * Reads a value using the specified encoding from the address pointed to by + * *data. Updates the value of *data to point to the next byte after the end + * of the data. + */ +static uint64_t read_value(char encoding, dw_eh_ptr_t *data) +{ + enum dwarf_data_encoding type = get_encoding(encoding); + uint64_t v; + switch (type) + { + // Read fixed-length types +#define READ(dwarf, type) \ + case dwarf:\ + v = (uint64_t)(*(type*)(*data));\ + *data += sizeof(type);\ + break; + READ(DW_EH_PE_udata2, uint16_t) + READ(DW_EH_PE_udata4, uint32_t) + READ(DW_EH_PE_udata8, uint64_t) + READ(DW_EH_PE_sdata2, int16_t) + READ(DW_EH_PE_sdata4, int32_t) + READ(DW_EH_PE_sdata8, int64_t) + READ(DW_EH_PE_absptr, intptr_t) +#undef READ + // Read variable-length types + case DW_EH_PE_sleb128: + v = read_sleb128(data); + break; + case DW_EH_PE_uleb128: + v = read_uleb128(data); + break; + default: abort(); + } + + return v; +} + +/** + * Resolves an indirect value. This expects an unwind context, an encoding, a + * decoded value, and the start of the region as arguments. The returned value + * is a pointer to the address identified by the encoded value. + * + * If the encoding does not specify an indirect value, then this returns v. + */ +static uint64_t resolve_indirect_value(_Unwind_Context *c, + unsigned char encoding, + int64_t v, + dw_eh_ptr_t start) +{ + switch (get_base(encoding)) + { + case DW_EH_PE_pcrel: + v += (uint64_t)start; + break; + case DW_EH_PE_textrel: + v += (uint64_t)_Unwind_GetTextRelBase(c); + break; + case DW_EH_PE_datarel: + v += (uint64_t)_Unwind_GetDataRelBase(c); + break; + case DW_EH_PE_funcrel: + v += (uint64_t)_Unwind_GetRegionStart(c); + default: + break; + } + // If this is an indirect value, then it is really the address of the real + // value + // TODO: Check whether this should really always be a pointer - it seems to + // be a GCC extensions, so not properly documented... + if (is_indirect(encoding)) + { + v = (uint64_t)(uintptr_t)*(void**)v; + } + return v; +} + + +/** + * Reads an encoding and a value, updating *data to point to the next byte. + */ +static inline void read_value_with_encoding(_Unwind_Context *context, + dw_eh_ptr_t *data, + uint64_t *out) +{ + dw_eh_ptr_t start = *data; + unsigned char encoding = *((*data)++); + // If this value is omitted, skip it and don't touch the output value + if (encoding == DW_EH_PE_omit) { return; } + + *out = read_value(encoding, data); + *out = resolve_indirect_value(context, encoding, *out, start); +} + +/** + * Structure storing a decoded language-specific data area. Use parse_lsda() + * to generate an instance of this structure from the address returned by the + * generic unwind library. + * + * You should not need to inspect the fields of this structure directly if you + * are just using this header. The structure stores the locations of the + * various tables used for unwinding exceptions and is used by the functions + * for reading values from these tables. + */ +struct dwarf_eh_lsda +{ + /// The start of the region. This is a cache of the value returned by + /// _Unwind_GetRegionStart(). + dw_eh_ptr_t region_start; + /// The start of the landing pads table. + dw_eh_ptr_t landing_pads; + /// The start of the type table. + dw_eh_ptr_t type_table; + /// The encoding used for entries in the type tables. + unsigned char type_table_encoding; + /// The location of the call-site table. + dw_eh_ptr_t call_site_table; + /// The location of the action table. + dw_eh_ptr_t action_table; + /// The encoding used for entries in the call-site table. + unsigned char callsite_encoding; +}; + +/** + * Parse the header on the language-specific data area and return a structure + * containing the addresses and encodings of the various tables. + */ +static inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context, + unsigned char *data) +{ + struct dwarf_eh_lsda lsda; + + lsda.region_start = (dw_eh_ptr_t)(uintptr_t)_Unwind_GetRegionStart(context); + + // If the landing pads are relative to anything other than the start of + // this region, find out where. This is @LPStart in the spec, although the + // encoding that GCC uses does not quite match the spec. + uint64_t v = (uint64_t)(uintptr_t)lsda.region_start; + read_value_with_encoding(context, &data, &v); + lsda.landing_pads = (dw_eh_ptr_t)(uintptr_t)v; + + // If there is a type table, find out where it is. This is @TTBase in the + // spec. Note: we find whether there is a type table pointer by checking + // whether the leading byte is DW_EH_PE_omit (0xff), which is not what the + // spec says, but does seem to be how G++ indicates this. + lsda.type_table = 0; + lsda.type_table_encoding = *data++; + if (lsda.type_table_encoding != DW_EH_PE_omit) + { + v = read_uleb128(&data); + dw_eh_ptr_t type_table = data; + type_table += v; + lsda.type_table = type_table; + //lsda.type_table = (uintptr_t*)(data + v); + } +#if __arm__ + lsda.type_table_encoding = (DW_EH_PE_pcrel | DW_EH_PE_indirect); +#endif + + lsda.callsite_encoding = (enum dwarf_data_encoding)(*(data++)); + + // Action table is immediately after the call site table + lsda.action_table = data; + uintptr_t callsite_size = (uintptr_t)read_uleb128(&data); + lsda.action_table = data + callsite_size; + // Call site table is immediately after the header + lsda.call_site_table = (dw_eh_ptr_t)data; + + + return lsda; +} + +/** + * Structure representing an action to be performed while unwinding. This + * contains the address that should be unwound to and the action record that + * provoked this action. + */ +struct dwarf_eh_action +{ + /** + * The address that this action directs should be the new program counter + * value after unwinding. + */ + dw_eh_ptr_t landing_pad; + /// The address of the action record. + dw_eh_ptr_t action_record; +}; + +/** + * Look up the landing pad that corresponds to the current invoke. + * Returns true if record exists. The context is provided by the generic + * unwind library and the lsda should be the result of a call to parse_lsda(). + * + * The action record is returned via the result parameter. + */ +static bool dwarf_eh_find_callsite(struct _Unwind_Context *context, + struct dwarf_eh_lsda *lsda, + struct dwarf_eh_action *result) +{ + result->action_record = 0; + result->landing_pad = 0; + // The current instruction pointer offset within the region + uint64_t ip = _Unwind_GetIP(context) - _Unwind_GetRegionStart(context); + unsigned char *callsite_table = (unsigned char*)lsda->call_site_table; + + while (callsite_table <= lsda->action_table) + { + // Once again, the layout deviates from the spec. + uint64_t call_site_start, call_site_size, landing_pad, action; + call_site_start = read_value(lsda->callsite_encoding, &callsite_table); + call_site_size = read_value(lsda->callsite_encoding, &callsite_table); + + // Call site entries are sorted, so if we find a call site that's after + // the current instruction pointer then there is no action associated + // with this call and we should unwind straight through this frame + // without doing anything. + if (call_site_start > ip) { break; } + + // Read the address of the landing pad and the action from the call + // site table. + landing_pad = read_value(lsda->callsite_encoding, &callsite_table); + action = read_uleb128(&callsite_table); + + // We should not include the call_site_start (beginning of the region) + // address in the ip range. For each call site: + // + // address1: call proc + // address2: next instruction + // + // The call stack contains address2 and not address1, address1 can be + // at the end of another EH region. + if (call_site_start < ip && ip <= call_site_start + call_site_size) + { + if (action) + { + // Action records are 1-biased so both no-record and zeroth + // record can be stored. + result->action_record = lsda->action_table + action - 1; + } + // No landing pad means keep unwinding. + if (landing_pad) + { + // Landing pad is the offset from the value in the header + result->landing_pad = lsda->landing_pads + landing_pad; + } + return true; + } + } + return false; +} + +/// Defines an exception class from 8 bytes (endian independent) +#define EXCEPTION_CLASS(a,b,c,d,e,f,g,h) \ + (((uint64_t)a << 56) +\ + ((uint64_t)b << 48) +\ + ((uint64_t)c << 40) +\ + ((uint64_t)d << 32) +\ + ((uint64_t)e << 24) +\ + ((uint64_t)f << 16) +\ + ((uint64_t)g << 8) +\ + ((uint64_t)h)) + +#define GENERIC_EXCEPTION_CLASS(e,f,g,h) \ + ((uint32_t)e << 24) +\ + ((uint32_t)f << 16) +\ + ((uint32_t)g << 8) +\ + ((uint32_t)h) Copied: vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/exception.cc (from r227972, vendor/libcxxrt/dist/exception.cc) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libcxxrt/1be67aa8295314fb794c4e933d9bb7c7c33e0ca4/exception.cc Fri Nov 25 15:48:30 2011 (r227973, copy of r227972, vendor/libcxxrt/dist/exception.cc) @@ -0,0 +1,1421 @@ +#include +#include +#include +#include +#include +#include +#include "typeinfo.h" +#include "dwarf_eh.h" +#include "cxxabi.h" + +using namespace ABI_NAMESPACE; + +/** + * Saves the result of the landing pad that we have found. For ARM, this is + * stored in the generic unwind structure, while on other platforms it is + * stored in the C++ exception. + */ +static void saveLandingPad(struct _Unwind_Context *context, + struct _Unwind_Exception *ucb, + struct __cxa_exception *ex, + int selector, + dw_eh_ptr_t landingPad) +{ +#ifdef __arm__ + // On ARM, we store the saved exception in the generic part of the structure + ucb->barrier_cache.sp = _Unwind_GetGR(context, 13); + ucb->barrier_cache.bitpattern[1] = (uint32_t)selector; + ucb->barrier_cache.bitpattern[3] = (uint32_t)landingPad; +#endif + // Cache the results for the phase 2 unwind, if we found a handler + // and this is not a foreign exception. + if (ex) + { + ex->handlerSwitchValue = selector; + ex->catchTemp = landingPad; + } +} + +/** + * Loads the saved landing pad. Returns 1 on success, 0 on failure. + */ +static int loadLandingPad(struct _Unwind_Context *context, + struct _Unwind_Exception *ucb, + struct __cxa_exception *ex, + unsigned long *selector, + dw_eh_ptr_t *landingPad) +{ +#ifdef __arm__ + *selector = ucb->barrier_cache.bitpattern[1]; + *landingPad = (dw_eh_ptr_t)ucb->barrier_cache.bitpattern[3]; + return 1; +#else + if (ex) + { + *selector = ex->handlerSwitchValue; + *landingPad = (dw_eh_ptr_t)ex->catchTemp; + return 0; + } + return 0; +#endif +} + +static inline _Unwind_Reason_Code continueUnwinding(struct _Unwind_Exception *ex, + struct _Unwind_Context *context) +{ +#ifdef __arm__ + if (__gnu_unwind_frame(ex, context) != _URC_OK) { return _URC_FAILURE; } +#endif + return _URC_CONTINUE_UNWIND; +} + + +extern "C" void __cxa_free_exception(void *thrown_exception); +extern "C" void __cxa_free_dependent_exception(void *thrown_exception); +extern "C" void* __dynamic_cast(const void *sub, + const __class_type_info *src, + const __class_type_info *dst, + ptrdiff_t src2dst_offset); + +/** + * The type of a handler that has been found. + */ +typedef enum +{ + /** No handler. */ + handler_none, + /** + * A cleanup - the exception will propagate through this frame, but code + * must be run when this happens. + */ + handler_cleanup, + /** + * A catch statement. The exception will not propagate past this frame + * (without an explicit rethrow). + */ + handler_catch +} handler_type; + +/** + * Per-thread info required by the runtime. We store a single structure + * pointer in thread-local storage, because this tends to be a scarce resource + * and it's impolite to steal all of it and not leave any for the rest of the + * program. + * + * Instances of this structure are allocated lazily - at most one per thread - + * and are destroyed on thread termination. + */ +struct __cxa_thread_info +{ + /** The termination handler for this thread. */ + terminate_handler terminateHandler; + /** The unexpected exception handler for this thread. */ + unexpected_handler unexpectedHandler; + /** + * The number of emergency buffers held by this thread. This is 0 in + * normal operation - the emergency buffers are only used when malloc() + * fails to return memory for allocating an exception. Threads are not + * permitted to hold more than 4 emergency buffers (as per recommendation + * in ABI spec [3.3.1]). + */ + int emergencyBuffersHeld; + /** + * The exception currently running in a cleanup. + */ + _Unwind_Exception *currentCleanup; + /** + * The public part of this structure, accessible from outside of this + * module. + */ + __cxa_eh_globals globals; +}; +/** + * Dependent exception. This + */ +struct __cxa_dependent_exception +{ +#if __LP64__ + void *primaryException; +#endif + std::type_info *exceptionType; + void (*exceptionDestructor) (void *); + unexpected_handler unexpectedHandler; + terminate_handler terminateHandler; + __cxa_exception *nextException; + int handlerCount; +#ifdef __arm__ + _Unwind_Exception *nextCleanup; + int cleanupCount; +#endif + int handlerSwitchValue; + const char *actionRecord; + const char *languageSpecificData; + void *catchTemp; + void *adjustedPtr; +#if !__LP64__ + void *primaryException; +#endif + _Unwind_Exception unwindHeader; +}; + + +namespace std +{ + void unexpected(); + class exception + { + public: + virtual ~exception() throw(); + virtual const char* what() const throw(); + }; + +} + +extern "C" std::type_info *__cxa_current_exception_type(); + +/** + * Class of exceptions to distinguish between this and other exception types. + * + * The first four characters are the vendor ID. Currently, we use GNUC, + * because we aim for ABI-compatibility with the GNU implementation, and + * various checks may test for equality of the class, which is incorrect. + */ +static const uint64_t exception_class = + EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\0'); +/** + * Class used for dependent exceptions. + */ +static const uint64_t dependent_exception_class = + EXCEPTION_CLASS('G', 'N', 'U', 'C', 'C', '+', '+', '\x01'); +/** + * The low four bytes of the exception class, indicating that we conform to the + * Itanium C++ ABI. This is currently unused, but should be used in the future + * if we change our exception class, to allow this library and libsupc++ to be + * linked to the same executable and both to interoperate. + */ +static const uint32_t abi_exception_class = + GENERIC_EXCEPTION_CLASS('C', '+', '+', '\0'); + +static bool isCXXException(uint64_t cls) +{ + return (cls == exception_class) || (cls == dependent_exception_class); +} + +static bool isDependentException(uint64_t cls) +{ + return cls == dependent_exception_class; +} + +static __cxa_exception *exceptionFromPointer(void *ex) +{ + return (__cxa_exception*)((char*)ex - + offsetof(struct __cxa_exception, unwindHeader)); +} +static __cxa_exception *realExceptionFromException(__cxa_exception *ex) +{ + if (!isDependentException(ex->unwindHeader.exception_class)) { return ex; } + return ((__cxa_exception*)(((__cxa_dependent_exception*)ex)->primaryException))-1; +} + + +namespace std +{ + // Forward declaration of standard library terminate() function used to + // abort execution. + void terminate(void); +} + +using namespace ABI_NAMESPACE; + + + +/** The global termination handler. */ +static terminate_handler terminateHandler = abort; +/** The global unexpected exception handler. */ +static unexpected_handler unexpectedHandler = std::terminate; + +/** Key used for thread-local data. */ +static pthread_key_t eh_key; + + +/** + * Cleanup function, allowing foreign exception handlers to correctly destroy + * this exception if they catch it. + */ +static void exception_cleanup(_Unwind_Reason_Code reason, + struct _Unwind_Exception *ex) +{ + __cxa_free_exception((void*)ex); +} +static void dependent_exception_cleanup(_Unwind_Reason_Code reason, + struct _Unwind_Exception *ex) +{ + + __cxa_free_dependent_exception((void*)ex); +} + +/** + * Recursively walk a list of exceptions and delete them all in post-order. + */ +static void free_exception_list(__cxa_exception *ex) +{ + if (0 != ex->nextException) + { + free_exception_list(ex->nextException); + } + // __cxa_free_exception() expects to be passed the thrown object, which + // immediately follows the exception, not the exception itself + __cxa_free_exception(ex+1); +} + +/** + * Cleanup function called when a thread exists to make certain that all of the + * per-thread data is deleted. + */ +static void thread_cleanup(void* thread_info) +{ + __cxa_thread_info *info = (__cxa_thread_info*)thread_info; + if (info->globals.caughtExceptions) + { + free_exception_list(info->globals.caughtExceptions); + } + free(thread_info); +} + + +/** + * Once control used to protect the key creation. + */ +static pthread_once_t once_control = PTHREAD_ONCE_INIT; + +/** + * Initialise eh_key. + */ +static void init_key(void) +{ + pthread_key_create(&eh_key, thread_cleanup); +} + +/** + * Returns the thread info structure, creating it if it is not already created. + */ +static __cxa_thread_info *thread_info() +{ + pthread_once(&once_control, init_key); + __cxa_thread_info *info = (__cxa_thread_info*)pthread_getspecific(eh_key); + if (0 == info) + { + info = (__cxa_thread_info*)calloc(1, sizeof(__cxa_thread_info)); + pthread_setspecific(eh_key, info); + } + return info; +} +/** + * Fast version of thread_info(). May fail if thread_info() is not called on + * this thread at least once already. + */ +static __cxa_thread_info *thread_info_fast() +{ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-vendor@FreeBSD.ORG Sat Nov 26 14:18:40 2011 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24E6B106575B; Sat, 26 Nov 2011 14:18:40 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 131778FC1B; Sat, 26 Nov 2011 14:18:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAQEIdM7094700; Sat, 26 Nov 2011 14:18:39 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAQEIdAB094697; Sat, 26 Nov 2011 14:18:39 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201111261418.pAQEIdAB094697@svn.freebsd.org> From: David Chisnall Date: Sat, 26 Nov 2011 14:18:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227995 - vendor/libcxxrt/dist X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Nov 2011 14:18:40 -0000 Author: theraven Date: Sat Nov 26 14:18:39 2011 New Revision: 227995 URL: http://svn.freebsd.org/changeset/base/227995 Log: Imported the latest version of libcxxrt. Approved by: dim (mentor) Added: vendor/libcxxrt/dist/LICENSE Modified: vendor/libcxxrt/dist/exception.cc vendor/libcxxrt/dist/memory.cc Added: vendor/libcxxrt/dist/LICENSE ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libcxxrt/dist/LICENSE Sat Nov 26 14:18:39 2011 (r227995) @@ -0,0 +1,14 @@ +The BSD License + +Copyright 2010-2011 PathScale, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of PathScale, Inc. Modified: vendor/libcxxrt/dist/exception.cc ============================================================================== --- vendor/libcxxrt/dist/exception.cc Sat Nov 26 14:17:58 2011 (r227994) +++ vendor/libcxxrt/dist/exception.cc Sat Nov 26 14:18:39 2011 (r227995) @@ -8,6 +8,17 @@ #include "dwarf_eh.h" #include "cxxabi.h" +#pragma weak pthread_key_create +#pragma weak pthread_setspecific +#pragma weak pthread_getspecific +#pragma weak pthread_once +#pragma weak pthread_once +#pragma weak pthread_cond_signal +#pragma weak pthread_cond_wait +#pragma weak pthread_mutex_lock +#pragma weak pthread_mutex_unlock + + using namespace ABI_NAMESPACE; /** @@ -289,11 +300,31 @@ static void thread_cleanup(void* thread_ static pthread_once_t once_control = PTHREAD_ONCE_INIT; /** + * We may not be linked against a full pthread implementation. If we're not, + * then we need to fake the thread-local storage by storing 'thread-local' + * things in a global. + */ +static bool fakeTLS; +/** + * Thread-local storage for a single-threaded program. + */ +static __cxa_thread_info singleThreadInfo; +/** * Initialise eh_key. */ static void init_key(void) { + if ((0 == pthread_key_create) || + (0 == pthread_setspecific) || + (0 == pthread_getspecific)) + { + fakeTLS = true; + return; + } pthread_key_create(&eh_key, thread_cleanup); + pthread_setspecific(eh_key, (void*)0x42); + fakeTLS = (pthread_getspecific(eh_key) != (void*)0x42); + pthread_setspecific(eh_key, 0); } /** @@ -301,7 +332,11 @@ static void init_key(void) */ static __cxa_thread_info *thread_info() { - pthread_once(&once_control, init_key); + if ((0 == pthread_once) || pthread_once(&once_control, init_key)) + { + fakeTLS = true; + } + if (fakeTLS) { return &singleThreadInfo; } __cxa_thread_info *info = (__cxa_thread_info*)pthread_getspecific(eh_key); if (0 == info) { @@ -316,6 +351,7 @@ static __cxa_thread_info *thread_info() */ static __cxa_thread_info *thread_info_fast() { + if (fakeTLS) { return &singleThreadInfo; } return (__cxa_thread_info*)pthread_getspecific(eh_key); } /** @@ -367,7 +403,10 @@ static char *emergency_malloc(size_t siz // Only 4 emergency buffers allowed per thread! if (info->emergencyBuffersHeld > 3) { return 0; } - pthread_mutex_lock(&emergency_malloc_lock); + if (pthread_mutex_lock) + { + pthread_mutex_lock(&emergency_malloc_lock); + } int buffer = -1; while (buffer < 0) { @@ -378,7 +417,10 @@ static char *emergency_malloc(size_t siz void *m = calloc(1, size); if (0 != m) { - pthread_mutex_unlock(&emergency_malloc_lock); + if (pthread_mutex_unlock) + { + pthread_mutex_unlock(&emergency_malloc_lock); + } return (char*)m; } for (int i=0 ; i<16 ; i++) @@ -395,10 +437,24 @@ static char *emergency_malloc(size_t siz // of the emergency buffers. if (buffer < 0) { + // If we don't have pthread_cond_wait, then there is only one + // thread and it's already used all of the emergency buffers, so we + // have no alternative but to die. Calling abort() instead of + // terminate, because terminate can throw exceptions, which can + // bring us back here and infinite loop. + if (!pthread_cond_wait) + { + fputs("Terminating while out of memory trying to throw an exception", + stderr); + abort(); + } pthread_cond_wait(&emergency_malloc_wait, &emergency_malloc_lock); } } - pthread_mutex_unlock(&emergency_malloc_lock); + if (pthread_mutex_unlock) + { + pthread_mutex_unlock(&emergency_malloc_lock); + } info->emergencyBuffersHeld++; return emergency_buffer + (1024 * buffer); } @@ -431,13 +487,19 @@ static void emergency_malloc_free(char * memset((void*)ptr, 0, 1024); // Signal the condition variable to wake up any threads that are blocking // waiting for some space in the emergency buffer - pthread_mutex_lock(&emergency_malloc_lock); + if (pthread_mutex_lock) + { + pthread_mutex_lock(&emergency_malloc_lock); + } // In theory, we don't need to do this with the lock held. In practice, // our array of bools will probably be updated using 32-bit or 64-bit // memory operations, so this update may clobber adjacent values. buffer_allocated[buffer] = false; - pthread_cond_signal(&emergency_malloc_wait); - pthread_mutex_unlock(&emergency_malloc_lock); + if (pthread_cond_signal && pthread_mutex_unlock) + { + pthread_cond_signal(&emergency_malloc_wait); + pthread_mutex_unlock(&emergency_malloc_lock); + } } static char *alloc_or_die(size_t size) Modified: vendor/libcxxrt/dist/memory.cc ============================================================================== --- vendor/libcxxrt/dist/memory.cc Sat Nov 26 14:17:58 2011 (r227994) +++ vendor/libcxxrt/dist/memory.cc Sat Nov 26 14:18:39 2011 (r227995) @@ -11,6 +11,10 @@ #include #include "stdexcept.h" +#if !__has_builtin(__sync_swap) +#define __sync_swap __sync_lock_test_and_set +#endif + namespace std { struct nothrow_t {}; @@ -33,7 +37,7 @@ namespace std __attribute__((weak)) new_handler set_new_handler(new_handler handler) { - return __sync_lock_test_and_set(&new_handl, handler); + return __sync_swap(&new_handl, handler); } } @@ -103,7 +107,7 @@ void * operator new[](size_t size) __attribute__((weak)) -void operator delete[](void * ptr) +void operator delete[](void * ptr) throw() { ::operator delete(ptr); } From owner-svn-src-vendor@FreeBSD.ORG Sat Nov 26 14:20:35 2011 Return-Path: Delivered-To: svn-src-vendor@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D210106564A; Sat, 26 Nov 2011 14:20:35 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 331A48FC0A; Sat, 26 Nov 2011 14:20:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pAQEKZh0094829; Sat, 26 Nov 2011 14:20:35 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pAQEKYKu094828; Sat, 26 Nov 2011 14:20:34 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201111261420.pAQEKYKu094828@svn.freebsd.org> From: David Chisnall Date: Sat, 26 Nov 2011 14:20:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227997 - vendor/libcxxrt/8931d9e5180830a5433d16ae6b3ad8dd9e629512 X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Nov 2011 14:20:35 -0000 Author: theraven Date: Sat Nov 26 14:20:34 2011 New Revision: 227997 URL: http://svn.freebsd.org/changeset/base/227997 Log: Versioned snapshot for libcxxrt Approved by: dim (mentor) Added: vendor/libcxxrt/8931d9e5180830a5433d16ae6b3ad8dd9e629512/ - copied from r227996, vendor/libcxxrt/dist/