Index: projects/clang350-import/contrib/libc++/include/type_traits =================================================================== --- projects/clang350-import/contrib/libc++/include/type_traits (revision 275366) +++ projects/clang350-import/contrib/libc++/include/type_traits (revision 275367) @@ -1,3292 +1,3344 @@ // -*- C++ -*- //===------------------------ type_traits ---------------------------------===// // // 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_TYPE_TRAITS #define _LIBCPP_TYPE_TRAITS /* type_traits synopsis namespace std { // helper class: template struct integral_constant; typedef integral_constant true_type; typedef integral_constant false_type; // helper traits template struct enable_if; template struct conditional; // Primary classification traits: template struct is_void; template struct is_null_pointer; // C++14 template struct is_integral; template struct is_floating_point; template struct is_array; template struct is_pointer; template struct is_lvalue_reference; template struct is_rvalue_reference; template struct is_member_object_pointer; template struct is_member_function_pointer; template struct is_enum; template struct is_union; template struct is_class; template struct is_function; // Secondary classification traits: template struct is_reference; template struct is_arithmetic; template struct is_fundamental; template struct is_member_pointer; template struct is_scalar; template struct is_object; template struct is_compound; // Const-volatile properties and transformations: template struct is_const; template struct is_volatile; template struct remove_const; template struct remove_volatile; template struct remove_cv; template struct add_const; template struct add_volatile; template struct add_cv; // Reference transformations: template struct remove_reference; template struct add_lvalue_reference; template struct add_rvalue_reference; // Pointer transformations: template struct remove_pointer; template struct add_pointer; // Integral properties: template struct is_signed; template struct is_unsigned; template struct make_signed; template struct make_unsigned; // Array properties and transformations: template struct rank; template struct extent; template struct remove_extent; template struct remove_all_extents; // Member introspection: template struct is_pod; template struct is_trivial; template struct is_trivially_copyable; template struct is_standard_layout; template struct is_literal_type; template struct is_empty; template struct is_polymorphic; template struct is_abstract; template struct is_constructible; template struct is_default_constructible; template struct is_copy_constructible; template struct is_move_constructible; template struct is_assignable; template struct is_copy_assignable; template struct is_move_assignable; template struct is_destructible; template struct is_trivially_constructible; template struct is_trivially_default_constructible; template struct is_trivially_copy_constructible; template struct is_trivially_move_constructible; template struct is_trivially_assignable; template struct is_trivially_copy_assignable; template struct is_trivially_move_assignable; template struct is_trivially_destructible; template struct is_nothrow_constructible; template struct is_nothrow_default_constructible; template struct is_nothrow_copy_constructible; template struct is_nothrow_move_constructible; template struct is_nothrow_assignable; template struct is_nothrow_copy_assignable; template struct is_nothrow_move_assignable; template struct is_nothrow_destructible; template struct has_virtual_destructor; // Relationships between types: template struct is_same; template struct is_base_of; template struct is_convertible; // Alignment properties and transformations: template struct alignment_of; template struct aligned_storage; template struct aligned_union; template struct decay; template struct common_type; template struct underlying_type; template class result_of; // undefined template class result_of; // const-volatile modifications: template using remove_const_t = typename remove_const::type; // C++14 template using remove_volatile_t = typename remove_volatile::type; // C++14 template using remove_cv_t = typename remove_cv::type; // C++14 template using add_const_t = typename add_const::type; // C++14 template using add_volatile_t = typename add_volatile::type; // C++14 template using add_cv_t = typename add_cv::type; // C++14 // reference modifications: template using remove_reference_t = typename remove_reference::type; // C++14 template using add_lvalue_reference_t = typename add_lvalue_reference::type; // C++14 template using add_rvalue_reference_t = typename add_rvalue_reference::type; // C++14 // sign modifications: template using make_signed_t = typename make_signed::type; // C++14 template using make_unsigned_t = typename make_unsigned::type; // C++14 // array modifications: template using remove_extent_t = typename remove_extent::type; // C++14 template using remove_all_extents_t = typename remove_all_extents::type; // C++14 // pointer modifications: template using remove_pointer_t = typename remove_pointer::type; // C++14 template using add_pointer_t = typename add_pointer::type; // C++14 // other transformations: template using aligned_storage_t = typename aligned_storage::type; // C++14 template using aligned_union_t = typename aligned_union::type; // C++14 template using decay_t = typename decay::type; // C++14 template using enable_if_t = typename enable_if::type; // C++14 template using conditional_t = typename conditional::type; // C++14 template using common_type_t = typename common_type::type; // C++14 template using underlying_type_t = typename underlying_type::type; // C++14 template using result_of_t = typename result_of::type; // C++14 } // std */ #include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;}; template struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _Then type;}; #if _LIBCPP_STD_VER > 11 template using conditional_t = typename conditional<_Bp, _If, _Then>::type; #endif template struct _LIBCPP_TYPE_VIS_ONLY enable_if {}; template struct _LIBCPP_TYPE_VIS_ONLY enable_if {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using enable_if_t = typename enable_if<_Bp, _Tp>::type; #endif struct __two {char __lx[2];}; // helper class: template struct _LIBCPP_TYPE_VIS_ONLY integral_constant { static _LIBCPP_CONSTEXPR const _Tp value = __v; typedef _Tp value_type; typedef integral_constant type; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator value_type() const {return value;} #if _LIBCPP_STD_VER > 11 _LIBCPP_INLINE_VISIBILITY constexpr value_type operator ()() const {return value;} #endif }; template _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; typedef integral_constant true_type; typedef integral_constant false_type; // is_const template struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {}; // is_volatile template struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {}; // remove_const template struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_const_t = typename remove_const<_Tp>::type; #endif // remove_volatile template struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_volatile_t = typename remove_volatile<_Tp>::type; #endif // remove_cv template struct _LIBCPP_TYPE_VIS_ONLY remove_cv {typedef typename remove_volatile::type>::type type;}; #if _LIBCPP_STD_VER > 11 template using remove_cv_t = typename remove_cv<_Tp>::type; #endif // is_void template struct __libcpp_is_void : public false_type {}; template <> struct __libcpp_is_void : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_void : public __libcpp_is_void::type> {}; // __is_nullptr_t template struct __libcpp___is_nullptr : public false_type {}; template <> struct __libcpp___is_nullptr : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t : public __libcpp___is_nullptr::type> {}; #if _LIBCPP_STD_VER > 11 template struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer : public __libcpp___is_nullptr::type> {}; #endif // is_integral template struct __libcpp_is_integral : public false_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template <> struct __libcpp_is_integral : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_integral : public __libcpp_is_integral::type> {}; // is_floating_point template struct __libcpp_is_floating_point : public false_type {}; template <> struct __libcpp_is_floating_point : public true_type {}; template <> struct __libcpp_is_floating_point : public true_type {}; template <> struct __libcpp_is_floating_point : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_floating_point : public __libcpp_is_floating_point::type> {}; // is_array template struct _LIBCPP_TYPE_VIS_ONLY is_array : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]> : public true_type {}; // is_pointer template struct __libcpp_is_pointer : public false_type {}; template struct __libcpp_is_pointer<_Tp*> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_pointer : public __libcpp_is_pointer::type> {}; // is_reference template struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {}; #endif template struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; #endif #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) #define _LIBCPP_HAS_TYPE_TRAITS #endif // is_union #if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY is_union : public integral_constant {}; #else template struct __libcpp_union : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_union : public __libcpp_union::type> {}; #endif // is_class #if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY is_class : public integral_constant {}; #else namespace __is_class_imp { template char __test(int _Tp::*); template __two __test(...); } template struct _LIBCPP_TYPE_VIS_ONLY is_class : public integral_constant(0)) == 1 && !is_union<_Tp>::value> {}; #endif // is_same template struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {}; // is_function namespace __is_function_imp { template char __test(_Tp*); template __two __test(...); template _Tp& __source(); } template ::value || is_union<_Tp>::value || is_void<_Tp>::value || is_reference<_Tp>::value || __is_nullptr_t<_Tp>::value > struct __libcpp_is_function : public integral_constant(__is_function_imp::__source<_Tp>())) == 1> {}; template struct __libcpp_is_function<_Tp, true> : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_function : public __libcpp_is_function<_Tp> {}; // is_member_function_pointer -template struct __libcpp_is_member_function_pointer : public false_type {}; -template struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; +// template struct __libcpp_is_member_function_pointer : public false_type {}; +// template struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; +// +template +struct __member_pointer_traits_imp +{ // forward declaration; specializations later +}; + + +namespace __libcpp_is_member_function_pointer_imp { + template + char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *); + + template + std::__two __test(...); +}; + +template struct __libcpp_is_member_function_pointer + : public integral_constant(nullptr)) == 1> {}; + template struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer : public __libcpp_is_member_function_pointer::type> {}; // is_member_pointer template struct __libcpp_is_member_pointer : public false_type {}; template struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer : public __libcpp_is_member_pointer::type> {}; // is_member_object_pointer template struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer : public integral_constant::value && !is_member_function_pointer<_Tp>::value> {}; // is_enum #if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY is_enum : public integral_constant {}; #else template struct _LIBCPP_TYPE_VIS_ONLY is_enum : public integral_constant::value && !is_integral<_Tp>::value && !is_floating_point<_Tp>::value && !is_array<_Tp>::value && !is_pointer<_Tp>::value && !is_reference<_Tp>::value && !is_member_pointer<_Tp>::value && !is_union<_Tp>::value && !is_class<_Tp>::value && !is_function<_Tp>::value > {}; #endif // is_arithmetic template struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic : public integral_constant::value || is_floating_point<_Tp>::value> {}; // is_fundamental template struct _LIBCPP_TYPE_VIS_ONLY is_fundamental : public integral_constant::value || __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; // is_scalar template struct _LIBCPP_TYPE_VIS_ONLY is_scalar : public integral_constant::value || is_member_pointer<_Tp>::value || is_pointer<_Tp>::value || __is_nullptr_t<_Tp>::value || is_enum<_Tp>::value > {}; template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar : public true_type {}; // is_object template struct _LIBCPP_TYPE_VIS_ONLY is_object : public integral_constant::value || is_array<_Tp>::value || is_union<_Tp>::value || is_class<_Tp>::value > {}; // is_compound template struct _LIBCPP_TYPE_VIS_ONLY is_compound : public integral_constant::value> {}; // add_const template ::value || is_function<_Tp>::value || is_const<_Tp>::value > struct __add_const {typedef _Tp type;}; template struct __add_const<_Tp, false> {typedef const _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY add_const {typedef typename __add_const<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 template using add_const_t = typename add_const<_Tp>::type; #endif // add_volatile template ::value || is_function<_Tp>::value || is_volatile<_Tp>::value > struct __add_volatile {typedef _Tp type;}; template struct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY add_volatile {typedef typename __add_volatile<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 template using add_volatile_t = typename add_volatile<_Tp>::type; #endif // add_cv template struct _LIBCPP_TYPE_VIS_ONLY add_cv {typedef typename add_const::type>::type type;}; #if _LIBCPP_STD_VER > 11 template using add_cv_t = typename add_cv<_Tp>::type; #endif // remove_reference template struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;}; #endif #if _LIBCPP_STD_VER > 11 template using remove_reference_t = typename remove_reference<_Tp>::type; #endif // add_lvalue_reference template struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;}; template struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef const void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef volatile void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef const volatile void type;}; #if _LIBCPP_STD_VER > 11 template using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; #endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef const void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef volatile void type;}; template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef const volatile void type;}; #if _LIBCPP_STD_VER > 11 template using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename add_rvalue_reference<_Tp>::type declval() _NOEXCEPT; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template typename add_lvalue_reference<_Tp>::type declval(); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES struct __any { __any(...); }; // remove_pointer template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_pointer_t = typename remove_pointer<_Tp>::type; #endif // add_pointer template struct _LIBCPP_TYPE_VIS_ONLY add_pointer {typedef typename remove_reference<_Tp>::type* type;}; #if _LIBCPP_STD_VER > 11 template using add_pointer_t = typename add_pointer<_Tp>::type; #endif // is_signed template ::value> struct ___is_signed : public integral_constant {}; template struct ___is_signed<_Tp, false> : public true_type {}; // floating point template ::value> struct __libcpp_is_signed : public ___is_signed<_Tp> {}; template struct __libcpp_is_signed<_Tp, false> : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {}; // is_unsigned template ::value> struct ___is_unsigned : public integral_constant {}; template struct ___is_unsigned<_Tp, false> : public false_type {}; // floating point template ::value> struct __libcpp_is_unsigned : public ___is_unsigned<_Tp> {}; template struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {}; // rank template struct _LIBCPP_TYPE_VIS_ONLY rank : public integral_constant {}; template struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]> : public integral_constant::value + 1> {}; template struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]> : public integral_constant::value + 1> {}; // extent template struct _LIBCPP_TYPE_VIS_ONLY extent : public integral_constant {}; template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0> : public integral_constant {}; template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip> : public integral_constant::value> {}; template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0> : public integral_constant {}; template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip> : public integral_constant::value> {}; // remove_extent template struct _LIBCPP_TYPE_VIS_ONLY remove_extent {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]> {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template using remove_extent_t = typename remove_extent<_Tp>::type; #endif // remove_all_extents template struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents {typedef _Tp type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]> {typedef typename remove_all_extents<_Tp>::type type;}; template struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]> {typedef typename remove_all_extents<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 template using remove_all_extents_t = typename remove_all_extents<_Tp>::type; #endif // decay template struct _LIBCPP_TYPE_VIS_ONLY decay { private: typedef typename remove_reference<_Tp>::type _Up; public: typedef typename conditional < is_array<_Up>::value, typename remove_extent<_Up>::type*, typename conditional < is_function<_Up>::value, typename add_pointer<_Up>::type, typename remove_cv<_Up>::type >::type >::type type; }; #if _LIBCPP_STD_VER > 11 template using decay_t = typename decay<_Tp>::type; #endif // is_abstract namespace __is_abstract_imp { template char __test(_Tp (*)[1]); template __two __test(...); } template ::value> struct __libcpp_abstract : public integral_constant(0)) != 1> {}; template struct __libcpp_abstract<_Tp, false> : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; // is_base_of #ifdef _LIBCPP_HAS_IS_BASE_OF template struct _LIBCPP_TYPE_VIS_ONLY is_base_of : public integral_constant {}; #else // __has_feature(is_base_of) namespace __is_base_of_imp { template struct _Dst { _Dst(const volatile _Tp &); }; template struct _Src { operator const volatile _Tp &(); template operator const _Dst<_Up> &(); }; template struct __one { typedef char type; }; template typename __one(declval<_Src<_Dp> >()))>::type __test(int); template __two __test(...); } template struct _LIBCPP_TYPE_VIS_ONLY is_base_of : public integral_constant::value && sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; #endif // __has_feature(is_base_of) // is_convertible #if __has_feature(is_convertible_to) template struct _LIBCPP_TYPE_VIS_ONLY is_convertible : public integral_constant::value> {}; #else // __has_feature(is_convertible_to) namespace __is_convertible_imp { template char __test(_Tp); template __two __test(...); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template _Tp&& __source(); #else template typename remove_reference<_Tp>::type& __source(); #endif template ::value, bool _IsFunction = is_function<_Tp>::value, bool _IsVoid = is_void<_Tp>::value> struct __is_array_function_or_void {enum {value = 0};}; template struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; template struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; template struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; } template ::type>::value> struct __is_convertible_check { static const size_t __v = 0; }; template struct __is_convertible_check<_Tp, 0> { static const size_t __v = sizeof(_Tp); }; template ::value, unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> struct __is_convertible : public integral_constant(__is_convertible_imp::__source<_T1>())) == 1 #else sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1 && !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value && (!is_const::type>::value || is_volatile::type>::value) && (is_same::type, typename remove_cv::type>::type>::value || is_base_of::type, _T1>::value)) #endif > {}; template struct __is_convertible<_T1, _T2, 1, 0> : false_type {}; template struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {}; template struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {}; template struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {}; template struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {}; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct __is_convertible<_T1, _T2*, 1, 0> : public integral_constant::type*, _T2*>::value> {}; template struct __is_convertible<_T1, _T2* const, 1, 0> : public integral_constant::type*, _T2*const>::value> {}; template struct __is_convertible<_T1, _T2* volatile, 1, 0> : public integral_constant::type*, _T2*volatile>::value> {}; template struct __is_convertible<_T1, _T2* const volatile, 1, 0> : public integral_constant::type*, _T2*const volatile>::value> {}; template struct __is_convertible<_T1, _T2, 2, 0> : public false_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct __is_convertible<_T1, _T1&&, 2, 0> : public true_type {}; #endif template struct __is_convertible<_T1, _T1&, 2, 0> : public true_type {}; template struct __is_convertible<_T1, _T1*, 2, 0> : public true_type {}; template struct __is_convertible<_T1, _T1*const, 2, 0> : public true_type {}; template struct __is_convertible<_T1, _T1*volatile, 2, 0> : public true_type {}; template struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {}; template struct __is_convertible<_T1, _T2, 3, 0> : public false_type {}; template struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; template struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; template struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; template struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; template struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; template struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; template struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; template struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; template struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; template struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; template struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; template struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_convertible : public __is_convertible<_T1, _T2> { static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; }; #endif // __has_feature(is_convertible_to) // is_empty #if __has_feature(is_empty) template struct _LIBCPP_TYPE_VIS_ONLY is_empty : public integral_constant {}; #else // __has_feature(is_empty) template struct __is_empty1 : public _Tp { double __lx; }; struct __is_empty2 { double __lx; }; template ::value> struct __libcpp_empty : public integral_constant) == sizeof(__is_empty2)> {}; template struct __libcpp_empty<_Tp, false> : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {}; #endif // __has_feature(is_empty) // is_polymorphic #if __has_feature(is_polymorphic) template struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic : public integral_constant {}; #else template char &__is_polymorphic_impl( typename enable_if(declval<_Tp*>())) != 0, int>::type); template __two &__is_polymorphic_impl(...); template struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic : public integral_constant(0)) == 1> {}; #endif // __has_feature(is_polymorphic) // has_virtual_destructor #if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor : public integral_constant {}; #else // _LIBCPP_HAS_TYPE_TRAITS template struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor : public false_type {}; #endif // _LIBCPP_HAS_TYPE_TRAITS // alignment_of template struct _LIBCPP_TYPE_VIS_ONLY alignment_of : public integral_constant {}; // aligned_storage template struct __type_list { typedef _Hp _Head; typedef _Tp _Tail; }; struct __nat { #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __nat() = delete; __nat(const __nat&) = delete; __nat& operator=(const __nat&) = delete; ~__nat() = delete; #endif }; template struct __align_type { static const size_t value = alignment_of<_Tp>::value; typedef _Tp type; }; struct __struct_double {long double __lx;}; struct __struct_double4 {double __lx[4];}; typedef __type_list<__align_type, __type_list<__align_type, __type_list<__align_type, __type_list<__align_type, __type_list<__align_type, __type_list<__align_type, __type_list<__align_type, __type_list<__align_type<__struct_double>, __type_list<__align_type<__struct_double4>, __type_list<__align_type, __nat > > > > > > > > > > __all_types; template struct __find_pod; template struct __find_pod<__type_list<_Hp, __nat>, _Align> { typedef typename conditional< _Align == _Hp::value, typename _Hp::type, void >::type type; }; template struct __find_pod<__type_list<_Hp, _Tp>, _Align> { typedef typename conditional< _Align == _Hp::value, typename _Hp::type, typename __find_pod<_Tp, _Align>::type >::type type; }; template struct __find_max_align; template struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant {}; template struct __select_align { private: static const size_t __min = _A2 < _A1 ? _A2 : _A1; static const size_t __max = _A1 < _A2 ? _A2 : _A1; public: static const size_t value = _Len < __max ? __min : __max; }; template struct __find_max_align<__type_list<_Hp, _Tp>, _Len> : public integral_constant::value>::value> {}; template ::value> struct _LIBCPP_TYPE_VIS_ONLY aligned_storage { typedef typename __find_pod<__all_types, _Align>::type _Aligner; static_assert(!is_void<_Aligner>::value, ""); union type { _Aligner __align; unsigned char __data[_Len]; }; }; #if _LIBCPP_STD_VER > 11 template ::value> using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; #endif #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ template \ struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\ {\ struct _ALIGNAS(n) type\ {\ unsigned char __lx[_Len];\ };\ } _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); // MSDN says that MSVC does not support alignment beyond 8192 (=0x2000) #if !defined(_LIBCPP_MSVC) _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); #endif // !_LIBCPP_MSVC #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION #ifndef _LIBCPP_HAS_NO_VARIADICS // aligned_union template struct __static_max; template struct __static_max<_I0> { static const size_t value = _I0; }; template struct __static_max<_I0, _I1, _In...> { static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : __static_max<_I1, _In...>::value; }; template struct aligned_union { static const size_t alignment_value = __static_max<__alignof__(_Type0), __alignof__(_Types)...>::value; static const size_t __len = __static_max<_Len, sizeof(_Type0), sizeof(_Types)...>::value; typedef typename aligned_storage<__len, alignment_value>::type type; }; #if _LIBCPP_STD_VER > 11 template using aligned_union_t = typename aligned_union<_Len, _Types...>::type; #endif #endif // _LIBCPP_HAS_NO_VARIADICS // __promote template ::value || is_void<_A1>::value) && (is_arithmetic<_A2>::value || is_void<_A2>::value) && (is_arithmetic<_A3>::value || is_void<_A3>::value)> class __promote {}; template class __promote<_A1, _A2, _A3, true> { private: typedef typename __promote<_A1>::type __type1; typedef typename __promote<_A2>::type __type2; typedef typename __promote<_A3>::type __type3; public: typedef decltype(__type1() + __type2() + __type3()) type; }; template class __promote<_A1, _A2, void, true> { private: typedef typename __promote<_A1>::type __type1; typedef typename __promote<_A2>::type __type2; public: typedef decltype(__type1() + __type2()) type; }; template class __promote<_A1, void, void, true> { public: typedef typename conditional::value, typename conditional::value, double, _A1>::type, void >::type type; }; #ifdef _LIBCPP_STORE_AS_OPTIMIZATION // __transform template ::value> struct __transform {typedef _Tp type;}; template struct __transform<_Tp, 1, true> {typedef unsigned char type;}; template struct __transform<_Tp, 2, true> {typedef unsigned short type;}; template struct __transform<_Tp, 4, true> {typedef unsigned int type;}; template struct __transform<_Tp, 8, true> {typedef unsigned long long type;}; #endif // _LIBCPP_STORE_AS_OPTIMIZATION // make_signed / make_unsigned typedef __type_list > > > > __signed_types; typedef __type_list > > > > __unsigned_types; template struct __find_first; template struct __find_first<__type_list<_Hp, _Tp>, _Size, true> { typedef _Hp type; }; template struct __find_first<__type_list<_Hp, _Tp>, _Size, false> { typedef typename __find_first<_Tp, _Size>::type type; }; template ::type>::value, bool = is_volatile::type>::value> struct __apply_cv { typedef _Up type; }; template struct __apply_cv<_Tp, _Up, true, false> { typedef const _Up type; }; template struct __apply_cv<_Tp, _Up, false, true> { typedef volatile _Up type; }; template struct __apply_cv<_Tp, _Up, true, true> { typedef const volatile _Up type; }; template struct __apply_cv<_Tp&, _Up, false, false> { typedef _Up& type; }; template struct __apply_cv<_Tp&, _Up, true, false> { typedef const _Up& type; }; template struct __apply_cv<_Tp&, _Up, false, true> { typedef volatile _Up& type; }; template struct __apply_cv<_Tp&, _Up, true, true> { typedef const volatile _Up& type; }; template ::value || is_enum<_Tp>::value> struct __make_signed {}; template struct __make_signed<_Tp, true> { typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; }; template <> struct __make_signed {}; template <> struct __make_signed< signed short, true> {typedef short type;}; template <> struct __make_signed {typedef short type;}; template <> struct __make_signed< signed int, true> {typedef int type;}; template <> struct __make_signed {typedef int type;}; template <> struct __make_signed< signed long, true> {typedef long type;}; template <> struct __make_signed {typedef long type;}; template <> struct __make_signed< signed long long, true> {typedef long long type;}; template <> struct __make_signed {typedef long long type;}; template struct _LIBCPP_TYPE_VIS_ONLY make_signed { typedef typename __apply_cv<_Tp, typename __make_signed::type>::type>::type type; }; #if _LIBCPP_STD_VER > 11 template using make_signed_t = typename make_signed<_Tp>::type; #endif template ::value || is_enum<_Tp>::value> struct __make_unsigned {}; template struct __make_unsigned<_Tp, true> { typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; }; template <> struct __make_unsigned {}; template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; template <> struct __make_unsigned {typedef unsigned short type;}; template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; template <> struct __make_unsigned {typedef unsigned int type;}; template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; template <> struct __make_unsigned {typedef unsigned long type;}; template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; template <> struct __make_unsigned {typedef unsigned long long type;}; template struct _LIBCPP_TYPE_VIS_ONLY make_unsigned { typedef typename __apply_cv<_Tp, typename __make_unsigned::type>::type>::type type; }; #if _LIBCPP_STD_VER > 11 template using make_unsigned_t = typename make_unsigned<_Tp>::type; #endif #ifdef _LIBCPP_HAS_NO_VARIADICS template struct _LIBCPP_TYPE_VIS_ONLY common_type { public: typedef typename common_type::type, V>::type type; }; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void> { public: typedef _Tp type; }; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void> { private: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES static _Tp&& __t(); static _Up&& __u(); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES static _Tp __t(); static _Up __u(); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES public: typedef typename remove_reference::type type; }; #else // _LIBCPP_HAS_NO_VARIADICS template struct common_type; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> { typedef typename decay<_Tp>::type type; }; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> { private: static _Tp&& __t(); static _Up&& __u(); static bool __f(); public: typedef typename decay::type type; }; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> { typedef typename common_type::type, _Vp...>::type type; }; #if _LIBCPP_STD_VER > 11 template using common_type_t = typename common_type<_Tp...>::type; #endif #endif // _LIBCPP_HAS_NO_VARIADICS // is_assignable template struct __select_2nd { typedef _Tp type; }; template typename __select_2nd() = _VSTD::declval<_Arg>())), true_type>::type #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __is_assignable_test(_Tp&&, _Arg&&); #else __is_assignable_test(_Tp, _Arg&); #endif template false_type #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __is_assignable_test(__any, _Arg&&); #else __is_assignable_test(__any, _Arg&); #endif template ::value || is_void<_Arg>::value> struct __is_assignable_imp : public common_type < decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>())) >::type {}; template struct __is_assignable_imp<_Tp, _Arg, true> : public false_type { }; template struct is_assignable : public __is_assignable_imp<_Tp, _Arg> {}; // is_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable : public is_assignable::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_assignable::type, const typename add_rvalue_reference<_Tp>::type> {}; #else : public is_copy_assignable<_Tp> {}; #endif // is_destructible template struct __destructible_test { _Tp __t; }; template decltype((_VSTD::declval<__destructible_test<_Tp> >().~__destructible_test<_Tp>(), true_type())) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __is_destructible_test(_Tp&&); #else __is_destructible_test(_Tp&); #endif false_type __is_destructible_test(__any); template ::value || is_abstract<_Tp>::value || is_function<_Tp>::value> struct __destructible_imp : public common_type < decltype(__is_destructible_test(declval<_Tp>())) >::type {}; template struct __destructible_imp<_Tp, true> : public false_type {}; template struct is_destructible : public __destructible_imp<_Tp> {}; template struct is_destructible<_Tp[]> : public false_type {}; // move #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename remove_reference<_Tp>::type&& move(_Tp&& __t) _NOEXCEPT { typedef typename remove_reference<_Tp>::type _Up; return static_cast<_Up&&>(__t); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT { return static_cast<_Tp&&>(__t); } template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT { static_assert(!std::is_lvalue_reference<_Tp>::value, "Can not forward an rvalue as an lvalue."); return static_cast<_Tp&&>(__t); } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY _Tp& move(_Tp& __t) { return __t; } template inline _LIBCPP_INLINE_VISIBILITY const _Tp& move(const _Tp& __t) { return __t; } template inline _LIBCPP_INLINE_VISIBILITY _Tp& forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT { return __t; } template class __rv { typedef typename remove_reference<_Tp>::type _Trr; _Trr& t_; public: _LIBCPP_INLINE_VISIBILITY _Trr* operator->() {return &t_;} _LIBCPP_INLINE_VISIBILITY explicit __rv(_Trr& __t) : t_(__t) {} }; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline _LIBCPP_INLINE_VISIBILITY typename decay<_Tp>::type __decay_copy(_Tp&& __t) { return _VSTD::forward<_Tp>(__t); } #else template inline _LIBCPP_INLINE_VISIBILITY typename decay<_Tp>::type __decay_copy(const _Tp& __t) { return _VSTD::forward<_Tp>(__t); } #endif -template -struct __member_pointer_traits_imp -{ -}; - #ifndef _LIBCPP_HAS_NO_VARIADICS template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; #if __has_feature(cxx_reference_qualified_functions) template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> { typedef _Class& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> { typedef _Class const& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> { typedef _Class volatile& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> { typedef _Class const volatile& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> { typedef _Class&& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> { typedef _Class const&& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> { typedef _Class volatile&& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> { typedef _Class const volatile&& _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_Param...); }; #endif // __has_feature(cxx_reference_qualified_functions) #else // _LIBCPP_HAS_NO_VARIADICS template struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false> { typedef _Class _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false> { typedef _Class const _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false> { typedef _Class volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false> { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false> { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false> { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1); }; template struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false> { typedef _Class const volatile _ClassType; typedef _Rp _ReturnType; + typedef _Rp (_FnType) (_P0, _P1, _P2); }; #endif // _LIBCPP_HAS_NO_VARIADICS template struct __member_pointer_traits_imp<_Rp _Class::*, false, true> { typedef _Class _ClassType; typedef _Rp _ReturnType; }; template struct __member_pointer_traits : public __member_pointer_traits_imp::type, is_member_function_pointer<_MP>::value, is_member_object_pointer<_MP>::value> { // typedef ... _ClassType; // typedef ... _ReturnType; +// typedef ... _FnType; }; // result_of template class result_of; #ifdef _LIBCPP_HAS_NO_VARIADICS template class __result_of { }; template class __result_of<_Fn(), true, false> { public: typedef decltype(declval<_Fn>()()) type; }; template class __result_of<_Fn(_A0), true, false> { public: typedef decltype(declval<_Fn>()(declval<_A0>())) type; }; template class __result_of<_Fn(_A0, _A1), true, false> { public: typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type; }; template class __result_of<_Fn(_A0, _A1, _A2), true, false> { public: typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type; }; template struct __result_of_mp; // member function pointer template struct __result_of_mp<_MP, _Tp, true> : public common_type::_ReturnType> { }; // member data pointer template struct __result_of_mdp; template struct __result_of_mdp<_Rp _Class::*, _Tp, false> { typedef typename __apply_cv()), _Rp>::type& type; }; template struct __result_of_mdp<_Rp _Class::*, _Tp, true> { typedef typename __apply_cv<_Tp, _Rp>::type& type; }; template struct __result_of_mp<_Rp _Class::*, _Tp, false> : public __result_of_mdp<_Rp _Class::*, _Tp, is_base_of<_Class, typename remove_reference<_Tp>::type>::value> { }; template class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer : public __result_of_mp::type, _Tp, is_member_function_pointer::type>::value> { }; template class __result_of<_Fn(_Tp, _A0), false, true> // _Fn must be member pointer : public __result_of_mp::type, _Tp, is_member_function_pointer::type>::value> { }; template class __result_of<_Fn(_Tp, _A0, _A1), false, true> // _Fn must be member pointer : public __result_of_mp::type, _Tp, is_member_function_pointer::type>::value> { }; template class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member pointer : public __result_of_mp::type, _Tp, is_member_function_pointer::type>::value> { }; // result_of template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()> : public __result_of<_Fn(), is_class::type>::value || is_function::type>::value, is_member_pointer::type>::value > { }; template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)> : public __result_of<_Fn(_A0), is_class::type>::value || is_function::type>::value, is_member_pointer::type>::value > { }; template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)> : public __result_of<_Fn(_A0, _A1), is_class::type>::value || is_function::type>::value, is_member_pointer::type>::value > { }; template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)> : public __result_of<_Fn(_A0, _A1, _A2), is_class::type>::value || is_function::type>::value, is_member_pointer::type>::value > { }; #endif // _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_VARIADICS // template struct is_constructible; // main is_constructible test template typename __select_2nd()...))), true_type>::type __is_constructible_test(_Tp&&, _Args&& ...); template false_type __is_constructible_test(__any, _Args&& ...); template struct __is_constructible // false, _Tp is not a scalar : public common_type < decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...)) >::type {}; // function types are not constructible template struct __is_constructible : public false_type {}; // handle scalars and reference types // Scalars are default constructible, references are not template struct __is_constructible : public is_scalar<_Tp> {}; // Scalars and references are constructible from one arg if that arg is // implicitly convertible to the scalar or reference. template struct __is_constructible_ref { true_type static __lxx(_Tp); false_type static __lxx(...); }; template struct __is_constructible : public common_type < decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>())) >::type {}; // Scalars and references are not constructible from multiple args. template struct __is_constructible : public false_type {}; // Treat scalars and reference types separately template struct __is_constructible_void_check : public __is_constructible::value || is_reference<_Tp>::value, _Tp, _Args...> {}; // If any of T or Args is void, is_constructible should be false template struct __is_constructible_void_check : public false_type {}; template struct __contains_void; template <> struct __contains_void<> : false_type {}; template struct __contains_void<_A0, _Args...> { static const bool value = is_void<_A0>::value || __contains_void<_Args...>::value; }; // is_constructible entry point template struct _LIBCPP_TYPE_VIS_ONLY is_constructible : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value || is_abstract<_Tp>::value, _Tp, _Args...> {}; // Array types are default constructible if their element type // is default constructible template struct __is_constructible : public is_constructible::type> {}; // Otherwise array types are not constructible by this syntax template struct __is_constructible : public false_type {}; // Incomplete array types are not constructible template struct __is_constructible : public false_type {}; #else // _LIBCPP_HAS_NO_VARIADICS // template struct is_constructible0; // main is_constructible0 test template decltype((_Tp(), true_type())) __is_constructible0_test(_Tp&); false_type __is_constructible0_test(__any); template decltype((_Tp(_VSTD::declval<_A0>()), true_type())) __is_constructible1_test(_Tp&, _A0&); template false_type __is_constructible1_test(__any, _A0&); template decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type())) __is_constructible2_test(_Tp&, _A0&, _A1&); template false_type __is_constructible2_test(__any, _A0&, _A1&); template struct __is_constructible0_imp // false, _Tp is not a scalar : public common_type < decltype(__is_constructible0_test(declval<_Tp&>())) >::type {}; template struct __is_constructible1_imp // false, _Tp is not a scalar : public common_type < decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>())) >::type {}; template struct __is_constructible2_imp // false, _Tp is not a scalar : public common_type < decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>())) >::type {}; // handle scalars and reference types // Scalars are default constructible, references are not template struct __is_constructible0_imp : public is_scalar<_Tp> {}; template struct __is_constructible1_imp : public is_convertible<_A0, _Tp> {}; template struct __is_constructible2_imp : public false_type {}; // Treat scalars and reference types separately template struct __is_constructible0_void_check : public __is_constructible0_imp::value || is_reference<_Tp>::value, _Tp> {}; template struct __is_constructible1_void_check : public __is_constructible1_imp::value || is_reference<_Tp>::value, _Tp, _A0> {}; template struct __is_constructible2_void_check : public __is_constructible2_imp::value || is_reference<_Tp>::value, _Tp, _A0, _A1> {}; // If any of T or Args is void, is_constructible should be false template struct __is_constructible0_void_check : public false_type {}; template struct __is_constructible1_void_check : public false_type {}; template struct __is_constructible2_void_check : public false_type {}; // is_constructible entry point namespace __is_construct { struct __nat {}; } template struct _LIBCPP_TYPE_VIS_ONLY is_constructible : public __is_constructible2_void_check::value || is_abstract<_Tp>::value || is_function<_Tp>::value || is_void<_A0>::value || is_void<_A1>::value, _Tp, _A0, _A1> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : public __is_constructible0_void_check::value || is_abstract<_Tp>::value || is_function<_Tp>::value, _Tp> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat> : public __is_constructible1_void_check::value || is_abstract<_Tp>::value || is_function<_Tp>::value || is_void<_A0>::value, _Tp, _A0> {}; // Array types are default constructible if their element type // is default constructible template struct __is_constructible0_imp : public is_constructible::type> {}; template struct __is_constructible1_imp : public false_type {}; template struct __is_constructible2_imp : public false_type {}; // Incomplete array types are not constructible template struct __is_constructible0_imp : public false_type {}; template struct __is_constructible1_imp : public false_type {}; template struct __is_constructible2_imp : public false_type {}; #endif // _LIBCPP_HAS_NO_VARIADICS // is_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible : public is_constructible<_Tp> {}; // is_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> {}; // is_move_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else : public is_copy_constructible<_Tp> #endif {}; // is_trivially_constructible #ifndef _LIBCPP_HAS_NO_VARIADICS #if __has_feature(is_trivially_constructible) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : integral_constant { }; #else // !__has_feature(is_trivially_constructible) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : false_type { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp> #if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&> #else struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp> #endif : integral_constant::value> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&> : integral_constant::value> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&> : integral_constant::value> { }; #endif // !__has_feature(is_trivially_constructible) #else // _LIBCPP_HAS_NO_VARIADICS template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : false_type { }; #if __has_feature(is_trivially_constructible) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : integral_constant { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, __is_construct::__nat> : integral_constant { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, __is_construct::__nat> : integral_constant { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, __is_construct::__nat> : integral_constant { }; #else // !__has_feature(is_trivially_constructible) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : integral_constant::value> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, __is_construct::__nat> : integral_constant::value> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, __is_construct::__nat> : integral_constant::value> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, __is_construct::__nat> : integral_constant::value> { }; #endif // !__has_feature(is_trivially_constructible) #endif // _LIBCPP_HAS_NO_VARIADICS // is_trivially_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible : public is_trivially_constructible<_Tp> {}; // is_trivially_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible : public is_trivially_constructible<_Tp, typename add_lvalue_reference::type> {}; // is_trivially_move_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else : public is_trivially_copy_constructible<_Tp> #endif {}; // is_trivially_assignable #if __has_feature(is_trivially_constructible) template struct is_trivially_assignable : integral_constant { }; #else // !__has_feature(is_trivially_constructible) template struct is_trivially_assignable : public false_type {}; template struct is_trivially_assignable<_Tp&, _Tp> : integral_constant::value> {}; template struct is_trivially_assignable<_Tp&, _Tp&> : integral_constant::value> {}; template struct is_trivially_assignable<_Tp&, const _Tp&> : integral_constant::value> {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct is_trivially_assignable<_Tp&, _Tp&&> : integral_constant::value> {}; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // !__has_feature(is_trivially_constructible) // is_trivially_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable : public is_trivially_assignable::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_trivially_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable : public is_trivially_assignable::type, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES typename add_rvalue_reference<_Tp>::type> #else typename add_lvalue_reference<_Tp>::type> #endif {}; // is_trivially_destructible #if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public integral_constant {}; #else // _LIBCPP_HAS_TYPE_TRAITS template struct __libcpp_trivial_destructor : public integral_constant::value || is_reference<_Tp>::value> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public __libcpp_trivial_destructor::type> {}; #endif // _LIBCPP_HAS_TYPE_TRAITS // is_nothrow_constructible +#if 0 +template +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible + : public integral_constant +{ +}; + +#else + #ifndef _LIBCPP_HAS_NO_VARIADICS #if __has_feature(cxx_noexcept) template struct __is_nothrow_constructible; template struct __is_nothrow_constructible : public integral_constant()...))> { }; template struct __is_nothrow_constructible : public false_type { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : __is_nothrow_constructible::value, _Tp, _Args...> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]> : __is_nothrow_constructible::value, _Tp> { }; #else // __has_feature(cxx_noexcept) template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : false_type { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp> #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&> #else struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp> #endif #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; #endif // __has_feature(cxx_noexcept) #else // _LIBCPP_HAS_NO_VARIADICS template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : false_type { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp, __is_construct::__nat> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&, __is_construct::__nat> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, __is_construct::__nat> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant #else : integral_constant::value> #endif { }; #endif // _LIBCPP_HAS_NO_VARIADICS +#endif // __has_feature(is_nothrow_constructible) // is_nothrow_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible : public is_nothrow_constructible<_Tp> {}; // is_nothrow_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> {}; // is_nothrow_move_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else : public is_nothrow_copy_constructible<_Tp> #endif {}; // is_nothrow_assignable #if __has_feature(cxx_noexcept) template struct __is_nothrow_assignable; template struct __is_nothrow_assignable : public false_type { }; template struct __is_nothrow_assignable : public integral_constant() = _VSTD::declval<_Arg>()) > { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable : public __is_nothrow_assignable::value, _Tp, _Arg> { }; #else // __has_feature(cxx_noexcept) template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else : integral_constant::value> {}; #endif template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else : integral_constant::value> {}; #endif template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else : integral_constant::value> {}; #endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct is_nothrow_assignable<_Tp&, _Tp&&> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant {}; #else : integral_constant::value> {}; #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // __has_feature(cxx_noexcept) // is_nothrow_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable : public is_nothrow_assignable::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_nothrow_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable : public is_nothrow_assignable::type, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES typename add_rvalue_reference<_Tp>::type> #else typename add_lvalue_reference<_Tp>::type> #endif {}; // is_nothrow_destructible #if __has_feature(cxx_noexcept) template struct __is_nothrow_destructible; template struct __is_nothrow_destructible : public false_type { }; template struct __is_nothrow_destructible : public integral_constant().~_Tp()) > { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __is_nothrow_destructible::value, _Tp> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]> : public is_nothrow_destructible<_Tp> { }; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&> : public true_type { }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&> : public true_type { }; #endif #else template struct __libcpp_nothrow_destructor : public integral_constant::value || is_reference<_Tp>::value> {}; template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __libcpp_nothrow_destructor::type> {}; #endif // is_pod #if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) template struct _LIBCPP_TYPE_VIS_ONLY is_pod : public integral_constant {}; #else // _LIBCPP_HAS_TYPE_TRAITS template struct _LIBCPP_TYPE_VIS_ONLY is_pod : public integral_constant::value && is_trivially_copy_constructible<_Tp>::value && is_trivially_copy_assignable<_Tp>::value && is_trivially_destructible<_Tp>::value> {}; #endif // _LIBCPP_HAS_TYPE_TRAITS // is_literal_type; template struct _LIBCPP_TYPE_VIS_ONLY is_literal_type #if __has_feature(is_literal) : public integral_constant #else : integral_constant::type>::value || is_reference::type>::value> #endif {}; // is_standard_layout; template struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout #if __has_feature(is_standard_layout) : public integral_constant #else : integral_constant::type>::value> #endif {}; // is_trivially_copyable; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable #if __has_feature(is_trivially_copyable) : public integral_constant #else : integral_constant::type>::value> #endif {}; // is_trivial; template struct _LIBCPP_TYPE_VIS_ONLY is_trivial #if __has_feature(is_trivial) : public integral_constant #else : integral_constant::value && is_trivially_default_constructible<_Tp>::value> #endif {}; #ifndef _LIBCPP_HAS_NO_VARIADICS // Check for complete types template struct __check_complete; template <> struct __check_complete<> { }; template struct __check_complete<_Hp, _T0, _Tp...> : private __check_complete<_Hp>, private __check_complete<_T0, _Tp...> { }; template struct __check_complete<_Hp, _Hp> : private __check_complete<_Hp> { }; template struct __check_complete<_Tp> { static_assert(sizeof(_Tp) > 0, "Type must be complete."); }; template struct __check_complete<_Tp&> : private __check_complete<_Tp> { }; template struct __check_complete<_Tp&&> : private __check_complete<_Tp> { }; template struct __check_complete<_Rp (*)(_Param...)> : private __check_complete<_Rp> { }; template struct __check_complete { }; template struct __check_complete<_Rp (_Param...)> : private __check_complete<_Rp> { }; template struct __check_complete { }; template struct __check_complete<_Rp (_Class::*)(_Param...)> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) volatile> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const volatile> : private __check_complete<_Class> { }; #if __has_feature(cxx_reference_qualified_functions) template struct __check_complete<_Rp (_Class::*)(_Param...) &> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) volatile&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) &&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const&&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&> : private __check_complete<_Class> { }; template struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&> : private __check_complete<_Class> { }; #endif template struct __check_complete<_Rp _Class::*> : private __check_complete<_Class> { }; // __invoke forward declarations // fall back - none of the bullets template auto __invoke(__any, _Args&& ...__args) -> __nat; // bullets 1 and 2 template ::type>::value && is_base_of::type>::_ClassType, typename remove_reference<_A0>::type>::value >::type > _LIBCPP_INLINE_VISIBILITY auto __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) -> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...)); template ::type>::value && !is_base_of::type>::_ClassType, typename remove_reference<_A0>::type>::value >::type > _LIBCPP_INLINE_VISIBILITY auto __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...)); // bullets 3 and 4 template ::type>::value && is_base_of::type>::_ClassType, typename remove_reference<_A0>::type>::value >::type > _LIBCPP_INLINE_VISIBILITY auto __invoke(_Fp&& __f, _A0&& __a0) -> decltype(_VSTD::forward<_A0>(__a0).*__f); template ::type>::value && !is_base_of::type>::_ClassType, typename remove_reference<_A0>::type>::value >::type > _LIBCPP_INLINE_VISIBILITY auto __invoke(_Fp&& __f, _A0&& __a0) -> decltype((*_VSTD::forward<_A0>(__a0)).*__f); // bullet 5 template _LIBCPP_INLINE_VISIBILITY auto __invoke(_Fp&& __f, _Args&& ...__args) -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...)); // __invokable template struct __invokable_imp : private __check_complete<_Fp> { typedef decltype( __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...) ) type; static const bool value = !is_same::value; }; template struct __invokable : public integral_constant::value> { }; // __invoke_of template struct __invoke_of_imp // false { }; template struct __invoke_of_imp { typedef typename __invokable_imp<_Fp, _Args...>::type type; }; template struct __invoke_of : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...> { }; template class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)> : public __invoke_of<_Fp, _Args...> { }; #if _LIBCPP_STD_VER > 11 template using result_of_t = typename result_of<_Tp>::type; #endif #endif // _LIBCPP_HAS_NO_VARIADICS template inline _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE typename enable_if < is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value >::type #else void #endif swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && is_nothrow_move_assignable<_Tp>::value) { _Tp __t(_VSTD::move(__x)); __x = _VSTD::move(__y); __y = _VSTD::move(__t); } template inline _LIBCPP_INLINE_VISIBILITY void iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(), *_VSTD::declval<_ForwardIterator2>()))) { swap(*__a, *__b); } // __swappable namespace __detail { using _VSTD::swap; __nat swap(__any, __any); template struct __swappable { typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type; static const bool value = !is_same::value; }; } // __detail template struct __is_swappable : public integral_constant::value> { }; #if __has_feature(cxx_noexcept) template struct __is_nothrow_swappable_imp : public integral_constant(), _VSTD::declval<_Tp&>()))> { }; template struct __is_nothrow_swappable_imp : public false_type { }; template struct __is_nothrow_swappable : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp> { }; #else // __has_feature(cxx_noexcept) template struct __is_nothrow_swappable : public false_type { }; #endif // __has_feature(cxx_noexcept) #ifdef _LIBCXX_UNDERLYING_TYPE template struct underlying_type { typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type; }; #if _LIBCPP_STD_VER > 11 template using underlying_type_t = typename underlying_type<_Tp>::type; #endif #else // _LIBCXX_UNDERLYING_TYPE template struct underlying_type { static_assert(_Support, "The underyling_type trait requires compiler " "support. Either no such support exists or " "libc++ does not know how to use it."); }; #endif // _LIBCXX_UNDERLYING_TYPE #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE template struct __has_operator_addressof_imp { template static auto __test(__any) -> false_type; template static auto __test(_Up* __u) -> typename __select_2ndoperator&()), true_type>::type; static const bool value = decltype(__test<_Tp>(nullptr))::value; }; template struct __has_operator_addressof : public integral_constant::value> {}; #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_TYPE_TRAITS Index: projects/clang350-import/contrib/libc++ =================================================================== --- projects/clang350-import/contrib/libc++ (revision 275366) +++ projects/clang350-import/contrib/libc++ (revision 275367) Property changes on: projects/clang350-import/contrib/libc++ ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/contrib/libc++:r274961,275076-275366 Index: projects/clang350-import/sys/cam/ctl/scsi_ctl.c =================================================================== --- projects/clang350-import/sys/cam/ctl/scsi_ctl.c (revision 275366) +++ projects/clang350-import/sys/cam/ctl/scsi_ctl.c (revision 275367) @@ -1,2086 +1,2063 @@ /*- * Copyright (c) 2008, 2009 Silicon Graphics International Corp. * 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, * without modification. * 2. Redistributions in binary form must reproduce at minimum a disclaimer * substantially similar to the "NO WARRANTY" disclaimer below * ("Disclaimer") and any redistribution must be conditioned upon * including a substantially similar Disclaimer requirement for further * binary redistribution. * * NO WARRANTY * 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 MERCHANTIBILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. * * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/scsi_ctl.c#4 $ */ /* * Peripheral driver interface between CAM and CTL (CAM Target Layer). * * Author: Ken Merry */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include struct ctlfe_softc { struct ctl_port port; path_id_t path_id; u_int maxio; struct cam_sim *sim; char port_name[DEV_IDLEN]; struct mtx lun_softc_mtx; STAILQ_HEAD(, ctlfe_lun_softc) lun_softc_list; STAILQ_ENTRY(ctlfe_softc) links; }; STAILQ_HEAD(, ctlfe_softc) ctlfe_softc_list; struct mtx ctlfe_list_mtx; static char ctlfe_mtx_desc[] = "ctlfelist"; #ifdef CTLFE_INIT_ENABLE static int ctlfe_max_targets = 1; static int ctlfe_num_targets = 0; #endif typedef enum { CTLFE_LUN_NONE = 0x00, CTLFE_LUN_WILDCARD = 0x01 } ctlfe_lun_flags; struct ctlfe_lun_softc { struct ctlfe_softc *parent_softc; struct cam_periph *periph; ctlfe_lun_flags flags; uint64_t ccbs_alloced; uint64_t ccbs_freed; uint64_t ctios_sent; uint64_t ctios_returned; uint64_t atios_sent; uint64_t atios_returned; uint64_t inots_sent; uint64_t inots_returned; /* bus_dma_tag_t dma_tag; */ TAILQ_HEAD(, ccb_hdr) work_queue; STAILQ_ENTRY(ctlfe_lun_softc) links; }; typedef enum { CTLFE_CMD_NONE = 0x00, CTLFE_CMD_PIECEWISE = 0x01 } ctlfe_cmd_flags; /* * The size limit of this structure is CTL_PORT_PRIV_SIZE, from ctl_io.h. * Currently that is 600 bytes. */ struct ctlfe_lun_cmd_info { int cur_transfer_index; size_t cur_transfer_off; ctlfe_cmd_flags flags; /* * XXX KDM struct bus_dma_segment is 8 bytes on i386, and 16 * bytes on amd64. So with 32 elements, this is 256 bytes on * i386 and 512 bytes on amd64. */ #define CTLFE_MAX_SEGS 32 bus_dma_segment_t cam_sglist[CTLFE_MAX_SEGS]; }; CTASSERT(sizeof(struct ctlfe_lun_cmd_info) <= CTL_PORT_PRIV_SIZE); /* * When we register the adapter/bus, request that this many ctl_ios be * allocated. This should be the maximum supported by the adapter, but we * currently don't have a way to get that back from the path inquiry. * XXX KDM add that to the path inquiry. */ #define CTLFE_REQ_CTL_IO 4096 /* * Number of Accept Target I/O CCBs to allocate and queue down to the * adapter per LUN. * XXX KDM should this be controlled by CTL? */ #define CTLFE_ATIO_PER_LUN 1024 /* * Number of Immediate Notify CCBs (used for aborts, resets, etc.) to * allocate and queue down to the adapter per LUN. * XXX KDM should this be controlled by CTL? */ #define CTLFE_IN_PER_LUN 1024 /* * Timeout (in seconds) on CTIO CCB allocation for doing a DMA or sending * status to the initiator. The SIM is expected to have its own timeouts, * so we're not putting this timeout around the CCB execution time. The * SIM should timeout and let us know if it has an issue. */ #define CTLFE_DMA_TIMEOUT 60 /* * Turn this on to enable extra debugging prints. */ #if 0 #define CTLFE_DEBUG #endif /* * Use randomly assigned WWNN/WWPN values. This is to work around an issue * in the FreeBSD initiator that makes it unable to rescan the target if * the target gets rebooted and the WWNN/WWPN stay the same. */ #if 0 #define RANDOM_WWNN #endif MALLOC_DEFINE(M_CTLFE, "CAM CTL FE", "CAM CTL FE interface"); #define io_ptr ppriv_ptr0 /* This is only used in the CTIO */ #define ccb_atio ppriv_ptr1 int ctlfeinitialize(void); void ctlfeshutdown(void); static periph_init_t ctlfeperiphinit; static void ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg); static periph_ctor_t ctlferegister; static periph_oninv_t ctlfeoninvalidate; static periph_dtor_t ctlfecleanup; static periph_start_t ctlfestart; static void ctlfedone(struct cam_periph *periph, union ccb *done_ccb); static void ctlfe_onoffline(void *arg, int online); static void ctlfe_online(void *arg); static void ctlfe_offline(void *arg); static int ctlfe_lun_enable(void *arg, struct ctl_id targ_id, int lun_id); static int ctlfe_lun_disable(void *arg, struct ctl_id targ_id, int lun_id); static void ctlfe_dump_sim(struct cam_sim *sim); static void ctlfe_dump_queue(struct ctlfe_lun_softc *softc); static void ctlfe_datamove(union ctl_io *io); static void ctlfe_done(union ctl_io *io); static void ctlfe_dump(void); static struct periph_driver ctlfe_driver = { ctlfeperiphinit, "ctl", TAILQ_HEAD_INITIALIZER(ctlfe_driver.units), /*generation*/ 0, CAM_PERIPH_DRV_EARLY }; static struct ctl_frontend ctlfe_frontend = { .name = "camtgt", .init = ctlfeinitialize, .fe_dump = ctlfe_dump, .shutdown = ctlfeshutdown, }; CTL_FRONTEND_DECLARE(ctlfe, ctlfe_frontend); extern struct ctl_softc *control_softc; void ctlfeshutdown(void) { return; } int ctlfeinitialize(void) { STAILQ_INIT(&ctlfe_softc_list); mtx_init(&ctlfe_list_mtx, ctlfe_mtx_desc, NULL, MTX_DEF); periphdriver_register(&ctlfe_driver); return (0); } void ctlfeperiphinit(void) { cam_status status; status = xpt_register_async(AC_PATH_REGISTERED | AC_PATH_DEREGISTERED | AC_CONTRACT, ctlfeasync, NULL, NULL); if (status != CAM_REQ_CMP) { printf("ctl: Failed to attach async callback due to CAM " "status 0x%x!\n", status); } } static void ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) { struct ctlfe_softc *softc; #ifdef CTLFEDEBUG printf("%s: entered\n", __func__); #endif mtx_lock(&ctlfe_list_mtx); STAILQ_FOREACH(softc, &ctlfe_softc_list, links) { if (softc->path_id == xpt_path_path_id(path)) break; } mtx_unlock(&ctlfe_list_mtx); /* * When a new path gets registered, and it is capable of target * mode, go ahead and attach. Later on, we may need to be more * selective, but for now this will be sufficient. */ switch (code) { case AC_PATH_REGISTERED: { struct ctl_port *port; struct ccb_pathinq *cpi; int retval; cpi = (struct ccb_pathinq *)arg; /* Don't attach if it doesn't support target mode */ if ((cpi->target_sprt & PIT_PROCESSOR) == 0) { #ifdef CTLFEDEBUG printf("%s: SIM %s%d doesn't support target mode\n", __func__, cpi->dev_name, cpi->unit_number); #endif break; } if (softc != NULL) { #ifdef CTLFEDEBUG printf("%s: CTL port for CAM path %u already exists\n", __func__, xpt_path_path_id(path)); #endif break; } #ifdef CTLFE_INIT_ENABLE if (ctlfe_num_targets >= ctlfe_max_targets) { union ccb *ccb; ccb = (union ccb *)malloc(sizeof(*ccb), M_TEMP, M_NOWAIT | M_ZERO); if (ccb == NULL) { printf("%s: unable to malloc CCB!\n", __func__); return; } xpt_setup_ccb(&ccb->ccb_h, path, CAM_PRIORITY_NONE); ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; ccb->knob.xport_specific.valid = KNOB_VALID_ROLE; ccb->knob.xport_specific.fc.role = KNOB_ROLE_INITIATOR; xpt_action(ccb); if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { printf("%s: SIM %s%d (path id %d) initiator " "enable failed with status %#x\n", __func__, cpi->dev_name, cpi->unit_number, cpi->ccb_h.path_id, ccb->ccb_h.status); } else { printf("%s: SIM %s%d (path id %d) initiator " "enable succeeded\n", __func__, cpi->dev_name, cpi->unit_number, cpi->ccb_h.path_id); } free(ccb, M_TEMP); break; } else { ctlfe_num_targets++; } printf("%s: ctlfe_num_targets = %d\n", __func__, ctlfe_num_targets); #endif /* CTLFE_INIT_ENABLE */ /* * We're in an interrupt context here, so we have to * use M_NOWAIT. Of course this means trouble if we * can't allocate memory. */ softc = malloc(sizeof(*softc), M_CTLFE, M_NOWAIT | M_ZERO); if (softc == NULL) { printf("%s: unable to malloc %zd bytes for softc\n", __func__, sizeof(*softc)); return; } softc->path_id = cpi->ccb_h.path_id; softc->sim = xpt_path_sim(path); if (cpi->maxio != 0) softc->maxio = cpi->maxio; else softc->maxio = DFLTPHYS; mtx_init(&softc->lun_softc_mtx, "LUN softc mtx", NULL, MTX_DEF); STAILQ_INIT(&softc->lun_softc_list); port = &softc->port; port->frontend = &ctlfe_frontend; /* * XXX KDM should we be more accurate here ? */ if (cpi->transport == XPORT_FC) port->port_type = CTL_PORT_FC; else if (cpi->transport == XPORT_SAS) port->port_type = CTL_PORT_SAS; else port->port_type = CTL_PORT_SCSI; /* XXX KDM what should the real number be here? */ port->num_requested_ctl_io = 4096; snprintf(softc->port_name, sizeof(softc->port_name), "%s%d", cpi->dev_name, cpi->unit_number); /* * XXX KDM it would be nice to allocate storage in the * frontend structure itself. */ port->port_name = softc->port_name; port->physical_port = cpi->bus_id; port->virtual_port = 0; port->port_online = ctlfe_online; port->port_offline = ctlfe_offline; port->onoff_arg = softc; port->lun_enable = ctlfe_lun_enable; port->lun_disable = ctlfe_lun_disable; port->targ_lun_arg = softc; port->fe_datamove = ctlfe_datamove; port->fe_done = ctlfe_done; /* * XXX KDM the path inquiry doesn't give us the maximum * number of targets supported. */ port->max_targets = cpi->max_target; port->max_target_id = cpi->max_target; /* * XXX KDM need to figure out whether we're the master or * slave. */ #ifdef CTLFEDEBUG printf("%s: calling ctl_port_register() for %s%d\n", __func__, cpi->dev_name, cpi->unit_number); #endif retval = ctl_port_register(port); if (retval != 0) { printf("%s: ctl_port_register() failed with " "error %d!\n", __func__, retval); mtx_destroy(&softc->lun_softc_mtx); free(softc, M_CTLFE); break; } else { mtx_lock(&ctlfe_list_mtx); STAILQ_INSERT_TAIL(&ctlfe_softc_list, softc, links); mtx_unlock(&ctlfe_list_mtx); } break; } case AC_PATH_DEREGISTERED: { if (softc != NULL) { /* * XXX KDM are we certain at this point that there * are no outstanding commands for this frontend? */ mtx_lock(&ctlfe_list_mtx); STAILQ_REMOVE(&ctlfe_softc_list, softc, ctlfe_softc, links); mtx_unlock(&ctlfe_list_mtx); ctl_port_deregister(&softc->port); mtx_destroy(&softc->lun_softc_mtx); free(softc, M_CTLFE); } break; } case AC_CONTRACT: { struct ac_contract *ac; ac = (struct ac_contract *)arg; switch (ac->contract_number) { case AC_CONTRACT_DEV_CHG: { struct ac_device_changed *dev_chg; int retval; dev_chg = (struct ac_device_changed *)ac->contract_data; printf("%s: WWPN %#jx port 0x%06x path %u target %u %s\n", __func__, dev_chg->wwpn, dev_chg->port, xpt_path_path_id(path), dev_chg->target, (dev_chg->arrived == 0) ? "left" : "arrived"); if (softc == NULL) { printf("%s: CTL port for CAM path %u not " "found!\n", __func__, xpt_path_path_id(path)); break; } if (dev_chg->arrived != 0) { retval = ctl_add_initiator(&softc->port, dev_chg->target, dev_chg->wwpn, NULL); } else { retval = ctl_remove_initiator(&softc->port, dev_chg->target); } if (retval < 0) { printf("%s: could not %s port %d iid %u " "WWPN %#jx!\n", __func__, (dev_chg->arrived != 0) ? "add" : "remove", softc->port.targ_port, dev_chg->target, (uintmax_t)dev_chg->wwpn); } break; } default: printf("%s: unsupported contract number %ju\n", __func__, (uintmax_t)ac->contract_number); break; } break; } default: break; } } static cam_status ctlferegister(struct cam_periph *periph, void *arg) { struct ctlfe_softc *bus_softc; struct ctlfe_lun_softc *softc; union ccb en_lun_ccb; cam_status status; int i; softc = (struct ctlfe_lun_softc *)arg; bus_softc = softc->parent_softc; TAILQ_INIT(&softc->work_queue); softc->periph = periph; periph->softc = softc; xpt_setup_ccb(&en_lun_ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); en_lun_ccb.ccb_h.func_code = XPT_EN_LUN; en_lun_ccb.cel.grp6_len = 0; en_lun_ccb.cel.grp7_len = 0; en_lun_ccb.cel.enable = 1; xpt_action(&en_lun_ccb); status = (en_lun_ccb.ccb_h.status & CAM_STATUS_MASK); if (status != CAM_REQ_CMP) { xpt_print(periph->path, "%s: Enable LUN failed, status 0x%x\n", __func__, en_lun_ccb.ccb_h.status); return (status); } status = CAM_REQ_CMP; for (i = 0; i < CTLFE_ATIO_PER_LUN; i++) { union ccb *new_ccb; union ctl_io *new_io; new_ccb = (union ccb *)malloc(sizeof(*new_ccb), M_CTLFE, M_ZERO|M_NOWAIT); if (new_ccb == NULL) { status = CAM_RESRC_UNAVAIL; break; } new_io = ctl_alloc_io_nowait(bus_softc->port.ctl_pool_ref); if (new_io == NULL) { free(new_ccb, M_CTLFE); status = CAM_RESRC_UNAVAIL; break; } new_ccb->ccb_h.io_ptr = new_io; xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1); new_ccb->ccb_h.func_code = XPT_ACCEPT_TARGET_IO; new_ccb->ccb_h.cbfcnp = ctlfedone; new_ccb->ccb_h.flags |= CAM_UNLOCKED; xpt_action(new_ccb); softc->atios_sent++; status = new_ccb->ccb_h.status; if ((status & CAM_STATUS_MASK) != CAM_REQ_INPROG) { ctl_free_io(new_io); free(new_ccb, M_CTLFE); break; } } status = cam_periph_acquire(periph); if ((status & CAM_STATUS_MASK) != CAM_REQ_CMP) { xpt_print(periph->path, "%s: could not acquire reference " "count, status = %#x\n", __func__, status); return (status); } if (i == 0) { xpt_print(periph->path, "%s: could not allocate ATIO CCBs, " "status 0x%x\n", __func__, status); return (CAM_REQ_CMP_ERR); } for (i = 0; i < CTLFE_IN_PER_LUN; i++) { union ccb *new_ccb; union ctl_io *new_io; new_ccb = (union ccb *)malloc(sizeof(*new_ccb), M_CTLFE, M_ZERO|M_NOWAIT); if (new_ccb == NULL) { status = CAM_RESRC_UNAVAIL; break; } new_io = ctl_alloc_io_nowait(bus_softc->port.ctl_pool_ref); if (new_io == NULL) { free(new_ccb, M_CTLFE); status = CAM_RESRC_UNAVAIL; break; } new_ccb->ccb_h.io_ptr = new_io; xpt_setup_ccb(&new_ccb->ccb_h, periph->path, /*priority*/ 1); new_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY; new_ccb->ccb_h.cbfcnp = ctlfedone; new_ccb->ccb_h.flags |= CAM_UNLOCKED; xpt_action(new_ccb); softc->inots_sent++; status = new_ccb->ccb_h.status; if ((status & CAM_STATUS_MASK) != CAM_REQ_INPROG) { /* * Note that we don't free the CCB here. If the * status is not CAM_REQ_INPROG, then we're * probably talking to a SIM that says it is * target-capable but doesn't support the * XPT_IMMEDIATE_NOTIFY CCB. i.e. it supports the * older API. In that case, it'll call xpt_done() * on the CCB, and we need to free it in our done * routine as a result. */ break; } } if ((i == 0) || (status != CAM_REQ_INPROG)) { xpt_print(periph->path, "%s: could not allocate immediate " "notify CCBs, status 0x%x\n", __func__, status); return (CAM_REQ_CMP_ERR); } + mtx_lock(&bus_softc->lun_softc_mtx); + STAILQ_INSERT_TAIL(&bus_softc->lun_softc_list, softc, links); + mtx_unlock(&bus_softc->lun_softc_mtx); return (CAM_REQ_CMP); } static void ctlfeoninvalidate(struct cam_periph *periph) { union ccb en_lun_ccb; cam_status status; struct ctlfe_softc *bus_softc; struct ctlfe_lun_softc *softc; softc = (struct ctlfe_lun_softc *)periph->softc; xpt_setup_ccb(&en_lun_ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); en_lun_ccb.ccb_h.func_code = XPT_EN_LUN; en_lun_ccb.cel.grp6_len = 0; en_lun_ccb.cel.grp7_len = 0; en_lun_ccb.cel.enable = 0; xpt_action(&en_lun_ccb); status = (en_lun_ccb.ccb_h.status & CAM_STATUS_MASK); if (status != CAM_REQ_CMP) { xpt_print(periph->path, "%s: Disable LUN failed, status 0x%x\n", __func__, en_lun_ccb.ccb_h.status); /* * XXX KDM what do we do now? */ } xpt_print(periph->path, "LUN removed, %ju ATIOs outstanding, %ju " "INOTs outstanding, %d refs\n", softc->atios_sent - softc->atios_returned, softc->inots_sent - softc->inots_returned, periph->refcount); bus_softc = softc->parent_softc; mtx_lock(&bus_softc->lun_softc_mtx); STAILQ_REMOVE(&bus_softc->lun_softc_list, softc, ctlfe_lun_softc, links); mtx_unlock(&bus_softc->lun_softc_mtx); } static void ctlfecleanup(struct cam_periph *periph) { struct ctlfe_lun_softc *softc; xpt_print(periph->path, "%s: Called\n", __func__); softc = (struct ctlfe_lun_softc *)periph->softc; /* * XXX KDM is there anything else that needs to be done here? */ free(softc, M_CTLFE); } static void ctlfedata(struct ctlfe_lun_softc *softc, union ctl_io *io, ccb_flags *flags, uint8_t **data_ptr, uint32_t *dxfer_len, u_int16_t *sglist_cnt) { struct ctlfe_softc *bus_softc; struct ctlfe_lun_cmd_info *cmd_info; struct ctl_sg_entry *ctl_sglist; bus_dma_segment_t *cam_sglist; size_t off; int i, idx; cmd_info = (struct ctlfe_lun_cmd_info *)io->io_hdr.port_priv; bus_softc = softc->parent_softc; /* * Set the direction, relative to the initiator. */ *flags &= ~CAM_DIR_MASK; if ((io->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_IN) *flags |= CAM_DIR_IN; else *flags |= CAM_DIR_OUT; *flags &= ~CAM_DATA_MASK; idx = cmd_info->cur_transfer_index; off = cmd_info->cur_transfer_off; cmd_info->flags &= ~CTLFE_CMD_PIECEWISE; if (io->scsiio.kern_sg_entries == 0) { /* No S/G list. */ *data_ptr = io->scsiio.kern_data_ptr + off; if (io->scsiio.kern_data_len - off <= bus_softc->maxio) { *dxfer_len = io->scsiio.kern_data_len - off; } else { *dxfer_len = bus_softc->maxio; cmd_info->cur_transfer_index = -1; cmd_info->cur_transfer_off = bus_softc->maxio; cmd_info->flags |= CTLFE_CMD_PIECEWISE; } *sglist_cnt = 0; if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) *flags |= CAM_DATA_PADDR; else *flags |= CAM_DATA_VADDR; } else { /* S/G list with physical or virtual pointers. */ ctl_sglist = (struct ctl_sg_entry *)io->scsiio.kern_data_ptr; cam_sglist = cmd_info->cam_sglist; *dxfer_len = 0; for (i = 0; i < io->scsiio.kern_sg_entries - idx; i++) { cam_sglist[i].ds_addr = (bus_addr_t)ctl_sglist[i + idx].addr + off; if (ctl_sglist[i + idx].len - off <= bus_softc->maxio - *dxfer_len) { cam_sglist[i].ds_len = ctl_sglist[idx + i].len - off; *dxfer_len += cam_sglist[i].ds_len; } else { cam_sglist[i].ds_len = bus_softc->maxio - *dxfer_len; cmd_info->cur_transfer_index = idx + i; cmd_info->cur_transfer_off = cam_sglist[i].ds_len + off; cmd_info->flags |= CTLFE_CMD_PIECEWISE; *dxfer_len += cam_sglist[i].ds_len; if (ctl_sglist[i].len != 0) i++; break; } if (i == (CTLFE_MAX_SEGS - 1) && idx + i < (io->scsiio.kern_sg_entries - 1)) { cmd_info->cur_transfer_index = idx + i + 1; cmd_info->cur_transfer_off = 0; cmd_info->flags |= CTLFE_CMD_PIECEWISE; i++; break; } off = 0; } *sglist_cnt = i; if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR) *flags |= CAM_DATA_SG_PADDR; else *flags |= CAM_DATA_SG; *data_ptr = (uint8_t *)cam_sglist; } } static void ctlfestart(struct cam_periph *periph, union ccb *start_ccb) { struct ctlfe_lun_softc *softc; struct ctlfe_lun_cmd_info *cmd_info; struct ccb_hdr *ccb_h; struct ccb_accept_tio *atio; struct ccb_scsiio *csio; uint8_t *data_ptr; uint32_t dxfer_len; ccb_flags flags; union ctl_io *io; uint8_t scsi_status; softc = (struct ctlfe_lun_softc *)periph->softc; softc->ccbs_alloced++; ccb_h = TAILQ_FIRST(&softc->work_queue); if (ccb_h == NULL) { softc->ccbs_freed++; xpt_release_ccb(start_ccb); return; } /* Take the ATIO off the work queue */ TAILQ_REMOVE(&softc->work_queue, ccb_h, periph_links.tqe); atio = (struct ccb_accept_tio *)ccb_h; io = (union ctl_io *)ccb_h->io_ptr; csio = &start_ccb->csio; flags = atio->ccb_h.flags & (CAM_DIS_DISCONNECT|CAM_TAG_ACTION_VALID|CAM_DIR_MASK); cmd_info = (struct ctlfe_lun_cmd_info *)io->io_hdr.port_priv; cmd_info->cur_transfer_index = 0; cmd_info->cur_transfer_off = 0; cmd_info->flags = 0; if (io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) { /* * Datamove call, we need to setup the S/G list. */ scsi_status = 0; csio->cdb_len = atio->cdb_len; ctlfedata(softc, io, &flags, &data_ptr, &dxfer_len, &csio->sglist_cnt); io->scsiio.ext_data_filled += dxfer_len; if (io->scsiio.ext_data_filled > io->scsiio.kern_total_len) { xpt_print(periph->path, "%s: tag 0x%04x " "fill len %u > total %u\n", __func__, io->scsiio.tag_num, io->scsiio.ext_data_filled, io->scsiio.kern_total_len); } } else { /* * We're done, send status back. */ if ((io->io_hdr.flags & CTL_FLAG_ABORT) && (io->io_hdr.flags & CTL_FLAG_ABORT_STATUS) == 0) { io->io_hdr.flags &= ~CTL_FLAG_STATUS_QUEUED; /* * If this command was aborted, we don't * need to send status back to the SIM. * Just free the CTIO and ctl_io, and * recycle the ATIO back to the SIM. */ xpt_print(periph->path, "%s: aborted " "command 0x%04x discarded\n", __func__, io->scsiio.tag_num); /* * For a wildcard attachment, commands can * come in with a specific target/lun. Reset * the target and LUN fields back to the * wildcard values before we send them back * down to the SIM. The SIM has a wildcard * LUN enabled, not whatever target/lun * these happened to be. */ if (softc->flags & CTLFE_LUN_WILDCARD) { atio->ccb_h.target_id = CAM_TARGET_WILDCARD; atio->ccb_h.target_lun = CAM_LUN_WILDCARD; } if ((atio->ccb_h.status & CAM_DEV_QFRZN) != 0) { cam_release_devq(periph->path, /*relsim_flags*/0, /*reduction*/0, /*timeout*/0, /*getcount_only*/0); atio->ccb_h.status &= ~CAM_DEV_QFRZN; } if (atio->ccb_h.func_code != XPT_ACCEPT_TARGET_IO) { xpt_print(periph->path, "%s: func_code " "is %#x\n", __func__, atio->ccb_h.func_code); } start_ccb->ccb_h.func_code = XPT_ABORT; start_ccb->cab.abort_ccb = (union ccb *)atio; /* Tell the SIM that we've aborted this ATIO */ xpt_action(start_ccb); softc->ccbs_freed++; xpt_release_ccb(start_ccb); /* * Send the ATIO back down to the SIM. */ xpt_action((union ccb *)atio); softc->atios_sent++; /* * If we still have work to do, ask for * another CCB. Otherwise, deactivate our * callout. */ if (!TAILQ_EMPTY(&softc->work_queue)) xpt_schedule(periph, /*priority*/ 1); return; } data_ptr = NULL; dxfer_len = 0; csio->sglist_cnt = 0; scsi_status = 0; } if ((io->io_hdr.flags & CTL_FLAG_STATUS_QUEUED) && (cmd_info->flags & CTLFE_CMD_PIECEWISE) == 0 && ((io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) == 0 || io->io_hdr.status == CTL_SUCCESS)) { io->io_hdr.flags |= CTL_FLAG_STATUS_SENT; flags |= CAM_SEND_STATUS; scsi_status = io->scsiio.scsi_status; csio->sense_len = io->scsiio.sense_len; #ifdef CTLFEDEBUG printf("%s: tag %04x status %x\n", __func__, atio->tag_id, io->io_hdr.status); #endif if (csio->sense_len != 0) { csio->sense_data = io->scsiio.sense_data; flags |= CAM_SEND_SENSE; } else if (scsi_status == SCSI_STATUS_CHECK_COND) { xpt_print(periph->path, "%s: check condition " "with no sense\n", __func__); } } #ifdef CTLFEDEBUG printf("%s: %s: tag %04x flags %x ptr %p len %u\n", __func__, (flags & CAM_SEND_STATUS) ? "done" : "datamove", atio->tag_id, flags, data_ptr, dxfer_len); #endif /* * Valid combinations: * - CAM_SEND_STATUS, CAM_DATA_SG = 0, dxfer_len = 0, * sglist_cnt = 0 * - CAM_SEND_STATUS = 0, CAM_DATA_SG = 0, dxfer_len != 0, * sglist_cnt = 0 * - CAM_SEND_STATUS = 0, CAM_DATA_SG, dxfer_len != 0, * sglist_cnt != 0 */ #ifdef CTLFEDEBUG if (((flags & CAM_SEND_STATUS) && (((flags & CAM_DATA_SG) != 0) || (dxfer_len != 0) || (csio->sglist_cnt != 0))) || (((flags & CAM_SEND_STATUS) == 0) && (dxfer_len == 0)) || ((flags & CAM_DATA_SG) && (csio->sglist_cnt == 0)) || (((flags & CAM_DATA_SG) == 0) && (csio->sglist_cnt != 0))) { printf("%s: tag %04x cdb %02x flags %#x dxfer_len " "%d sg %u\n", __func__, atio->tag_id, atio->cdb_io.cdb_bytes[0], flags, dxfer_len, csio->sglist_cnt); printf("%s: tag %04x io status %#x\n", __func__, atio->tag_id, io->io_hdr.status); } #endif cam_fill_ctio(csio, /*retries*/ 2, ctlfedone, flags, (flags & CAM_TAG_ACTION_VALID) ? MSG_SIMPLE_Q_TAG : 0, atio->tag_id, atio->init_id, scsi_status, /*data_ptr*/ data_ptr, /*dxfer_len*/ dxfer_len, /*timeout*/ 5 * 1000); start_ccb->ccb_h.flags |= CAM_UNLOCKED; start_ccb->ccb_h.ccb_atio = atio; if (io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) io->io_hdr.flags |= CTL_FLAG_DMA_INPROG; io->io_hdr.flags &= ~(CTL_FLAG_DMA_QUEUED | CTL_FLAG_STATUS_QUEUED); softc->ctios_sent++; cam_periph_unlock(periph); xpt_action(start_ccb); cam_periph_lock(periph); if ((atio->ccb_h.status & CAM_DEV_QFRZN) != 0) { cam_release_devq(periph->path, /*relsim_flags*/0, /*reduction*/0, /*timeout*/0, /*getcount_only*/0); atio->ccb_h.status &= ~CAM_DEV_QFRZN; } /* * If we still have work to do, ask for another CCB. */ if (!TAILQ_EMPTY(&softc->work_queue)) xpt_schedule(periph, /*priority*/ 1); } static void ctlfe_free_ccb(struct cam_periph *periph, union ccb *ccb) { struct ctlfe_lun_softc *softc; softc = (struct ctlfe_lun_softc *)periph->softc; switch (ccb->ccb_h.func_code) { case XPT_ACCEPT_TARGET_IO: softc->atios_returned++; break; case XPT_IMMEDIATE_NOTIFY: case XPT_NOTIFY_ACKNOWLEDGE: softc->inots_returned++; break; default: break; } ctl_free_io(ccb->ccb_h.io_ptr); free(ccb, M_CTLFE); KASSERT(softc->atios_returned <= softc->atios_sent, ("%s: " "atios_returned %ju > atios_sent %ju", __func__, softc->atios_returned, softc->atios_sent)); KASSERT(softc->inots_returned <= softc->inots_sent, ("%s: " "inots_returned %ju > inots_sent %ju", __func__, softc->inots_returned, softc->inots_sent)); /* * If we have received all of our CCBs, we can release our * reference on the peripheral driver. It will probably go away * now. */ if ((softc->atios_returned == softc->atios_sent) && (softc->inots_returned == softc->inots_sent)) { cam_periph_release_locked(periph); } } static int ctlfe_adjust_cdb(struct ccb_accept_tio *atio, uint32_t offset) { uint64_t lba; uint32_t num_blocks, nbc; uint8_t *cmdbyt = (atio->ccb_h.flags & CAM_CDB_POINTER)? atio->cdb_io.cdb_ptr : atio->cdb_io.cdb_bytes; nbc = offset >> 9; /* ASSUMING 512 BYTE BLOCKS */ switch (cmdbyt[0]) { case READ_6: case WRITE_6: { struct scsi_rw_6 *cdb = (struct scsi_rw_6 *)cmdbyt; lba = scsi_3btoul(cdb->addr); lba &= 0x1fffff; num_blocks = cdb->length; if (num_blocks == 0) num_blocks = 256; lba += nbc; num_blocks -= nbc; scsi_ulto3b(lba, cdb->addr); cdb->length = num_blocks; break; } case READ_10: case WRITE_10: { struct scsi_rw_10 *cdb = (struct scsi_rw_10 *)cmdbyt; lba = scsi_4btoul(cdb->addr); num_blocks = scsi_2btoul(cdb->length); lba += nbc; num_blocks -= nbc; scsi_ulto4b(lba, cdb->addr); scsi_ulto2b(num_blocks, cdb->length); break; } case READ_12: case WRITE_12: { struct scsi_rw_12 *cdb = (struct scsi_rw_12 *)cmdbyt; lba = scsi_4btoul(cdb->addr); num_blocks = scsi_4btoul(cdb->length); lba += nbc; num_blocks -= nbc; scsi_ulto4b(lba, cdb->addr); scsi_ulto4b(num_blocks, cdb->length); break; } case READ_16: case WRITE_16: case WRITE_ATOMIC_16: { struct scsi_rw_16 *cdb = (struct scsi_rw_16 *)cmdbyt; lba = scsi_8btou64(cdb->addr); num_blocks = scsi_4btoul(cdb->length); lba += nbc; num_blocks -= nbc; scsi_u64to8b(lba, cdb->addr); scsi_ulto4b(num_blocks, cdb->length); break; } default: return -1; } return (0); } static void ctlfedone(struct cam_periph *periph, union ccb *done_ccb) { struct ctlfe_lun_softc *softc; struct ctlfe_softc *bus_softc; struct ccb_accept_tio *atio = NULL; union ctl_io *io = NULL; struct mtx *mtx; KASSERT((done_ccb->ccb_h.flags & CAM_UNLOCKED) != 0, ("CCB in ctlfedone() without CAM_UNLOCKED flag")); #ifdef CTLFE_DEBUG printf("%s: entered, func_code = %#x\n", __func__, done_ccb->ccb_h.func_code); #endif softc = (struct ctlfe_lun_softc *)periph->softc; bus_softc = softc->parent_softc; mtx = cam_periph_mtx(periph); mtx_lock(mtx); /* * If the peripheral is invalid, ATIOs and immediate notify CCBs * need to be freed. Most of the ATIOs and INOTs that come back * will be CCBs that are being returned from the SIM as a result of * our disabling the LUN. * * Other CCB types are handled in their respective cases below. */ if (periph->flags & CAM_PERIPH_INVALID) { switch (done_ccb->ccb_h.func_code) { case XPT_ACCEPT_TARGET_IO: case XPT_IMMEDIATE_NOTIFY: case XPT_NOTIFY_ACKNOWLEDGE: ctlfe_free_ccb(periph, done_ccb); goto out; default: break; } } switch (done_ccb->ccb_h.func_code) { case XPT_ACCEPT_TARGET_IO: { atio = &done_ccb->atio; softc->atios_returned++; resubmit: /* * Allocate a ctl_io, pass it to CTL, and wait for the * datamove or done. */ mtx_unlock(mtx); io = done_ccb->ccb_h.io_ptr; ctl_zero_io(io); /* Save pointers on both sides */ io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = done_ccb; done_ccb->ccb_h.io_ptr = io; /* * Only SCSI I/O comes down this path, resets, etc. come * down the immediate notify path below. */ io->io_hdr.io_type = CTL_IO_SCSI; io->io_hdr.nexus.initid.id = atio->init_id; io->io_hdr.nexus.targ_port = bus_softc->port.targ_port; io->io_hdr.nexus.targ_target.id = atio->ccb_h.target_id; io->io_hdr.nexus.targ_lun = atio->ccb_h.target_lun; io->scsiio.tag_num = atio->tag_id; switch (atio->tag_action) { case CAM_TAG_ACTION_NONE: io->scsiio.tag_type = CTL_TAG_UNTAGGED; break; case MSG_SIMPLE_TASK: io->scsiio.tag_type = CTL_TAG_SIMPLE; break; case MSG_HEAD_OF_QUEUE_TASK: io->scsiio.tag_type = CTL_TAG_HEAD_OF_QUEUE; break; case MSG_ORDERED_TASK: io->scsiio.tag_type = CTL_TAG_ORDERED; break; case MSG_ACA_TASK: io->scsiio.tag_type = CTL_TAG_ACA; break; default: io->scsiio.tag_type = CTL_TAG_UNTAGGED; printf("%s: unhandled tag type %#x!!\n", __func__, atio->tag_action); break; } if (atio->cdb_len > sizeof(io->scsiio.cdb)) { printf("%s: WARNING: CDB len %d > ctl_io space %zd\n", __func__, atio->cdb_len, sizeof(io->scsiio.cdb)); } io->scsiio.cdb_len = min(atio->cdb_len, sizeof(io->scsiio.cdb)); bcopy(atio->cdb_io.cdb_bytes, io->scsiio.cdb, io->scsiio.cdb_len); #ifdef CTLFEDEBUG printf("%s: %ju:%d:%ju:%d: tag %04x CDB %02x\n", __func__, (uintmax_t)io->io_hdr.nexus.initid.id, io->io_hdr.nexus.targ_port, (uintmax_t)io->io_hdr.nexus.targ_target.id, io->io_hdr.nexus.targ_lun, io->scsiio.tag_num, io->scsiio.cdb[0]); #endif ctl_queue(io); return; } case XPT_CONT_TARGET_IO: { int srr = 0; uint32_t srr_off = 0; atio = (struct ccb_accept_tio *)done_ccb->ccb_h.ccb_atio; io = (union ctl_io *)atio->ccb_h.io_ptr; softc->ctios_returned++; #ifdef CTLFEDEBUG printf("%s: got XPT_CONT_TARGET_IO tag %#x flags %#x\n", __func__, atio->tag_id, done_ccb->ccb_h.flags); #endif /* * Handle SRR case were the data pointer is pushed back hack */ if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_MESSAGE_RECV && done_ccb->csio.msg_ptr != NULL && done_ccb->csio.msg_ptr[0] == MSG_EXTENDED && done_ccb->csio.msg_ptr[1] == 5 && done_ccb->csio.msg_ptr[2] == 0) { srr = 1; srr_off = (done_ccb->csio.msg_ptr[3] << 24) | (done_ccb->csio.msg_ptr[4] << 16) | (done_ccb->csio.msg_ptr[5] << 8) | (done_ccb->csio.msg_ptr[6]); } if (srr && (io->io_hdr.flags & CTL_FLAG_DMA_INPROG) == 0) { /* * If status was being sent, the back end data is now * history. Hack it up and resubmit a new command with * the CDB adjusted. If the SIM does the right thing, * all of the resid math should work. */ softc->ccbs_freed++; xpt_release_ccb(done_ccb); if (ctlfe_adjust_cdb(atio, srr_off) == 0) { done_ccb = (union ccb *)atio; goto resubmit; } /* * Fall through to doom.... */ } else if (srr) { /* * If we have an srr and we're still sending data, we * should be able to adjust offsets and cycle again. */ io->scsiio.kern_rel_offset = io->scsiio.ext_data_filled = srr_off; io->scsiio.ext_data_len = io->scsiio.kern_total_len - io->scsiio.kern_rel_offset; softc->ccbs_freed++; io->scsiio.io_hdr.status = CTL_STATUS_NONE; xpt_release_ccb(done_ccb); TAILQ_INSERT_HEAD(&softc->work_queue, &atio->ccb_h, periph_links.tqe); xpt_schedule(periph, /*priority*/ 1); break; } /* * If we were sending status back to the initiator, free up * resources. If we were doing a datamove, call the * datamove done routine. */ if ((io->io_hdr.flags & CTL_FLAG_DMA_INPROG) == 0) { softc->ccbs_freed++; xpt_release_ccb(done_ccb); /* * For a wildcard attachment, commands can come in * with a specific target/lun. Reset the target * and LUN fields back to the wildcard values before * we send them back down to the SIM. The SIM has * a wildcard LUN enabled, not whatever target/lun * these happened to be. */ if (softc->flags & CTLFE_LUN_WILDCARD) { atio->ccb_h.target_id = CAM_TARGET_WILDCARD; atio->ccb_h.target_lun = CAM_LUN_WILDCARD; } if (periph->flags & CAM_PERIPH_INVALID) { ctlfe_free_ccb(periph, (union ccb *)atio); } else { softc->atios_sent++; mtx_unlock(mtx); xpt_action((union ccb *)atio); return; } } else { struct ctlfe_lun_cmd_info *cmd_info; struct ccb_scsiio *csio; csio = &done_ccb->csio; cmd_info = (struct ctlfe_lun_cmd_info *) io->io_hdr.port_priv; io->io_hdr.flags &= ~CTL_FLAG_DMA_INPROG; io->scsiio.ext_data_len += csio->dxfer_len; if (io->scsiio.ext_data_len > io->scsiio.kern_total_len) { xpt_print(periph->path, "%s: tag 0x%04x " "done len %u > total %u sent %u\n", __func__, io->scsiio.tag_num, io->scsiio.ext_data_len, io->scsiio.kern_total_len, io->scsiio.ext_data_filled); } /* * Translate CAM status to CTL status. Success * does not change the overall, ctl_io status. In * that case we just set port_status to 0. If we * have a failure, though, set a data phase error * for the overall ctl_io. */ switch (done_ccb->ccb_h.status & CAM_STATUS_MASK) { case CAM_REQ_CMP: io->io_hdr.port_status = 0; break; default: /* * XXX KDM we probably need to figure out a * standard set of errors that the SIM * drivers should return in the event of a * data transfer failure. A data phase * error will at least point the user to a * data transfer error of some sort. * Hopefully the SIM printed out some * additional information to give the user * a clue what happened. */ io->io_hdr.port_status = 0xbad1; ctl_set_data_phase_error(&io->scsiio); /* * XXX KDM figure out residual. */ break; } /* * If we had to break this S/G list into multiple * pieces, figure out where we are in the list, and * continue sending pieces if necessary. */ if ((cmd_info->flags & CTLFE_CMD_PIECEWISE) && (io->io_hdr.port_status == 0)) { ccb_flags flags; uint8_t scsi_status; uint8_t *data_ptr; uint32_t dxfer_len; flags = atio->ccb_h.flags & (CAM_DIS_DISCONNECT| CAM_TAG_ACTION_VALID); ctlfedata(softc, io, &flags, &data_ptr, &dxfer_len, &csio->sglist_cnt); scsi_status = 0; if (((flags & CAM_SEND_STATUS) == 0) && (dxfer_len == 0)) { printf("%s: tag %04x no status or " "len cdb = %02x\n", __func__, atio->tag_id, atio->cdb_io.cdb_bytes[0]); printf("%s: tag %04x io status %#x\n", __func__, atio->tag_id, io->io_hdr.status); } cam_fill_ctio(csio, /*retries*/ 2, ctlfedone, flags, (flags & CAM_TAG_ACTION_VALID) ? MSG_SIMPLE_Q_TAG : 0, atio->tag_id, atio->init_id, scsi_status, /*data_ptr*/ data_ptr, /*dxfer_len*/ dxfer_len, /*timeout*/ 5 * 1000); csio->ccb_h.flags |= CAM_UNLOCKED; csio->resid = 0; csio->ccb_h.ccb_atio = atio; io->io_hdr.flags |= CTL_FLAG_DMA_INPROG; softc->ctios_sent++; mtx_unlock(mtx); xpt_action((union ccb *)csio); } else { /* * Release the CTIO. The ATIO will be sent back * down to the SIM once we send status. */ softc->ccbs_freed++; xpt_release_ccb(done_ccb); mtx_unlock(mtx); /* Call the backend move done callback */ io->scsiio.be_move_done(io); } return; } break; } case XPT_IMMEDIATE_NOTIFY: { union ctl_io *io; struct ccb_immediate_notify *inot; cam_status status; int frozen, send_ctl_io; inot = &done_ccb->cin1; softc->inots_returned++; frozen = (done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0; printf("%s: got XPT_IMMEDIATE_NOTIFY status %#x tag %#x " "seq %#x\n", __func__, inot->ccb_h.status, inot->tag_id, inot->seq_id); io = done_ccb->ccb_h.io_ptr; ctl_zero_io(io); send_ctl_io = 1; io->io_hdr.io_type = CTL_IO_TASK; io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr =done_ccb; inot->ccb_h.io_ptr = io; io->io_hdr.nexus.initid.id = inot->initiator_id; io->io_hdr.nexus.targ_port = bus_softc->port.targ_port; io->io_hdr.nexus.targ_target.id = inot->ccb_h.target_id; io->io_hdr.nexus.targ_lun = inot->ccb_h.target_lun; /* XXX KDM should this be the tag_id? */ io->taskio.tag_num = inot->seq_id; status = inot->ccb_h.status & CAM_STATUS_MASK; switch (status) { case CAM_SCSI_BUS_RESET: io->taskio.task_action = CTL_TASK_BUS_RESET; break; case CAM_BDR_SENT: io->taskio.task_action = CTL_TASK_TARGET_RESET; break; case CAM_MESSAGE_RECV: switch (inot->arg) { case MSG_ABORT_TASK_SET: io->taskio.task_action = CTL_TASK_ABORT_TASK_SET; break; case MSG_TARGET_RESET: io->taskio.task_action = CTL_TASK_TARGET_RESET; break; case MSG_ABORT_TASK: io->taskio.task_action = CTL_TASK_ABORT_TASK; break; case MSG_LOGICAL_UNIT_RESET: io->taskio.task_action = CTL_TASK_LUN_RESET; break; case MSG_CLEAR_TASK_SET: io->taskio.task_action = CTL_TASK_CLEAR_TASK_SET; break; case MSG_CLEAR_ACA: io->taskio.task_action = CTL_TASK_CLEAR_ACA; break; case MSG_NOOP: send_ctl_io = 0; break; default: xpt_print(periph->path, "%s: unsupported message 0x%x\n", __func__, inot->arg); send_ctl_io = 0; break; } break; case CAM_REQ_ABORTED: /* * This request was sent back by the driver. * XXX KDM what do we do here? */ send_ctl_io = 0; break; case CAM_REQ_INVALID: case CAM_PROVIDE_FAIL: default: /* * We should only get here if we're talking * to a talking to a SIM that is target * capable but supports the old API. In * that case, we need to just free the CCB. * If we actually send a notify acknowledge, * it will send that back with an error as * well. */ if ((status != CAM_REQ_INVALID) && (status != CAM_PROVIDE_FAIL)) xpt_print(periph->path, "%s: unsupported CAM status 0x%x\n", __func__, status); ctlfe_free_ccb(periph, done_ccb); goto out; } if (send_ctl_io != 0) { ctl_queue(io); } else { done_ccb->ccb_h.status = CAM_REQ_INPROG; done_ccb->ccb_h.func_code = XPT_NOTIFY_ACKNOWLEDGE; xpt_action(done_ccb); } if (frozen != 0) { cam_release_devq(periph->path, /*relsim_flags*/ 0, /*opening reduction*/ 0, /*timeout*/ 0, /*getcount_only*/ 0); } break; } case XPT_NOTIFY_ACKNOWLEDGE: /* * Queue this back down to the SIM as an immediate notify. */ done_ccb->ccb_h.func_code = XPT_IMMEDIATE_NOTIFY; xpt_action(done_ccb); softc->inots_sent++; break; case XPT_SET_SIM_KNOB: case XPT_GET_SIM_KNOB: break; default: panic("%s: unexpected CCB type %#x", __func__, done_ccb->ccb_h.func_code); break; } out: mtx_unlock(mtx); } static void ctlfe_onoffline(void *arg, int online) { struct ctlfe_softc *bus_softc; union ccb *ccb; cam_status status; struct cam_path *path; int set_wwnn; bus_softc = (struct ctlfe_softc *)arg; set_wwnn = 0; status = xpt_create_path(&path, /*periph*/ NULL, bus_softc->path_id, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); if (status != CAM_REQ_CMP) { printf("%s: unable to create path!\n", __func__); return; } - ccb = (union ccb *)malloc(sizeof(*ccb), M_TEMP, M_NOWAIT | M_ZERO); - if (ccb == NULL) { - printf("%s: unable to malloc CCB!\n", __func__); - xpt_free_path(path); - return; - } + ccb = xpt_alloc_ccb(); xpt_setup_ccb(&ccb->ccb_h, path, CAM_PRIORITY_NONE); /* * Copan WWN format: * * Bits 63-60: 0x5 NAA, IEEE registered name * Bits 59-36: 0x000ED5 IEEE Company name assigned to Copan * Bits 35-12: Copan SSN (Sequential Serial Number) * Bits 11-8: Type of port: * 1 == N-Port * 2 == F-Port * 3 == NL-Port * Bits 7-0: 0 == Node Name, >0 == Port Number */ if (online != 0) { ccb->ccb_h.func_code = XPT_GET_SIM_KNOB; xpt_action(ccb); if ((ccb->knob.xport_specific.valid & KNOB_VALID_ADDRESS) != 0){ #ifdef RANDOM_WWNN uint64_t random_bits; #endif printf("%s: %s current WWNN %#jx\n", __func__, bus_softc->port_name, ccb->knob.xport_specific.fc.wwnn); printf("%s: %s current WWPN %#jx\n", __func__, bus_softc->port_name, ccb->knob.xport_specific.fc.wwpn); #ifdef RANDOM_WWNN arc4rand(&random_bits, sizeof(random_bits), 0); #endif /* * XXX KDM this is a bit of a kludge for now. We * take the current WWNN/WWPN from the card, and * replace the company identifier and the NL-Port * indicator and the port number (for the WWPN). * This should be replaced later with ddb_GetWWNN, * or possibly a more centralized scheme. (It * would be nice to have the WWNN/WWPN for each * port stored in the ctl_port structure.) */ #ifdef RANDOM_WWNN ccb->knob.xport_specific.fc.wwnn = (random_bits & 0x0000000fffffff00ULL) | /* Company ID */ 0x5000ED5000000000ULL | /* NL-Port */ 0x0300; ccb->knob.xport_specific.fc.wwpn = (random_bits & 0x0000000fffffff00ULL) | /* Company ID */ 0x5000ED5000000000ULL | /* NL-Port */ 0x3000 | /* Port Num */ (bus_softc->port.targ_port & 0xff); /* * This is a bit of an API break/reversal, but if * we're doing the random WWNN that's a little * different anyway. So record what we're actually * using with the frontend code so it's reported * accurately. */ ctl_port_set_wwns(&bus_softc->port, true, ccb->knob.xport_specific.fc.wwnn, true, ccb->knob.xport_specific.fc.wwpn); set_wwnn = 1; #else /* RANDOM_WWNN */ /* * If the user has specified a WWNN/WWPN, send them * down to the SIM. Otherwise, record what the SIM * has reported. */ if ((bus_softc->port.wwnn != 0) && (bus_softc->port.wwpn != 0)) { ccb->knob.xport_specific.fc.wwnn = bus_softc->port.wwnn; ccb->knob.xport_specific.fc.wwpn = bus_softc->port.wwpn; set_wwnn = 1; } else { ctl_port_set_wwns(&bus_softc->port, true, ccb->knob.xport_specific.fc.wwnn, true, ccb->knob.xport_specific.fc.wwpn); } #endif /* RANDOM_WWNN */ if (set_wwnn != 0) { printf("%s: %s new WWNN %#jx\n", __func__, bus_softc->port_name, ccb->knob.xport_specific.fc.wwnn); printf("%s: %s new WWPN %#jx\n", __func__, bus_softc->port_name, ccb->knob.xport_specific.fc.wwpn); } } else { printf("%s: %s has no valid WWNN/WWPN\n", __func__, bus_softc->port_name); } } ccb->ccb_h.func_code = XPT_SET_SIM_KNOB; ccb->knob.xport_specific.valid = KNOB_VALID_ROLE; if (set_wwnn != 0) ccb->knob.xport_specific.valid |= KNOB_VALID_ADDRESS; if (online != 0) ccb->knob.xport_specific.fc.role = KNOB_ROLE_TARGET; else ccb->knob.xport_specific.fc.role = KNOB_ROLE_NONE; xpt_action(ccb); if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { printf("%s: SIM %s (path id %d) target %s failed with " "status %#x\n", __func__, bus_softc->port_name, bus_softc->path_id, (online != 0) ? "enable" : "disable", ccb->ccb_h.status); } else { printf("%s: SIM %s (path id %d) target %s succeeded\n", __func__, bus_softc->port_name, bus_softc->path_id, (online != 0) ? "enable" : "disable"); } xpt_free_path(path); - - free(ccb, M_TEMP); - - return; + xpt_free_ccb(ccb); } static void ctlfe_online(void *arg) { struct ctlfe_softc *bus_softc; struct cam_path *path; cam_status status; struct ctlfe_lun_softc *lun_softc; struct cam_periph *periph; bus_softc = (struct ctlfe_softc *)arg; /* * Create the wildcard LUN before bringing the port online. */ status = xpt_create_path(&path, /*periph*/ NULL, bus_softc->path_id, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); if (status != CAM_REQ_CMP) { printf("%s: unable to create path for wildcard periph\n", __func__); return; } - lun_softc = malloc(sizeof(*lun_softc), M_CTLFE, - M_NOWAIT | M_ZERO); - if (lun_softc == NULL) { - xpt_print(path, "%s: unable to allocate softc for " - "wildcard periph\n", __func__); - xpt_free_path(path); - return; - } + lun_softc = malloc(sizeof(*lun_softc), M_CTLFE, M_WAITOK | M_ZERO); xpt_path_lock(path); periph = cam_periph_find(path, "ctl"); if (periph != NULL) { /* We've already got a periph, no need to alloc a new one. */ xpt_path_unlock(path); xpt_free_path(path); free(lun_softc, M_CTLFE); return; } lun_softc->parent_softc = bus_softc; lun_softc->flags |= CTLFE_LUN_WILDCARD; status = cam_periph_alloc(ctlferegister, ctlfeoninvalidate, ctlfecleanup, ctlfestart, "ctl", CAM_PERIPH_BIO, path, ctlfeasync, 0, lun_softc); if ((status & CAM_STATUS_MASK) != CAM_REQ_CMP) { const struct cam_status_entry *entry; entry = cam_fetch_status_entry(status); printf("%s: CAM error %s (%#x) returned from " "cam_periph_alloc()\n", __func__, (entry != NULL) ? entry->status_text : "Unknown", status); free(lun_softc, M_CTLFE); - } else { - mtx_lock(&bus_softc->lun_softc_mtx); - STAILQ_INSERT_TAIL(&bus_softc->lun_softc_list, lun_softc, links); - mtx_unlock(&bus_softc->lun_softc_mtx); - ctlfe_onoffline(arg, /*online*/ 1); } xpt_path_unlock(path); + ctlfe_onoffline(arg, /*online*/ 1); xpt_free_path(path); } static void ctlfe_offline(void *arg) { struct ctlfe_softc *bus_softc; struct cam_path *path; cam_status status; struct cam_periph *periph; bus_softc = (struct ctlfe_softc *)arg; + ctlfe_onoffline(arg, /*online*/ 0); + /* * Disable the wildcard LUN for this port now that we have taken * the port offline. */ status = xpt_create_path(&path, /*periph*/ NULL, bus_softc->path_id, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); if (status != CAM_REQ_CMP) { printf("%s: unable to create path for wildcard periph\n", __func__); return; } - xpt_path_lock(path); - - ctlfe_onoffline(arg, /*online*/ 0); - if ((periph = cam_periph_find(path, "ctl")) != NULL) cam_periph_invalidate(periph); - xpt_path_unlock(path); xpt_free_path(path); } /* * This will get called to enable a LUN on every bus that is attached to * CTL. So we only need to create a path/periph for this particular bus. */ static int ctlfe_lun_enable(void *arg, struct ctl_id targ_id, int lun_id) { struct ctlfe_softc *bus_softc; struct ctlfe_lun_softc *softc; struct cam_path *path; struct cam_periph *periph; cam_status status; bus_softc = (struct ctlfe_softc *)arg; status = xpt_create_path(&path, /*periph*/ NULL, bus_softc->path_id, targ_id.id, lun_id); /* XXX KDM need some way to return status to CTL here? */ if (status != CAM_REQ_CMP) { printf("%s: could not create path, status %#x\n", __func__, status); return (1); } softc = malloc(sizeof(*softc), M_CTLFE, M_WAITOK | M_ZERO); xpt_path_lock(path); periph = cam_periph_find(path, "ctl"); if (periph != NULL) { /* We've already got a periph, no need to alloc a new one. */ xpt_path_unlock(path); xpt_free_path(path); free(softc, M_CTLFE); return (0); } softc->parent_softc = bus_softc; status = cam_periph_alloc(ctlferegister, ctlfeoninvalidate, ctlfecleanup, ctlfestart, "ctl", CAM_PERIPH_BIO, path, ctlfeasync, 0, softc); if ((status & CAM_STATUS_MASK) != CAM_REQ_CMP) { const struct cam_status_entry *entry; entry = cam_fetch_status_entry(status); printf("%s: CAM error %s (%#x) returned from " "cam_periph_alloc()\n", __func__, (entry != NULL) ? entry->status_text : "Unknown", status); free(softc, M_CTLFE); - } else { - mtx_lock(&bus_softc->lun_softc_mtx); - STAILQ_INSERT_TAIL(&bus_softc->lun_softc_list, softc, links); - mtx_unlock(&bus_softc->lun_softc_mtx); } xpt_path_unlock(path); xpt_free_path(path); return (0); } /* * This will get called when the user removes a LUN to disable that LUN * on every bus that is attached to CTL. */ static int ctlfe_lun_disable(void *arg, struct ctl_id targ_id, int lun_id) { struct ctlfe_softc *softc; struct ctlfe_lun_softc *lun_softc; softc = (struct ctlfe_softc *)arg; mtx_lock(&softc->lun_softc_mtx); STAILQ_FOREACH(lun_softc, &softc->lun_softc_list, links) { struct cam_path *path; path = lun_softc->periph->path; if ((xpt_path_target_id(path) == targ_id.id) && (xpt_path_lun_id(path) == lun_id)) { break; } } if (lun_softc == NULL) { mtx_unlock(&softc->lun_softc_mtx); printf("%s: can't find target %d lun %d\n", __func__, targ_id.id, lun_id); return (1); } cam_periph_acquire(lun_softc->periph); mtx_unlock(&softc->lun_softc_mtx); cam_periph_lock(lun_softc->periph); cam_periph_invalidate(lun_softc->periph); cam_periph_unlock(lun_softc->periph); cam_periph_release(lun_softc->periph); return (0); } static void ctlfe_dump_sim(struct cam_sim *sim) { printf("%s%d: max tagged openings: %d, max dev openings: %d\n", sim->sim_name, sim->unit_number, sim->max_tagged_dev_openings, sim->max_dev_openings); } /* * Assumes that the SIM lock is held. */ static void ctlfe_dump_queue(struct ctlfe_lun_softc *softc) { struct ccb_hdr *hdr; struct cam_periph *periph; int num_items; periph = softc->periph; num_items = 0; TAILQ_FOREACH(hdr, &softc->work_queue, periph_links.tqe) { union ctl_io *io = hdr->io_ptr; num_items++; /* * Only regular SCSI I/O is put on the work * queue, so we can print sense here. There may be no * sense if it's no the queue for a DMA, but this serves to * print out the CCB as well. * * XXX KDM switch this over to scsi_sense_print() when * CTL is merged in with CAM. */ ctl_io_error_print(io, NULL); /* * Print DMA status if we are DMA_QUEUED. */ if (io->io_hdr.flags & CTL_FLAG_DMA_QUEUED) { xpt_print(periph->path, "Total %u, Current %u, Resid %u\n", io->scsiio.kern_total_len, io->scsiio.kern_data_len, io->scsiio.kern_data_resid); } } xpt_print(periph->path, "%d requests total waiting for CCBs\n", num_items); xpt_print(periph->path, "%ju CCBs outstanding (%ju allocated, %ju " "freed)\n", (uintmax_t)(softc->ccbs_alloced - softc->ccbs_freed), (uintmax_t)softc->ccbs_alloced, (uintmax_t)softc->ccbs_freed); xpt_print(periph->path, "%ju CTIOs outstanding (%ju sent, %ju " "returned\n", (uintmax_t)(softc->ctios_sent - softc->ctios_returned), softc->ctios_sent, softc->ctios_returned); } /* * Datamove/done routine called by CTL. Put ourselves on the queue to * receive a CCB from CAM so we can queue the continue I/O request down * to the adapter. */ static void ctlfe_datamove(union ctl_io *io) { union ccb *ccb; struct cam_periph *periph; struct ctlfe_lun_softc *softc; KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, ("Unexpected io_type (%d) in ctlfe_datamove", io->io_hdr.io_type)); ccb = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr; periph = xpt_path_periph(ccb->ccb_h.path); cam_periph_lock(periph); softc = (struct ctlfe_lun_softc *)periph->softc; io->io_hdr.flags |= CTL_FLAG_DMA_QUEUED; if ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_STATUS_NONE) io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED; TAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, periph_links.tqe); xpt_schedule(periph, /*priority*/ 1); cam_periph_unlock(periph); } static void ctlfe_done(union ctl_io *io) { union ccb *ccb; struct cam_periph *periph; struct ctlfe_lun_softc *softc; ccb = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr; periph = xpt_path_periph(ccb->ccb_h.path); cam_periph_lock(periph); softc = (struct ctlfe_lun_softc *)periph->softc; if (io->io_hdr.io_type == CTL_IO_TASK) { /* * Task management commands don't require any further * communication back to the adapter. Requeue the CCB * to the adapter, and free the CTL I/O. */ xpt_print(ccb->ccb_h.path, "%s: returning task I/O " "tag %#x seq %#x\n", __func__, ccb->cin1.tag_id, ccb->cin1.seq_id); /* * Send the notify acknowledge down to the SIM, to let it * know we processed the task management command. */ ccb->ccb_h.status = CAM_REQ_INPROG; ccb->ccb_h.func_code = XPT_NOTIFY_ACKNOWLEDGE; xpt_action(ccb); } else if (io->io_hdr.flags & CTL_FLAG_STATUS_SENT) { if (softc->flags & CTLFE_LUN_WILDCARD) { ccb->ccb_h.target_id = CAM_TARGET_WILDCARD; ccb->ccb_h.target_lun = CAM_LUN_WILDCARD; } if (periph->flags & CAM_PERIPH_INVALID) { ctlfe_free_ccb(periph, ccb); } else { softc->atios_sent++; cam_periph_unlock(periph); xpt_action(ccb); return; } } else { io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED; TAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h, periph_links.tqe); xpt_schedule(periph, /*priority*/ 1); } cam_periph_unlock(periph); } static void ctlfe_dump(void) { struct ctlfe_softc *bus_softc; struct ctlfe_lun_softc *lun_softc; STAILQ_FOREACH(bus_softc, &ctlfe_softc_list, links) { ctlfe_dump_sim(bus_softc->sim); STAILQ_FOREACH(lun_softc, &bus_softc->lun_softc_list, links) ctlfe_dump_queue(lun_softc); } } Index: projects/clang350-import/sys =================================================================== --- projects/clang350-import/sys (revision 275366) +++ projects/clang350-import/sys (revision 275367) Property changes on: projects/clang350-import/sys ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/sys:r275364-275366 Index: projects/clang350-import =================================================================== --- projects/clang350-import (revision 275366) +++ projects/clang350-import (revision 275367) Property changes on: projects/clang350-import ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r275364-275366