1 // boost/chrono/config.hpp -------------------------------------------------//
3 // Copyright Beman Dawes 2003, 2006, 2008
4 // Copyright 2009-2011 Vicente J. Botet Escriba
5 // Copyright (c) Microsoft Corporation 2014
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)
10 // See http://www.boost.org/libs/chrono for documentation.
12 #ifndef BOOST_CHRONO_CONFIG_HPP
13 #define BOOST_CHRONO_CONFIG_HPP
15 #include <boost/config.hpp>
16 #include <boost/predef.h>
18 #if !defined BOOST_CHRONO_VERSION
19 #define BOOST_CHRONO_VERSION 1
21 #if BOOST_CHRONO_VERSION!=1 && BOOST_CHRONO_VERSION!=2
22 #error "BOOST_CHRONO_VERSION must be 1 or 2"
26 #if defined(BOOST_CHRONO_SOURCE) && !defined(BOOST_USE_WINDOWS_H)
27 #define BOOST_USE_WINDOWS_H
30 #if ! defined BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT \
31 && ! defined BOOST_CHRONO_DONT_PROVIDE_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT
33 # define BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT
37 // BOOST_CHRONO_POSIX_API, BOOST_CHRONO_MAC_API, or BOOST_CHRONO_WINDOWS_API
38 // can be defined by the user to specify which API should be used
40 #if defined(BOOST_CHRONO_WINDOWS_API)
41 # warning Boost.Chrono will use the Windows API
42 #elif defined(BOOST_CHRONO_MAC_API)
43 # warning Boost.Chrono will use the Mac API
44 #elif defined(BOOST_CHRONO_POSIX_API)
45 # warning Boost.Chrono will use the POSIX API
48 # if defined( BOOST_CHRONO_WINDOWS_API ) && defined( BOOST_CHRONO_POSIX_API )
49 # error both BOOST_CHRONO_WINDOWS_API and BOOST_CHRONO_POSIX_API are defined
50 # elif defined( BOOST_CHRONO_WINDOWS_API ) && defined( BOOST_CHRONO_MAC_API )
51 # error both BOOST_CHRONO_WINDOWS_API and BOOST_CHRONO_MAC_API are defined
52 # elif defined( BOOST_CHRONO_MAC_API ) && defined( BOOST_CHRONO_POSIX_API )
53 # error both BOOST_CHRONO_MAC_API and BOOST_CHRONO_POSIX_API are defined
54 # elif !defined( BOOST_CHRONO_WINDOWS_API ) && !defined( BOOST_CHRONO_MAC_API ) && !defined( BOOST_CHRONO_POSIX_API )
55 # if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32))
56 # define BOOST_CHRONO_WINDOWS_API
57 # elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
58 # define BOOST_CHRONO_MAC_API
60 # define BOOST_CHRONO_POSIX_API
64 # if defined( BOOST_CHRONO_WINDOWS_API )
66 # define BOOST_CHRONO_HAS_PROCESS_CLOCKS
68 # define BOOST_CHRONO_HAS_CLOCK_STEADY
69 # if BOOST_PLAT_WINDOWS_DESKTOP
70 # define BOOST_CHRONO_HAS_THREAD_CLOCK
72 # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true
75 # if defined( BOOST_CHRONO_MAC_API )
76 # define BOOST_CHRONO_HAS_PROCESS_CLOCKS
77 # define BOOST_CHRONO_HAS_CLOCK_STEADY
78 # define BOOST_CHRONO_HAS_THREAD_CLOCK
79 # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true
82 # if defined( BOOST_CHRONO_POSIX_API )
83 # define BOOST_CHRONO_HAS_PROCESS_CLOCKS
84 # include <time.h> //to check for CLOCK_REALTIME and CLOCK_MONOTONIC and _POSIX_THREAD_CPUTIME
85 # if defined(CLOCK_MONOTONIC)
86 # define BOOST_CHRONO_HAS_CLOCK_STEADY
88 # if defined(_POSIX_THREAD_CPUTIME) && !defined(BOOST_DISABLE_THREADS)
89 # define BOOST_CHRONO_HAS_THREAD_CLOCK
90 # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true
92 # if defined(CLOCK_THREAD_CPUTIME_ID) && !defined(BOOST_DISABLE_THREADS)
93 # define BOOST_CHRONO_HAS_THREAD_CLOCK
94 # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true
96 # if defined(sun) || defined(__sun)
97 # undef BOOST_CHRONO_HAS_THREAD_CLOCK
98 # undef BOOST_CHRONO_THREAD_CLOCK_IS_STEADY
100 # if (defined(__HP_aCC) || defined(__GNUC__)) && defined(__hpux)
101 # undef BOOST_CHRONO_HAS_THREAD_CLOCK
102 # undef BOOST_CHRONO_THREAD_CLOCK_IS_STEADY
104 # if defined(__VXWORKS__)
105 # undef BOOST_CHRONO_HAS_PROCESS_CLOCKS
109 #if defined(BOOST_CHRONO_THREAD_DISABLED) && defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
110 #undef BOOST_CHRONO_HAS_THREAD_CLOCK
111 #undef BOOST_CHRONO_THREAD_CLOCK_IS_STEADY
114 // unicode support ------------------------------//
116 #if defined(BOOST_NO_CXX11_UNICODE_LITERALS) || defined(BOOST_NO_CXX11_CHAR16_T) || defined(BOOST_NO_CXX11_CHAR32_T)
117 //~ #define BOOST_CHRONO_HAS_UNICODE_SUPPORT
119 #define BOOST_CHRONO_HAS_UNICODE_SUPPORT 1
122 #ifndef BOOST_CHRONO_LIB_CONSTEXPR
123 #if defined( BOOST_NO_CXX11_NUMERIC_LIMITS )
124 #define BOOST_CHRONO_LIB_CONSTEXPR
125 #elif defined(_LIBCPP_VERSION) && !defined(_LIBCPP_CONSTEXPR)
126 #define BOOST_CHRONO_LIB_CONSTEXPR
128 #define BOOST_CHRONO_LIB_CONSTEXPR BOOST_CONSTEXPR
132 #if defined( BOOST_NO_CXX11_NUMERIC_LIMITS )
133 # define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW throw()
135 #ifdef BOOST_NO_CXX11_NOEXCEPT
136 # define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW throw()
138 # define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW noexcept
142 #if defined BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING \
143 && defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
144 #error "BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING && BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING defined"
147 #if defined BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 \
148 && defined BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0
149 #error "BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 && BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 defined"
152 #if ! defined BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING \
153 && ! defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
154 #define BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING
157 #if (BOOST_CHRONO_VERSION == 2)
158 #if ! defined BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 \
159 && ! defined BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0
160 #define BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0
164 #ifdef BOOST_CHRONO_HEADER_ONLY
165 #define BOOST_CHRONO_INLINE inline
166 #define BOOST_CHRONO_STATIC inline
167 #define BOOST_CHRONO_DECL
170 #define BOOST_CHRONO_INLINE
171 #define BOOST_CHRONO_STATIC static
173 // enable dynamic linking on Windows ---------------------------------------//
175 // we need to import/export our code only if the user has specifically
176 // asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
177 // libraries to be dynamically linked, or BOOST_CHRONO_DYN_LINK
178 // if they want just this one to be dynamically liked:
179 #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CHRONO_DYN_LINK)
180 // export if this is our own source, otherwise import:
181 #ifdef BOOST_CHRONO_SOURCE
182 # define BOOST_CHRONO_DECL BOOST_SYMBOL_EXPORT
184 # define BOOST_CHRONO_DECL BOOST_SYMBOL_IMPORT
185 #endif // BOOST_CHRONO_SOURCE
188 // if BOOST_CHRONO_DECL isn't defined yet define it now:
189 #ifndef BOOST_CHRONO_DECL
190 #define BOOST_CHRONO_DECL
195 // enable automatic library variant selection ------------------------------//
197 #if !defined(BOOST_CHRONO_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_CHRONO_NO_LIB)
199 // Set the name of our library; this will get undef'ed by auto_link.hpp
200 // once it's done with it:
202 #define BOOST_LIB_NAME boost_chrono
204 // If we're importing code from a dll, then tell auto_link.hpp about it:
206 #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CHRONO_DYN_LINK)
207 # define BOOST_DYN_LINK
210 // And include the header that does the work:
212 #include <boost/config/auto_link.hpp>
213 #endif // auto-linking disabled
214 #endif // BOOST_CHRONO_HEADER_ONLY
215 #endif // BOOST_CHRONO_CONFIG_HPP