Home | History | Annotate | Download | only in detail
      1 //
      2 // detail/config.hpp
      3 // ~~~~~~~~~~~~~~~~~
      4 //
      5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
      6 //
      7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
      8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
      9 //
     10 
     11 #ifndef ASIO_DETAIL_CONFIG_HPP
     12 #define ASIO_DETAIL_CONFIG_HPP
     13 
     14 # define ASIO_DISABLE_BOOST_ARRAY 1
     15 # define ASIO_DISABLE_BOOST_ASSERT 1
     16 # define ASIO_DISABLE_BOOST_BIND 1
     17 # define ASIO_DISABLE_BOOST_CHRONO 1
     18 # define ASIO_DISABLE_BOOST_DATE_TIME 1
     19 # define ASIO_DISABLE_BOOST_LIMITS 1
     20 # define ASIO_DISABLE_BOOST_REGEX 1
     21 # define ASIO_DISABLE_BOOST_STATIC_CONSTANT 1
     22 # define ASIO_DISABLE_BOOST_THROW_EXCEPTION 1
     23 # define ASIO_DISABLE_BOOST_WORKAROUND 1
     24 
     25 // Default to a header-only implementation. The user must specifically request
     26 // separate compilation by defining either ASIO_SEPARATE_COMPILATION or
     27 // ASIO_DYN_LINK (as a DLL/shared library implies separate compilation).
     28 
     29 # define ASIO_DECL inline
     30 
     31 // If ASIO_DECL isn't defined yet define it now.
     32 #if !defined(ASIO_DECL)
     33 # define ASIO_DECL
     34 #endif // !defined(ASIO_DECL)
     35 
     36 // Microsoft Visual C++ detection.
     37 
     38 // Clang / libc++ detection.
     39 # if (__cplusplus >= 201103)
     40 #  if __has_include(<__config>)
     41 #   include <__config>
     42 #   if defined(_LIBCPP_VERSION)
     43 #    define ASIO_HAS_CLANG_LIBCXX 1
     44 #   endif // defined(_LIBCPP_VERSION)
     45 #  endif // __has_include(<__config>)
     46 # endif // (__cplusplus >= 201103)
     47 
     48 // Support move construction and assignment on compilers known to allow it.
     49 
     50 // If ASIO_MOVE_CAST isn't defined, and move support is available, define
     51 // ASIO_MOVE_ARG and ASIO_MOVE_CAST to take advantage of rvalue
     52 // references and perfect forwarding.
     53 #if defined(ASIO_HAS_MOVE) && !defined(ASIO_MOVE_CAST)
     54 # define ASIO_MOVE_ARG(type) type&&
     55 # define ASIO_MOVE_CAST(type) static_cast<type&&>
     56 # define ASIO_MOVE_CAST2(type1, type2) static_cast<type1, type2&&>
     57 #endif // defined(ASIO_HAS_MOVE) && !defined(ASIO_MOVE_CAST)
     58 
     59 // If ASIO_MOVE_CAST still isn't defined, default to a C++03-compatible
     60 // implementation. Note that older g++ and MSVC versions don't like it when you
     61 // pass a non-member function through a const reference, so for most compilers
     62 // we'll play it safe and stick with the old approach of passing the handler by
     63 // value.
     64 #if !defined(ASIO_MOVE_CAST)
     65 # if defined(__GNUC__)
     66 #  if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ > 4)
     67 #   define ASIO_MOVE_ARG(type) const type&
     68 #  else // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ > 4)
     69 #   define ASIO_MOVE_ARG(type) type
     70 #  endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ > 4)
     71 # else
     72 #  define ASIO_MOVE_ARG(type) type
     73 # endif
     74 # define ASIO_MOVE_CAST(type) static_cast<const type&>
     75 # define ASIO_MOVE_CAST2(type1, type2) static_cast<const type1, type2&>
     76 #endif // !defined(ASIO_MOVE_CAST)
     77 
     78 // Support variadic templates on compilers known to allow it.
     79 
     80 // Support constexpr on compilers known to allow it.
     81 #if !defined(ASIO_CONSTEXPR)
     82 #  define ASIO_CONSTEXPR constexpr
     83 #endif // !defined(ASIO_CONSTEXPR)
     84 
     85 // Standard library support for system errors.
     86 
     87 // Compliant C++11 compilers put noexcept specifiers on error_category members.
     88 #if !defined(ASIO_ERROR_CATEGORY_NOEXCEPT)
     89 # if (BOOST_VERSION >= 105300)
     90 #  define ASIO_ERROR_CATEGORY_NOEXCEPT BOOST_NOEXCEPT
     91 # else
     92 #  if __has_feature(__cxx_noexcept__)
     93 #   define ASIO_ERROR_CATEGORY_NOEXCEPT noexcept(true)
     94 #  endif // __has_feature(__cxx_noexcept__)
     95 # endif
     96 # if !defined(ASIO_ERROR_CATEGORY_NOEXCEPT)
     97 #  define ASIO_ERROR_CATEGORY_NOEXCEPT
     98 # endif // !defined(ASIO_ERROR_CATEGORY_NOEXCEPT)
     99 #endif // !defined(ASIO_ERROR_CATEGORY_NOEXCEPT)
    100 
    101 // Standard library support for arrays.
    102 
    103 // Standard library support for shared_ptr and weak_ptr.
    104 
    105 // Standard library support for atomic operations.
    106 
    107 // Standard library support for chrono. Some standard libraries (such as the
    108 // libstdc++ shipped with gcc 4.6) provide monotonic_clock as per early C++0x
    109 // drafts, rather than the eventually standardised name of steady_clock.
    110 
    111 // Boost support for chrono.
    112 
    113 // Boost support for the DateTime library.
    114 
    115 // Standard library support for addressof.
    116 
    117 // Standard library support for the function class.
    118 
    119 // Standard library support for type traits.
    120 
    121 // Standard library support for the cstdint header.
    122 
    123 // Standard library support for the thread class.
    124 
    125 // Standard library support for the mutex and condition variable classes.
    126 
    127 // WinRT target.
    128 # if defined(__cplusplus_winrt)
    129 #  include <winapifamily.h>
    130 #  if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)     && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
    131 #   define ASIO_WINDOWS_RUNTIME 1
    132 #  endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
    133          // && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
    134 # endif // defined(__cplusplus_winrt)
    135 
    136 // Windows target. Excludes WinRT.
    137 
    138 // Windows: target OS version.
    139 
    140 // Windows: minimise header inclusion.
    141 
    142 // Windows: suppress definition of "min" and "max" macros.
    143 
    144 // Windows: IO Completion Ports.
    145 
    146 // On POSIX (and POSIX-like) platforms we need to include unistd.h in order to
    147 // get access to the various platform feature macros, e.g. to be able to test
    148 // for threads support.
    149 #if !defined(ASIO_HAS_UNISTD_H)
    150 #  if defined(unix)     || defined(__unix)     || defined(_XOPEN_SOURCE)     || defined(_POSIX_SOURCE)     || (defined(__MACH__) && defined(__APPLE__))     || defined(__FreeBSD__)     || defined(__NetBSD__)     || defined(__OpenBSD__)     || defined(__linux__)
    151 #   define ASIO_HAS_UNISTD_H 1
    152 #  endif
    153 #endif // !defined(ASIO_HAS_UNISTD_H)
    154 #if defined(ASIO_HAS_UNISTD_H)
    155 # include <unistd.h>
    156 #endif // defined(ASIO_HAS_UNISTD_H)
    157 
    158 // Linux: epoll, eventfd and timerfd.
    159 #if defined(__linux__)
    160 # include <linux/version.h>
    161 # if !defined(ASIO_HAS_EPOLL)
    162 # endif // !defined(ASIO_HAS_EPOLL)
    163 #  if defined(ASIO_HAS_EPOLL)
    164 #   if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
    165 #    define ASIO_HAS_TIMERFD 1
    166 #   endif // (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
    167 #  endif // defined(ASIO_HAS_EPOLL)
    168 #endif // defined(__linux__)
    169 
    170 // Mac OS X, FreeBSD, NetBSD, OpenBSD: kqueue.
    171 #if (defined(__MACH__) && defined(__APPLE__))    || defined(__FreeBSD__)    || defined(__NetBSD__)    || defined(__OpenBSD__)
    172 #endif // (defined(__MACH__) && defined(__APPLE__))
    173        //   || defined(__FreeBSD__)
    174        //   || defined(__NetBSD__)
    175        //   || defined(__OpenBSD__)
    176 
    177 // Solaris: /dev/poll.
    178 #if defined(__sun)
    179 # if !defined(ASIO_HAS_DEV_POLL)
    180 #  if !defined(ASIO_DISABLE_DEV_POLL)
    181 #   define ASIO_HAS_DEV_POLL 1
    182 #  endif // !defined(ASIO_DISABLE_DEV_POLL)
    183 # endif // !defined(ASIO_HAS_DEV_POLL)
    184 #endif // defined(__sun)
    185 
    186 // Serial ports.
    187         //   || !defined(ASIO_WINDOWS)
    188         //   && !defined(ASIO_WINDOWS_RUNTIME)
    189         //   && !defined(__CYGWIN__)
    190 
    191 // Windows: stream handles.
    192 # if !defined(ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
    193 # endif // !defined(ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
    194 
    195 // Windows: random access handles.
    196 # if !defined(ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE)
    197 # endif // !defined(ASIO_DISABLE_WINDOWS_RANDOM_ACCESS_HANDLE)
    198 
    199 // Windows: object handles.
    200 # if !defined(ASIO_DISABLE_WINDOWS_OBJECT_HANDLE)
    201 # endif // !defined(ASIO_DISABLE_WINDOWS_OBJECT_HANDLE)
    202 
    203 // Windows: OVERLAPPED wrapper.
    204 # if !defined(ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR)
    205 # endif // !defined(ASIO_DISABLE_WINDOWS_OVERLAPPED_PTR)
    206 
    207 // POSIX: stream-oriented file descriptors.
    208 
    209 // UNIX domain sockets.
    210 
    211 // Can use sigaction() instead of signal().
    212 #if !defined(ASIO_HAS_SIGACTION)
    213 # if !defined(ASIO_DISABLE_SIGACTION)
    214 #   define ASIO_HAS_SIGACTION 1
    215          //   && !defined(ASIO_WINDOWS_RUNTIME)
    216          //   && !defined(__CYGWIN__)
    217 # endif // !defined(ASIO_DISABLE_SIGACTION)
    218 #endif // !defined(ASIO_HAS_SIGACTION)
    219 
    220 // Can use signal().
    221 #if !defined(ASIO_HAS_SIGNAL)
    222 # if !defined(ASIO_DISABLE_SIGNAL)
    223 #  if !defined(UNDER_CE)
    224 #   define ASIO_HAS_SIGNAL 1
    225 #  endif // !defined(UNDER_CE)
    226 # endif // !defined(ASIO_DISABLE_SIGNAL)
    227 #endif // !defined(ASIO_HAS_SIGNAL)
    228 
    229 // Can use getaddrinfo() and getnameinfo().
    230 
    231 // Whether standard iostreams are disabled.
    232 
    233 // Whether exception handling is disabled.
    234 #if !defined(ASIO_NO_EXCEPTIONS)
    235 #endif // !defined(ASIO_NO_EXCEPTIONS)
    236 
    237 // Whether the typeid operator is supported.
    238 #if !defined(ASIO_NO_TYPEID)
    239 #endif // !defined(ASIO_NO_TYPEID)
    240 
    241 // Threads.
    242 
    243 // POSIX threads.
    244 #if !defined(ASIO_HAS_PTHREADS)
    245 #  if   defined(_POSIX_THREADS)
    246 #   define ASIO_HAS_PTHREADS 1
    247 #  endif // defined(ASIO_HAS_BOOST_CONFIG) && defined(BOOST_HAS_PTHREADS)
    248 #endif // !defined(ASIO_HAS_PTHREADS)
    249 
    250 // Helper to prevent macro expansion.
    251 #define ASIO_PREVENT_MACRO_SUBSTITUTION
    252 
    253 // Helper to define in-class constants.
    254 #if !defined(ASIO_STATIC_CONSTANT)
    255 #  define ASIO_STATIC_CONSTANT(type, assignment)      static const type assignment
    256 #endif // !defined(ASIO_STATIC_CONSTANT)
    257 
    258 // Boost array library.
    259 
    260 // Boost assert macro.
    261 
    262 // Boost limits header.
    263 
    264 // Boost throw_exception function.
    265 
    266 // Boost regex library.
    267 
    268 // Boost bind function.
    269 
    270 // Boost's BOOST_WORKAROUND macro.
    271 
    272 // Microsoft Visual C++'s secure C runtime library.
    273 #if !defined(ASIO_HAS_SECURE_RTL)
    274 # if !defined(ASIO_DISABLE_SECURE_RTL)
    275          // && (ASIO_MSVC >= 1400)
    276          // && !defined(UNDER_CE)
    277 # endif // !defined(ASIO_DISABLE_SECURE_RTL)
    278 #endif // !defined(ASIO_HAS_SECURE_RTL)
    279 
    280 // Handler hooking. Disabled for ancient Borland C++ and gcc compilers.
    281 #if !defined(ASIO_HAS_HANDLER_HOOKS)
    282 # if !defined(ASIO_DISABLE_HANDLER_HOOKS)
    283 #  if defined(__GNUC__)
    284 #   if (__GNUC__ >= 3)
    285 #    define ASIO_HAS_HANDLER_HOOKS 1
    286 #   endif // (__GNUC__ >= 3)
    287 #  else
    288 #   define ASIO_HAS_HANDLER_HOOKS 1
    289 #  endif // !defined(__BORLANDC__)
    290 # endif // !defined(ASIO_DISABLE_HANDLER_HOOKS)
    291 #endif // !defined(ASIO_HAS_HANDLER_HOOKS)
    292 
    293 // Support for the __thread keyword extension.
    294 #if !defined(ASIO_THREAD_KEYWORD)
    295 # define ASIO_THREAD_KEYWORD __thread
    296 #endif // !defined(ASIO_THREAD_KEYWORD)
    297 
    298 // Support for POSIX ssize_t typedef.
    299 #if !defined(ASIO_DISABLE_SSIZE_T)
    300 # if defined(__linux__)     || (defined(__MACH__) && defined(__APPLE__))
    301 #  define ASIO_HAS_SSIZE_T 1
    302 # endif // defined(__linux__)
    303         //   || (defined(__MACH__) && defined(__APPLE__))
    304 #endif // !defined(ASIO_DISABLE_SSIZE_T)
    305 
    306 #endif // ASIO_DETAIL_CONFIG_HPP
    307