123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- #ifndef BOOST_DLL_ALIAS_HPP
- #define BOOST_DLL_ALIAS_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
- namespace boost { namespace dll {
- #ifdef BOOST_DLL_DOXYGEN
- #define BOOST_DLL_FORCE_ALIAS_INSTANTIATION
- #define BOOST_DLL_FORCE_NO_WEAK_EXPORTS
- #endif
- #if defined(_MSC_VER) // MSVC, Clang-cl, and ICC on 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 bytes" \
- ); \
- __pragma(section(#SectionName, Permissions)) __declspec(allocate(#SectionName)) \
-
- #else // #if BOOST_COMP_MSVC
- #if BOOST_OS_WINDOWS || BOOST_OS_ANDROID || BOOST_COMP_IBM
- #define BOOST_DLL_SELECTANY
- #else // #if BOOST_OS_WINDOWS
- #define BOOST_DLL_SELECTANY __attribute__((weak))
- #endif // #if BOOST_OS_WINDOWS
- #if !BOOST_OS_MACOS && !BOOST_OS_IOS
- #define BOOST_DLL_SECTION(SectionName, Permissions) \
- BOOST_STATIC_ASSERT_MSG( \
- sizeof(#SectionName) < 10, \
- "Some platforms require section names to be at most 8 bytes" \
- ); \
- __attribute__ ((section (#SectionName))) \
-
- #else // #if !BOOST_OS_MACOS && !BOOST_OS_IOS
- #define BOOST_DLL_SECTION(SectionName, Permissions) \
- BOOST_STATIC_ASSERT_MSG( \
- sizeof(#SectionName) < 10, \
- "Some platforms require section names to be at most 8 bytes" \
- ); \
- __attribute__ ((section ( "__DATA," #SectionName))) \
-
- #endif // #if #if !BOOST_OS_MACOS && !BOOST_OS_IOS
- #endif // #if BOOST_COMP_MSVC
- #define BOOST_DLL_ALIAS(FunctionOrVar, AliasName) \
- BOOST_DLL_ALIAS_SECTIONED(FunctionOrVar, AliasName, boostdll) \
-
- #if ((BOOST_COMP_GNUC && BOOST_OS_WINDOWS) || BOOST_OS_ANDROID || BOOST_COMP_IBM || defined(BOOST_DLL_FORCE_NO_WEAK_EXPORTS)) \
- && !defined(BOOST_DLL_FORCE_ALIAS_INSTANTIATION) && !defined(BOOST_DLL_DOXYGEN)
- #define BOOST_DLL_ALIAS_SECTIONED(FunctionOrVar, AliasName, SectionName) \
- namespace _autoaliases { \
- extern "C" BOOST_SYMBOL_EXPORT const void *AliasName; \
- } \
-
- #define BOOST_DLL_AUTO_ALIAS(FunctionOrVar) \
- namespace _autoaliases { \
- extern "C" BOOST_SYMBOL_EXPORT const void *FunctionOrVar; \
- } \
-
- #else
- #define BOOST_DLL_ALIAS_SECTIONED(FunctionOrVar, AliasName, SectionName) \
- namespace _autoaliases { \
- extern "C" BOOST_SYMBOL_EXPORT const void *AliasName; \
- BOOST_DLL_SECTION(SectionName, read) BOOST_DLL_SELECTANY \
- const void * AliasName = reinterpret_cast<const void*>(reinterpret_cast<intptr_t>( \
- &FunctionOrVar \
- )); \
- } \
-
- #define BOOST_DLL_AUTO_ALIAS(FunctionOrVar) \
- namespace _autoaliases { \
- BOOST_DLL_SELECTANY const void * dummy_ ## FunctionOrVar \
- = reinterpret_cast<const void*>(reinterpret_cast<intptr_t>( \
- &FunctionOrVar \
- )); \
- extern "C" BOOST_SYMBOL_EXPORT const void *FunctionOrVar; \
- BOOST_DLL_SECTION(boostdll, read) BOOST_DLL_SELECTANY \
- const void * FunctionOrVar = dummy_ ## FunctionOrVar; \
- } \
-
- #endif
- }}
- #endif // BOOST_DLL_ALIAS_HPP
|