update boost on linux

This commit is contained in:
Bassem Girgis
2019-08-10 16:06:25 -05:00
parent 76ad52be58
commit 861b918727
5363 changed files with 483306 additions and 116507 deletions

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,12 +8,16 @@
#ifndef BOOST_DLL_ALIAS_HPP
#define BOOST_DLL_ALIAS_HPP
#include <boost/config.hpp>
#include <boost/dll/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>
#if BOOST_COMP_GNUC // MSVC does not have <stdint.h> and defines it in some other header, MinGW requires that header.
#include <stdint.h> // intptr_t
#endif
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
@@ -32,18 +36,18 @@ namespace boost { namespace dll {
#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.
/// This may be useful for working around linker problems or to test your program for compatibility 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)
#if BOOST_COMP_MSVC || ((BOOST_COMP_INTEL || BOOST_COMP_CLANG) && 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" \
"Some platforms require section names to be at most 8 bytes" \
); \
__pragma(section(#SectionName, Permissions)) __declspec(allocate(#SectionName)) \
/**/
@@ -82,7 +86,7 @@ namespace boost { namespace dll {
#define BOOST_DLL_SECTION(SectionName, Permissions) \
BOOST_STATIC_ASSERT_MSG( \
sizeof(#SectionName) < 10, \
"Some platforms require section names to be at most 8 bytest" \
"Some platforms require section names to be at most 8 bytes" \
); \
__attribute__ ((section (#SectionName))) \
/**/
@@ -91,7 +95,7 @@ namespace boost { namespace dll {
#define BOOST_DLL_SECTION(SectionName, Permissions) \
BOOST_STATIC_ASSERT_MSG( \
sizeof(#SectionName) < 10, \
"Some platforms require section names to be at most 8 bytest" \
"Some platforms require section names to be at most 8 bytes" \
); \
__attribute__ ((section ( "__DATA," #SectionName))) \
/**/
@@ -124,7 +128,7 @@ namespace boost { namespace dll {
/*!
* \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)`
* This macro is useful in cases of long mangled C++ names. For example some `void boost::foo(std::string)`
* 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
@@ -213,7 +217,7 @@ namespace boost { namespace dll {
/*!
* \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)`
* This macro is useful in cases of long mangled C++ names. For example some `void boost::foo(std::string)`
* 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.*

View File

@@ -0,0 +1,78 @@
// Copyright 2018-2019 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)
/// \file boost/dll/config.hpp
/// \brief Imports filesystem, error_code, errc, system_error, make_error_code from Boost or C++17 into `boost::dll::fs` namespace.
#ifndef BOOST_DLL_DETAIL_CONFIG_HPP
#define BOOST_DLL_DETAIL_CONFIG_HPP
#include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
#ifdef BOOST_DLL_DOXYGEN
/// Define this macro to make Boost.DLL use C++17's std::filesystem::path, std::system_error and std::error_code.
#define BOOST_DLL_USE_STD_FS BOOST_DLL_USE_STD_FS
/// This namespace contains aliases to the Boost or C++17 classes. Aliases are configured using BOOST_DLL_USE_STD_FS macro.
namespace boost { namespace dll { namespace fs {
/// Alias to `std::filesystem::path` if \forcedmacrolink{BOOST_DLL_USE_STD_FS} is defined by user.
/// Alias to `boost::filesystem::path` otherwise.
using path = std::conditional_t<BOOST_DLL_USE_STD_FS, std::filesystem::path, boost::filesystem::path>;
/// Alias to `std::error_code` if \forcedmacrolink{BOOST_DLL_USE_STD_FS} is defined by user.
/// boost::system::error_code otherwise.
using error_code = std::conditional_t<BOOST_DLL_USE_STD_FS, std::error_code, boost::system::error_code>;
/// Alias to `std::system_error` if \forcedmacrolink{BOOST_DLL_USE_STD_FS} is defined by user.
/// Alias to `boost::system::system_error` otherwise.
using system_error = std::conditional_t<BOOST_DLL_USE_STD_FS, std::system_error, boost::system::system_error>;
}}}
#endif
#ifdef BOOST_DLL_USE_STD_FS
#include <filesystem>
#include <system_error>
namespace boost { namespace dll { namespace fs {
using namespace std::filesystem;
using std::error_code;
using std::system_error;
using std::make_error_code;
using std::errc;
using std::system_category;
}}}
#else // BOOST_DLL_USE_STD_FS
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/system/error_code.hpp>
namespace boost { namespace dll { namespace fs {
using namespace boost::filesystem;
using boost::system::error_code;
using boost::system::system_error;
using boost::system::errc::make_error_code;
namespace errc = boost::system::errc;
using boost::system::system_category;
}}}
#endif // BOOST_DLL_USE_STD_FS
#endif // BOOST_DLL_DETAIL_PUSH_OPTIONS_HPP

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2017 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,11 +8,13 @@
#ifndef BOOST_DLL_DETAIL_AGGRESSIVE_PTR_CAST_HPP
#define BOOST_DLL_DETAIL_AGGRESSIVE_PTR_CAST_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
#include <boost/core/addressof.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_member_pointer.hpp>
@@ -20,7 +22,6 @@
#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)

View File

@@ -9,7 +9,7 @@
#ifndef BOOST_DLL_DETAIL_CTOR_DTOR_HPP_
#define BOOST_DLL_DETAIL_CTOR_DTOR_HPP_
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
@@ -46,7 +46,7 @@ struct constructor<Class(Args...)> {
//! The allocating constructor. @warning May differ with the compiler. Use @ref constructor::call_allocating instead.
allocating_t allocating;
//! Call the standard contructor
//! Call the standard constructor
void call_standard (Class * const ptr, Args...args){ (ptr->*standard)(static_cast<Args>(args)...); }
//! Call the deleting destructor
@@ -91,7 +91,7 @@ struct destructor {
//! The deleting destructor. @warning May differ with the compiler. Use @ref destructor::call_deallocating instead.
deleting_t deleting;
//! Call the standard contructor
//! Call the standard constructor
void call_standard(Class * const ptr){ standard(ptr); }
//! Call the deleting destructor
@@ -130,7 +130,7 @@ 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);
void * buf = &lib.template get<unsigned char>(dt);
standard_t dtor;
std::memcpy(&dtor, &buf, sizeof(dtor));
return destructor<Class>(dtor);
@@ -152,12 +152,12 @@ constructor<Signature> load_ctor(Lib & lib, const mangled_storage_impl::ctor_sym
{
//the only way this works on mingw/win.
//For some reason there is always an 0xA in the following poniter, which screws with the this pointer.
void *buf = &lib.template get<int>(ct.C1);
void *buf = &lib.template get<unsigned char>(ct.C1);
std::memcpy(&s, &buf, sizeof(void*));
}
if (!ct.C3.empty())
{
void *buf = &lib.template get<int>(ct.C3);
void *buf = &lib.template get<unsigned char>(ct.C3);
std::memcpy(&a, &buf, sizeof(void*));
}

View File

@@ -8,9 +8,10 @@
#ifndef BOOST_DLL_DEMANGLE_SYMBOL_HPP_
#define BOOST_DLL_DEMANGLE_SYMBOL_HPP_
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <string>
#include <algorithm>
#include <memory>
#if defined(BOOST_MSVC) || defined(BOOST_MSVC_FULL_VER)
@@ -88,7 +89,7 @@ inline std::string demangle_symbol(const char *mangled_name)
}
//for my personal convinience
//for my personal convenience
inline std::string demangle_symbol(const std::string& mangled_name)
{
return demangle_symbol(mangled_name.c_str());

View File

@@ -70,7 +70,7 @@ public:
explicit mangled_storage_base(library_info & li) : mangled_storage_base(li.symbols()) {}
explicit mangled_storage_base(
const boost::filesystem::path& library_path,
const boost::dll::fs::path& library_path,
bool throw_if_not_native_format = true)
: mangled_storage_base(library_info(library_path, throw_if_not_native_format).symbols())
{
@@ -78,7 +78,7 @@ public:
}
void load(library_info & li) { storage_.clear(); add_symbols(li.symbols()); };
void load(const boost::filesystem::path& library_path,
void load(const boost::dll::fs::path& library_path,
bool throw_if_not_native_format = true)
{
storage_.clear();

View File

@@ -36,7 +36,7 @@ class mangled_storage_impl : public mangled_storage_base
{
return get_name<Return>();
}
//function to remove preceeding 'class ' or 'struct ' if the are given in this format.
//function to remove preceding 'class ' or 'struct ' if the are given in this format.
inline static void trim_typename(std::string & val);
public:
@@ -78,7 +78,7 @@ public:
void mangled_storage_impl::trim_typename(std::string & val)
{
//remove preceeding class or struct, because you might want to use a struct as class, et vice versa
//remove preceding class or struct, because you might want to use a struct as class, et vice versa
if (val.size() >= 6)
{
using namespace std;
@@ -98,46 +98,48 @@ namespace parser
{
namespace x3 = spirit::x3;
auto ptr_rule_impl(std::integral_constant<std::size_t, 32>)
inline auto ptr_rule_impl(std::integral_constant<std::size_t, 32>)
{
return -((-x3::space) >> "__ptr32");
}
auto ptr_rule_impl(std::integral_constant<std::size_t, 64>)
inline auto ptr_rule_impl(std::integral_constant<std::size_t, 64>)
{
return -((-x3::space) >> "__ptr64");
}
auto ptr_rule() { return ptr_rule_impl(std::integral_constant<std::size_t, sizeof(std::size_t)*8>());}
inline auto ptr_rule() {
return ptr_rule_impl(std::integral_constant<std::size_t, sizeof(std::size_t)*8>());
}
auto const visibility = ("public:" | x3::lit("protected:") | "private:");
auto const virtual_ = x3::space >> "virtual";
auto const static_ = x3::space >> x3::lit("static") ;
auto const_rule_impl(true_type ) {return x3::space >> "const";};
auto const_rule_impl(false_type) {return x3::eps;};
inline auto const_rule_impl(true_type ) {return x3::space >> "const";};
inline auto const_rule_impl(false_type) {return x3::eps;};
template<typename T>
auto const_rule() {using t = is_const<typename remove_reference<T>::type>; return const_rule_impl(t());}
auto volatile_rule_impl(true_type ) {return x3::space >> "volatile";};
auto volatile_rule_impl(false_type) {return x3::eps;};
inline auto volatile_rule_impl(true_type ) {return x3::space >> "volatile";};
inline auto volatile_rule_impl(false_type) {return x3::eps;};
template<typename T>
auto volatile_rule() {using t = is_volatile<typename remove_reference<T>::type>; return volatile_rule_impl(t());}
auto inv_const_rule_impl(true_type ) {return "const" >> x3::space ;};
auto inv_const_rule_impl(false_type) {return x3::eps;};
inline auto inv_const_rule_impl(true_type ) {return "const" >> x3::space ;};
inline auto inv_const_rule_impl(false_type) {return x3::eps;};
template<typename T>
auto inv_const_rule() {using t = is_const<typename remove_reference<T>::type>; return inv_const_rule_impl(t());}
auto inv_volatile_rule_impl(true_type ) {return "volatile" >> x3::space;};
auto inv_volatile_rule_impl(false_type) {return x3::eps;};
inline auto inv_volatile_rule_impl(true_type ) {return "volatile" >> x3::space;};
inline auto inv_volatile_rule_impl(false_type) {return x3::eps;};
template<typename T>
auto inv_volatile_rule() {using t = is_volatile<typename remove_reference<T>::type>; return inv_volatile_rule_impl(t());}
auto reference_rule_impl(false_type, false_type) {return x3::eps;}
auto reference_rule_impl(true_type, false_type) {return x3::space >>"&" ;}
auto reference_rule_impl(false_type, true_type ) {return x3::space >>"&&" ;}
inline auto reference_rule_impl(false_type, false_type) {return x3::eps;}
inline auto reference_rule_impl(true_type, false_type) {return x3::space >>"&" ;}
inline auto reference_rule_impl(false_type, true_type ) {return x3::space >>"&&" ;}
template<typename T>
@@ -158,7 +160,7 @@ namespace parser
ptr_rule();
}
template<>
auto type_rule<void>(const std::string &) { return x3::string("void"); };
inline auto type_rule<void>(const std::string &) { return x3::string("void"); };
auto const cdecl_ = "__cdecl" >> x3::space;
auto const stdcall = "__stdcall" >> x3::space;

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,14 +8,16 @@
#ifndef BOOST_DLL_DETAIL_POSIX_ELF_INFO_HPP
#define BOOST_DLL_DETAIL_POSIX_ELF_INFO_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
#include <cstring>
#include <boost/filesystem/fstream.hpp>
#include <fstream>
#include <boost/cstdint.hpp>
#include <boost/dll/detail/x_info_interface.hpp>
namespace boost { namespace dll { namespace detail {
@@ -91,7 +93,7 @@ typedef Elf_Sym_template<boost::uint64_t> Elf64_Sym_;
template <class AddressOffsetT>
class elf_info: public x_info_interface {
boost::filesystem::ifstream& f_;
std::ifstream& f_;
typedef boost::dll::detail::Elf_Ehdr_template<AddressOffsetT> header_t;
typedef boost::dll::detail::Elf_Shdr_template<AddressOffsetT> section_t;
@@ -111,7 +113,7 @@ class elf_info: public x_info_interface {
BOOST_STATIC_CONSTANT(unsigned char, STV_PROTECTED_ = 3); /* Not preemptible, not exported */
public:
static bool parsing_supported(boost::filesystem::ifstream& f) {
static bool parsing_supported(std::ifstream& f) {
const unsigned char magic_bytes[5] = {
0x7f, 'E', 'L', 'F', sizeof(boost::uint32_t) == sizeof(AddressOffsetT) ? 1 : 2
};
@@ -128,7 +130,7 @@ public:
return true;
}
explicit elf_info(boost::filesystem::ifstream& f) BOOST_NOEXCEPT
explicit elf_info(std::ifstream& f) BOOST_NOEXCEPT
: f_(f)
{}
@@ -186,14 +188,14 @@ private:
if (section.sh_type == SHT_SYMTAB_) {
symbols.resize(static_cast<std::size_t>(section.sh_size / sizeof(symbol_t)));
const boost::filesystem::ifstream::pos_type pos = f_.tellg();
const std::ifstream::pos_type pos = f_.tellg();
f_.seekg(section.sh_offset);
read_raw(symbols[0], static_cast<std::size_t>(section.sh_size - (section.sh_size % sizeof(symbol_t))) );
f_.seekg(pos);
} else if (section.sh_type == SHT_STRTAB_) {
text.resize(static_cast<std::size_t>(section.sh_size));
const boost::filesystem::ifstream::pos_type pos = f_.tellg();
const std::ifstream::pos_type pos = f_.tellg();
f_.seekg(section.sh_offset);
read_raw(text[0], static_cast<std::size_t>(section.sh_size));
f_.seekg(pos);

View File

@@ -1,4 +1,4 @@
// Copyright 2015-2016 Klemens D. Morgenstern
// Copyright 2015-2018 Klemens D. Morgenstern
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,13 +8,16 @@
#ifndef BOOST_DLL_DETAIL_MACHO_INFO_HPP
#define BOOST_DLL_DETAIL_MACHO_INFO_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
#include <boost/filesystem/fstream.hpp>
#include <algorithm>
#include <fstream>
#include <boost/cstdint.hpp>
#include <boost/dll/detail/x_info_interface.hpp>
namespace boost { namespace dll { namespace detail {
@@ -155,7 +158,7 @@ typedef nlist_template<boost::uint64_t> nlist_64_;
template <class AddressOffsetT>
class macho_info: public x_info_interface {
boost::filesystem::ifstream& f_;
std::ifstream& f_;
typedef boost::dll::detail::mach_header_template<AddressOffsetT> header_t;
typedef boost::dll::detail::load_command_ load_command_t;
@@ -167,7 +170,7 @@ class macho_info: public x_info_interface {
BOOST_STATIC_CONSTANT(boost::uint32_t, SEGMENT_CMD_NUMBER = (sizeof(AddressOffsetT) > 4 ? load_command_types::LC_SEGMENT_64_ : load_command_types::LC_SEGMENT_));
public:
static bool parsing_supported(boost::filesystem::ifstream& f) {
static bool parsing_supported(std::ifstream& f) {
static const uint32_t magic_bytes = (sizeof(AddressOffsetT) <= sizeof(uint32_t) ? 0xfeedface : 0xfeedfacf);
uint32_t magic;
@@ -176,7 +179,7 @@ public:
return (magic_bytes == magic);
}
explicit macho_info(boost::filesystem::ifstream& f) BOOST_NOEXCEPT
explicit macho_info(std::ifstream& f) BOOST_NOEXCEPT
: f_(f)
{}
@@ -192,16 +195,16 @@ private:
load_command_t command;
f_.seekg(sizeof(header_t));
for (std::size_t i = 0; i < h.ncmds; ++i) {
const boost::filesystem::ifstream::pos_type pos = f_.tellg();
const std::ifstream::pos_type pos = f_.tellg();
read_raw(command);
if (command.cmd != cmd_num) {
f_.seekg(pos + static_cast<boost::filesystem::ifstream::pos_type>(command.cmdsize));
f_.seekg(pos + static_cast<std::ifstream::pos_type>(command.cmdsize));
continue;
}
f_.seekg(pos);
callback_f(*this);
f_.seekg(pos + static_cast<boost::filesystem::ifstream::pos_type>(command.cmdsize));
f_.seekg(pos + static_cast<std::ifstream::pos_type>(command.cmdsize));
}
}

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,13 +8,17 @@
#ifndef BOOST_DLL_DETAIL_WINDOWS_PE_INFO_HPP
#define BOOST_DLL_DETAIL_WINDOWS_PE_INFO_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif
#include <boost/filesystem/fstream.hpp>
#include <cstring>
#include <fstream>
#include <boost/assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/dll/detail/x_info_interface.hpp>
namespace boost { namespace dll { namespace detail {
@@ -25,13 +29,13 @@ namespace boost { namespace dll { namespace detail {
// http://msdn.microsoft.com/en-us/magazine/cc301808.aspx
//
// Basic Windows typedefs. We can not use <boost/detail/winapi/basic_types.hpp> header
// Basic Windows typedefs. We can not use <boost/winapi/basic_types.hpp> header
// because that header must be included only on Windows platform
typedef unsigned char BYTE_;
typedef unsigned short WORD_;
typedef unsigned long DWORD_;
typedef long LONG_;
typedef unsigned long ULONG_;
typedef boost::uint32_t DWORD_;
typedef boost::int32_t LONG_;
typedef boost::uint32_t ULONG_;
typedef boost::int64_t LONGLONG_;
typedef boost::uint64_t ULONGLONG_;
@@ -161,7 +165,7 @@ typedef IMAGE_NT_HEADERS_template<boost::dll::detail::ULONGLONG_> IMAGE_NT_HEAD
template <class AddressOffsetT>
class pe_info: public x_info_interface {
boost::filesystem::ifstream& f_;
std::ifstream& f_;
typedef IMAGE_NT_HEADERS_template<AddressOffsetT> header_t;
typedef IMAGE_EXPORT_DIRECTORY_ exports_t;
@@ -174,7 +178,7 @@ class pe_info: public x_info_interface {
}
public:
static bool parsing_supported(boost::filesystem::ifstream& f) {
static bool parsing_supported(std::ifstream& f) {
dos_t dos;
f.seekg(0);
f.read(reinterpret_cast<char*>(&dos), sizeof(dos));
@@ -193,7 +197,7 @@ public:
}
explicit pe_info(boost::filesystem::ifstream& f) BOOST_NOEXCEPT
explicit pe_info(std::ifstream& f) BOOST_NOEXCEPT
: f_(f)
{}
@@ -370,15 +374,14 @@ public:
MSVCR110D.dll
*/
/*
std::vector<std::string> depend_of(boost::system::error_code &ec) BOOST_NOEXCEPT {
std::vector<std::string> depend_of(boost::dll::fs::error_code &ec) BOOST_NOEXCEPT {
std::vector<std::string> ret;
IMAGE_DOS_HEADER* image_dos_header = (IMAGE_DOS_HEADER*)native();
if(!image_dos_header) {
// ERROR_BAD_EXE_FORMAT
ec = boost::system::error_code(
boost::system::errc::executable_format_error,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::executable_format_error
);
return ret;
@@ -387,9 +390,8 @@ public:
IMAGE_OPTIONAL_HEADER* image_optional_header = (IMAGE_OPTIONAL_HEADER*)((boost::dll::detail::BYTE_*)native() + image_dos_header->e_lfanew + 24);
if(!image_optional_header) {
// ERROR_BAD_EXE_FORMAT
ec = boost::system::error_code(
boost::system::errc::executable_format_error,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::executable_format_error
);
return ret;
@@ -398,9 +400,8 @@ public:
IMAGE_IMPORT_DESCRIPTOR* image_import_descriptor = (IMAGE_IMPORT_DESCRIPTOR*)((boost::dll::detail::BYTE_*)native() + image_optional_header->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
if(!image_import_descriptor) {
// ERROR_BAD_EXE_FORMAT
ec = boost::system::error_code(
boost::system::errc::executable_format_error,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::executable_format_error
);
return ret;

View File

@@ -1,4 +1,5 @@
// Copyright 2014-2015 Renato Tegon Forti, Antony Polukhin.
// Copyright 2016-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -7,10 +8,9 @@
#ifndef BOOST_DLL_DETAIL_POSIX_PATH_FROM_HANDLE_HPP
#define BOOST_DLL_DETAIL_POSIX_PATH_FROM_HANDLE_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/dll/detail/system_error.hpp>
#include <boost/dll/detail/posix/program_location_impl.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/predef/os.h>
#ifdef BOOST_HAS_PRAGMA_ONCE
@@ -30,7 +30,7 @@ namespace boost { namespace dll { namespace detail {
);
}
inline boost::filesystem::path path_from_handle(void* handle, boost::system::error_code &ec) {
inline boost::dll::fs::path path_from_handle(void* handle, boost::dll::fs::error_code &ec) {
handle = strip_handle(handle);
// Iterate through all images currently in memory
@@ -53,12 +53,11 @@ namespace boost { namespace dll { namespace detail {
}
boost::dll::detail::reset_dlerror();
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
return boost::filesystem::path();
return boost::dll::fs::path();
}
}}} // namespace boost::dll::detail
@@ -79,12 +78,12 @@ namespace boost { namespace dll { namespace detail {
// ... // Ignoring remaning parts of the structure
};
inline boost::filesystem::path path_from_handle(const void* handle, boost::system::error_code &ec) {
inline boost::dll::fs::path path_from_handle(const void* handle, boost::dll::fs::error_code &ec) {
static const std::size_t work_around_b_24465209__offset = 128;
const struct soinfo* si = reinterpret_cast<const struct soinfo*>(
static_cast<const char*>(handle) + work_around_b_24465209__offset
);
boost::filesystem::path ret = boost::dll::symbol_location_ptr(si->base, ec);
boost::dll::fs::path ret = boost::dll::symbol_location_ptr(si->base, ec);
if (ec) {
ec.clear();
@@ -120,7 +119,7 @@ namespace boost { namespace dll { namespace detail {
};
#endif // #if BOOST_OS_QNX
inline boost::filesystem::path path_from_handle(void* handle, boost::system::error_code &ec) {
inline boost::dll::fs::path path_from_handle(void* handle, boost::dll::fs::error_code &ec) {
// RTLD_DI_LINKMAP (RTLD_DI_ORIGIN returns only folder and is not suitable for this case)
// Obtain the Link_map for the handle that is specified.
// The p argument points to a Link_map pointer (Link_map
@@ -145,19 +144,18 @@ namespace boost { namespace dll { namespace detail {
#endif
if (!link_map) {
boost::dll::detail::reset_dlerror();
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
return boost::filesystem::path();
return boost::dll::fs::path();
}
if (!link_map->l_name || *link_map->l_name == '\0') {
return program_location_impl(ec);
}
return boost::filesystem::path(link_map->l_name);
return boost::dll::fs::path(link_map->l_name);
}
}}} // namespace boost::dll::detail

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,9 +8,8 @@
#ifndef BOOST_DLL_DETAIL_POSIX_PROGRAM_LOCATION_IMPL_HPP
#define BOOST_DLL_DETAIL_POSIX_PROGRAM_LOCATION_IMPL_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/dll/detail/system_error.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/predef/os.h>
#ifdef BOOST_HAS_PRAGMA_ONCE
@@ -22,23 +21,22 @@
#include <mach-o/dyld.h>
namespace boost { namespace dll { namespace detail {
inline boost::filesystem::path program_location_impl(boost::system::error_code &ec) {
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code &ec) {
ec.clear();
char path[1024];
uint32_t size = sizeof(path);
if (_NSGetExecutablePath(path, &size) == 0)
return boost::filesystem::path(path);
return boost::dll::fs::path(path);
char *p = new char[size];
if (_NSGetExecutablePath(p, &size) != 0) {
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
}
boost::filesystem::path ret(p);
boost::dll::fs::path ret(p);
delete[] p;
return ret;
}
@@ -48,10 +46,10 @@ namespace boost { namespace dll { namespace detail {
#include <stdlib.h>
namespace boost { namespace dll { namespace detail {
inline boost::filesystem::path program_location_impl(boost::system::error_code& ec) {
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code& ec) {
ec.clear();
return boost::filesystem::path(getexecname());
return boost::dll::fs::path(getexecname());
}
}}} // namespace boost::dll::detail
@@ -62,7 +60,7 @@ namespace boost { namespace dll { namespace detail {
#include <stdlib.h>
namespace boost { namespace dll { namespace detail {
inline boost::filesystem::path program_location_impl(boost::system::error_code& ec) {
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code& ec) {
ec.clear();
int mib[4];
@@ -74,7 +72,7 @@ namespace boost { namespace dll { namespace detail {
size_t cb = sizeof(buf);
sysctl(mib, 4, buf, &cb, NULL, 0);
return boost::filesystem::path(buf);
return boost::dll::fs::path(buf);
}
}}} // namespace boost::dll::detail
@@ -82,19 +80,18 @@ namespace boost { namespace dll { namespace detail {
#elif BOOST_OS_BSD_NET
#include <boost/filesystem/operations.hpp>
namespace boost { namespace dll { namespace detail {
inline boost::filesystem::path program_location_impl(boost::system::error_code &ec) {
return boost::filesystem::read_symlink("/proc/curproc/exe", ec);
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code &ec) {
return boost::dll::fs::read_symlink("/proc/curproc/exe", ec);
}
}}} // namespace boost::dll::detail
#elif BOOST_OS_BSD_DRAGONFLY
#include <boost/filesystem/operations.hpp>
namespace boost { namespace dll { namespace detail {
inline boost::filesystem::path program_location_impl(boost::system::error_code &ec) {
return boost::filesystem::read_symlink("/proc/curproc/file", ec);
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code &ec) {
return boost::dll::fs::read_symlink("/proc/curproc/file", ec);
}
}}} // namespace boost::dll::detail
@@ -103,7 +100,7 @@ namespace boost { namespace dll { namespace detail {
#include <fstream>
#include <string> // for std::getline
namespace boost { namespace dll { namespace detail {
inline boost::filesystem::path program_location_impl(boost::system::error_code &ec) {
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code &ec) {
ec.clear();
std::string s;
@@ -111,26 +108,24 @@ namespace boost { namespace dll { namespace detail {
std::getline(ifs, s);
if (ifs.fail() || s.empty()) {
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
}
return boost::filesystem::path(s);
return boost::dll::fs::path(s);
}
}}} // namespace boost::dll::detail
#else // BOOST_OS_LINUX || BOOST_OS_UNIX || BOOST_OS_HPUX || BOOST_OS_ANDROID
#include <boost/filesystem/operations.hpp>
namespace boost { namespace dll { namespace detail {
inline boost::filesystem::path program_location_impl(boost::system::error_code &ec) {
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code &ec) {
// We can not use
// boost::dll::detail::path_from_handle(dlopen(NULL, RTLD_LAZY | RTLD_LOCAL), ignore);
// because such code returns empty path.
return boost::filesystem::read_symlink("/proc/self/exe", ec); // Linux specific
return boost::dll::fs::read_symlink("/proc/self/exe", ec); // Linux specific
}
}}} // namespace boost::dll::detail

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2016 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,15 +8,13 @@
#ifndef BOOST_DLL_SHARED_LIBRARY_IMPL_HPP
#define BOOST_DLL_SHARED_LIBRARY_IMPL_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/dll/shared_library_load_mode.hpp>
#include <boost/dll/detail/posix/path_from_handle.hpp>
#include <boost/dll/detail/posix/program_location_impl.hpp>
#include <boost/move/utility.hpp>
#include <boost/swap.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/predef/os.h>
#include <dlfcn.h>
@@ -48,7 +46,7 @@ public:
~shared_library_impl() BOOST_NOEXCEPT {
unload();
}
shared_library_impl(BOOST_RV_REF(shared_library_impl) sl) BOOST_NOEXCEPT
: handle_(sl.handle_)
{
@@ -60,16 +58,26 @@ public:
return *this;
}
void load(boost::filesystem::path sl, load_mode::type mode, boost::system::error_code &ec) {
static boost::dll::fs::path decorate(const boost::dll::fs::path & sl) {
boost::dll::fs::path actual_path = (
std::strncmp(sl.filename().string().c_str(), "lib", 3)
? boost::dll::fs::path((sl.has_parent_path() ? sl.parent_path() / L"lib" : L"lib").native() + sl.filename().native())
: sl
);
actual_path += suffix();
return actual_path;
}
void load(boost::dll::fs::path sl, load_mode::type mode, boost::dll::fs::error_code &ec) {
typedef int native_mode_t;
unload();
// Do not allow opening NULL paths. User must use program_location() instead
if (sl.empty()) {
boost::dll::detail::reset_dlerror();
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
return;
@@ -90,8 +98,8 @@ public:
}
#else
if (!sl.is_absolute() && !(mode & load_mode::search_system_folders)) {
boost::system::error_code current_path_ec;
boost::filesystem::path prog_loc = boost::filesystem::current_path(current_path_ec);
boost::dll::fs::error_code current_path_ec;
boost::dll::fs::path prog_loc = boost::dll::fs::current_path(current_path_ec);
if (!current_path_ec) {
prog_loc /= sl;
sl.swap(prog_loc);
@@ -105,18 +113,21 @@ public:
if (!!(mode & load_mode::append_decorations)) {
mode &= ~load_mode::append_decorations;
boost::filesystem::path actual_path = (
std::strncmp(sl.filename().string().c_str(), "lib", 3)
? (sl.has_parent_path() ? sl.parent_path() / L"lib" : L"lib").native() + sl.filename().native()
: sl
);
actual_path += suffix();
boost::dll::fs::path actual_path = decorate(sl);
handle_ = dlopen(actual_path.c_str(), static_cast<native_mode_t>(mode));
if (handle_) {
boost::dll::detail::reset_dlerror();
return;
}
boost::dll::fs::error_code prog_loc_err;
boost::dll::fs::path loc = boost::dll::detail::program_location_impl(prog_loc_err);
if (boost::dll::fs::exists(actual_path) && !boost::dll::fs::equivalent(sl, loc, prog_loc_err)) {
// decorated path exists : current error is not a bad file descriptor and we are not trying to load the executable itself
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::executable_format_error
);
return;
}
}
// Opening by exactly specified path
@@ -126,28 +137,26 @@ public:
return;
}
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
// Maybe user wanted to load the executable itself? Checking...
// We assume that usually user wants to load a dynamic library not the executable itself, that's why
// we try this only after traditional load fails.
boost::system::error_code prog_loc_err;
boost::filesystem::path loc = boost::dll::detail::program_location_impl(prog_loc_err);
if (!prog_loc_err && boost::filesystem::equivalent(sl, loc, prog_loc_err) && !prog_loc_err) {
// As is known the function dlopen() loads the dynamic library file
// named by the null-terminated string filename and returns an opaque
// "handle" for the dynamic library. If filename is NULL, then the
boost::dll::fs::error_code prog_loc_err;
boost::dll::fs::path loc = boost::dll::detail::program_location_impl(prog_loc_err);
if (!prog_loc_err && boost::dll::fs::equivalent(sl, loc, prog_loc_err) && !prog_loc_err) {
// As is known the function dlopen() loads the dynamic library file
// named by the null-terminated string filename and returns an opaque
// "handle" for the dynamic library. If filename is NULL, then the
// returned handle is for the main program.
ec.clear();
boost::dll::detail::reset_dlerror();
handle_ = dlopen(NULL, static_cast<native_mode_t>(mode));
if (!handle_) {
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
}
}
@@ -170,11 +179,11 @@ public:
boost::swap(handle_, rhs.handle_);
}
boost::filesystem::path full_module_path(boost::system::error_code &ec) const {
boost::dll::fs::path full_module_path(boost::dll::fs::error_code &ec) const {
return boost::dll::detail::path_from_handle(handle_, ec);
}
static boost::filesystem::path suffix() {
static boost::dll::fs::path suffix() {
// https://sourceforge.net/p/predef/wiki/OperatingSystems/
#if BOOST_OS_MACOS || BOOST_OS_IOS
return ".dylib";
@@ -183,13 +192,12 @@ public:
#endif
}
void* symbol_addr(const char* sb, boost::system::error_code &ec) const BOOST_NOEXCEPT {
void* symbol_addr(const char* sb, boost::dll::fs::error_code &ec) const BOOST_NOEXCEPT {
// dlsym - obtain the address of a symbol from a dlopen object
void* const symbol = dlsym(handle_, sb);
if (symbol == NULL) {
ec = boost::system::error_code(
boost::system::errc::invalid_seek,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::invalid_seek
);
}
@@ -212,4 +220,3 @@ private:
}}} // boost::dll::detail
#endif // BOOST_DLL_SHARED_LIBRARY_IMPL_HPP

View File

@@ -1,4 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -7,10 +8,8 @@
#ifndef BOOST_DLL_SYSTEM_ERROR_HPP
#define BOOST_DLL_SYSTEM_ERROR_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/predef/os.h>
#include <boost/system/error_code.hpp>
#include <boost/system/system_error.hpp>
#include <boost/throw_exception.hpp>
#if !BOOST_OS_WINDOWS
@@ -30,12 +29,12 @@ namespace boost { namespace dll { namespace detail {
#endif
}
inline void report_error(const boost::system::error_code& ec, const char* message) {
inline void report_error(const boost::dll::fs::error_code& ec, const char* message) {
#if !BOOST_OS_WINDOWS
const char* const error_txt = dlerror();
if (error_txt) {
boost::throw_exception(
boost::system::system_error(
boost::dll::fs::system_error(
ec,
message + std::string(" (dlerror system message: ") + error_txt + std::string(")")
)
@@ -44,7 +43,7 @@ namespace boost { namespace dll { namespace detail {
#endif
boost::throw_exception(
boost::system::system_error(
boost::dll::fs::system_error(
ec, message
)
);

View File

@@ -11,6 +11,10 @@
#include <typeinfo>
#include <cstring>
#include <boost/dll/config.hpp>
#if defined(BOOST_MSVC) || defined(BOOST_MSVC_VER)
#include <boost/winapi/basic_types.hpp>
#endif
namespace boost { namespace dll { namespace detail {
@@ -23,11 +27,11 @@ const std::type_info& load_type_info(Lib & lib, Storage & storage)
{
struct RTTICompleteObjectLocator
{
boost::detail::winapi::DWORD_ signature; //always zero ?
boost::detail::winapi::DWORD_ offset; //offset of this vtable in the complete class
boost::detail::winapi::DWORD_ cdOffset; //constructor displacement offset
boost::detail::winapi::DWORD_ pTypeDescriptorOffset; //TypeDescriptor of the complete class
boost::detail::winapi::DWORD_ pClassDescriptorOffset; //describes inheritance hierarchy (ignored)
boost::winapi::DWORD_ signature; //always zero ?
boost::winapi::DWORD_ offset; //offset of this vtable in the complete class
boost::winapi::DWORD_ cdOffset; //constructor displacement offset
boost::winapi::DWORD_ pTypeDescriptorOffset; //TypeDescriptor of the complete class
boost::winapi::DWORD_ pClassDescriptorOffset; //describes inheritance hierarchy (ignored)
};
RTTICompleteObjectLocator** vtable_p = &lib.template get<RTTICompleteObjectLocator*>(storage.template get_vtable<Class>());
@@ -50,9 +54,9 @@ const std::type_info& load_type_info(Lib & lib, Storage & storage)
{
struct RTTICompleteObjectLocator
{
boost::detail::winapi::DWORD_ signature; //always zero ?
boost::detail::winapi::DWORD_ offset; //offset of this vtable in the complete class
boost::detail::winapi::DWORD_ cdOffset; //constructor displacement offset
boost::winapi::DWORD_ signature; //always zero ?
boost::winapi::DWORD_ offset; //offset of this vtable in the complete class
boost::winapi::DWORD_ cdOffset; //constructor displacement offset
const std::type_info* pTypeDescriptor; //TypeDescriptor of the complete class
void* pClassDescriptor; //describes inheritance hierarchy (ignored)
};

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,11 +8,10 @@
#ifndef BOOST_DLL_DETAIL_WINDOWS_PATH_FROM_HANDLE_HPP
#define BOOST_DLL_DETAIL_WINDOWS_PATH_FROM_HANDLE_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/dll/detail/system_error.hpp>
#include <boost/detail/winapi/dll.hpp>
#include <boost/detail/winapi/get_last_error.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/winapi/dll.hpp>
#include <boost/winapi/get_last_error.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
@@ -20,40 +19,43 @@
namespace boost { namespace dll { namespace detail {
static inline boost::system::error_code last_error_code() BOOST_NOEXCEPT {
boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
return boost::system::error_code(
err,
boost::system::system_category()
inline boost::dll::fs::error_code last_error_code() BOOST_NOEXCEPT {
boost::winapi::DWORD_ err = boost::winapi::GetLastError();
return boost::dll::fs::error_code(
static_cast<int>(err),
boost::dll::fs::system_category()
);
}
inline boost::filesystem::path path_from_handle(boost::detail::winapi::HMODULE_ handle, boost::system::error_code &ec) {
BOOST_STATIC_CONSTANT(boost::detail::winapi::DWORD_, ERROR_INSUFFICIENT_BUFFER_ = 0x7A);
BOOST_STATIC_CONSTANT(boost::detail::winapi::DWORD_, DEFAULT_PATH_SIZE_ = 260);
inline boost::dll::fs::path path_from_handle(boost::winapi::HMODULE_ handle, boost::dll::fs::error_code &ec) {
BOOST_STATIC_CONSTANT(boost::winapi::DWORD_, ERROR_INSUFFICIENT_BUFFER_ = 0x7A);
BOOST_STATIC_CONSTANT(boost::winapi::DWORD_, DEFAULT_PATH_SIZE_ = 260);
// On success, GetModuleFileNameW() doesn't reset last error to ERROR_SUCCESS. Resetting it manually.
boost::winapi::GetLastError();
// If `handle` parameter is NULL, GetModuleFileName retrieves the path of the
// executable file of the current process.
boost::detail::winapi::WCHAR_ path_hldr[DEFAULT_PATH_SIZE_];
boost::detail::winapi::GetModuleFileNameW(handle, path_hldr, DEFAULT_PATH_SIZE_);
ec = last_error_code();
boost::winapi::WCHAR_ path_hldr[DEFAULT_PATH_SIZE_];
boost::winapi::GetModuleFileNameW(handle, path_hldr, DEFAULT_PATH_SIZE_);
ec = boost::dll::detail::last_error_code();
if (!ec) {
return boost::filesystem::path(path_hldr);
return boost::dll::fs::path(path_hldr);
}
for (unsigned i = 2; i < 1025 && static_cast<boost::detail::winapi::DWORD_>(ec.value()) == ERROR_INSUFFICIENT_BUFFER_; i *= 2) {
for (unsigned i = 2; i < 1025 && static_cast<boost::winapi::DWORD_>(ec.value()) == ERROR_INSUFFICIENT_BUFFER_; i *= 2) {
std::wstring p(DEFAULT_PATH_SIZE_ * i, L'\0');
const std::size_t size = boost::detail::winapi::GetModuleFileNameW(handle, &p[0], DEFAULT_PATH_SIZE_ * i);
ec = last_error_code();
const std::size_t size = boost::winapi::GetModuleFileNameW(handle, &p[0], DEFAULT_PATH_SIZE_ * i);
ec = boost::dll::detail::last_error_code();
if (!ec) {
p.resize(size);
return boost::filesystem::path(p);
return boost::dll::fs::path(p);
}
}
// Error other than ERROR_INSUFFICIENT_BUFFER_ occurred or failed to allocate buffer big enough
return boost::filesystem::path();
// Error other than ERROR_INSUFFICIENT_BUFFER_ occurred or failed to allocate buffer big enough.
return boost::dll::fs::path();
}
}}} // namespace boost::dll::detail

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2016 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,7 +8,7 @@
#ifndef BOOST_DLL_SHARED_LIBRARY_IMPL_HPP
#define BOOST_DLL_SHARED_LIBRARY_IMPL_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/dll/shared_library_load_mode.hpp>
#include <boost/dll/detail/aggressive_ptr_cast.hpp>
#include <boost/dll/detail/system_error.hpp>
@@ -16,10 +16,8 @@
#include <boost/move/utility.hpp>
#include <boost/swap.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/detail/winapi/dll.hpp>
#include <boost/winapi/dll.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
@@ -31,7 +29,7 @@ class shared_library_impl {
BOOST_MOVABLE_BUT_NOT_COPYABLE(shared_library_impl)
public:
typedef boost::detail::winapi::HMODULE_ native_handle_t;
typedef boost::winapi::HMODULE_ native_handle_t;
shared_library_impl() BOOST_NOEXCEPT
: handle_(NULL)
@@ -40,7 +38,7 @@ public:
~shared_library_impl() BOOST_NOEXCEPT {
unload();
}
shared_library_impl(BOOST_RV_REF(shared_library_impl) sl) BOOST_NOEXCEPT
: handle_(sl.handle_)
{
@@ -52,14 +50,20 @@ public:
return *this;
}
void load(boost::filesystem::path sl, load_mode::type mode, boost::system::error_code &ec) {
typedef boost::detail::winapi::DWORD_ native_mode_t;
static boost::dll::fs::path decorate(const boost::dll::fs::path& sl) {
boost::dll::fs::path actual_path = sl;
actual_path += suffix();
return actual_path;
}
void load(boost::dll::fs::path sl, load_mode::type mode, boost::dll::fs::error_code &ec) {
typedef boost::winapi::DWORD_ native_mode_t;
unload();
if (!sl.is_absolute() && !(mode & load_mode::search_system_folders)) {
boost::dll::fs::error_code current_path_ec;
boost::dll::fs::path prog_loc = boost::dll::fs::current_path(current_path_ec);
boost::system::error_code current_path_ec;
boost::filesystem::path prog_loc = boost::filesystem::current_path(current_path_ec);
if (!current_path_ec) {
prog_loc /= sl;
sl.swap(prog_loc);
@@ -71,18 +75,17 @@ public:
if (!!(mode & load_mode::append_decorations)) {
mode &= ~load_mode::append_decorations;
handle_ = boost::detail::winapi::LoadLibraryExW((sl.native() + L".dll").c_str(), 0, static_cast<native_mode_t>(mode));
if (!handle_) {
// MinGW loves 'lib' prefix and puts it even on Windows platform
const boost::filesystem::path load_path = (sl.has_parent_path() ? sl.parent_path() / L"lib" : L"lib").native() + sl.filename().native() + L".dll";
handle_ = boost::detail::winapi::LoadLibraryExW(
load_path.c_str(),
0,
static_cast<native_mode_t>(mode)
);
if (load_impl(decorate(sl), static_cast<native_mode_t>(mode), ec)) {
return;
}
if (handle_) {
// MinGW loves 'lib' prefix and puts it even on Windows platform.
const boost::dll::fs::path mingw_load_path = (
sl.has_parent_path()
? sl.parent_path() / L"lib"
: L"lib"
).native() + sl.filename().native() + suffix().native();
if (load_impl(mingw_load_path, static_cast<native_mode_t>(mode), ec)) {
return;
}
}
@@ -95,14 +98,13 @@ public:
// we have some path. So we do not check for path, only for extension. We can not be sure that
// such behavior remain across all platforms, so we add L"." by hand.
if (sl.has_extension()) {
handle_ = boost::detail::winapi::LoadLibraryExW(sl.c_str(), 0, static_cast<native_mode_t>(mode));
handle_ = boost::winapi::LoadLibraryExW(sl.c_str(), 0, static_cast<native_mode_t>(mode));
} else {
handle_ = boost::detail::winapi::LoadLibraryExW((sl.native() + L".").c_str(), 0, static_cast<native_mode_t>(mode));
handle_ = boost::winapi::LoadLibraryExW((sl.native() + L".").c_str(), 0, static_cast<native_mode_t>(mode));
}
// LoadLibraryExW method is capable of self loading from program_location() path. No special actions
// must be taken to allow self loading.
if (!handle_) {
ec = boost::dll::detail::last_error_code();
}
@@ -114,7 +116,7 @@ public:
void unload() BOOST_NOEXCEPT {
if (handle_) {
boost::detail::winapi::FreeLibrary(handle_);
boost::winapi::FreeLibrary(handle_);
handle_ = 0;
}
}
@@ -123,22 +125,21 @@ public:
boost::swap(handle_, rhs.handle_);
}
boost::filesystem::path full_module_path(boost::system::error_code &ec) const {
boost::dll::fs::path full_module_path(boost::dll::fs::error_code &ec) const {
return boost::dll::detail::path_from_handle(handle_, ec);
}
static boost::filesystem::path suffix() {
static boost::dll::fs::path suffix() {
return L".dll";
}
void* symbol_addr(const char* sb, boost::system::error_code &ec) const BOOST_NOEXCEPT {
void* symbol_addr(const char* sb, boost::dll::fs::error_code &ec) const BOOST_NOEXCEPT {
if (is_resource()) {
// `GetProcAddress` could not be called for libraries loaded with
// `LOAD_LIBRARY_AS_DATAFILE`, `LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE`
// or `LOAD_LIBRARY_AS_IMAGE_RESOURCE`.
ec = boost::system::error_code(
boost::system::errc::operation_not_supported,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::operation_not_supported
);
return NULL;
@@ -148,7 +149,7 @@ public:
// there is no version for UNICODE on desktop/server Windows, because
// names of functions are stored in narrow characters.
void* const symbol = boost::dll::detail::aggressive_ptr_cast<void*>(
boost::detail::winapi::get_proc_address(handle_, sb)
boost::winapi::get_proc_address(handle_, sb)
);
if (symbol == NULL) {
ec = boost::dll::detail::last_error_code();
@@ -162,9 +163,26 @@ public:
}
private:
// Returns true if this load attempt should be the last one.
bool load_impl(const boost::dll::fs::path &load_path, boost::winapi::DWORD_ mode, boost::dll::fs::error_code &ec) {
handle_ = boost::winapi::LoadLibraryExW(load_path.c_str(), 0, mode);
if (handle_) {
return true;
}
ec = boost::dll::detail::last_error_code();
if (boost::dll::fs::exists(load_path)) {
// decorated path exists : current error is not a bad file descriptor
return true;
}
ec.clear();
return false;
}
bool is_resource() const BOOST_NOEXCEPT {
return false; /*!!(
reinterpret_cast<boost::detail::winapi::ULONG_PTR_>(handle_) & static_cast<boost::detail::winapi::ULONG_PTR_>(3)
reinterpret_cast<boost::winapi::ULONG_PTR_>(handle_) & static_cast<boost::winapi::ULONG_PTR_>(3)
);*/
}
@@ -174,4 +192,3 @@ private:
}}} // boost::dll::detail
#endif // BOOST_DLL_SHARED_LIBRARY_IMPL_HPP

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,7 +8,7 @@
#ifndef BOOST_DLL_DETAIL_X_INFO_INTERFACE_HPP
#define BOOST_DLL_DETAIL_X_INFO_INTERFACE_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2016 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,12 +8,12 @@
#ifndef BOOST_DLL_IMPORT_HPP
#define BOOST_DLL_IMPORT_HPP
#include <boost/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/dll/config.hpp>
#include <boost/core/addressof.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/is_object.hpp>
#include <boost/make_shared.hpp>
#include <boost/dll/shared_library.hpp>
#include <boost/utility/addressof.hpp>
#include <boost/move/move.hpp>
#if defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) || defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
@@ -125,11 +125,11 @@ namespace detail {
*
* \return callable object if T is a function type, or boost::shared_ptr<T> if T is an object type.
*
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
* Overload that accepts path also throws std::bad_alloc in case of insufficient memory.
*/
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const char* name,
BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::dll::fs::path& lib, const char* name,
load_mode::type mode = load_mode::default_mode)
{
typedef typename boost::dll::detail::import_type<T>::base_type type;
@@ -138,15 +138,15 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const ch
return type(p, boost::addressof(p->get<T>(name)));
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const std::string& name,
BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::dll::fs::path& lib, const std::string& name,
load_mode::type mode = load_mode::default_mode)
{
return import<T>(lib, name.c_str(), mode);
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import(const shared_library& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::base_type type;
@@ -155,13 +155,13 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(const shared_library& lib, const char* name)
return type(p, boost::addressof(p->get<T>(name)));
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import(const shared_library& lib, const std::string& name) {
return import<T>(lib, name.c_str());
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import(BOOST_RV_REF(shared_library) lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::base_type type;
@@ -172,7 +172,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(BOOST_RV_REF(shared_library) lib, const char
return type(p, boost::addressof(p->get<T>(name)));
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import(BOOST_RV_REF(shared_library) lib, const std::string& name) {
return import<T>(boost::move(lib), name.c_str());
@@ -215,11 +215,11 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(BOOST_RV_REF(shared_library) lib, const std:
*
* \return callable object if T is a function type, or boost::shared_ptr<T> if T is an object type.
*
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
* Overload that accepts path also throws std::bad_alloc in case of insufficient memory.
*/
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::filesystem::path& lib, const char* name,
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::dll::fs::path& lib, const char* name,
load_mode::type mode = load_mode::default_mode)
{
typedef typename boost::dll::detail::import_type<T>::base_type type;
@@ -228,15 +228,15 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::filesystem::path& lib, co
return type(p, p->get<T*>(name));
}
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::filesystem::path& lib, const std::string& name,
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::dll::fs::path& lib, const std::string& name,
load_mode::type mode = load_mode::default_mode)
{
return import_alias<T>(lib, name.c_str(), mode);
}
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const shared_library& lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::base_type type;
@@ -245,13 +245,13 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const shared_library& lib, const char*
return type(p, p->get<T*>(name));
}
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const shared_library& lib, const std::string& name) {
return import_alias<T>(lib, name.c_str());
}
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(BOOST_RV_REF(shared_library) lib, const char* name) {
typedef typename boost::dll::detail::import_type<T>::base_type type;
@@ -262,7 +262,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_alias(BOOST_RV_REF(shared_library) lib, cons
return type(p, p->get<T*>(name));
}
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(BOOST_RV_REF(shared_library) lib, const std::string& name) {
return import_alias<T>(boost::move(lib), name.c_str());

View File

@@ -1,4 +1,4 @@
// Copyright 2015-2016 Klemens D. Morgenstern
// Copyright 2015-2018 Klemens D. Morgenstern
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -250,16 +250,15 @@ inline std::unique_ptr<T, detail::deleter<T>> imported_class<T>::make_data(const
if (!ctor.has_allocating() || !dtor.has_deleting())
{
boost::system::error_code ec;
boost::dll::fs::error_code ec;
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
// report_error() calls dlsym, do not use it here!
boost::throw_exception(
boost::system::system_error(
boost::dll::fs::system_error(
ec, "boost::dll::detail::make_data() failed: no allocating ctor or dtor was found"
)
);
@@ -280,16 +279,15 @@ inline std::unique_ptr<T, detail::deleter<T>> imported_class<T>::make_data(const
if (!ctor.has_standard() || !dtor.has_standard())
{
boost::system::error_code ec;
boost::dll::fs::error_code ec;
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
// report_error() calls dlsym, do not use it here!
boost::throw_exception(
boost::system::system_error(
boost::dll::fs::system_error(
ec, "boost::dll::detail::make_data() failed: no regular ctor or dtor was found"
)
);
@@ -412,7 +410,7 @@ inline void boost::dll::experimental::imported_class<T>::move_assign(imported_cl
*
* \return class object.
*
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
* Overload that accepts path also throws std::bad_alloc in case of insufficient memory.
*/
template<typename T, typename ... Args> imported_class<T>

View File

@@ -1,4 +1,4 @@
// Copyright 2015-2016 Klemens D. Morgenstern
// Copyright 2015-2018 Klemens D. Morgenstern
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,13 +8,13 @@
#ifndef BOOST_DLL_IMPORT_MANGLED_HPP_
#define BOOST_DLL_IMPORT_MANGLED_HPP_
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/make_shared.hpp>
#include <boost/move/move.hpp>
#include <boost/dll/smart_library.hpp>
#include <boost/dll/detail/import_mangled_helpers.hpp>
#include <boost/utility/addressof.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/core/addressof.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_object.hpp>
@@ -215,13 +215,13 @@ struct mangled_import_type<sequence<T>, false, false, true> //is variable
*
* \return callable object if T is a function type, or boost::shared_ptr<T> if T is an object type.
*
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
* Overload that accepts path also throws std::bad_alloc in case of insufficient memory.
*/
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const boost::filesystem::path& lib, const char* name,
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const boost::dll::fs::path& lib, const char* name,
load_mode::type mode = load_mode::default_mode)
{
typedef typename boost::dll::experimental::detail::mangled_import_type<
@@ -234,15 +234,15 @@ BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const boost::filesystem::pat
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const boost::filesystem::path& lib, const std::string& name,
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const boost::dll::fs::path& lib, const std::string& name,
load_mode::type mode = load_mode::default_mode)
{
return import_mangled<Args...>(lib, name.c_str(), mode);
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const smart_library& lib, const char* name) {
typedef typename boost::dll::experimental::detail::mangled_import_type<detail::sequence<Args...>> type;
@@ -250,13 +250,13 @@ BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const smart_library& lib, co
return type::make(lib, name);
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const smart_library& lib, const std::string& name) {
return import_mangled<Args...>(lib, name.c_str());
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(smart_library) lib, const char* name) {
typedef typename boost::dll::experimental::detail::mangled_import_type<detail::sequence<Args...>> type;
@@ -264,13 +264,13 @@ BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(smart_library)
return type::make(lib, name);
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(smart_library) lib, const std::string& name) {
return import_mangled<Args...>(boost::move(lib), name.c_str());
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const shared_library& lib, const char* name) {
typedef typename boost::dll::experimental::detail::mangled_import_type<detail::sequence<Args...>> type;
@@ -279,13 +279,13 @@ BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const shared_library& lib, c
return type::make(p, name);
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const shared_library& lib, const std::string& name) {
return import_mangled<Args...>(lib, name.c_str());
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(shared_library) lib, const char* name) {
typedef typename boost::dll::experimental::detail::mangled_import_type<detail::sequence<Args...>> type;
@@ -295,7 +295,7 @@ BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(shared_library)
return type::make(p, name);
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
//! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode)
template <class ...Args>
BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(BOOST_RV_REF(shared_library) lib, const std::string& name) {
return import_mangled<Args...>(boost::move(lib), name.c_str());

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,15 +8,18 @@
#ifndef BOOST_DLL_LIBRARY_INFO_HPP
#define BOOST_DLL_LIBRARY_INFO_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/mpl/max_element.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/aligned_storage.hpp>
#include <boost/noncopyable.hpp>
#include <boost/predef/os.h>
#include <boost/predef/architecture.h>
#include <boost/throw_exception.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <fstream>
#include <boost/dll/detail/pe_info.hpp>
#include <boost/dll/detail/elf_info.hpp>
#include <boost/dll/detail/macho_info.hpp>
@@ -37,7 +40,7 @@ namespace boost { namespace dll {
*/
class library_info: private boost::noncopyable {
private:
boost::filesystem::ifstream f_;
std::ifstream f_;
boost::aligned_storage< // making my own std::aligned_union from scratch. TODO: move to TypeTraits
boost::mpl::deref<
@@ -127,14 +130,25 @@ public:
* \param throw_if_not_native_format Throw an exception if this file format is not
* supported by OS.
*/
explicit library_info(const boost::filesystem::path& library_path, bool throw_if_not_native_format = true)
: f_(library_path, std::ios_base::in | std::ios_base::binary)
explicit library_info(const boost::dll::fs::path& library_path, bool throw_if_not_native_format = true)
: f_(
#ifdef BOOST_DLL_USE_STD_FS
library_path,
// Copied from boost/filesystem/fstream.hpp
#elif defined(BOOST_WINDOWS_API) && (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405 || defined(_STLPORT_VERSION))
// !Dinkumware || early Dinkumware || STLPort masquerading as Dinkumware
library_path.string().c_str(), // use narrow, since wide not available
#else // use the native c_str, which will be narrow on POSIX, wide on Windows
library_path.c_str(),
#endif
std::ios_base::in | std::ios_base::binary
)
, impl_()
{
f_.exceptions(
boost::filesystem::ifstream::failbit
| boost::filesystem::ifstream::badbit
| boost::filesystem::ifstream::eofbit
std::ios_base::failbit
| std::ifstream::badbit
| std::ifstream::eofbit
);
init(throw_if_not_native_format);

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2017 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,12 +8,12 @@
#ifndef BOOST_DLL_RUNTIME_SYMBOL_INFO_HPP
#define BOOST_DLL_RUNTIME_SYMBOL_INFO_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/predef/os.h>
#include <boost/predef/compiler/visualc.h>
#include <boost/dll/detail/aggressive_ptr_cast.hpp>
#if BOOST_OS_WINDOWS
# include <boost/detail/winapi/dll.hpp>
# include <boost/winapi/dll.hpp>
# include <boost/dll/detail/windows/path_from_handle.hpp>
#else
# include <dlfcn.h>
@@ -30,7 +30,7 @@ namespace boost { namespace dll {
#if BOOST_OS_WINDOWS
namespace detail {
inline boost::filesystem::path program_location_impl(boost::system::error_code& ec) {
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code& ec) {
return boost::dll::detail::path_from_handle(NULL, ec);
}
} // namespace detail
@@ -42,7 +42,7 @@ namespace detail {
* \param ptr_to_symbol Pointer to symbol which location is to be determined.
* \param ec Variable that will be set to the result of the operation.
* \return Path to the binary object that holds symbol or empty path in case error.
* \throws std::bad_alloc in case of insufficient memory. Overload that does not accept boost::system::error_code also throws boost::system::system_error.
* \throws std::bad_alloc in case of insufficient memory. Overload that does not accept \forcedlinkfs{error_code} also throws \forcedlinkfs{system_error}.
*
* \b Examples:
* \code
@@ -53,13 +53,12 @@ namespace detail {
* \endcode
*/
template <class T>
inline boost::filesystem::path symbol_location_ptr(T ptr_to_symbol, boost::system::error_code& ec) {
inline boost::dll::fs::path symbol_location_ptr(T ptr_to_symbol, boost::dll::fs::error_code& ec) {
BOOST_STATIC_ASSERT_MSG(boost::is_pointer<T>::value, "boost::dll::symbol_location_ptr works only with pointers! `ptr_to_symbol` must be a pointer");
boost::filesystem::path ret;
boost::dll::fs::path ret;
if (!ptr_to_symbol) {
ec = boost::system::error_code(
boost::system::errc::bad_address,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_address
);
return ret;
@@ -69,13 +68,13 @@ namespace detail {
const void* ptr = boost::dll::detail::aggressive_ptr_cast<const void*>(ptr_to_symbol);
#if BOOST_OS_WINDOWS
boost::detail::winapi::MEMORY_BASIC_INFORMATION_ mbi;
if (!boost::detail::winapi::VirtualQuery(ptr, &mbi, sizeof(mbi))) {
boost::winapi::MEMORY_BASIC_INFORMATION_ mbi;
if (!boost::winapi::VirtualQuery(ptr, &mbi, sizeof(mbi))) {
ec = boost::dll::detail::last_error_code();
return ret;
}
return boost::dll::detail::path_from_handle(reinterpret_cast<boost::detail::winapi::HMODULE_>(mbi.AllocationBase), ec);
return boost::dll::detail::path_from_handle(reinterpret_cast<boost::winapi::HMODULE_>(mbi.AllocationBase), ec);
#else
Dl_info info;
@@ -86,9 +85,8 @@ namespace detail {
ret = info.dli_fname;
} else {
boost::dll::detail::reset_dlerror();
ec = boost::system::error_code(
boost::system::errc::bad_address,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_address
);
}
@@ -96,11 +94,11 @@ namespace detail {
#endif
}
//! \overload symbol_location_ptr(const void* ptr_to_symbol, boost::system::error_code& ec)
//! \overload symbol_location_ptr(const void* ptr_to_symbol, boost::dll::fs::error_code& ec)
template <class T>
inline boost::filesystem::path symbol_location_ptr(T ptr_to_symbol) {
boost::filesystem::path ret;
boost::system::error_code ec;
inline boost::dll::fs::path symbol_location_ptr(T ptr_to_symbol) {
boost::dll::fs::path ret;
boost::dll::fs::error_code ec;
ret = boost::dll::symbol_location_ptr(ptr_to_symbol, ec);
if (ec) {
@@ -117,7 +115,7 @@ namespace detail {
* \param symbol Symbol which location is to be determined.
* \param ec Variable that will be set to the result of the operation.
* \return Path to the binary object that holds symbol or empty path in case error.
* \throws std::bad_alloc in case of insufficient memory. Overload that does not accept boost::system::error_code also throws boost::system::system_error.
* \throws std::bad_alloc in case of insufficient memory. Overload that does not accept \forcedlinkfs{error_code} also throws \forcedlinkfs{system_error}.
*
* \b Examples:
* \code
@@ -134,7 +132,7 @@ namespace detail {
* \endcode
*/
template <class T>
inline boost::filesystem::path symbol_location(const T& symbol, boost::system::error_code& ec) {
inline boost::dll::fs::path symbol_location(const T& symbol, boost::dll::fs::error_code& ec) {
ec.clear();
return boost::dll::symbol_location_ptr(
boost::dll::detail::aggressive_ptr_cast<const void*>(boost::addressof(symbol)),
@@ -146,15 +144,15 @@ namespace detail {
// Without this MSVC 7.1 fails with:
// ..\boost\dll\runtime_symbol_info.hpp(133) : error C2780: 'filesystem::path dll::symbol_location(const T &)' : expects 1 arguments - 2 provided
template <class T>
inline boost::filesystem::path symbol_location(const T& symbol, const char* /*workaround*/ = 0)
inline boost::dll::fs::path symbol_location(const T& symbol, const char* /*workaround*/ = 0)
#else
//! \overload symbol_location(const T& symbol, boost::system::error_code& ec)
//! \overload symbol_location(const T& symbol, boost::dll::fs::error_code& ec)
template <class T>
inline boost::filesystem::path symbol_location(const T& symbol)
inline boost::dll::fs::path symbol_location(const T& symbol)
#endif
{
boost::filesystem::path ret;
boost::system::error_code ec;
boost::dll::fs::path ret;
boost::dll::fs::error_code ec;
ret = boost::dll::symbol_location_ptr(
boost::dll::detail::aggressive_ptr_cast<const void*>(boost::addressof(symbol)),
ec
@@ -178,18 +176,18 @@ namespace detail {
* (the line in which the `this_line_location()` method was called).
*
* \param ec Variable that will be set to the result of the operation.
* \throws std::bad_alloc in case of insufficient memory. Overload that does not accept boost::system::error_code also throws boost::system::system_error.
* \throws std::bad_alloc in case of insufficient memory. Overload that does not accept \forcedlinkfs{error_code} also throws \forcedlinkfs{system_error}.
*/
static inline boost::filesystem::path this_line_location(boost::system::error_code& ec) {
typedef boost::filesystem::path(func_t)(boost::system::error_code& );
static inline boost::dll::fs::path this_line_location(boost::dll::fs::error_code& ec) {
typedef boost::dll::fs::path(func_t)(boost::dll::fs::error_code& );
func_t& f = this_line_location;
return boost::dll::symbol_location(f, ec);
}
//! \overload this_line_location(boost::system::error_code& ec)
static inline boost::filesystem::path this_line_location() {
boost::filesystem::path ret;
boost::system::error_code ec;
//! \overload this_line_location(boost::dll::fs::error_code& ec)
static inline boost::dll::fs::path this_line_location() {
boost::dll::fs::path ret;
boost::dll::fs::error_code ec;
ret = this_line_location(ec);
if (ec) {
@@ -211,17 +209,17 @@ namespace detail {
* on Linux OS.
*
* \param ec Variable that will be set to the result of the operation.
* \throws std::bad_alloc in case of insufficient memory. Overload that does not accept boost::system::error_code also throws boost::system::system_error.
* \throws std::bad_alloc in case of insufficient memory. Overload that does not accept \forcedlinkfs{error_code} also throws \forcedlinkfs{system_error}.
*/
inline boost::filesystem::path program_location(boost::system::error_code& ec) {
inline boost::dll::fs::path program_location(boost::dll::fs::error_code& ec) {
ec.clear();
return boost::dll::detail::program_location_impl(ec);
}
//! \overload program_location(boost::system::error_code& ec) {
inline boost::filesystem::path program_location() {
boost::filesystem::path ret;
boost::system::error_code ec;
//! \overload program_location(boost::dll::fs::error_code& ec) {
inline boost::dll::fs::path program_location() {
boost::dll::fs::path ret;
boost::dll::fs::error_code ec;
ret = boost::dll::detail::program_location_impl(ec);
if (ec) {

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2016 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -12,11 +12,11 @@
/// \brief Contains the boost::dll::shared_library class, core class for all the
/// DLL/DSO operations.
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/predef/os.h>
#include <boost/utility/enable_if.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/core/explicit_operator_bool.hpp>
#include <boost/type_traits/is_member_pointer.hpp>
#include <boost/utility/explicit_operator_bool.hpp>
#include <boost/dll/detail/system_error.hpp>
#include <boost/dll/detail/aggressive_ptr_cast.hpp>
@@ -55,7 +55,7 @@ class shared_library
public:
#ifdef BOOST_DLL_DOXYGEN
typedef platform_specific native_handle_t;
#else
#else
typedef shared_library_impl::native_handle_t native_handle_t;
#endif
@@ -73,7 +73,7 @@ public:
*
* \param lib A library to copy.
* \post lib == *this
* \throw boost::system::system_error, std::bad_alloc in case of insufficient memory.
* \throw \forcedlinkfs{system_error}, std::bad_alloc in case of insufficient memory.
*/
shared_library(const shared_library& lib)
: base_t()
@@ -90,7 +90,7 @@ public:
* \post lib == *this
* \throw std::bad_alloc in case of insufficient memory.
*/
shared_library(const shared_library& lib, boost::system::error_code& ec)
shared_library(const shared_library& lib, boost::dll::fs::error_code& ec)
: base_t()
{
assign(lib, ec);
@@ -111,11 +111,11 @@ public:
* Loads a library by specified path with a specified mode.
*
* \param lib_path Library file name. Can handle std::string, const char*, std::wstring,
* const wchar_t* or boost::filesystem::path.
* const wchar_t* or \forcedlinkfs{path}.
* \param mode A mode that will be used on library load.
* \throw boost::system::system_error, std::bad_alloc in case of insufficient memory.
* \throw \forcedlinkfs{system_error}, std::bad_alloc in case of insufficient memory.
*/
explicit shared_library(const boost::filesystem::path& lib_path, load_mode::type mode = load_mode::default_mode) {
explicit shared_library(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) {
shared_library::load(lib_path, mode);
}
@@ -123,17 +123,17 @@ public:
* Loads a library by specified path with a specified mode.
*
* \param lib_path Library file name. Can handle std::string, const char*, std::wstring,
* const wchar_t* or boost::filesystem::path.
* const wchar_t* or \forcedlinkfs{path}.
* \param mode A mode that will be used on library load.
* \param ec Variable that will be set to the result of the operation.
* \throw std::bad_alloc in case of insufficient memory.
*/
shared_library(const boost::filesystem::path& lib_path, boost::system::error_code& ec, load_mode::type mode = load_mode::default_mode) {
shared_library(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode) {
shared_library::load(lib_path, mode, ec);
}
//! \overload shared_library(const boost::filesystem::path& lib_path, boost::system::error_code& ec, load_mode::type mode = load_mode::default_mode)
shared_library(const boost::filesystem::path& lib_path, load_mode::type mode, boost::system::error_code& ec) {
//! \overload shared_library(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode)
shared_library(const boost::dll::fs::path& lib_path, load_mode::type mode, boost::dll::fs::error_code& ec) {
shared_library::load(lib_path, mode, ec);
}
@@ -142,10 +142,10 @@ public:
*
* \param lib A shared library to assign from.
* \post lib == *this
* \throw boost::system::system_error, std::bad_alloc in case of insufficient memory.
* \throw \forcedlinkfs{system_error}, std::bad_alloc in case of insufficient memory.
*/
shared_library& operator=(BOOST_COPY_ASSIGN_REF(shared_library) lib) {
boost::system::error_code ec;
boost::dll::fs::error_code ec;
assign(lib, ec);
if (ec) {
boost::dll::detail::report_error(ec, "boost::dll::shared_library::operator= failed");
@@ -186,7 +186,7 @@ public:
* \param ec Variable that will be set to the result of the operation.
* \throw std::bad_alloc in case of insufficient memory.
*/
shared_library& assign(const shared_library& lib, boost::system::error_code& ec) {
shared_library& assign(const shared_library& lib, boost::dll::fs::error_code& ec) {
ec.clear();
if (native() == lib.native()) {
@@ -198,7 +198,7 @@ public:
return *this;
}
boost::filesystem::path loc = lib.location(ec);
boost::dll::fs::path loc = lib.location(ec);
if (ec) {
return *this;
}
@@ -217,10 +217,10 @@ public:
*
* \param lib A library instance to assign from.
* \post lib.location() == this->location()
* \throw boost::system::system_error, std::bad_alloc in case of insufficient memory.
* \throw \forcedlinkfs{system_error}, std::bad_alloc in case of insufficient memory.
*/
shared_library& assign(const shared_library& lib) {
boost::system::error_code ec;
boost::dll::fs::error_code ec;
assign(lib, ec);
if (ec) {
boost::dll::detail::report_error(ec, "boost::dll::shared_library::assign() failed");
@@ -236,13 +236,13 @@ public:
* call unload() and then load the new provided library.
*
* \param lib_path Library file name. Can handle std::string, const char*, std::wstring,
* const wchar_t* or boost::filesystem::path.
* const wchar_t* or \forcedlinkfs{path}.
* \param mode A mode that will be used on library load.
* \throw boost::system::system_error, std::bad_alloc in case of insufficient memory.
* \throw \forcedlinkfs{system_error}, std::bad_alloc in case of insufficient memory.
*
*/
void load(const boost::filesystem::path& lib_path, load_mode::type mode = load_mode::default_mode) {
boost::system::error_code ec;
void load(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) {
boost::dll::fs::error_code ec;
base_t::load(lib_path, mode, ec);
@@ -258,18 +258,18 @@ public:
* call unload() and then load the new provided library.
*
* \param lib_path Library file name. Can handle std::string, const char*, std::wstring,
* const wchar_t* or boost::filesystem::path.
* const wchar_t* or \forcedlinkfs{path}.
* \param ec Variable that will be set to the result of the operation.
* \param mode A mode that will be used on library load.
* \throw std::bad_alloc in case of insufficient memory.
*/
void load(const boost::filesystem::path& lib_path, boost::system::error_code& ec, load_mode::type mode = load_mode::default_mode) {
void load(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode) {
ec.clear();
base_t::load(lib_path, mode, ec);
}
//! \overload void load(const boost::filesystem::path& lib_path, boost::system::error_code& ec, load_mode::type mode = load_mode::default_mode)
void load(const boost::filesystem::path& lib_path, load_mode::type mode, boost::system::error_code& ec) {
//! \overload void load(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode)
void load(const boost::dll::fs::path& lib_path, load_mode::type mode, boost::dll::fs::error_code& ec) {
ec.clear();
base_t::load(lib_path, mode, ec);
}
@@ -322,7 +322,7 @@ public:
* \throw Nothing.
*/
bool has(const char* symbol_name) const BOOST_NOEXCEPT {
boost::system::error_code ec;
boost::dll::fs::error_code ec;
return is_loaded() && !!base_t::symbol_addr(symbol_name, ec) && !ec;
}
@@ -345,7 +345,7 @@ public:
* \tparam T Type of the symbol that we are going to import. Must be explicitly specified.
* \param symbol_name Null-terminated symbol name. Can handle std::string, char*, const char*.
* \return Reference to the symbol.
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
*/
template <typename T>
inline typename boost::enable_if_c<boost::is_member_pointer<T>::value || boost::is_reference<T>::value, T>::type get(const std::string& symbol_name) const {
@@ -384,7 +384,7 @@ public:
*
* \tparam T Type of the symbol that we are going to import. Must be explicitly specified..
* \param alias_name Null-terminated alias symbol name. Can handle std::string, char*, const char*.
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
*/
template <typename T>
inline T& get_alias(const char* alias_name) const {
@@ -402,17 +402,16 @@ private:
// get_void is required to reduce binary size: it does not depend on a template
// parameter and will be instantiated only once.
void* get_void(const char* sb) const {
boost::system::error_code ec;
boost::dll::fs::error_code ec;
if (!is_loaded()) {
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
// report_error() calls dlsym, do not use it here!
boost::throw_exception(
boost::system::system_error(
boost::dll::fs::system_error(
ec, "boost::dll::shared_library::get() failed: no library was loaded"
)
);
@@ -448,24 +447,23 @@ public:
* \endcode
*
* \return Full path to the shared library.
* \throw boost::system::system_error, std::bad_alloc.
* \throw \forcedlinkfs{system_error}, std::bad_alloc.
*/
boost::filesystem::path location() const {
boost::system::error_code ec;
boost::dll::fs::path location() const {
boost::dll::fs::error_code ec;
if (!is_loaded()) {
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
boost::throw_exception(
boost::system::system_error(
boost::dll::fs::system_error(
ec, "boost::dll::shared_library::location() failed (no library was loaded)"
)
);
}
boost::filesystem::path full_path = base_t::full_module_path(ec);
boost::dll::fs::path full_path = base_t::full_module_path(ec);
if (ec) {
boost::dll::detail::report_error(ec, "boost::dll::shared_library::location() failed");
@@ -487,14 +485,13 @@ public:
* \return Full path to the shared library.
* \throw std::bad_alloc.
*/
boost::filesystem::path location(boost::system::error_code& ec) const {
boost::dll::fs::path location(boost::dll::fs::error_code& ec) const {
if (!is_loaded()) {
ec = boost::system::error_code(
boost::system::errc::bad_file_descriptor,
boost::system::generic_category()
ec = boost::dll::fs::make_error_code(
boost::dll::fs::errc::bad_file_descriptor
);
return boost::filesystem::path();
return boost::dll::fs::path();
}
ec.clear();
@@ -507,10 +504,33 @@ public:
*
* \return The suffix od shared module: ".dll" (Windows), ".so" (Unix/Linux/BSD), ".dylib" (MacOS/IOS)
*/
static boost::filesystem::path suffix() {
static boost::dll::fs::path suffix() {
return base_t::suffix();
}
/*!
* Returns the decorated path to a shared module name, i.e. with needed prefix/suffix added.
*
* \b Recommendations: Use `load` with `load_mode::append_decorations` instead of constructing the decorated path via `decorate()` and loading by it.
*
* For instance, for a path like "path/to/boost" it returns :
* - path/to/libboost.so on posix platforms
* - path/to/libboost.dylib on OSX
* - path/to/boost.dll on Windows
*
* Method handles both relative and absolute paths.
*
* - Windows note: `decorate()` does not prepend "lib" to the decorated path. Use `load` with `load_mode::append_decorations` for MinGW compatibility purpose.
* - Posix note: if the initial module name is already prepended with lib, only the suffix() is appended to the path
*
* \param sl the module name and path to decorate - for instance : /usr/lib/boost
*
* \return The decorated unportable path that may not exists in the filesystem or could be wrong due to platform specifics.
*/
static boost::dll::fs::path decorate(const boost::dll::fs::path& sl) {
return base_t::decorate(sl);
}
/*!
* Swaps two libraries. Does not invalidate existing symbols and functions loaded from libraries.
*
@@ -547,4 +567,3 @@ inline void swap(shared_library& lhs, shared_library& rhs) BOOST_NOEXCEPT {
}} // boost::dll
#endif // BOOST_DLL_SHARED_LIBRARY_HPP

View File

@@ -1,5 +1,5 @@
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
// Copyright 2015-2016 Antony Polukhin.
// Copyright 2015-2019 Antony Polukhin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
@@ -8,13 +8,12 @@
#ifndef BOOST_DLL_SHARED_LIBRARY_MODE_HPP
#define BOOST_DLL_SHARED_LIBRARY_MODE_HPP
#include <boost/config.hpp>
#include <boost/dll/config.hpp>
#include <boost/predef/os.h>
#include <boost/predef/library/c.h>
#if BOOST_OS_WINDOWS
//#include <boost/detail/winapi/dll.hpp>
#include <boost/detail/winapi/dll.hpp>
# include <boost/winapi/dll.hpp>
#else
# include <dlfcn.h>
#endif
@@ -175,9 +174,9 @@ enum type {
search_system_folders
#elif BOOST_OS_WINDOWS
default_mode = 0,
dont_resolve_dll_references = boost::detail::winapi::DONT_RESOLVE_DLL_REFERENCES_,
load_ignore_code_authz_level = boost::detail::winapi::LOAD_IGNORE_CODE_AUTHZ_LEVEL_,
load_with_altered_search_path = boost::detail::winapi::LOAD_WITH_ALTERED_SEARCH_PATH_,
dont_resolve_dll_references = boost::winapi::DONT_RESOLVE_DLL_REFERENCES_,
load_ignore_code_authz_level = boost::winapi::LOAD_IGNORE_CODE_AUTHZ_LEVEL_,
load_with_altered_search_path = boost::winapi::LOAD_WITH_ALTERED_SEARCH_PATH_,
rtld_lazy = 0,
rtld_now = 0,
rtld_global = 0,

View File

@@ -11,8 +11,17 @@
/// \warning Extremely experimental! Requires C++14! Will change in next version of Boost! boost/dll/smart_library.hpp is not included in boost/dll.hpp
/// \brief Contains the boost::dll::experimental::smart_library class for loading mangled symbols.
#include <boost/predef.h>
#if BOOST_COMP_GNUC || BOOST_COMP_CLANG || BOOST_COMP_HPACC || BOOST_COMP_IBM
#if BOOST_OS_WINDOWS && BOOST_COMP_CLANG
#warning "Clang-win is not supported"
#include <boost/dll/detail/demangling/msvc.hpp>
#else
#include <boost/dll/detail/demangling/itanium.hpp>
#endif
#elif BOOST_COMP_MSVC
#include <boost/dll/detail/demangling/msvc.hpp>
#else
@@ -26,7 +35,6 @@
#include <boost/type_traits/is_object.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/is_function.hpp>
#include <boost/predef/compiler.h>
@@ -61,7 +69,7 @@ using boost::dll::detail::destructor;
* BOOST_DLL_MEMBER_EXPORT for this, so that MinGW and MSVC can provide those functions. This does however not work with gcc on linux.
*
* Direct initialization of members.
* On linux the following member variable i will not be initialized when using the allocating contructor:
* On linux the following member variable i will not be initialized when using the allocating constructor:
* \code
* struct BOOST_SYMBOL_EXPORT my_class { int i; my_class() : i(42) {} };
* \endcode
@@ -80,7 +88,7 @@ public:
using mangled_storage = detail::mangled_storage_impl;
/*!
* Acces to the mangled storage, which is created on construction.
* Access to the mangled storage, which is created on construction.
*
* \throw Nothing.
*/
@@ -92,19 +100,19 @@ public:
//! \copydoc shared_library::shared_library()
smart_library() BOOST_NOEXCEPT {};
//! \copydoc shared_library::shared_library(const boost::filesystem::path& lib_path, load_mode::type mode = load_mode::default_mode)
smart_library(const boost::filesystem::path& lib_path, load_mode::type mode = load_mode::default_mode) {
//! \copydoc shared_library::shared_library(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode)
smart_library(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) {
_lib.load(lib_path, mode);
_storage.load(lib_path);
}
//! \copydoc shared_library::shared_library(const boost::filesystem::path& lib_path, boost::system::error_code& ec, load_mode::type mode = load_mode::default_mode)
smart_library(const boost::filesystem::path& lib_path, boost::system::error_code& ec, load_mode::type mode = load_mode::default_mode) {
//! \copydoc shared_library::shared_library(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode)
smart_library(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode) {
load(lib_path, mode, ec);
}
//! \copydoc shared_library::shared_library(const boost::filesystem::path& lib_path, load_mode::type mode, boost::system::error_code& ec)
smart_library(const boost::filesystem::path& lib_path, load_mode::type mode, boost::system::error_code& ec) {
//! \copydoc shared_library::shared_library(const boost::dll::fs::path& lib_path, load_mode::type mode, boost::dll::fs::error_code& ec)
smart_library(const boost::dll::fs::path& lib_path, load_mode::type mode, boost::dll::fs::error_code& ec) {
load(lib_path, mode, ec);
}
/*!
@@ -163,9 +171,9 @@ public:
*/
~smart_library() BOOST_NOEXCEPT {};
//! \copydoc shared_library::load(const boost::filesystem::path& lib_path, load_mode::type mode = load_mode::default_mode)
void load(const boost::filesystem::path& lib_path, load_mode::type mode = load_mode::default_mode) {
boost::system::error_code ec;
//! \copydoc shared_library::load(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode)
void load(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) {
boost::dll::fs::error_code ec;
_storage.load(lib_path);
_lib.load(lib_path, mode, ec);
@@ -174,15 +182,15 @@ public:
}
}
//! \copydoc shared_library::load(const boost::filesystem::path& lib_path, boost::system::error_code& ec, load_mode::type mode = load_mode::default_mode)
void load(const boost::filesystem::path& lib_path, boost::system::error_code& ec, load_mode::type mode = load_mode::default_mode) {
//! \copydoc shared_library::load(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode)
void load(const boost::dll::fs::path& lib_path, boost::dll::fs::error_code& ec, load_mode::type mode = load_mode::default_mode) {
ec.clear();
_storage.load(lib_path);
_lib.load(lib_path, mode, ec);
}
//! \copydoc shared_library::load(const boost::filesystem::path& lib_path, load_mode::type mode, boost::system::error_code& ec)
void load(const boost::filesystem::path& lib_path, load_mode::type mode, boost::system::error_code& ec) {
//! \copydoc shared_library::load(const boost::dll::fs::path& lib_path, load_mode::type mode, boost::dll::fs::error_code& ec)
void load(const boost::dll::fs::path& lib_path, load_mode::type mode, boost::dll::fs::error_code& ec) {
ec.clear();
_storage.load(lib_path);
_lib.load(lib_path, mode, ec);
@@ -199,7 +207,7 @@ public:
* \tparam T Type of the variable
* \return A reference to the variable of type T.
*
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
*/
template<typename T>
T& get_variable(const std::string &name) const {
@@ -225,7 +233,7 @@ public:
* \tparam Func Type of the function, required for determining the overload
* \return A reference to the function of type F.
*
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
*/
template<typename Func>
Func& get_function(const std::string &name) const {
@@ -254,7 +262,7 @@ public:
* \tparam Func Signature of the function, required for determining the overload
* \return A pointer to the member-function with the signature provided
*
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
*/
template<typename Class, typename Func>
typename boost::dll::detail::get_mem_fn_type<Class, Func>::mem_fn get_mem_fn(const std::string& name) const {
@@ -277,7 +285,7 @@ public:
* \tparam Signature Signature of the function, required for determining the overload. The return type is the class which this is the constructor of.
* \return A constructor object.
*
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
*/
template<typename Signature>
constructor<Signature> get_constructor() const {
@@ -295,10 +303,10 @@ public:
* destructor<MyClass> f1 = lib.get_mem_fn<MyClass>();
* \endcode
*
* \tparam Class The class whichs destructor shall be loaded
* \tparam Class The class whose destructor shall be loaded
* \return A destructor object.
*
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
*
*/
template<typename Class>
@@ -316,10 +324,10 @@ public:
* std::type_info &ti = lib.get_Type_info<MyClass>();
* \endcode
*
* \tparam Class The class whichs typeinfo shall be loaded
* \tparam Class The class whose typeinfo shall be loaded
* \return A reference to a type_info object.
*
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
* \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded.
*
*/
template<typename Class>