diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-01-24 08:10:58 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-01-24 08:10:58 +0200 |
commit | 2fcb8f32f339f3a3cb550f10f565d6072f565012 (patch) | |
tree | 1124a256ba5fe1f66272b781a99374c4c688e3d7 /butl | |
parent | f29c9a5a0cdca0205f98d55ad20d1145295db126 (diff) |
Redo config as feature test macros
Diffstat (limited to 'butl')
-rw-r--r-- | butl/buildfile | 55 | ||||
-rw-r--r-- | butl/config | 52 | ||||
-rw-r--r-- | butl/diagnostics | 11 | ||||
-rw-r--r-- | butl/diagnostics.cxx | 2 | ||||
-rw-r--r-- | butl/ft/exception | 39 | ||||
-rw-r--r-- | butl/ft/lang | 29 | ||||
-rw-r--r-- | butl/ft/shared_mutex | 42 | ||||
-rw-r--r-- | butl/utility | 18 | ||||
-rw-r--r-- | butl/utility.cxx | 4 |
9 files changed, 158 insertions, 94 deletions
diff --git a/butl/buildfile b/butl/buildfile index dd2e6bb..734195e 100644 --- a/butl/buildfile +++ b/butl/buildfile @@ -3,32 +3,34 @@ # license : MIT; see accompanying LICENSE file lib{butl}: \ -{hxx cxx}{ base64 } \ -{hxx cxx}{ char-scanner } \ -{hxx }{ config } \ -{hxx cxx}{ diagnostics } \ -{hxx }{ export } \ -{hxx ixx cxx}{ fdstream } \ -{hxx ixx cxx}{ filesystem } \ -{hxx }{ manifest-forward } \ -{hxx cxx}{ manifest-parser } \ -{hxx cxx}{ manifest-serializer } \ -{hxx }{ multi-index } \ -{hxx }{ optional } \ -{hxx cxx}{ pager } \ -{hxx ixx txx cxx}{ path } \ -{hxx }{ path-io } \ -{hxx }{ path-map } \ -{hxx txx }{ prefix-map } \ -{hxx ixx cxx}{ process } \ -{hxx cxx}{ sha256 } \ -{hxx }{ small-vector } \ -{hxx txx }{ string-table } \ -{hxx cxx}{ target-triplet } \ -{hxx cxx}{ timestamp } \ -{hxx ixx cxx}{ utility } \ -{hxx }{ vector-view } \ -{hxx }{ version } + {hxx cxx}{ base64 } \ + {hxx cxx}{ char-scanner } \ + {hxx cxx}{ diagnostics } \ + {hxx }{ export } \ + {hxx ixx cxx}{ fdstream } \ + {hxx ixx cxx}{ filesystem } \ + {hxx }{ manifest-forward } \ + {hxx cxx}{ manifest-parser } \ + {hxx cxx}{ manifest-serializer } \ + {hxx }{ multi-index } \ + {hxx }{ optional } \ + {hxx cxx}{ pager } \ + {hxx ixx txx cxx}{ path } \ + {hxx }{ path-io } \ + {hxx }{ path-map } \ + {hxx txx }{ prefix-map } \ + {hxx ixx cxx}{ process } \ + {hxx cxx}{ sha256 } \ + {hxx }{ small-vector } \ + {hxx txx }{ string-table } \ + {hxx cxx}{ target-triplet } \ + {hxx cxx}{ timestamp } \ + {hxx ixx cxx}{ utility } \ + {hxx }{ vector-view } \ + {hxx }{ version } \ +ft/{hxx }{ exception } \ +ft/{hxx }{ lang } \ +ft/{hxx }{ shared_mutex } # Exclude these from compilation on non-Windows targets. # @@ -66,3 +68,4 @@ libs{butl}: cxx.export.poptions += -DLIBBUTL_SHARED # Install into the butl/ subdirectory of, say, /usr/include/. # install.include = $install.include/butl/ +install.include.subdirs = true # Recreate subdirectories. diff --git a/butl/config b/butl/config deleted file mode 100644 index 0a5169f..0000000 --- a/butl/config +++ /dev/null @@ -1,52 +0,0 @@ -// file : butl/config -*- C++ -*- -// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#ifndef BUTL_CONFIG -#define BUTL_CONFIG - -#include <cstddef> // _LIBCPP_VERSION, __GLIBCXX__ - -// thread_local -// -// If this macro is undefined then we assume one can use __thread but only -// for values that do not require dynamic (runtime) initialization. -// -// Apparently Apple's Clang "temporarily disabled" C++11 thread_local -// until they can implement a "fast" version, which reportedly happened in -// XCode 8. So for now we will continue using __thread for this target. -// -#ifdef __apple_build_version__ -# if __apple_build_version__ >= 8000000 -# define BUTL_CXX11_THREAD_LOCAL -# endif -#else -# define BUTL_CXX11_THREAD_LOCAL -#endif - -// std::uncaught_exceptions() -// -// VC has it since 1900 which is the lowest version we support. -// -#if defined(_MSC_VER) -# define BUTL_CXX17_UNCAUGHT_EXCEPTIONS -// -// Clang's libc++ seems to have it for a while (but not before 1200) so we -// assume it's there from 1200 (it doesn't define a feature test macros). But -// not for MacOS, where it is explicitly marked as unavailable until MacOS -// 10.12. -// -#elif defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 1200 -# if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \ - __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200 -# define BUTL_CXX17_UNCAUGHT_EXCEPTIONS -# endif -// -// GCC libstdc++ has it since GCC 6 and it defines the feature test macro. -// We will also use this for any other runtime. -// -#elif defined(__cpp_lib_uncaught_exceptions) -# define BUTL_CXX17_UNCAUGHT_EXCEPTIONS -#endif - -#endif // BUTL_CONFIG diff --git a/butl/diagnostics b/butl/diagnostics index da24c69..694fae7 100644 --- a/butl/diagnostics +++ b/butl/diagnostics @@ -8,8 +8,9 @@ #include <cassert> #include <ostream> #include <sstream> -#include <utility> // move(), forward() -#include <exception> // uncaught_exception(s)() +#include <utility> // move(), forward() +#include <butl/ft/exception> // uncaught_exceptions +#include <exception> // uncaught_exception(s)() #include <butl/export> #include <butl/utility> @@ -42,7 +43,7 @@ namespace butl diag_record () : -#ifdef BUTL_CXX17_UNCAUGHT_EXCEPTIONS +#ifdef __cpp_lib_uncaught_exceptions uncaught_ (std::uncaught_exceptions ()), #endif empty_ (true), @@ -94,7 +95,7 @@ namespace butl #else diag_record (diag_record&& r) : -#ifdef BUTL_CXX17_UNCAUGHT_EXCEPTIONS +#ifdef __cpp_lib_uncaught_exceptions uncaught_ (r.uncaught_), #endif empty_ (r.empty_), @@ -115,7 +116,7 @@ namespace butl diag_record& operator= (const diag_record&) = delete; protected: -#ifdef BUTL_CXX17_UNCAUGHT_EXCEPTIONS +#ifdef __cpp_lib_uncaught_exceptions const int uncaught_; #endif mutable bool empty_; diff --git a/butl/diagnostics.cxx b/butl/diagnostics.cxx index 83c78ae..bdff3d8 100644 --- a/butl/diagnostics.cxx +++ b/butl/diagnostics.cxx @@ -31,7 +31,7 @@ namespace butl // Don't flush the record if this destructor was called as part of the // stack unwinding. // -#ifdef BUTL_CXX17_UNCAUGHT_EXCEPTIONS +#ifdef __cpp_lib_uncaught_exceptions if (uncaught_ == std::uncaught_exceptions ()) flush (); #else diff --git a/butl/ft/exception b/butl/ft/exception new file mode 100644 index 0000000..2dd3a38 --- /dev/null +++ b/butl/ft/exception @@ -0,0 +1,39 @@ +// file : butl/ft/exception -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUTL_FT_EXCEPTION +#define BUTL_FT_EXCEPTION + +#include <cstddef> // _LIBCPP_VERSION +#include <exception> + +// __cpp_lib_uncaught_exceptions +// +#ifndef __cpp_lib_uncaught_exceptions + // + // VC has it since 1900. + // +# if defined(_MSC_VER) +# if _MSC_VER >= 1900 +# define __cpp_lib_uncaught_exceptions 201411 +# endif + // + // Clang's libc++ seems to have it for a while (but not before 1200) so we + // assume it's there from 1200. But not for MacOS, where it is explicitly + // marked as unavailable until MacOS 10.12. + // +# elif defined(_LIBCPP_VERSION) +# if _LIBCPP_VERSION >= 1200 && \ + (!defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \ + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200) +# define __cpp_lib_uncaught_exceptions 201411 +# endif + // + // GCC libstdc++ has it since GCC 6 and it defines the feature test macro. + // We will also use this for any other runtime. + // +# endif +#endif + +#endif // BUTL_FT_EXCEPTION diff --git a/butl/ft/lang b/butl/ft/lang new file mode 100644 index 0000000..8cfc441 --- /dev/null +++ b/butl/ft/lang @@ -0,0 +1,29 @@ +// file : butl/ft/lang -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUTL_FT_LANG +#define BUTL_FT_LANG + +// __cpp_thread_local (extension) +// +// If this macro is undefined then one may choose to fallback to __thread. +// Note, however, that it only for values that do not require dynamic +// (runtime) initialization. +// +#ifndef __cpp_thread_local + // + // Apparently Apple's Clang "temporarily disabled" C++11 thread_local until + // they can implement a "fast" version, which reportedly happened in XCode + // 8. + // +# if defined(__apple_build_version__) +# if __apple_build_version__ >= 8000000 +# define __cpp_thread_local 201103 +# endif +# else +# define __cpp_thread_local 201103 +# endif +#endif + +#endif // BUTL_FT_LANG diff --git a/butl/ft/shared_mutex b/butl/ft/shared_mutex new file mode 100644 index 0000000..b4bab94 --- /dev/null +++ b/butl/ft/shared_mutex @@ -0,0 +1,42 @@ +// file : butl/ft/shared_mutex -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUTL_FT_SHARED_MUTEX +#define BUTL_FT_SHARED_MUTEX + +#include <cstddef> // _LIBCPP_VERSION +#include <shared_mutex> + +// __cpp_lib_shared_mutex +// +#ifndef __cpp_lib_shared_mutex + // + // VC has it since 1900. + // +# if defined(_MSC_VER) +# if _MSC_VER >= 1900 +# define __cpp_lib_shared_mutex 201505 +# endif + // + // Clang's libc++ seems to have it for a while (but not before 1200) so we + // assume it's there from 1200. + // +# elif defined(_LIBCPP_VERSION) +# if _LIBCPP_VERSION >= 1200 +# define __cpp_lib_shared_mutex 201505 +# endif + // + // GCC libstdc++ has it since GCC 6 and it defines the feature test macro. + // We will also use this for any other runtime. + // +# endif +#endif + +// __cpp_lib_shared_mutex +// +#ifndef __cpp_lib_shared_timed_mutex +# define __cpp_lib_shared_timed_mutex 201402 +#endif + +#endif // BUTL_FT_SHARED_MUTEX diff --git a/butl/utility b/butl/utility index ac94171..208a840 100644 --- a/butl/utility +++ b/butl/utility @@ -6,15 +6,17 @@ #define BUTL_UTILITY #include <string> -#include <iosfwd> // ostream -#include <cstddef> // size_t -#include <utility> // move(), forward() -#include <cstring> // strcmp(), strlen() -#include <exception> // exception, uncaught_exception(s)() +#include <iosfwd> // ostream +#include <cstddef> // size_t +#include <utility> // move(), forward() +#include <cstring> // strcmp(), strlen() +#include <butl/ft/exception> // uncaught_exceptions +#include <exception> // exception, uncaught_exception(s)() +#include <butl/ft/lang> // thread_local + //#include <functional> // hash #include <butl/export> -#include <butl/config> namespace butl { @@ -165,7 +167,7 @@ namespace butl return exception_guard<F> (std::move (f)); } -#ifdef BUTL_CXX17_UNCAUGHT_EXCEPTIONS +#ifdef __cpp_lib_uncaught_exceptions template <typename F> struct exception_guard { @@ -190,7 +192,7 @@ namespace butl // part of the exception stack unwindining. // extern -#ifdef BUTL_CXX11_THREAD_LOCAL +#ifdef __cpp_thread_local thread_local #else __thread diff --git a/butl/utility.cxx b/butl/utility.cxx index d971a3f..84c8a74 100644 --- a/butl/utility.cxx +++ b/butl/utility.cxx @@ -8,9 +8,9 @@ namespace butl { -#ifndef BUTL_CXX17_UNCAUGHT_EXCEPTIONS +#ifndef __cpp_lib_uncaught_exceptions -#ifdef BUTL_CXX11_THREAD_LOCAL +#ifdef __cpp_thread_local thread_local #else __thread |