Commit 1c1e17d8 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

removing boost-dll

parent c77d9bd8
......@@ -82,7 +82,6 @@ install(FILES "${CMAKE_BINARY_DIR}/xacc_config.hpp" DESTINATION include/xacc)
include_directories(${CMAKE_BINARY_DIR})
include_directories(${MPI_INCLUDE_PATH})
include_directories(${Boost_INCLUDE_DIRS})
include_directories(tpls/boost-dll)
include_directories(${CppMicroServices_INCLUDE_DIR})
include_directories("${CMAKE_SOURCE_DIR}/xacc")
include_directories("${CMAKE_SOURCE_DIR}/xacc/ir")
......@@ -92,7 +91,6 @@ include_directories("${CMAKE_SOURCE_DIR}/xacc/accelerator")
include_directories("${CMAKE_SOURCE_DIR}/xacc/utils")
# Add subdirectories
add_subdirectory(tpls)
add_subdirectory(xacc)
add_subdirectory(quantum)
add_subdirectory(impls)
......
add_subdirectory(boost-dll)
file(GLOB BOOST_DLL_FILES boost/dll/*.hpp)
file(GLOB BOOST_DLL_DETAIL_FILES boost/dll/detail/*.hpp)
file(GLOB BOOST_DLL_DETAIL_POSIX_FILES boost/dll/detail/posix/*.hpp)
file(GLOB BOOST_DLL_DETAIL_DEMANGLING_FILES boost/dll/detail/demangling/*.hpp)
file(GLOB BOOST_DLL_DETAIL_WINDOWS_FILES boost/dll/detail/windows/*.hpp)
install(FILES "boost/dll.hpp" DESTINATION include/boost)
install(FILES ${BOOST_DLL_FILES} DESTINATION include/boost/dll)
install(FILES ${BOOST_DLL_DETAIL_FILES} DESTINATION include/boost/dll/detail)
install(FILES ${BOOST_DLL_DETAIL_POSIX_FILES} DESTINATION include/boost/dll/detail/posix)
install(FILES ${BOOST_DLL_DETAIL_DEMANGLING_FILES} DESTINATION include/boost/dll/detail/demangling)
install(FILES ${BOOST_DLL_DETAIL_WINDOWS_FILES} DESTINATION include/boost/dll/detail/windows)
\ No newline at end of file
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2016 Antony Polukhin.
//
// 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_DLL_DLL_HPP
#define BOOST_DLL_DLL_HPP
/// \file boost/dll.hpp
/// \brief Includes all the non-experimental headers of the Boost.DLL library.
#include <boost/config.hpp>
#include <boost/dll/shared_library.hpp>
#include <boost/dll/alias.hpp>
#include <boost/dll/import.hpp>
#include <boost/dll/library_info.hpp>
#include <boost/dll/runtime_symbol_info.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
#endif // BOOST_DLL_DLL_HPP
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015 Antony Polukhin.
//
// 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_DLL_ALIAS_HPP
#define BOOST_DLL_ALIAS_HPP
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/predef/compiler.h>
#include <boost/predef/os.h>
#include <boost/dll/detail/aggressive_ptr_cast.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
/// \file boost/dll/alias.hpp
/// \brief Includes alias methods and macro. You can include this header or
/// boost/dll/shared_library.hpp to reduce dependencies
/// in case you do not use the refcountable functions.
namespace boost { namespace dll {
#ifdef BOOST_DLL_DOXYGEN
/// Define this macro to explicitly specify translation unit in which alias must be instantiated.
/// See section 'Limitations' for more info. You may find usage examples in source codes of almost each tutorial.
/// Must be used in code, when \forcedmacrolink{BOOST_DLL_FORCE_NO_WEAK_EXPORTS} is defined
#define BOOST_DLL_FORCE_ALIAS_INSTANTIATION
/// Define this macro to disable exporting weak symbols and start using the \forcedmacrolink{BOOST_DLL_FORCE_ALIAS_INSTANTIATION}.
/// This may be usefull for working around linker problems or to test your program for compatability with linkers that do not support export of weak symbols.
#define BOOST_DLL_FORCE_NO_WEAK_EXPORTS
#endif
#if BOOST_COMP_MSVC || (BOOST_COMP_INTEL && BOOST_OS_WINDOWS)
#define BOOST_DLL_SELECTANY __declspec(selectany)
#define BOOST_DLL_SECTION(SectionName, Permissions) \
BOOST_STATIC_ASSERT_MSG( \
sizeof(#SectionName) < 10, \
"Some platforms require section names to be at most 8 bytest" \
); \
__pragma(section(#SectionName, Permissions)) __declspec(allocate(#SectionName)) \
/**/
#else // #if BOOST_COMP_MSVC
#if BOOST_OS_WINDOWS || BOOST_OS_ANDROID || BOOST_COMP_IBM
// There are some problems with mixing `__dllexport__` and `weak` using MinGW
// See https://sourceware.org/bugzilla/show_bug.cgi?id=17480
//
// Android had an issue with exporting weak symbols
// https://code.google.com/p/android/issues/detail?id=70206
#define BOOST_DLL_SELECTANY
#else // #if BOOST_OS_WINDOWS
/*!
* \brief Macro that allows linker to select any occurrence of this symbol instead of
* failing with 'multiple definitions' error at linktime.
*
* This macro does not work on Android, IBM XL C/C++ and MinGW+Windows
* because of linker problems with exporting weak symbols
* (See https://code.google.com/p/android/issues/detail?id=70206, https://sourceware.org/bugzilla/show_bug.cgi?id=17480)
*/
#define BOOST_DLL_SELECTANY __attribute__((weak))
#endif // #if BOOST_OS_WINDOWS
// TODO: improve section permissions using following info:
// http://stackoverflow.com/questions/6252812/what-does-the-aw-flag-in-the-section-attribute-mean
#if !BOOST_OS_MACOS && !BOOST_OS_IOS
/*!
* \brief Macro that puts symbol to a specific section. On MacOS all the sections are put into "__DATA" segment.
* \param SectionName Name of the section. Must be a valid C identifier without quotes not longer than 8 bytes.
* \param Permissions Can be "read" or "write" (without quotes!).
*/
#define BOOST_DLL_SECTION(SectionName, Permissions) \
BOOST_STATIC_ASSERT_MSG( \
sizeof(#SectionName) < 10, \
"Some platforms require section names to be at most 8 bytest" \
); \
__attribute__ ((section (#SectionName))) \
/**/
#else // #if !BOOST_OS_MACOS && !BOOST_OS_IOS
#define BOOST_DLL_SECTION(SectionName, Permissions) \
BOOST_STATIC_ASSERT_MSG( \
sizeof(#SectionName) < 10, \
"Some platforms require section names to be at most 8 bytest" \
); \
__attribute__ ((section ( "__DATA," #SectionName))) \
/**/
#endif // #if #if !BOOST_OS_MACOS && !BOOST_OS_IOS
#endif // #if BOOST_COMP_MSVC
// Alias - is just a variable that pointers to original data
//
// A few attempts were made to avoid additional indirection:
// 1)
// // Does not work on Windows, work on Linux
// extern "C" BOOST_SYMBOL_EXPORT void AliasName() {
// reinterpret_cast<void (*)()>(Function)();
// }
//
// 2)
// // Does not work on Linux (changes permissions of .text section and produces incorrect DSO)
// extern "C" BOOST_SYMBOL_EXPORT void* __attribute__ ((section(".text#")))
// func_ptr = *reinterpret_cast<std::ptrdiff_t**>(&foo::bar);
//
// 3) // requires mangled name of `Function`
// // AliasName() __attribute__ ((weak, alias ("Function")))
//
// // hard to use
// `#pragma comment(linker, "/alternatename:_pWeakValue=_pDefaultWeakValue")`
/*!
* \brief Makes an alias name for exported function or variable.
*
* This macro is useful in cases of long mangled C++ names. For example some `void boost::foo(std::sting)`
* function name will change to something like `N5boostN3foosE` after mangling.
* Importing function by `N5boostN3foosE` name does not looks user friendly, especially assuming the fact
* that different compilers have different mangling schemes. AliasName is the name that won't be mangled
* and can be used as a portable import name.
*
*
* Can be used in any namespace, including global. FunctionOrVar must be fully qualified,
* so that address of it could be taken. Multiple different aliases for a single variable/function
* are allowed.
*
* Make sure that AliasNames are unique per library/executable. Functions or variables
* in global namespace must not have names same as AliasNames.
*
* Same AliasName in different translation units must point to the same FunctionOrVar.
*
* Puts all the aliases into the \b "boostdll" read only section of the binary. Equal to
* \forcedmacrolink{BOOST_DLL_ALIAS_SECTIONED}(FunctionOrVar, AliasName, boostdll).
*
* \param FunctionOrVar Function or variable for which an alias must be made.
* \param AliasName Name of the alias. Must be a valid C identifier.
*
* \b Example:
* \code
* namespace foo {
* void bar(std::string&);
*
* BOOST_DLL_ALIAS(foo::bar, foo_bar)
* }
*
* BOOST_DLL_ALIAS(foo::bar, foo_bar_another_alias_name)
* \endcode
*
* \b See: \forcedmacrolink{BOOST_DLL_ALIAS_SECTIONED} for making alias in a specific section.
*/
#define BOOST_DLL_ALIAS(FunctionOrVar, AliasName) \
BOOST_DLL_ALIAS_SECTIONED(FunctionOrVar, AliasName, boostdll) \
/**/
#if ((BOOST_COMP_GNUC && BOOST_OS_WINDOWS) || BOOST_OS_ANDROID || BOOST_COMP_IBM || defined(BOOST_DLL_FORCE_NO_WEAK_EXPORTS)) \
&& !defined(BOOST_DLL_FORCE_ALIAS_INSTANTIATION) && !defined(BOOST_DLL_DOXYGEN)
#define BOOST_DLL_ALIAS_SECTIONED(FunctionOrVar, AliasName, SectionName) \
namespace _autoaliases { \
extern "C" BOOST_SYMBOL_EXPORT const void *AliasName; \
} /* namespace _autoaliases */ \
/**/
#define BOOST_DLL_AUTO_ALIAS(FunctionOrVar) \
namespace _autoaliases { \
extern "C" BOOST_SYMBOL_EXPORT const void *FunctionOrVar; \
} /* namespace _autoaliases */ \
/**/
#else
// Note: we can not use `aggressive_ptr_cast` here, because in that case GCC applies
// different permissions to the section and it causes Segmentation fault.
// Note: we can not use `boost::addressof()` here, because in that case GCC
// may optimize away the FunctionOrVar instance and we'll get a pointer to unexisting symbol.
/*!
* \brief Same as \forcedmacrolink{BOOST_DLL_ALIAS} but puts alias name into the user specified section.
*
* \param FunctionOrVar Function or variable for which an alias must be made.
* \param AliasName Name of the alias. Must be a valid C identifier.
* \param SectionName Name of the section. Must be a valid C identifier without quotes not longer than 8 bytes.
*
* \b Example:
* \code
* namespace foo {
* void bar(std::string&);
*
* BOOST_DLL_ALIAS_SECTIONED(foo::bar, foo_bar, sect_1) // section "sect_1" now exports "foo_bar"
* }
* \endcode
*
*/
#define BOOST_DLL_ALIAS_SECTIONED(FunctionOrVar, AliasName, SectionName) \
namespace _autoaliases { \
extern "C" BOOST_SYMBOL_EXPORT const void *AliasName; \
BOOST_DLL_SECTION(SectionName, read) BOOST_DLL_SELECTANY \
const void * AliasName = reinterpret_cast<const void*>(reinterpret_cast<intptr_t>( \
&FunctionOrVar \
)); \
} /* namespace _autoaliases */ \
/**/
/*!
* \brief Exports variable or function with unmangled alias name.
*
* This macro is useful in cases of long mangled C++ names. For example some `void boost::foo(std::sting)`
* function name will change to something like `N5boostN3foosE` after mangling.
* Importing function by `N5boostN3foosE` name does not looks user friendly, especially assuming the fact
* that different compilers have different mangling schemes.*
*
* Must be used in scope where FunctionOrVar declared. FunctionOrVar must be a valid C name, which means that
* it must not contain `::`.
*
* Functions or variables
* in global namespace must not have names same as FunctionOrVar.
*
* Puts all the aliases into the \b "boostdll" read only section of the binary. Almost same as
* \forcedmacrolink{BOOST_DLL_ALIAS}(FunctionOrVar, FunctionOrVar).
*
* \param FunctionOrVar Function or variable for which an unmangled alias must be made.
*
* \b Example:
* \code
* namespace foo {
* void bar(std::string&);
* BOOST_DLL_AUTO_ALIAS(bar)
* }
*
* \endcode
*
* \b See: \forcedmacrolink{BOOST_DLL_ALIAS} for making an alias with different names.
*/
#define BOOST_DLL_AUTO_ALIAS(FunctionOrVar) \
namespace _autoaliases { \
BOOST_DLL_SELECTANY const void * dummy_ ## FunctionOrVar \
= reinterpret_cast<const void*>(reinterpret_cast<intptr_t>( \
&FunctionOrVar \
)); \
extern "C" BOOST_SYMBOL_EXPORT const void *FunctionOrVar; \
BOOST_DLL_SECTION(boostdll, read) BOOST_DLL_SELECTANY \
const void * FunctionOrVar = dummy_ ## FunctionOrVar; \
} /* namespace _autoaliases */ \
/**/
#endif
}} // namespace boost::dll
#endif // BOOST_DLL_ALIAS_HPP
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2017 Antony Polukhin.
//
// 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_DLL_DETAIL_AGGRESSIVE_PTR_CAST_HPP
#define BOOST_DLL_DETAIL_AGGRESSIVE_PTR_CAST_HPP
#include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_member_pointer.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/enable_if.hpp>
#include <cstring> // std::memcpy
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 301)
# pragma GCC system_header
#endif
namespace boost { namespace dll { namespace detail {
// GCC warns when reinterpret_cast between function pointer and object pointer occur.
// This method suppress the warnings and ensures that such casts are safe.
template <class To, class From>
BOOST_FORCEINLINE typename boost::disable_if_c<boost::is_member_pointer<To>::value || boost::is_reference<To>::value || boost::is_member_pointer<From>::value, To>::type
aggressive_ptr_cast(From v) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT_MSG(
boost::is_pointer<To>::value && boost::is_pointer<From>::value,
"`agressive_ptr_cast` function must be used only for pointer casting."
);
BOOST_STATIC_ASSERT_MSG(
boost::is_void< typename boost::remove_pointer<To>::type >::value
|| boost::is_void< typename boost::remove_pointer<From>::type >::value,
"`agressive_ptr_cast` function must be used only for casting to or from void pointers."
);
BOOST_STATIC_ASSERT_MSG(
sizeof(v) == sizeof(To),
"Pointer to function and pointer to object differ in size on your platform."
);
return reinterpret_cast<To>(v);
}
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning(disable: 4172) // "returning address of local variable or temporary" but **v is not local!
#endif
template <class To, class From>
BOOST_FORCEINLINE typename boost::disable_if_c<!boost::is_reference<To>::value || boost::is_member_pointer<From>::value, To>::type
aggressive_ptr_cast(From v) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT_MSG(
boost::is_pointer<From>::value,
"`agressive_ptr_cast` function must be used only for pointer casting."
);
BOOST_STATIC_ASSERT_MSG(
boost::is_void< typename boost::remove_pointer<From>::type >::value,
"`agressive_ptr_cast` function must be used only for casting to or from void pointers."
);
BOOST_STATIC_ASSERT_MSG(
sizeof(v) == sizeof(typename boost::remove_reference<To>::type*),
"Pointer to function and pointer to object differ in size on your platform."
);
return static_cast<To>(
**reinterpret_cast<typename boost::remove_reference<To>::type**>(
v
)
);
}
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
template <class To, class From>
BOOST_FORCEINLINE typename boost::disable_if_c<!boost::is_member_pointer<To>::value || boost::is_member_pointer<From>::value, To>::type
aggressive_ptr_cast(From v) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT_MSG(
boost::is_pointer<From>::value,
"`agressive_ptr_cast` function must be used only for pointer casting."
);
BOOST_STATIC_ASSERT_MSG(
boost::is_void< typename boost::remove_pointer<From>::type >::value,
"`agressive_ptr_cast` function must be used only for casting to or from void pointers."
);
To res = 0;
std::memcpy(&res, &v, sizeof(From));
return res;
}
template <class To, class From>
BOOST_FORCEINLINE typename boost::disable_if_c<boost::is_member_pointer<To>::value || !boost::is_member_pointer<From>::value, To>::type
aggressive_ptr_cast(From /* v */) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT_MSG(
boost::is_pointer<To>::value,
"`agressive_ptr_cast` function must be used only for pointer casting."
);
BOOST_STATIC_ASSERT_MSG(
boost::is_void< typename boost::remove_pointer<To>::type >::value,
"`agressive_ptr_cast` function must be used only for casting to or from void pointers."
);
BOOST_STATIC_ASSERT_MSG(
!sizeof(From),
"Casting from member pointers to void pointer is not implemnted in `agressive_ptr_cast`."
);
return 0;
}
}}} // boost::dll::detail
#endif // BOOST_DLL_DETAIL_AGGRESSIVE_PTR_CAST_HPP
// Copyright 2016 Klemens Morgenstern, Antony Polukhin
//
// 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)
// For more information, see http://www.boost.org
#ifndef BOOST_DLL_DETAIL_CTOR_DTOR_HPP_
#define BOOST_DLL_DETAIL_CTOR_DTOR_HPP_
#include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
#include <boost/dll/detail/aggressive_ptr_cast.hpp>
#include <boost/dll/detail/get_mem_fn_type.hpp>
#if defined(BOOST_MSVC) || defined(BOOST_MSVC_VER)
# include <boost/dll/detail/demangling/msvc.hpp>
#else
# include <boost/dll/detail/demangling/itanium.hpp>
#endif
namespace boost { namespace dll { namespace detail {
/*!
* This class stores a constructor.
*
* In some compilers there are several constructors in code, which may include an allocating one.
* This can be used if the imported class shall be put on the heap, which is why the class provied both types.
*/
template<typename Signature>
struct constructor;
template<typename Class, typename ...Args>
struct constructor<Class(Args...)> {
typedef typename detail::get_mem_fn_type<Class, void(Args...)>::mem_fn standard_t;
typedef Class*(*allocating_t)(Args...);
//! The standard, i.e. not allocating constructor. @warning May differ with the compiler. Use @ref constructor::call_standard instead.
standard_t standard;
//! The allocating constructor. @warning May differ with the compiler. Use @ref constructor::call_allocating instead.
allocating_t allocating;
//! Call the standard contructor
void call_standard (Class * const ptr, Args...args){ (ptr->*standard)(static_cast<Args>(args)...); }
//! Call the deleting destructor
Class * call_allocating(Args...args){ return allocating(static_cast<Args>(args)...); }
//! True if a allocating constructor could be loaded.
bool has_allocating() const { return allocating != nullptr; }
//! True if a standard constructor could be loaded.
bool has_standard() const { return standard != nullptr; }
//! False if neither the allocating nor the standard constructor is available.
bool is_empty() const { return (allocating == nullptr) && (standard == nullptr) ; }
constructor() = delete;
constructor(const constructor &) = default;
explicit constructor(standard_t standard, allocating_t allocating = nullptr)
: standard(standard)
, allocating(allocating)
{}
};
template <typename Class>
struct destructor {
#if !defined(_WIN32)
typedef void(*type)(Class* const);
#elif !defined(_WIN64)
typedef void(__thiscall * type)(Class* const);
#else
typedef void(__cdecl * type)(Class* const);
#endif
typedef type standard_t;
typedef type deleting_t;
//! The standard, i.e. not deleting destructor. @warning May differ with the compiler. Use @ref destructor::call_standard instead.
standard_t standard;
//! The deleting destructor. @warning May differ with the compiler. Use @ref destructor::call_deallocating instead.
deleting_t deleting;
//! Call the standard contructor
void call_standard(Class * const ptr){ standard(ptr); }
//! Call the deleting destructor
void call_deleting(Class * const ptr){ deleting(ptr); }
//! True if a deleting destructor could be loaded.
bool has_deleting() const { return deleting != nullptr; }
//! True if a standard destructor could be loaded.
bool has_standard() const { return standard != nullptr; }
//! False if neither the deleting nor the standard destructor is available.
bool is_empty() const { return (deleting == nullptr) && (standard == nullptr) ; }
destructor() = delete;
//! Copy destructor.
destructor(const destructor &) = default;
//! Construct it from both the standard destructor and the allocating destructor
explicit destructor(const standard_t &standard, const deleting_t &deleting = nullptr)
: standard(standard)
, deleting(deleting)
{}
};
#if defined(BOOST_MSVC) || defined(BOOST_MSVC_VER)
template<typename Signature, typename Lib>
constructor<Signature> load_ctor(Lib & lib, const mangled_storage_impl::ctor_sym & ct) {
typedef typename constructor<Signature>::standard_t standard_t;
standard_t ctor = lib.template get<standard_t>(ct);
return constructor<Signature>(ctor);
}
template<typename Class, typename Lib>
destructor<Class> load_dtor(Lib & lib, const mangled_storage_impl::dtor_sym & dt) {
typedef typename destructor<Class>::standard_t standard_t;
//@apolukhin That does NOT work this way with MSVC-14 x32 via memcpy. The x64 is different.
//standard_t dtor = &lib.template get< typename boost::remove_pointer<standard_t>::type >(dt);
void * buf = &lib.template get<int>(dt);
standard_t dtor;
std::memcpy(&dtor, &buf, sizeof(dtor));
return destructor<Class>(dtor);
}
#else
template<typename Signature, typename Lib>
constructor<Signature> load_ctor(Lib & lib, const mangled_storage_impl::ctor_sym & ct) {
typedef typename constructor<Signature>::standard_t stand;
typedef typename constructor<Signature>::allocating_t alloc;
stand s = nullptr;
alloc a = nullptr;
//see here for the abi http://mentorembedded.github.io/cxx-abi/abi.html#mangling-special-ctor-dtor
if (!ct.C1.empty())
{
//the only way this works on mingw/win.