diff options
author | bugaevskiy <bugaevskiy@yandex-team.com> | 2022-09-25 19:28:13 +0300 |
---|---|---|
committer | bugaevskiy <bugaevskiy@yandex-team.com> | 2022-09-25 19:28:13 +0300 |
commit | 7e4be6d951751b3da88d4cf2b57559870c56d3ed (patch) | |
tree | 74926995779c1206655027e4ea919b90c1f13ded /contrib | |
parent | 28b6f457594e2f97604ba60b967734a623bf3449 (diff) | |
download | ydb-7e4be6d951751b3da88d4cf2b57559870c56d3ed.tar.gz |
Remove boost/libs stub
Diffstat (limited to 'contrib')
16 files changed, 87 insertions, 124 deletions
diff --git a/contrib/restricted/boost/bind/include/boost/bind.hpp b/contrib/restricted/boost/bind/include/boost/bind.hpp deleted file mode 100644 index 85ba128410..0000000000 --- a/contrib/restricted/boost/bind/include/boost/bind.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef BOOST_BIND_HPP_INCLUDED -#define BOOST_BIND_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// bind.hpp - binds function objects to arguments -// -// Copyright (c) 2009, 2015 Peter Dimov -// -// Distributed under the Boost Software License, Version 1.0. -// See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt -// -// See http://www.boost.org/libs/bind/bind.html for documentation. -// -// For backward compatibility, this header includes -// <boost/bind/bind.hpp> and then imports the placeholders _1, _2, -// _3, ... into the global namespace. Definitions in the global -// namespace are not a good practice and this use is deprecated. -// Please switch to including <boost/bind/bind.hpp> directly, -// adding the using directive locally where appropriate. -// Alternatively, the existing behavior may be preserved by defining -// the macro BOOST_BIND_GLOBAL_PLACEHOLDERS. - -#include <boost/bind/bind.hpp> -#include <boost/config/pragma_message.hpp> - -#ifndef BOOST_BIND_NO_PLACEHOLDERS - -#if 0 //!defined(BOOST_BIND_GLOBAL_PLACEHOLDERS) - -BOOST_PRAGMA_MESSAGE( - "The practice of declaring the Bind placeholders (_1, _2, ...) " - "in the global namespace is deprecated. Please use " - "<boost/bind/bind.hpp> + using namespace boost::placeholders, " - "or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior." -) - -#endif - -#if defined(BOOST_CLANG) -# pragma clang diagnostic push -# if __has_warning("-Wheader-hygiene") -# pragma clang diagnostic ignored "-Wheader-hygiene" -# endif -#endif - -using namespace boost::placeholders; - -#if defined(BOOST_CLANG) -# pragma clang diagnostic pop -#endif - -#endif // #ifndef BOOST_BIND_NO_PLACEHOLDERS - -#endif // #ifndef BOOST_BIND_HPP_INCLUDED diff --git a/contrib/restricted/boost/python/include/boost/python/converter/obj_mgr_arg_from_python.hpp b/contrib/restricted/boost/python/include/boost/python/converter/obj_mgr_arg_from_python.hpp index cd4e1e0ea8..5132804082 100644 --- a/contrib/restricted/boost/python/include/boost/python/converter/obj_mgr_arg_from_python.hpp +++ b/contrib/restricted/boost/python/include/boost/python/converter/obj_mgr_arg_from_python.hpp @@ -81,9 +81,9 @@ inline object_manager_ref_arg_from_python<Ref>::object_manager_ref_arg_from_pyth # if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 243 // needed for warning suppression python::detail::borrowed_reference x_ = python::detail::borrowed_reference(x); - python::detail::construct_referent<Ref>(&m_result.bytes, x_); + python::detail::construct_referent<Ref>(m_result.bytes, x_); # else - python::detail::construct_referent<Ref>(&m_result.bytes, (python::detail::borrowed_reference)x); + python::detail::construct_referent<Ref>(m_result.bytes, (python::detail::borrowed_reference)x); # endif } diff --git a/contrib/restricted/boost/python/include/boost/python/converter/rvalue_from_python_data.hpp b/contrib/restricted/boost/python/include/boost/python/converter/rvalue_from_python_data.hpp index acb38f8498..d728681b3e 100644 --- a/contrib/restricted/boost/python/include/boost/python/converter/rvalue_from_python_data.hpp +++ b/contrib/restricted/boost/python/include/boost/python/converter/rvalue_from_python_data.hpp @@ -9,6 +9,7 @@ # include <boost/python/detail/referent_storage.hpp> # include <boost/python/detail/destroy.hpp> # include <boost/python/detail/type_traits.hpp> +# include <boost/align/align.hpp> # include <boost/static_assert.hpp> # include <cstddef> @@ -132,7 +133,13 @@ template <class T> inline rvalue_from_python_data<T>::~rvalue_from_python_data() { if (this->stage1.convertible == this->storage.bytes) - python::detail::destroy_referent<ref_type>(this->storage.bytes); + { + size_t allocated = sizeof(this->storage); + void *ptr = this->storage.bytes; + void *aligned_storage = + ::boost::alignment::align(boost::python::detail::alignment_of<T>::value, 0, ptr, allocated); + python::detail::destroy_referent<ref_type>(aligned_storage); + } } }}} // namespace boost::python::converter diff --git a/contrib/restricted/boost/python/include/boost/python/converter/shared_ptr_from_python.hpp b/contrib/restricted/boost/python/include/boost/python/converter/shared_ptr_from_python.hpp index bb2ae863ff..b5c62ba940 100644 --- a/contrib/restricted/boost/python/include/boost/python/converter/shared_ptr_from_python.hpp +++ b/contrib/restricted/boost/python/include/boost/python/converter/shared_ptr_from_python.hpp @@ -49,13 +49,17 @@ struct shared_ptr_from_python new (storage) SP<T>(); else { - SP<void> hold_convertible_ref_count( - (void*)0, shared_ptr_deleter(handle<>(borrowed(source))) ); - // use aliasing constructor - new (storage) SP<T>(hold_convertible_ref_count, - static_cast<T*>(data->convertible)); + void *const storage = ((converter::rvalue_from_python_storage<SP<T> >*)data)->storage.bytes; + // Deal with the "None" case. + if (data->convertible == source) + new (storage) SP<T>(); + else + { + SP<void> hold_convertible_ref_count((void*)0, shared_ptr_deleter(handle<>(borrowed(source))) ); + // use aliasing constructor + new (storage) SP<T>(hold_convertible_ref_count, static_cast<T*>(data->convertible)); + } } - data->convertible = storage; } }; diff --git a/contrib/restricted/boost/python/include/boost/python/detail/referent_storage.hpp b/contrib/restricted/boost/python/include/boost/python/detail/referent_storage.hpp index 2cddf696d5..f646d2ae1d 100644 --- a/contrib/restricted/boost/python/include/boost/python/detail/referent_storage.hpp +++ b/contrib/restricted/boost/python/include/boost/python/detail/referent_storage.hpp @@ -5,39 +5,21 @@ #ifndef REFERENT_STORAGE_DWA200278_HPP # define REFERENT_STORAGE_DWA200278_HPP # include <boost/mpl/if.hpp> +# include <boost/type_traits/aligned_storage.hpp> # include <cstddef> namespace boost { namespace python { namespace detail { -struct alignment_dummy; -typedef void (*function_ptr)(); -typedef int (alignment_dummy::*member_ptr); -typedef int (alignment_dummy::*member_function_ptr)(); - -# define BOOST_PYTHON_ALIGNER(T, n) \ - typename mpl::if_c< \ - sizeof(T) <= size, T, char>::type t##n - -// Storage for size bytes, aligned to all fundamental types no larger than size -template <std::size_t size> -union aligned_storage +template <std::size_t size, std::size_t alignment = std::size_t(-1)> +struct aligned_storage { - BOOST_PYTHON_ALIGNER(char, 0); - BOOST_PYTHON_ALIGNER(short, 1); - BOOST_PYTHON_ALIGNER(int, 2); - BOOST_PYTHON_ALIGNER(long, 3); - BOOST_PYTHON_ALIGNER(float, 4); - BOOST_PYTHON_ALIGNER(double, 5); - BOOST_PYTHON_ALIGNER(long double, 6); - BOOST_PYTHON_ALIGNER(void*, 7); - BOOST_PYTHON_ALIGNER(function_ptr, 8); - BOOST_PYTHON_ALIGNER(member_ptr, 9); - BOOST_PYTHON_ALIGNER(member_function_ptr, 10); + union type + { + typename ::boost::aligned_storage<size, alignment>::type data; char bytes[size]; + }; }; - -# undef BOOST_PYTHON_ALIGNER - + // Compute the size of T's referent. We wouldn't need this at all, // but sizeof() is broken in CodeWarriors <= 8.0 template <class T> struct referent_size; @@ -50,15 +32,12 @@ union aligned_storage std::size_t, value = sizeof(T)); }; - // A metafunction returning a POD type which can store U, where T == // U&. If T is not a reference type, returns a POD which can store T. template <class T> struct referent_storage { - typedef aligned_storage< - ::boost::python::detail::referent_size<T>::value - > type; + typedef typename aligned_storage<referent_size<T>::value, alignment_of<T>::value>::type type; }; }}} // namespace boost::python::detail diff --git a/contrib/restricted/boost/python/include/boost/python/exception_translator.hpp b/contrib/restricted/boost/python/include/boost/python/exception_translator.hpp index 75ed0e1eec..1aa1465bdf 100644 --- a/contrib/restricted/boost/python/include/boost/python/exception_translator.hpp +++ b/contrib/restricted/boost/python/include/boost/python/exception_translator.hpp @@ -7,7 +7,7 @@ # include <boost/python/detail/prefix.hpp> -# include <boost/bind.hpp> +# include <boost/bind/bind.hpp> # include <boost/bind/placeholders.hpp> # include <boost/type.hpp> # include <boost/python/detail/translate_exception.hpp> @@ -18,6 +18,7 @@ namespace boost { namespace python { template <class ExceptionType, class Translate> void register_exception_translator(Translate translate, boost::type<ExceptionType>* = 0) { + using namespace boost::placeholders; detail::register_exception_handler( boost::bind<bool>(detail::translate_exception<ExceptionType,Translate>(), _1, _2, translate) ); diff --git a/contrib/restricted/boost/python/include/boost/python/instance_holder.hpp b/contrib/restricted/boost/python/include/boost/python/instance_holder.hpp index 2ffb4bf956..3113bd93c7 100644 --- a/contrib/restricted/boost/python/include/boost/python/instance_holder.hpp +++ b/contrib/restricted/boost/python/include/boost/python/instance_holder.hpp @@ -38,7 +38,7 @@ struct BOOST_PYTHON_DECL instance_holder : private noncopyable // Allocate storage for an object of the given size at the given // offset in the Python instance<> object if bytes are available // there. Otherwise allocate size bytes of heap memory. - static void* allocate(PyObject*, std::size_t offset, std::size_t size); + static void* allocate(PyObject*, std::size_t offset, std::size_t size, std::size_t alignment = 1); // Deallocate storage from the heap if it was not carved out of // the given Python object by allocate(), above. diff --git a/contrib/restricted/boost/python/include/boost/python/iterator.hpp b/contrib/restricted/boost/python/include/boost/python/iterator.hpp index 7c06ca2320..b0ea578959 100644 --- a/contrib/restricted/boost/python/include/boost/python/iterator.hpp +++ b/contrib/restricted/boost/python/include/boost/python/iterator.hpp @@ -22,7 +22,7 @@ works correctly. */ # pragma warning(disable: 4180) # endif -# include <boost/bind.hpp> +# include <boost/bind/bind.hpp> # include <boost/bind/protect.hpp> namespace boost { namespace python { @@ -40,6 +40,7 @@ namespace detail , Target&(*)() ) { + using namespace boost::placeholders; return objects::make_iterator_function<Target>( boost::protect(boost::bind(get_start, _1)) , boost::protect(boost::bind(get_finish, _1)) diff --git a/contrib/restricted/boost/python/include/boost/python/object/instance.hpp b/contrib/restricted/boost/python/include/boost/python/object/instance.hpp index 27b91a1e5f..ee4a6c5822 100644 --- a/contrib/restricted/boost/python/include/boost/python/object/instance.hpp +++ b/contrib/restricted/boost/python/include/boost/python/object/instance.hpp @@ -6,7 +6,7 @@ # define INSTANCE_DWA200295_HPP # include <boost/python/detail/prefix.hpp> - +# include <boost/python/detail/type_traits.hpp> # include <cstddef> namespace boost { namespace python @@ -28,7 +28,7 @@ struct instance typedef typename boost::python::detail::type_with_alignment< boost::python::detail::alignment_of<Data>::value >::type align_t; - + union { align_t align; @@ -41,9 +41,10 @@ struct additional_instance_size { typedef instance<Data> instance_data; typedef instance<char> instance_char; - BOOST_STATIC_CONSTANT( - std::size_t, value = sizeof(instance_data) - - BOOST_PYTHON_OFFSETOF(instance_char,storage)); + BOOST_STATIC_CONSTANT(std::size_t, + value = sizeof(instance_data) - + BOOST_PYTHON_OFFSETOF(instance_char,storage) + + boost::python::detail::alignment_of<Data>::value); }; }}} // namespace boost::python::object diff --git a/contrib/restricted/boost/python/include/boost/python/object/make_holder.hpp b/contrib/restricted/boost/python/include/boost/python/object/make_holder.hpp index 0d54dd9f66..735e5395ca 100644 --- a/contrib/restricted/boost/python/include/boost/python/object/make_holder.hpp +++ b/contrib/restricted/boost/python/include/boost/python/object/make_holder.hpp @@ -89,8 +89,9 @@ struct make_holder<N> BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, t, a)) { typedef instance<Holder> instance_t; - - void* memory = Holder::allocate(p, offsetof(instance_t, storage), sizeof(Holder)); + + void* memory = Holder::allocate(p, offsetof(instance_t, storage), sizeof(Holder), + boost::python::detail::alignment_of<Holder>::value); try { (new (memory) Holder( p BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_DO_FORWARD_ARG, nil)))->install(p); diff --git a/contrib/restricted/boost/python/include/boost/python/object/make_instance.hpp b/contrib/restricted/boost/python/include/boost/python/object/make_instance.hpp index 5eb3aa9d9c..713fdc5ecd 100644 --- a/contrib/restricted/boost/python/include/boost/python/object/make_instance.hpp +++ b/contrib/restricted/boost/python/include/boost/python/object/make_instance.hpp @@ -43,11 +43,14 @@ struct make_instance_impl // construct the new C++ object and install the pointer // in the Python object. - Derived::construct(&instance->storage, (PyObject*)instance, x)->install(raw_result); + Holder *holder =Derived::construct(instance->storage.bytes, (PyObject*)instance, x); + holder->install(raw_result); // Note the position of the internally-stored Holder, // for the sake of destruction - Py_SET_SIZE(instance, offsetof(instance_t, storage)); + const size_t offset = reinterpret_cast<size_t>(holder) - + reinterpret_cast<size_t>(instance->storage.bytes) + offsetof(instance_t, storage); + Py_SET_SIZE(instance, offset); // Release ownership of the python object protect.cancel(); @@ -69,7 +72,10 @@ struct make_instance static inline Holder* construct(void* storage, PyObject* instance, reference_wrapper<T const> x) { - return new (storage) Holder(instance, x); + size_t allocated = objects::additional_instance_size<Holder>::value; + void* aligned_storage = ::boost::alignment::align(boost::python::detail::alignment_of<Holder>::value, + sizeof(Holder), storage, allocated); + return new (aligned_storage) Holder(instance, x); } }; diff --git a/contrib/restricted/boost/python/src/exec.cpp b/contrib/restricted/boost/python/src/exec.cpp index 8bc8be996b..df1971691b 100644 --- a/contrib/restricted/boost/python/src/exec.cpp +++ b/contrib/restricted/boost/python/src/exec.cpp @@ -128,7 +128,7 @@ object BOOST_PYTHON_DECL exec_file(char const *filename, object global, object l PyObject* result = PyRun_File(fs, f, Py_file_input, - global.ptr(), local.ptr()); + global.ptr(), local.ptr()); if (!result) throw_error_already_set(); return object(detail::new_reference(result)); } diff --git a/contrib/restricted/boost/python/src/object/class.cpp b/contrib/restricted/boost/python/src/object/class.cpp index 9f8dc61ad1..c3afd1127f 100644 --- a/contrib/restricted/boost/python/src/object/class.cpp +++ b/contrib/restricted/boost/python/src/object/class.cpp @@ -5,6 +5,7 @@ #include <boost/python/detail/prefix.hpp> #include <boost/mpl/lambda.hpp> // #including this first is an intel6 workaround +#include <boost/cstdint.hpp> #include <boost/python/object/class.hpp> #include <boost/python/object/instance.hpp> @@ -721,28 +722,47 @@ namespace objects } // namespace objects -void* instance_holder::allocate(PyObject* self_, std::size_t holder_offset, std::size_t holder_size) +typedef unsigned int alignment_marker_t; + +void* instance_holder::allocate(PyObject* self_, std::size_t holder_offset, std::size_t holder_size, std::size_t alignment) { assert(PyType_IsSubtype(Py_TYPE(Py_TYPE(self_)), &class_metatype_object)); objects::instance<>* self = (objects::instance<>*)self_; - int total_size_needed = holder_offset + holder_size; + int total_size_needed = holder_offset + holder_size + alignment - 1; if (-Py_SIZE(self) >= total_size_needed) { // holder_offset should at least point into the variable-sized part assert(holder_offset >= offsetof(objects::instance<>,storage)); + size_t allocated = holder_size + alignment; + void* storage = (char*)self + holder_offset; + void* aligned_storage = ::boost::alignment::align(alignment, holder_size, storage, allocated); + // Record the fact that the storage is occupied, noting where it starts - Py_SET_SIZE(self, holder_offset); - return (char*)self + holder_offset; + const size_t offset = reinterpret_cast<uintptr_t>(aligned_storage) - reinterpret_cast<uintptr_t>(storage) + holder_offset; + Py_SET_SIZE(self, offset); + return (char*)self + offset; } else { - void* const result = PyMem_Malloc(holder_size); - if (result == 0) + const size_t base_allocation = sizeof(alignment_marker_t) + holder_size + alignment - 1; + void* const base_storage = PyMem_Malloc(base_allocation); + if (base_storage == 0) throw std::bad_alloc(); - return result; + + const uintptr_t x = reinterpret_cast<uintptr_t>(base_storage) + sizeof(alignment_marker_t); + //this has problems for x -> max(void *) + //const size_t padding = alignment - ((x + sizeof(alignment_marker_t)) % alignment); + //only works for alignments with alignments of powers of 2, but no edge conditions + const uintptr_t padding = alignment == 1 ? 0 : ( alignment - (x & (alignment - 1)) ); + const size_t aligned_offset = sizeof(alignment_marker_t) + padding; + void* const aligned_storage = (char *)base_storage + aligned_offset; + BOOST_ASSERT((char *) aligned_storage + holder_size <= (char *)base_storage + base_allocation); + alignment_marker_t* const marker_storage = reinterpret_cast<alignment_marker_t *>((char *)aligned_storage - sizeof(alignment_marker_t)); + *marker_storage = static_cast<alignment_marker_t>(padding); + return aligned_storage; } } @@ -752,7 +772,9 @@ void instance_holder::deallocate(PyObject* self_, void* storage) noexcept objects::instance<>* self = (objects::instance<>*)self_; if (storage != (char*)self + Py_SIZE(self)) { - PyMem_Free(storage); + alignment_marker_t* marker_storage = reinterpret_cast<alignment_marker_t *>((char *)storage - sizeof(alignment_marker_t)); + void *malloced_storage = (char *) storage - sizeof(alignment_marker_t) - (*marker_storage); + PyMem_Free(malloced_storage); } } diff --git a/contrib/restricted/boost/python/src/object/function.cpp b/contrib/restricted/boost/python/src/object/function.cpp index 787679e138..4adb49453c 100644 --- a/contrib/restricted/boost/python/src/object/function.cpp +++ b/contrib/restricted/boost/python/src/object/function.cpp @@ -21,7 +21,7 @@ #include <boost/python/detail/none.hpp> #include <boost/mpl/vector/vector10.hpp> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <algorithm> #include <cstring> diff --git a/contrib/restricted/boost/python/src/object/inheritance.cpp b/contrib/restricted/boost/python/src/object/inheritance.cpp index 7dc9db1cd7..a7b3156e41 100644 --- a/contrib/restricted/boost/python/src/object/inheritance.cpp +++ b/contrib/restricted/boost/python/src/object/inheritance.cpp @@ -11,7 +11,7 @@ #include <boost/graph/adjacency_list.hpp> #include <boost/graph/reverse_graph.hpp> #include <boost/property_map/property_map.hpp> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <boost/integer_traits.hpp> #include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple_comparison.hpp> @@ -184,6 +184,7 @@ namespace // map a type to a position in the index inline type_index_t::iterator type_position(class_id type) { + using namespace boost::placeholders; typedef index_entry entry; return std::lower_bound( diff --git a/contrib/restricted/boost/python/src/object/iterator.cpp b/contrib/restricted/boost/python/src/object/iterator.cpp index 3f6c4adacd..6b885a982c 100644 --- a/contrib/restricted/boost/python/src/object/iterator.cpp +++ b/contrib/restricted/boost/python/src/object/iterator.cpp @@ -5,7 +5,7 @@ #include <boost/python/object/iterator_core.hpp> #include <boost/python/object/function_object.hpp> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <boost/mpl/vector/vector10.hpp> namespace boost { namespace python { namespace objects { |