Skip to content

Commit

Permalink
Fixing last part of #721: Make HPX usable for Xeon Phi
Browse files Browse the repository at this point in the history
 - reliably fix Intel compiler support, this includes pushing Boost changes upstream
  • Loading branch information
sithhell committed Sep 9, 2013
1 parent ce4fae5 commit b986d57
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 1 deletion.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Expand Up @@ -176,6 +176,12 @@ hpx_include_directories(${hpx_SOURCE_DIR}/external/endian)
if(${BOOST_MINOR_VERSION} LESS 49)
hpx_include_directories(${hpx_SOURCE_DIR}/external/serialization)
endif()
# If we compile natively for the MIC, we need some workarounds for certain
# boost headers
# FIXME: push changes upstream
if(HPX_NATIVE_MIC)
hpx_include_directories(${hpx_SOURCE_DIR}/external/asio)
endif()

if(UNIX)
hpx_link_directories(${CMAKE_BINARY_DIR}/lib/hpx)
Expand Down Expand Up @@ -1492,6 +1498,16 @@ if(NOT HPX_NO_INSTALL)
PATTERN ".git" EXCLUDE)
endif()

if(HPX_NATIVE_MIC)
# FIXME: push changes upstream
install(
DIRECTORY external/asio/boost
DESTINATION include/hpx/external
COMPONENT core
FILES_MATCHING PATTERN "*.hpp"
PATTERN ".git" EXCLUDE)
endif()

if(${BOOST_MINOR_VERSION} LESS 53)
# install Boost.Atomic library for older Boost versions only
install(
Expand Down
202 changes: 202 additions & 0 deletions external/asio/boost/asio/ip/basic_resolver_iterator.hpp
@@ -0,0 +1,202 @@
//
// ip/basic_resolver_iterator.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
//

#ifndef BOOST_ASIO_IP_BASIC_RESOLVER_ITERATOR_HPP
#define BOOST_ASIO_IP_BASIC_RESOLVER_ITERATOR_HPP

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)

#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <cstring>
#include <iterator>
#include <string>
#include <vector>
#include <boost/asio/detail/shared_ptr.hpp>
#include <boost/asio/detail/socket_ops.hpp>
#include <boost/asio/detail/socket_types.hpp>
#include <boost/asio/ip/basic_resolver_entry.hpp>

#include <boost/asio/detail/push_options.hpp>

namespace boost {
namespace asio {
namespace ip {

/// An iterator over the entries produced by a resolver.
/**
* The boost::asio::ip::basic_resolver_iterator class template is used to define
* iterators over the results returned by a resolver.
*
* The iterator's value_type, obtained when the iterator is dereferenced, is:
* @code const basic_resolver_entry<InternetProtocol> @endcode
*
* @par Thread Safety
* @e Distinct @e objects: Safe.@n
* @e Shared @e objects: Unsafe.
*/
template <typename InternetProtocol>
class basic_resolver_iterator
{
public:
/// The type used for the distance between two iterators.
typedef std::ptrdiff_t difference_type;

/// The type of the value pointed to by the iterator.
typedef basic_resolver_entry<InternetProtocol> value_type;

/// The type of the result of applying operator->() to the iterator.
typedef const basic_resolver_entry<InternetProtocol>* pointer;

/// The type of the result of applying operator*() to the iterator.
typedef const basic_resolver_entry<InternetProtocol>& reference;

/// The iterator category.
typedef std::forward_iterator_tag iterator_category;

/// Default constructor creates an end iterator.
basic_resolver_iterator()
: index_(0)
{
}

basic_resolver_iterator(basic_resolver_iterator const & o)
: index_(o.index_)
, values_(o.values_)
{}

/// Create an iterator from an addrinfo list returned by getaddrinfo.
static basic_resolver_iterator create(
boost::asio::detail::addrinfo_type* address_info,
const std::string& host_name, const std::string& service_name)
{
basic_resolver_iterator iter;
if (!address_info)
return iter;

std::string actual_host_name = host_name;
if (address_info->ai_canonname)
actual_host_name = address_info->ai_canonname;

iter.values_.reset(new values_type);

while (address_info)
{
if (address_info->ai_family == PF_INET
|| address_info->ai_family == PF_INET6)
{
using namespace std; // For memcpy.
typename InternetProtocol::endpoint endpoint;
endpoint.resize(static_cast<std::size_t>(address_info->ai_addrlen));
memcpy(endpoint.data(), address_info->ai_addr,
address_info->ai_addrlen);
iter.values_->push_back(
basic_resolver_entry<InternetProtocol>(endpoint,
actual_host_name, service_name));
}
address_info = address_info->ai_next;
}

return iter;
}

/// Create an iterator from an endpoint, host name and service name.
static basic_resolver_iterator create(
const typename InternetProtocol::endpoint& endpoint,
const std::string& host_name, const std::string& service_name)
{
basic_resolver_iterator iter;
iter.values_.reset(new values_type);
iter.values_->push_back(
basic_resolver_entry<InternetProtocol>(
endpoint, host_name, service_name));
return iter;
}

/// Dereference an iterator.
const basic_resolver_entry<InternetProtocol>& operator*() const
{
return dereference();
}

/// Dereference an iterator.
const basic_resolver_entry<InternetProtocol>* operator->() const
{
return &dereference();
}

/// Increment operator (prefix).
basic_resolver_iterator& operator++()
{
increment();
return *this;
}

/// Increment operator (postfix).
basic_resolver_iterator operator++(int)
{
basic_resolver_iterator tmp(*this);
++*this;
return tmp;
}

/// Test two iterators for equality.
friend bool operator==(const basic_resolver_iterator& a,
const basic_resolver_iterator& b)
{
return a.equal(b);
}

/// Test two iterators for inequality.
friend bool operator!=(const basic_resolver_iterator& a,
const basic_resolver_iterator& b)
{
return !a.equal(b);
}

private:
void increment()
{
if (++index_ == values_->size())
{
// Reset state to match a default constructed end iterator.
values_.reset();
index_ = 0;
}
}

bool equal(const basic_resolver_iterator& other) const
{
if (!values_ && !other.values_)
return true;
if (values_ != other.values_)
return false;
return index_ == other.index_;
}

const basic_resolver_entry<InternetProtocol>& dereference() const
{
return (*values_)[index_];
}

std::size_t index_;
typedef std::vector<basic_resolver_entry<InternetProtocol> > values_type;
boost::asio::detail::shared_ptr<values_type> values_;
};

} // namespace ip
} // namespace asio
} // namespace boost

#include <boost/asio/detail/pop_options.hpp>

#endif // BOOST_ASIO_IP_BASIC_RESOLVER_ITERATOR_HPP
2 changes: 1 addition & 1 deletion hpx/config/boost/compiler/intel.hpp
Expand Up @@ -215,7 +215,7 @@ template<> struct assert_intrinsic_wchar_t<unsigned short> {};
//# undef BOOST_NO_CXX11_RVALUE_REFERENCES // Enabling this breaks Filesystem and Exception libraries
//# undef BOOST_NO_CXX11_SCOPED_ENUMS // doesn't really work!!
# undef BOOST_NO_CXX11_DELETED_FUNCTIONS
# undef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
//# undef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
# undef BOOST_NO_CXX11_LAMBDAS
# undef BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS
# undef BOOST_NO_CXX11_DECLTYPE
Expand Down

0 comments on commit b986d57

Please sign in to comment.