From d1d6e27ab661f71d90fb6530db84d5a2b92550a8 Mon Sep 17 00:00:00 2001 From: kenshi84 Date: Tue, 20 Dec 2016 11:51:22 +0900 Subject: [PATCH] moved boost cpp into hpp since they're supposed to be header only --- external/CMakeLists.txt | 1 - external/boost/CMakeLists.txt | 35 ----- .../boost/archive/portable_binary_archive.hpp | 2 + .../archive/portable_binary_iarchive.hpp | 132 +++++++++++++++++ .../archive/portable_binary_oarchive.hpp | 100 +++++++++++++ .../boost/src/portable_binary_iarchive.cpp | 135 ------------------ .../boost/src/portable_binary_oarchive.cpp | 102 ------------- src/wallet/CMakeLists.txt | 1 - 8 files changed, 234 insertions(+), 274 deletions(-) delete mode 100644 external/boost/CMakeLists.txt delete mode 100644 external/boost/src/portable_binary_iarchive.cpp delete mode 100644 external/boost/src/portable_binary_oarchive.cpp diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index c3eba838..91611b11 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -98,4 +98,3 @@ else() endif() add_subdirectory(db_drivers) -add_subdirectory(boost) diff --git a/external/boost/CMakeLists.txt b/external/boost/CMakeLists.txt deleted file mode 100644 index 03bdbe86..00000000 --- a/external/boost/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2014-2016, The Monero Project -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are -# permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of -# conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, this list -# of conditions and the following disclaimer in the documentation and/or other -# materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its contributors may be -# used to endorse or promote products derived from this software without specific -# prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -cmake_minimum_required(VERSION 2.8.7) - -project(boost_extra) - -add_library(boost_extra - src/portable_binary_iarchive.cpp - src/portable_binary_oarchive.cpp) diff --git a/external/boost/archive/portable_binary_archive.hpp b/external/boost/archive/portable_binary_archive.hpp index f3668b9a..560ef121 100644 --- a/external/boost/archive/portable_binary_archive.hpp +++ b/external/boost/archive/portable_binary_archive.hpp @@ -23,6 +23,8 @@ #include #include +#include + namespace boost { namespace archive { enum portable_binary_archive_flags { diff --git a/external/boost/archive/portable_binary_iarchive.hpp b/external/boost/archive/portable_binary_iarchive.hpp index 30804d95..c33085b0 100644 --- a/external/boost/archive/portable_binary_iarchive.hpp +++ b/external/boost/archive/portable_binary_iarchive.hpp @@ -30,6 +30,7 @@ #include #include +#include namespace boost { namespace archive { @@ -201,6 +202,137 @@ public: // required by export in boost <= 1.34 #define BOOST_ARCHIVE_CUSTOM_IARCHIVE_TYPES portable_binary_iarchive +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// portable_binary_iarchive.cpp + +// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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 for updates, documentation, and revision history. + +#include +#include + +#include +#include +#include + +namespace boost { namespace archive { + +inline void +portable_binary_iarchive::load_impl(boost::intmax_t & l, char maxsize){ + char size; + l = 0; + this->primitive_base_t::load(size); + + if(0 == size){ + return; + } + + bool negative = (size < 0); + if(negative) + size = -size; + + if(size > maxsize) + boost::serialization::throw_exception( + portable_binary_iarchive_exception() + ); + + char * cptr = reinterpret_cast(& l); + #ifdef BOOST_BIG_ENDIAN + cptr += (sizeof(boost::intmax_t) - size); + #endif + this->primitive_base_t::load_binary(cptr, size); + + #ifdef BOOST_BIG_ENDIAN + if(m_flags & endian_little) + #else + if(m_flags & endian_big) + #endif + reverse_bytes(size, cptr); + + if(negative) + l = -l; +} + +inline void +portable_binary_iarchive::load_override( + boost::archive::class_name_type & t +){ + std::string cn; + cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE); + load_override(cn); + if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1)) + boost::serialization::throw_exception( + boost::archive::archive_exception( + boost::archive::archive_exception::invalid_class_name) + ); + std::memcpy(t, cn.data(), cn.size()); + // borland tweak + t.t[cn.size()] = '\0'; +} + +inline void +portable_binary_iarchive::init(unsigned int flags){ + if(0 == (flags & boost::archive::no_header)){ + // read signature in an archive version independent manner + std::string file_signature; + * this >> file_signature; + if(file_signature != boost::archive::BOOST_ARCHIVE_SIGNATURE()) + boost::serialization::throw_exception( + boost::archive::archive_exception( + boost::archive::archive_exception::invalid_signature + ) + ); + // make sure the version of the reading archive library can + // support the format of the archive being read + boost::archive::library_version_type input_library_version; + * this >> input_library_version; + + // extra little .t is to get around borland quirk + if(boost::archive::BOOST_ARCHIVE_VERSION() < input_library_version) + boost::serialization::throw_exception( + boost::archive::archive_exception( + boost::archive::archive_exception::unsupported_version + ) + ); + + #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) + this->set_library_version(input_library_version); + //#else + //#if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + //detail:: + //#endif + boost::archive::detail::basic_iarchive::set_library_version( + input_library_version + ); + #endif + } + unsigned char x; + load(x); + m_flags = x << CHAR_BIT; +} + +} } + +namespace boost { +namespace archive { + +namespace detail { + template class archive_serializer_map; +} + +template class basic_binary_iprimitive< + portable_binary_iarchive, + std::istream::char_type, + std::istream::traits_type +> ; + +} // namespace archive +} // namespace boost + #if defined(_MSC_VER) #pragma warning( pop ) #endif diff --git a/external/boost/archive/portable_binary_oarchive.hpp b/external/boost/archive/portable_binary_oarchive.hpp index 89ac3d9f..19027f65 100644 --- a/external/boost/archive/portable_binary_oarchive.hpp +++ b/external/boost/archive/portable_binary_oarchive.hpp @@ -29,6 +29,7 @@ #include #include +#include namespace boost { namespace archive { @@ -187,6 +188,105 @@ public: // required by export in boost <= 1.34 #define BOOST_ARCHIVE_CUSTOM_OARCHIVE_TYPES portable_binary_oarchive +/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 +// portable_binary_oarchive.cpp + +// (C) Copyright 2002-7 Robert Ramey - http://www.rrsd.com . +// Use, modification and distribution is subject to 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 for updates, documentation, and revision history. + +#include +#include + +namespace boost { namespace archive { + +inline void +portable_binary_oarchive::save_impl( + const boost::intmax_t l, + const char maxsize +){ + char size = 0; + + if(l == 0){ + this->primitive_base_t::save(size); + return; + } + + boost::intmax_t ll; + bool negative = (l < 0); + if(negative) + ll = -l; + else + ll = l; + + do{ + ll >>= CHAR_BIT; + ++size; + }while(ll != 0); + + this->primitive_base_t::save( + static_cast(negative ? -size : size) + ); + + if(negative) + ll = -l; + else + ll = l; + char * cptr = reinterpret_cast(& ll); + #ifdef BOOST_BIG_ENDIAN + cptr += (sizeof(boost::intmax_t) - size); + if(m_flags & endian_little) + reverse_bytes(size, cptr); + #else + if(m_flags & endian_big) + reverse_bytes(size, cptr); + #endif + this->primitive_base_t::save_binary(cptr, size); +} + +inline void +portable_binary_oarchive::init(unsigned int flags) { + if(m_flags == (endian_big | endian_little)){ + boost::serialization::throw_exception( + portable_binary_oarchive_exception() + ); + } + if(0 == (flags & boost::archive::no_header)){ + // write signature in an archive version independent manner + const std::string file_signature( + boost::archive::BOOST_ARCHIVE_SIGNATURE() + ); + * this << file_signature; + // write library version + const boost::archive::library_version_type v( + boost::archive::BOOST_ARCHIVE_VERSION() + ); + * this << v; + } + save(static_cast(m_flags >> CHAR_BIT)); +} + +} } + +namespace boost { +namespace archive { + +namespace detail { + template class archive_serializer_map; +} + +template class basic_binary_oprimitive< + portable_binary_oarchive, + std::ostream::char_type, + std::ostream::traits_type +> ; + +} // namespace archive +} // namespace boost + #if defined(_MSC_VER) #pragma warning( pop ) #endif diff --git a/external/boost/src/portable_binary_iarchive.cpp b/external/boost/src/portable_binary_iarchive.cpp deleted file mode 100644 index 4fdcf882..00000000 --- a/external/boost/src/portable_binary_iarchive.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// portable_binary_iarchive.cpp - -// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . -// Use, modification and distribution is subject to 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 for updates, documentation, and revision history. - -#include -#include - -#include -#include -#include - -#include - -namespace boost { namespace archive { - -void -portable_binary_iarchive::load_impl(boost::intmax_t & l, char maxsize){ - char size; - l = 0; - this->primitive_base_t::load(size); - - if(0 == size){ - return; - } - - bool negative = (size < 0); - if(negative) - size = -size; - - if(size > maxsize) - boost::serialization::throw_exception( - portable_binary_iarchive_exception() - ); - - char * cptr = reinterpret_cast(& l); - #ifdef BOOST_BIG_ENDIAN - cptr += (sizeof(boost::intmax_t) - size); - #endif - this->primitive_base_t::load_binary(cptr, size); - - #ifdef BOOST_BIG_ENDIAN - if(m_flags & endian_little) - #else - if(m_flags & endian_big) - #endif - reverse_bytes(size, cptr); - - if(negative) - l = -l; -} - -void -portable_binary_iarchive::load_override( - boost::archive::class_name_type & t -){ - std::string cn; - cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE); - load_override(cn); - if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1)) - boost::serialization::throw_exception( - boost::archive::archive_exception( - boost::archive::archive_exception::invalid_class_name) - ); - std::memcpy(t, cn.data(), cn.size()); - // borland tweak - t.t[cn.size()] = '\0'; -} - -void -portable_binary_iarchive::init(unsigned int flags){ - if(0 == (flags & boost::archive::no_header)){ - // read signature in an archive version independent manner - std::string file_signature; - * this >> file_signature; - if(file_signature != boost::archive::BOOST_ARCHIVE_SIGNATURE()) - boost::serialization::throw_exception( - boost::archive::archive_exception( - boost::archive::archive_exception::invalid_signature - ) - ); - // make sure the version of the reading archive library can - // support the format of the archive being read - boost::archive::library_version_type input_library_version; - * this >> input_library_version; - - // extra little .t is to get around borland quirk - if(boost::archive::BOOST_ARCHIVE_VERSION() < input_library_version) - boost::serialization::throw_exception( - boost::archive::archive_exception( - boost::archive::archive_exception::unsupported_version - ) - ); - - #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) - this->set_library_version(input_library_version); - //#else - //#if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1200) - //detail:: - //#endif - boost::archive::detail::basic_iarchive::set_library_version( - input_library_version - ); - #endif - } - unsigned char x; - load(x); - m_flags = x << CHAR_BIT; -} - -} } - -#include -#include - -namespace boost { -namespace archive { - -namespace detail { - template class archive_serializer_map; -} - -template class basic_binary_iprimitive< - portable_binary_iarchive, - std::istream::char_type, - std::istream::traits_type -> ; - -} // namespace archive -} // namespace boost diff --git a/external/boost/src/portable_binary_oarchive.cpp b/external/boost/src/portable_binary_oarchive.cpp deleted file mode 100644 index ee6215bd..00000000 --- a/external/boost/src/portable_binary_oarchive.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 -// portable_binary_oarchive.cpp - -// (C) Copyright 2002-7 Robert Ramey - http://www.rrsd.com . -// Use, modification and distribution is subject to 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 for updates, documentation, and revision history. - -#include -#include -#include - -namespace boost { namespace archive { - -void -portable_binary_oarchive::save_impl( - const boost::intmax_t l, - const char maxsize -){ - char size = 0; - - if(l == 0){ - this->primitive_base_t::save(size); - return; - } - - boost::intmax_t ll; - bool negative = (l < 0); - if(negative) - ll = -l; - else - ll = l; - - do{ - ll >>= CHAR_BIT; - ++size; - }while(ll != 0); - - this->primitive_base_t::save( - static_cast(negative ? -size : size) - ); - - if(negative) - ll = -l; - else - ll = l; - char * cptr = reinterpret_cast(& ll); - #ifdef BOOST_BIG_ENDIAN - cptr += (sizeof(boost::intmax_t) - size); - if(m_flags & endian_little) - reverse_bytes(size, cptr); - #else - if(m_flags & endian_big) - reverse_bytes(size, cptr); - #endif - this->primitive_base_t::save_binary(cptr, size); -} - -void -portable_binary_oarchive::init(unsigned int flags) { - if(m_flags == (endian_big | endian_little)){ - boost::serialization::throw_exception( - portable_binary_oarchive_exception() - ); - } - if(0 == (flags & boost::archive::no_header)){ - // write signature in an archive version independent manner - const std::string file_signature( - boost::archive::BOOST_ARCHIVE_SIGNATURE() - ); - * this << file_signature; - // write library version - const boost::archive::library_version_type v( - boost::archive::BOOST_ARCHIVE_VERSION() - ); - * this << v; - } - save(static_cast(m_flags >> CHAR_BIT)); -} - -} } - -#include -#include - -namespace boost { -namespace archive { - -namespace detail { - template class archive_serializer_map; -} - -template class basic_binary_oprimitive< - portable_binary_oarchive, - std::ostream::char_type, - std::ostream::traits_type -> ; - -} // namespace archive -} // namespace boost diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt index e34b7b57..056a1ca1 100644 --- a/src/wallet/CMakeLists.txt +++ b/src/wallet/CMakeLists.txt @@ -73,7 +73,6 @@ target_link_libraries(wallet cryptonote_core mnemonics p2p - boost_extra ${Boost_CHRONO_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} ${Boost_FILESYSTEM_LIBRARY}