update boost
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/thread/exceptions.hpp>
|
||||
#include <boost/assert/source_location.hpp>
|
||||
|
||||
#if defined(BOOST_THREAD_POSIX) // This one can be defined by users, so it should go first
|
||||
#define BOOST_LOG_ADAPTIVE_MUTEX_USE_PTHREAD
|
||||
@@ -44,6 +45,8 @@
|
||||
#if defined(__INTEL_COMPILER) || defined(_MSC_VER)
|
||||
# if defined(__INTEL_COMPILER)
|
||||
# define BOOST_LOG_COMPILER_BARRIER __memory_barrier()
|
||||
# elif defined(__clang__) // clang-win also defines _MSC_VER
|
||||
# define BOOST_LOG_COMPILER_BARRIER __atomic_signal_fence(__ATOMIC_SEQ_CST)
|
||||
# else
|
||||
extern "C" void _ReadWriteBarrier(void);
|
||||
# if defined(BOOST_MSVC)
|
||||
@@ -212,11 +215,7 @@ private:
|
||||
template< typename ExceptionT >
|
||||
static BOOST_NOINLINE BOOST_LOG_NORETURN void throw_exception(int err, const char* descr, const char* func, const char* file, int line)
|
||||
{
|
||||
#if !defined(BOOST_EXCEPTION_DISABLE)
|
||||
boost::exception_detail::throw_exception_(ExceptionT(err, descr), func, file, line);
|
||||
#else
|
||||
boost::throw_exception(ExceptionT(err, descr));
|
||||
#endif
|
||||
boost::throw_exception(ExceptionT(err, descr), boost::source_location(file, line, func));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <boost/container/allocator_traits.hpp>
|
||||
#endif
|
||||
#include <boost/log/utility/use_std_allocator.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
@@ -46,9 +47,6 @@ using boost::container::allocator_traits;
|
||||
* The important difference from <tt>std::allocator_traits<Alloc>::rebind_alloc<U></tt> is that this
|
||||
* trait does not require template aliases and thus is compatible with C++03. There is
|
||||
* <tt>boost::container::allocator_traits<Alloc>::portable_rebind_alloc<U></tt>, but it is not present in <tt>std::allocator_traits</tt>.
|
||||
* It will also attempt to instantiate the allocator type to test if it provides the nested <tt>rebind</tt> template. We don't want
|
||||
* that to happen because it prohibits using <tt>std::allocator<void></tt> in C++17 and later, which deprecated
|
||||
* this allocator specialization. This standalone trait does not use the nested <tt>rebind</tt> template in this case.
|
||||
*/
|
||||
template< typename Allocator, typename U >
|
||||
struct rebind_alloc
|
||||
@@ -60,8 +58,20 @@ struct rebind_alloc
|
||||
#endif
|
||||
};
|
||||
|
||||
/*!
|
||||
* This specialization mostly exists to keep <tt>std::allocator<void></tt> working.
|
||||
* The default template will attempt to instantiate the allocator type to test if it provides the nested <tt>rebind</tt> template.
|
||||
* We don't want that to happen because it prohibits using <tt>std::allocator<void></tt> in C++17 and later, which deprecated
|
||||
* this allocator specialization. This specialization does not use the nested <tt>rebind</tt> template in this case.
|
||||
*/
|
||||
template< typename T, typename U >
|
||||
struct rebind_alloc< std::allocator< T >, U >
|
||||
{
|
||||
typedef std::allocator< U > type;
|
||||
};
|
||||
|
||||
template< typename U >
|
||||
struct rebind_alloc< std::allocator< void >, U >
|
||||
struct rebind_alloc< use_std_allocator, U >
|
||||
{
|
||||
typedef std::allocator< U > type;
|
||||
};
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include <string>
|
||||
#include <streambuf>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/locale/utf.hpp>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
@@ -244,7 +244,7 @@ public:
|
||||
|
||||
protected:
|
||||
//! Puts all buffered data to the string
|
||||
int sync()
|
||||
int sync() BOOST_OVERRIDE
|
||||
{
|
||||
char_type* pBase = this->pbase();
|
||||
char_type* pPtr = this->pptr();
|
||||
@@ -256,7 +256,7 @@ protected:
|
||||
return 0;
|
||||
}
|
||||
//! Puts an unbuffered character to the string
|
||||
int_type overflow(int_type c)
|
||||
int_type overflow(int_type c) BOOST_OVERRIDE
|
||||
{
|
||||
this_type::sync();
|
||||
if (!traits_type::eq_int_type(c, traits_type::eof()))
|
||||
@@ -268,7 +268,7 @@ protected:
|
||||
return traits_type::not_eof(c);
|
||||
}
|
||||
//! Puts a character sequence to the string
|
||||
std::streamsize xsputn(const char_type* s, std::streamsize n)
|
||||
std::streamsize xsputn(const char_type* s, std::streamsize n) BOOST_OVERRIDE
|
||||
{
|
||||
this_type::sync();
|
||||
return static_cast< std::streamsize >(this->append(s, static_cast< size_type >(n)));
|
||||
@@ -278,43 +278,45 @@ protected:
|
||||
size_type length_until_boundary(const char_type* s, size_type n, size_type max_size) const
|
||||
{
|
||||
BOOST_ASSERT(max_size <= n);
|
||||
return length_until_boundary(s, n, max_size, boost::integral_constant< bool, sizeof(char_type) == 1u >());
|
||||
return length_until_boundary(s, n, max_size, boost::integral_constant< std::size_t, sizeof(char_type) >());
|
||||
}
|
||||
|
||||
private:
|
||||
//! Finds the string length so that it includes only complete characters, and does not exceed \a max_size
|
||||
size_type length_until_boundary(const char_type* s, size_type, size_type max_size, boost::true_type) const
|
||||
size_type length_until_boundary(const char_type* s, size_type n, size_type max_size, boost::integral_constant< std::size_t, 1u >) const
|
||||
{
|
||||
std::locale loc = this->getloc();
|
||||
std::codecvt< wchar_t, char, std::mbstate_t > const& fac = std::use_facet< std::codecvt< wchar_t, char, std::mbstate_t > >(loc);
|
||||
std::mbstate_t mbs = std::mbstate_t();
|
||||
return static_cast< size_type >(fac.length(mbs, s, s + max_size, ~static_cast< std::size_t >(0u)));
|
||||
return static_cast< size_type >(fac.length(mbs, s, s + max_size, n));
|
||||
}
|
||||
|
||||
//! Finds the string length so that it includes only complete characters, and does not exceed \a max_size
|
||||
static size_type length_until_boundary(const char_type* s, size_type n, size_type max_size, boost::false_type)
|
||||
static size_type length_until_boundary(const char_type* s, size_type n, size_type max_size, boost::integral_constant< std::size_t, 2u >)
|
||||
{
|
||||
// Note: Although it's not required to be true for wchar_t, here we assume that the string has Unicode encoding.
|
||||
// Note: Although it's not required to be true for wchar_t, here we assume that the string has Unicode encoding (UTF-16 or UCS-2).
|
||||
// Compilers use some version of Unicode for wchar_t on all tested platforms, and std::locale doesn't offer a way
|
||||
// to find the character boundary for character types other than char anyway.
|
||||
typedef boost::locale::utf::utf_traits< char_type > utf_traits;
|
||||
|
||||
size_type pos = max_size;
|
||||
while (pos > 0u)
|
||||
{
|
||||
--pos;
|
||||
if (utf_traits::is_lead(s[pos]))
|
||||
{
|
||||
const char_type* p = s + pos;
|
||||
boost::locale::utf::code_point cp = utf_traits::decode(p, s + n);
|
||||
if (boost::locale::utf::is_valid_codepoint(cp) && p <= (s + max_size))
|
||||
return static_cast< size_type >(p - s);
|
||||
}
|
||||
uint_fast16_t c = static_cast< uint_fast16_t >(s[pos]);
|
||||
// Check if this is a leading surrogate
|
||||
if ((c & 0xFC00u) != 0xD800u)
|
||||
return pos + 1u;
|
||||
}
|
||||
|
||||
return 0u;
|
||||
}
|
||||
|
||||
//! Finds the string length so that it includes only complete characters, and does not exceed \a max_size
|
||||
static size_type length_until_boundary(const char_type* s, size_type n, size_type max_size, boost::integral_constant< std::size_t, 4u >)
|
||||
{
|
||||
// In UTF-32 and UCS-4 one code point is encoded as one code unit
|
||||
return max_size;
|
||||
}
|
||||
|
||||
//! Copy constructor (closed)
|
||||
BOOST_DELETED_FUNCTION(basic_ostringstreambuf(basic_ostringstreambuf const& that))
|
||||
//! Assignment (closed)
|
||||
|
||||
@@ -17,16 +17,8 @@
|
||||
#ifndef BOOST_LOG_DETAIL_CONFIG_HPP_INCLUDED_
|
||||
#define BOOST_LOG_DETAIL_CONFIG_HPP_INCLUDED_
|
||||
|
||||
// This check must be before any system headers are included, or __MSVCRT_VERSION__ may get defined to 0x0600
|
||||
#if defined(__MINGW32__) && !defined(__MSVCRT_VERSION__)
|
||||
// Target MinGW headers to at least MSVC 7.0 runtime by default. This will enable some useful functions.
|
||||
#define __MSVCRT_VERSION__ 0x0700
|
||||
#endif
|
||||
|
||||
#include <boost/predef/os.h>
|
||||
|
||||
// Try including WinAPI config as soon as possible so that any other headers don't include Windows SDK headers
|
||||
#if defined(BOOST_OS_WINDOWS_AVAILABLE)
|
||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)
|
||||
#include <boost/winapi/config.hpp>
|
||||
#endif
|
||||
|
||||
@@ -42,10 +34,6 @@
|
||||
# define BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH)
|
||||
#include <boost/preprocessor/stringize.hpp>
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_WINDOWS)
|
||||
# ifndef BOOST_LOG_WITHOUT_DEBUG_OUTPUT
|
||||
# define BOOST_LOG_WITHOUT_DEBUG_OUTPUT
|
||||
@@ -104,10 +92,12 @@
|
||||
# define BOOST_LOG_BROKEN_CONSTANT_EXPRESSIONS
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_HDR_CODECVT)
|
||||
#if (defined(BOOST_NO_CXX11_HDR_CODECVT) && BOOST_CXX_VERSION < 201703) || (defined(_MSVC_STL_VERSION) && _MSVC_STL_VERSION < 142)
|
||||
// The compiler does not support std::codecvt<char16_t> and std::codecvt<char32_t> specializations.
|
||||
// The BOOST_NO_CXX11_HDR_CODECVT means there's no usable <codecvt>, which is slightly different from this macro.
|
||||
// But in order for <codecvt> to be implemented the std::codecvt specializations have to be implemented as well.
|
||||
// We need to check the C++ version as well, since <codecvt> is deprecated from C++17 onwards which may cause
|
||||
// BOOST_NO_CXX11_HDR_CODECVT to be set, even though std::codecvt in <locale> is just fine.
|
||||
# define BOOST_LOG_NO_CXX11_CODECVT_FACETS
|
||||
#endif
|
||||
|
||||
@@ -123,7 +113,7 @@
|
||||
# include <vsbConfig.h>
|
||||
#endif
|
||||
|
||||
#if (!defined(__CRYSTAX__) && defined(__ANDROID__) && (__ANDROID_API__+0) < 21) \
|
||||
#if (!defined(__CRYSTAX__) && defined(__ANDROID__) && (__ANDROID_API__ < 21)) \
|
||||
|| (defined(__VXWORKS__) && !defined(_WRS_CONFIG_USER_MANAGEMENT))
|
||||
// Until Android API version 21 Google NDK does not provide getpwuid_r
|
||||
# define BOOST_LOG_NO_GETPWUID_R
|
||||
@@ -147,21 +137,37 @@
|
||||
#define BOOST_LOG_NO_CXX11_ARG_PACKS_TO_NON_VARIADIC_ARGS_EXPANSION
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_CONSTEXPR) || (defined(BOOST_GCC) && ((BOOST_GCC+0) / 100) <= 406)
|
||||
#if defined(BOOST_NO_CXX11_CONSTEXPR) || (defined(BOOST_GCC) && (BOOST_GCC / 100) <= 406)
|
||||
// GCC 4.6 does not support in-class brace initializers for static constexpr array members
|
||||
#define BOOST_LOG_NO_CXX11_CONSTEXPR_DATA_MEMBER_BRACE_INITIALIZERS
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || (defined(BOOST_GCC) && ((BOOST_GCC+0) / 100) <= 406)
|
||||
// GCC 4.6 cannot handle a defaulted function with noexcept specifier
|
||||
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || (defined(BOOST_GCC) && (BOOST_GCC / 100) <= 406)
|
||||
// GCC 4.6 cannot handle defaulted functions with noexcept specifier or virtual functions
|
||||
#define BOOST_LOG_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS
|
||||
#define BOOST_LOG_NO_CXX11_DEFAULTED_VIRTUAL_FUNCTIONS
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || (defined(BOOST_CLANG) && (((__clang_major__+0) == 3) && ((__clang_minor__+0) <= 1)))
|
||||
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || (defined(BOOST_CLANG) && ((__clang_major__ == 3) && (__clang_minor__ <= 1)))
|
||||
// Clang 3.1 cannot handle a defaulted constexpr constructor in some cases (presumably, if the class contains a member with a constexpr constructor)
|
||||
#define BOOST_LOG_NO_CXX11_DEFAULTED_CONSTEXPR_CONSTRUCTORS
|
||||
#endif
|
||||
|
||||
// The macro indicates that the compiler does not support C++20 pack expansions in lambda init-captures.
|
||||
// Early gcc, clang and MSVC versions support C++20 pack expansions in lambda init-captures,
|
||||
// but define __cpp_init_captures to a lower value.
|
||||
#if (!defined(__cpp_init_captures) || (__cpp_init_captures < 201803)) && \
|
||||
!(\
|
||||
BOOST_CXX_VERSION > 201703 && \
|
||||
(\
|
||||
(defined(BOOST_GCC) && (BOOST_GCC >= 90000)) || \
|
||||
(defined(BOOST_CLANG) && (BOOST_CLANG_VERSION >= 90000)) || \
|
||||
(defined(BOOST_MSVC) && (BOOST_MSVC >= 1922))\
|
||||
)\
|
||||
)
|
||||
#define BOOST_LOG_NO_CXX20_PACK_EXPANSION_IN_LAMBDA_INIT_CAPTURE
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define BOOST_LOG_NO_VTABLE __declspec(novtable)
|
||||
#else
|
||||
@@ -171,6 +177,14 @@
|
||||
// An MS-like compilers' extension that allows to optimize away the needless code
|
||||
#if defined(_MSC_VER)
|
||||
# define BOOST_LOG_ASSUME(expr) __assume(expr)
|
||||
#elif defined(__has_builtin)
|
||||
// Clang 3.6 adds __builtin_assume, but enabling it causes weird compilation errors, where the compiler
|
||||
// doesn't see one of attachable_sstream_buf::append overloads. It works fine with Clang 3.7 and later.
|
||||
# if __has_builtin(__builtin_assume) && (!defined(__clang__) || (__clang_major__ * 100 + __clang_minor__) >= 307)
|
||||
# define BOOST_LOG_ASSUME(expr) __builtin_assume(expr)
|
||||
# else
|
||||
# define BOOST_LOG_ASSUME(expr)
|
||||
# endif
|
||||
#else
|
||||
# define BOOST_LOG_ASSUME(expr)
|
||||
#endif
|
||||
@@ -245,15 +259,7 @@
|
||||
// other Boost libraries. We explicitly add comments here for other libraries.
|
||||
// In dynamic-library builds this is not needed.
|
||||
# if !defined(BOOST_LOG_DLL)
|
||||
# include <boost/system/config.hpp>
|
||||
# include <boost/filesystem/config.hpp>
|
||||
# if !defined(BOOST_DATE_TIME_NO_LIB) && !defined(BOOST_DATE_TIME_SOURCE)
|
||||
# define BOOST_LIB_NAME boost_date_time
|
||||
# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
|
||||
# define BOOST_DYN_LINK
|
||||
# endif
|
||||
# include <boost/config/auto_link.hpp>
|
||||
# endif
|
||||
// Boost.Thread's config is included below, if needed
|
||||
# endif
|
||||
# endif // auto-linking disabled
|
||||
@@ -328,7 +334,9 @@ namespace boost {
|
||||
# if defined(BOOST_THREAD_PLATFORM_PTHREAD)
|
||||
# define BOOST_LOG_VERSION_NAMESPACE v2_mt_posix
|
||||
# elif defined(BOOST_THREAD_PLATFORM_WIN32)
|
||||
# if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
|
||||
# if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN8
|
||||
# define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt62
|
||||
# elif BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
|
||||
# define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt6
|
||||
# else
|
||||
# define BOOST_LOG_VERSION_NAMESPACE v2_mt_nt5
|
||||
@@ -344,7 +352,9 @@ namespace boost {
|
||||
# if defined(BOOST_THREAD_PLATFORM_PTHREAD)
|
||||
# define BOOST_LOG_VERSION_NAMESPACE v2s_mt_posix
|
||||
# elif defined(BOOST_THREAD_PLATFORM_WIN32)
|
||||
# if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
|
||||
# if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN8
|
||||
# define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt62
|
||||
# elif BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
|
||||
# define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt6
|
||||
# else
|
||||
# define BOOST_LOG_VERSION_NAMESPACE v2s_mt_nt5
|
||||
@@ -365,7 +375,7 @@ inline namespace BOOST_LOG_VERSION_NAMESPACE {}
|
||||
# define BOOST_LOG_OPEN_NAMESPACE namespace log { inline namespace BOOST_LOG_VERSION_NAMESPACE {
|
||||
# define BOOST_LOG_CLOSE_NAMESPACE }}
|
||||
|
||||
# elif defined(BOOST_GCC) && (BOOST_GCC+0) >= 40400
|
||||
# elif defined(BOOST_GCC) && (BOOST_GCC >= 40400)
|
||||
|
||||
// GCC 7 deprecated strong using directives but allows inline namespaces in C++03 mode since GCC 4.4.
|
||||
__extension__ inline namespace BOOST_LOG_VERSION_NAMESPACE {}
|
||||
@@ -398,7 +408,7 @@ namespace log {}
|
||||
#endif // !defined(BOOST_LOG_DOXYGEN_PASS)
|
||||
|
||||
#if defined(BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH)
|
||||
#pragma detect_mismatch("boost_log_abi", BOOST_PP_STRINGIZE(BOOST_LOG_VERSION_NAMESPACE))
|
||||
#pragma detect_mismatch("boost_log_abi", BOOST_STRINGIZE(BOOST_LOG_VERSION_NAMESPACE))
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
@@ -343,21 +343,21 @@ struct date_time_format_parser_callback :
|
||||
typedef CharT char_type;
|
||||
|
||||
//! Destructor
|
||||
virtual ~date_time_format_parser_callback() {}
|
||||
~date_time_format_parser_callback() BOOST_OVERRIDE {}
|
||||
|
||||
/*!
|
||||
* \brief The function is called when the parser discovers a string literal in the format string
|
||||
*
|
||||
* \param lit The string of characters not interpreted as a placeholder
|
||||
*/
|
||||
virtual void on_literal(iterator_range< const char_type* > const& lit) = 0;
|
||||
void on_literal(iterator_range< const char_type* > const& lit) BOOST_OVERRIDE = 0;
|
||||
|
||||
/*!
|
||||
* \brief The method is called when an unknown placeholder is found in the format string
|
||||
*
|
||||
* \param ph The placeholder with the leading percent sign
|
||||
*/
|
||||
virtual void on_placeholder(iterator_range< const char_type* > const& ph)
|
||||
void on_placeholder(iterator_range< const char_type* > const& ph) BOOST_OVERRIDE
|
||||
{
|
||||
// By default interpret all unrecognized placeholders as literals
|
||||
on_literal(ph);
|
||||
|
||||
@@ -63,10 +63,10 @@ public:
|
||||
boost::log::aux::timestamp m_timestamp;
|
||||
record_view m_record;
|
||||
|
||||
enqueued_record(enqueued_record const& that) : m_timestamp(that.m_timestamp), m_record(that.m_record)
|
||||
enqueued_record(enqueued_record const& that) BOOST_NOEXCEPT : m_timestamp(that.m_timestamp), m_record(that.m_record)
|
||||
{
|
||||
}
|
||||
enqueued_record(BOOST_RV_REF(enqueued_record) that) :
|
||||
enqueued_record(BOOST_RV_REF(enqueued_record) that) BOOST_NOEXCEPT :
|
||||
m_timestamp(that.m_timestamp),
|
||||
m_record(boost::move(that.m_record))
|
||||
{
|
||||
@@ -76,13 +76,13 @@ public:
|
||||
m_record(rec)
|
||||
{
|
||||
}
|
||||
enqueued_record& operator= (BOOST_COPY_ASSIGN_REF(enqueued_record) that)
|
||||
enqueued_record& operator= (BOOST_COPY_ASSIGN_REF(enqueued_record) that) BOOST_NOEXCEPT
|
||||
{
|
||||
m_timestamp = that.m_timestamp;
|
||||
m_record = that.m_record;
|
||||
return *this;
|
||||
}
|
||||
enqueued_record& operator= (BOOST_RV_REF(enqueued_record) that)
|
||||
enqueued_record& operator= (BOOST_RV_REF(enqueued_record) that) BOOST_NOEXCEPT
|
||||
{
|
||||
m_timestamp = that.m_timestamp;
|
||||
m_record = boost::move(that.m_record);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2007 - 2015.
|
||||
* Copyright Andrey Semashev 2007 - 2021.
|
||||
* 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)
|
||||
@@ -21,26 +21,25 @@
|
||||
|
||||
#ifndef BOOST_LOG_NO_THREADS
|
||||
|
||||
#if defined(BOOST_THREAD_PLATFORM_PTHREAD)
|
||||
# include <boost/atomic/capabilities.hpp>
|
||||
# if (defined(linux) || defined(__linux) || defined(__linux__)) && BOOST_ATOMIC_INT_LOCK_FREE == 2
|
||||
# include <boost/atomic/atomic.hpp>
|
||||
# define BOOST_LOG_EVENT_USE_FUTEX
|
||||
# elif defined(_POSIX_SEMAPHORES) && (_POSIX_SEMAPHORES + 0) > 0 && BOOST_ATOMIC_FLAG_LOCK_FREE == 2
|
||||
# include <semaphore.h>
|
||||
# include <boost/cstdint.hpp>
|
||||
# include <boost/atomic/atomic_flag.hpp>
|
||||
# define BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE
|
||||
# endif
|
||||
#elif defined(BOOST_THREAD_PLATFORM_WIN32)
|
||||
# include <boost/cstdint.hpp>
|
||||
# define BOOST_LOG_EVENT_USE_WINAPI
|
||||
#endif
|
||||
#include <boost/atomic/capabilities.hpp>
|
||||
|
||||
#if !defined(BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE) && !defined(BOOST_LOG_EVENT_USE_WINAPI)
|
||||
# include <boost/thread/mutex.hpp>
|
||||
# include <boost/thread/condition_variable.hpp>
|
||||
# define BOOST_LOG_EVENT_USE_BOOST_CONDITION
|
||||
#if BOOST_ATOMIC_HAS_NATIVE_INT32_WAIT_NOTIFY == 2
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/atomic/atomic.hpp>
|
||||
#define BOOST_LOG_EVENT_USE_ATOMIC
|
||||
#elif defined(BOOST_THREAD_PLATFORM_PTHREAD) && defined(_POSIX_SEMAPHORES) && _POSIX_SEMAPHORES > 0 && BOOST_ATOMIC_FLAG_LOCK_FREE == 2
|
||||
#include <semaphore.h>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/atomic/atomic_flag.hpp>
|
||||
#define BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE
|
||||
#elif defined(BOOST_THREAD_PLATFORM_WIN32)
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/atomic/atomic.hpp>
|
||||
#define BOOST_LOG_EVENT_USE_WINAPI
|
||||
#else
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
#define BOOST_LOG_EVENT_USE_BOOST_CONDITION_VARIABLE
|
||||
#endif
|
||||
|
||||
#include <boost/log/detail/header.hpp>
|
||||
@@ -51,18 +50,16 @@ BOOST_LOG_OPEN_NAMESPACE
|
||||
|
||||
namespace aux {
|
||||
|
||||
#if defined(BOOST_LOG_EVENT_USE_FUTEX)
|
||||
#if defined(BOOST_LOG_EVENT_USE_ATOMIC)
|
||||
|
||||
class futex_based_event
|
||||
class atomic_based_event
|
||||
{
|
||||
private:
|
||||
boost::atomic< int > m_state;
|
||||
boost::atomic< boost::uint32_t > m_state;
|
||||
|
||||
public:
|
||||
//! Default constructor
|
||||
BOOST_LOG_API futex_based_event();
|
||||
//! Destructor
|
||||
BOOST_LOG_API ~futex_based_event();
|
||||
atomic_based_event() : m_state(0u) {}
|
||||
|
||||
//! Waits for the object to become signalled
|
||||
BOOST_LOG_API void wait();
|
||||
@@ -70,11 +67,11 @@ public:
|
||||
BOOST_LOG_API void set_signalled();
|
||||
|
||||
// Copying prohibited
|
||||
BOOST_DELETED_FUNCTION(futex_based_event(futex_based_event const&))
|
||||
BOOST_DELETED_FUNCTION(futex_based_event& operator= (futex_based_event const&))
|
||||
BOOST_DELETED_FUNCTION(atomic_based_event(atomic_based_event const&))
|
||||
BOOST_DELETED_FUNCTION(atomic_based_event& operator= (atomic_based_event const&))
|
||||
};
|
||||
|
||||
typedef futex_based_event event;
|
||||
typedef atomic_based_event event;
|
||||
|
||||
#elif defined(BOOST_LOG_EVENT_USE_POSIX_SEMAPHORE)
|
||||
|
||||
@@ -107,7 +104,7 @@ typedef sem_based_event event;
|
||||
class winapi_based_event
|
||||
{
|
||||
private:
|
||||
boost::uint32_t m_state;
|
||||
boost::atomic< boost::uint32_t > m_state;
|
||||
void* m_event;
|
||||
|
||||
public:
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
|
||||
#if !defined(BOOST_LOG_ENABLE_WARNINGS)
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
|
||||
#elif (defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) \
|
||||
&& (__GNUC__ * 100 + __GNUC_MINOR__) >= 406) || defined(__clang__)
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
|
||||
@@ -94,13 +94,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
format_description(BOOST_RV_REF(format_description) that)
|
||||
format_description(BOOST_RV_REF(format_description) that) BOOST_NOEXCEPT
|
||||
{
|
||||
literal_chars.swap(that.literal_chars);
|
||||
format_elements.swap(that.format_elements);
|
||||
}
|
||||
|
||||
format_description& operator= (format_description that)
|
||||
format_description& operator= (format_description that) BOOST_NOEXCEPT
|
||||
{
|
||||
literal_chars.swap(that.literal_chars);
|
||||
format_elements.swap(that.format_elements);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#if !defined(BOOST_LOG_ENABLE_WARNINGS)
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
|
||||
#pragma warning(push, 3)
|
||||
// 'm_A' : class 'A' needs to have dll-interface to be used by clients of class 'B'
|
||||
@@ -45,8 +45,10 @@
|
||||
// 'X': This function or variable may be unsafe. Consider using Y instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#elif defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) \
|
||||
&& (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
|
||||
#elif (defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) \
|
||||
&& (__GNUC__ * 100 + __GNUC_MINOR__) >= 406) || defined(__clang__)
|
||||
|
||||
// Note: clang-cl goes here as well, as it seems to support gcc-style warning control pragmas.
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
// 'var' defined but not used
|
||||
@@ -61,6 +63,11 @@
|
||||
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
// the argument to '__builtin_assume' has side effects that will be discarded
|
||||
#pragma clang diagnostic ignored "-Wassume"
|
||||
#endif // defined(__clang__)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // !defined(BOOST_LOG_ENABLE_WARNINGS)
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
/*!
|
||||
* Constructs the pseudo-lock. The mutex is not affected during the construction.
|
||||
*/
|
||||
explicit no_lock(MutexT&) {}
|
||||
explicit no_lock(MutexT&) BOOST_NOEXCEPT {}
|
||||
|
||||
private:
|
||||
no_lock(no_lock const&);
|
||||
@@ -117,7 +117,7 @@ protected:
|
||||
template< typename MutexT >
|
||||
struct exclusive_lock_guard
|
||||
{
|
||||
explicit exclusive_lock_guard(MutexT& m) : m_Mutex(m)
|
||||
explicit exclusive_lock_guard(MutexT& m) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(m.lock())) : m_Mutex(m)
|
||||
{
|
||||
m.lock();
|
||||
}
|
||||
@@ -137,7 +137,7 @@ private:
|
||||
template< typename MutexT >
|
||||
struct shared_lock_guard
|
||||
{
|
||||
explicit shared_lock_guard(MutexT& m) : m_Mutex(m)
|
||||
explicit shared_lock_guard(MutexT& m) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(m.lock_shared())) : m_Mutex(m)
|
||||
{
|
||||
m.lock_shared();
|
||||
}
|
||||
@@ -158,7 +158,7 @@ template< typename MutexT1, typename MutexT2 >
|
||||
class multiple_unique_lock2
|
||||
{
|
||||
public:
|
||||
multiple_unique_lock2(MutexT1& m1, MutexT2& m2) :
|
||||
multiple_unique_lock2(MutexT1& m1, MutexT2& m2) BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(m1.lock()) && BOOST_NOEXCEPT_EXPR(m2.lock())) :
|
||||
m_p1(&m1),
|
||||
m_p2(&m2)
|
||||
{
|
||||
|
||||
@@ -46,36 +46,36 @@
|
||||
public:\
|
||||
BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_MAX_PARAMETER_ARGS, macro, args)
|
||||
|
||||
#define BOOST_LOG_CTOR_FORWARD_1(n, types)\
|
||||
#define BOOST_LOG_CTOR_FORWARD_1(z, n, types)\
|
||||
template< typename T0 >\
|
||||
explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(T0 const& arg0, typename boost::log::aux::enable_if_named_parameters< T0, boost::log::aux::sfinae_dummy >::type = boost::log::aux::sfinae_dummy()) :\
|
||||
BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))) {}
|
||||
BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS_Z(z, n, arg))) {}
|
||||
|
||||
#define BOOST_LOG_CTOR_FORWARD_N(n, types)\
|
||||
template< BOOST_PP_ENUM_PARAMS(n, typename T) >\
|
||||
explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg)) :\
|
||||
BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))) {}
|
||||
#define BOOST_LOG_CTOR_FORWARD_N(z, n, types)\
|
||||
template< BOOST_PP_ENUM_PARAMS_Z(z, n, typename T) >\
|
||||
explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, T, const& arg)) :\
|
||||
BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS_Z(z, n, arg))) {}
|
||||
|
||||
#define BOOST_LOG_CTOR_FORWARD(z, n, types)\
|
||||
BOOST_PP_IF(BOOST_PP_EQUAL(n, 1), BOOST_LOG_CTOR_FORWARD_1, BOOST_LOG_CTOR_FORWARD_N)(n, types)
|
||||
BOOST_PP_IF(BOOST_PP_EQUAL(n, 1), BOOST_LOG_CTOR_FORWARD_1, BOOST_LOG_CTOR_FORWARD_N)(z, n, types)
|
||||
|
||||
// The macro expands to a number of templated constructors that aggregate their named arguments
|
||||
// into an ArgumentsPack and pass it to the base class constructor.
|
||||
#define BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_FORWARD(class_type, base_type)\
|
||||
BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_GEN(BOOST_LOG_CTOR_FORWARD, (class_type, base_type))
|
||||
|
||||
#define BOOST_LOG_CTOR_CALL_1(n, types)\
|
||||
#define BOOST_LOG_CTOR_CALL_1(z, n, types)\
|
||||
template< typename T0 >\
|
||||
explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(T0 const& arg0, typename boost::log::aux::enable_if_named_parameters< T0, boost::log::aux::sfinae_dummy >::type = boost::log::aux::sfinae_dummy())\
|
||||
{ BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))); }
|
||||
{ BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS_Z(z, n, arg))); }
|
||||
|
||||
#define BOOST_LOG_CTOR_CALL_N(n, types)\
|
||||
template< BOOST_PP_ENUM_PARAMS(n, typename T) >\
|
||||
explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg))\
|
||||
{ BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS(n, arg))); }
|
||||
#define BOOST_LOG_CTOR_CALL_N(z, n, types)\
|
||||
template< BOOST_PP_ENUM_PARAMS_Z(z, n, typename T) >\
|
||||
explicit BOOST_PP_TUPLE_ELEM(2, 0, types)(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, T, const& arg))\
|
||||
{ BOOST_PP_TUPLE_ELEM(2, 1, types)((BOOST_PP_ENUM_PARAMS_Z(z, n, arg))); }
|
||||
|
||||
#define BOOST_LOG_CTOR_CALL(z, n, types)\
|
||||
BOOST_PP_IF(BOOST_PP_EQUAL(n, 1), BOOST_LOG_CTOR_CALL_1, BOOST_LOG_CTOR_CALL_N)(n, types)
|
||||
BOOST_PP_IF(BOOST_PP_EQUAL(n, 1), BOOST_LOG_CTOR_CALL_1, BOOST_LOG_CTOR_CALL_N)(z, n, types)
|
||||
|
||||
// The macro expands to a number of templated constructors that aggregate their named arguments
|
||||
// into an ArgumentsPack and pass it to a function call.
|
||||
|
||||
@@ -17,12 +17,16 @@
|
||||
#define BOOST_LOG_DETAIL_SINK_INIT_HELPERS_HPP_INCLUDED_
|
||||
|
||||
#include <string>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/parameter/binding.hpp>
|
||||
#include <boost/type_traits/is_void.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/phoenix/core/is_actor.hpp>
|
||||
#include <boost/utility/string_view_fwd.hpp>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
#include <string_view>
|
||||
#endif
|
||||
#include <boost/log/core/core.hpp>
|
||||
#include <boost/log/expressions/filter.hpp>
|
||||
#include <boost/log/expressions/formatter.hpp>
|
||||
@@ -30,6 +34,7 @@
|
||||
#include <boost/log/utility/setup/formatter_parser.hpp>
|
||||
#include <boost/log/keywords/filter.hpp>
|
||||
#include <boost/log/keywords/format.hpp>
|
||||
#include <boost/log/detail/is_character_type.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
@@ -44,18 +49,39 @@ namespace aux {
|
||||
|
||||
// The function creates a filter functional object from the provided argument
|
||||
template< typename CharT >
|
||||
inline filter acquire_filter(const CharT* filter)
|
||||
inline typename boost::enable_if_c<
|
||||
log::aux::is_character_type< CharT >::value,
|
||||
filter
|
||||
>::type acquire_filter(const CharT* filter)
|
||||
{
|
||||
return boost::log::parse_filter(filter);
|
||||
}
|
||||
|
||||
template< typename CharT, typename TraitsT, typename AllocatorT >
|
||||
inline filter acquire_filter(std::basic_string< CharT, TraitsT, AllocatorT > const& filter)
|
||||
{
|
||||
return boost::log::parse_filter(filter);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
template< typename CharT, typename TraitsT >
|
||||
inline filter acquire_filter(std::basic_string_view< CharT, TraitsT > const& filter)
|
||||
{
|
||||
const CharT* p = filter.data();
|
||||
return boost::log::parse_filter(p, p + filter.size());
|
||||
}
|
||||
#endif // !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
template< typename CharT, typename TraitsT >
|
||||
inline filter acquire_filter(boost::basic_string_view< CharT, TraitsT > const& filter)
|
||||
{
|
||||
const CharT* p = filter.data();
|
||||
return boost::log::parse_filter(p, p + filter.size());
|
||||
}
|
||||
|
||||
template< typename FilterT >
|
||||
inline typename boost::enable_if_c<
|
||||
phoenix::is_actor< FilterT >::value,
|
||||
inline typename boost::disable_if_c<
|
||||
boost::is_array< FilterT >::value,
|
||||
FilterT const&
|
||||
>::type acquire_filter(FilterT const& filter)
|
||||
{
|
||||
@@ -64,31 +90,52 @@ inline typename boost::enable_if_c<
|
||||
|
||||
// The function installs filter into the sink, if provided in the arguments pack
|
||||
template< typename SinkT, typename ArgsT >
|
||||
inline void setup_filter(SinkT&, ArgsT const&, mpl::true_)
|
||||
inline void setup_filter(SinkT&, ArgsT const&, boost::true_type)
|
||||
{
|
||||
}
|
||||
|
||||
template< typename SinkT, typename ArgsT >
|
||||
inline void setup_filter(SinkT& s, ArgsT const& args, mpl::false_)
|
||||
inline void setup_filter(SinkT& s, ArgsT const& args, boost::false_type)
|
||||
{
|
||||
s.set_filter(aux::acquire_filter(args[keywords::filter]));
|
||||
}
|
||||
|
||||
|
||||
// The function creates a filter functional object from the provided argument
|
||||
// The function creates a formatter functional object from the provided argument
|
||||
template< typename CharT >
|
||||
inline basic_formatter< CharT > acquire_formatter(const CharT* formatter)
|
||||
inline typename boost::enable_if_c<
|
||||
log::aux::is_character_type< CharT >::value,
|
||||
basic_formatter< CharT >
|
||||
>::type acquire_formatter(const CharT* formatter)
|
||||
{
|
||||
return boost::log::parse_formatter(formatter);
|
||||
}
|
||||
|
||||
template< typename CharT, typename TraitsT, typename AllocatorT >
|
||||
inline basic_formatter< CharT > acquire_formatter(std::basic_string< CharT, TraitsT, AllocatorT > const& formatter)
|
||||
{
|
||||
return boost::log::parse_formatter(formatter);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
template< typename CharT, typename TraitsT >
|
||||
inline basic_formatter< CharT > acquire_formatter(std::basic_string_view< CharT, TraitsT > const& formatter)
|
||||
{
|
||||
const CharT* p = formatter.data();
|
||||
return boost::log::parse_formatter(p, p + formatter.size());
|
||||
}
|
||||
#endif // !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
|
||||
|
||||
template< typename CharT, typename TraitsT >
|
||||
inline basic_formatter< CharT > acquire_formatter(boost::basic_string_view< CharT, TraitsT > const& formatter)
|
||||
{
|
||||
const CharT* p = formatter.data();
|
||||
return boost::log::parse_formatter(p, p + formatter.size());
|
||||
}
|
||||
|
||||
template< typename FormatterT >
|
||||
inline typename boost::enable_if_c<
|
||||
phoenix::is_actor< FormatterT >::value,
|
||||
inline typename boost::disable_if_c<
|
||||
boost::is_array< FormatterT >::value,
|
||||
FormatterT const&
|
||||
>::type acquire_formatter(FormatterT const& formatter)
|
||||
{
|
||||
@@ -97,12 +144,12 @@ inline typename boost::enable_if_c<
|
||||
|
||||
// The function installs filter into the sink, if provided in the arguments pack
|
||||
template< typename SinkT, typename ArgsT >
|
||||
inline void setup_formatter(SinkT&, ArgsT const&, mpl::true_)
|
||||
inline void setup_formatter(SinkT&, ArgsT const&, boost::true_type)
|
||||
{
|
||||
}
|
||||
|
||||
template< typename SinkT, typename ArgsT >
|
||||
inline void setup_formatter(SinkT& s, ArgsT const& args, mpl::false_)
|
||||
inline void setup_formatter(SinkT& s, ArgsT const& args, boost::false_type)
|
||||
{
|
||||
s.set_formatter(aux::acquire_formatter(args[keywords::format]));
|
||||
}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2007 - 2015.
|
||||
* 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 snprintf.hpp
|
||||
* \author Andrey Semashev
|
||||
* \date 20.02.2009
|
||||
*
|
||||
* \brief This header is the Boost.Log library implementation, see the library documentation
|
||||
* at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_LOG_DETAIL_SNPRINTF_HPP_INCLUDED_
|
||||
#define BOOST_LOG_DETAIL_SNPRINTF_HPP_INCLUDED_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstddef>
|
||||
#include <cstdarg>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#ifdef BOOST_LOG_USE_WCHAR_T
|
||||
#include <wchar.h>
|
||||
#endif // BOOST_LOG_USE_WCHAR_T
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
BOOST_LOG_OPEN_NAMESPACE
|
||||
|
||||
namespace aux {
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
|
||||
|
||||
// MSVC snprintfs are not conforming but they are good enough for our cases.
|
||||
// MinGW32, at least the older versions up until gcc 4.7, also provide the non-conforming interface.
|
||||
inline int vsnprintf(char* buf, std::size_t size, const char* format, std::va_list args)
|
||||
{
|
||||
int n = _vsnprintf(buf, size, format, args);
|
||||
if (static_cast< unsigned int >(n) >= size)
|
||||
{
|
||||
n = static_cast< int >(size);
|
||||
buf[size - 1] = '\0';
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
# ifdef BOOST_LOG_USE_WCHAR_T
|
||||
inline int vswprintf(wchar_t* buf, std::size_t size, const wchar_t* format, std::va_list args)
|
||||
{
|
||||
int n = _vsnwprintf(buf, size, format, args);
|
||||
if (static_cast< unsigned int >(n) >= size)
|
||||
{
|
||||
n = static_cast< int >(size);
|
||||
buf[size - 1] = L'\0';
|
||||
}
|
||||
return n;
|
||||
}
|
||||
# endif // BOOST_LOG_USE_WCHAR_T
|
||||
|
||||
inline int snprintf(char* buf, std::size_t size, const char* format, ...)
|
||||
{
|
||||
std::va_list args;
|
||||
va_start(args, format);
|
||||
int n = vsnprintf(buf, size, format, args);
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
|
||||
# ifdef BOOST_LOG_USE_WCHAR_T
|
||||
inline int swprintf(wchar_t* buf, std::size_t size, const wchar_t* format, ...)
|
||||
{
|
||||
std::va_list args;
|
||||
va_start(args, format);
|
||||
int n = vswprintf(buf, size, format, args);
|
||||
va_end(args);
|
||||
return n;
|
||||
}
|
||||
# endif // BOOST_LOG_USE_WCHAR_T
|
||||
|
||||
#else
|
||||
|
||||
// Standard-conforming compilers already have the correct snprintfs
|
||||
using ::snprintf;
|
||||
using ::vsnprintf;
|
||||
|
||||
# ifdef BOOST_LOG_USE_WCHAR_T
|
||||
using ::swprintf;
|
||||
using ::vswprintf;
|
||||
# endif // BOOST_LOG_USE_WCHAR_T
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace aux
|
||||
|
||||
BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/log/detail/footer.hpp>
|
||||
|
||||
#endif // BOOST_LOG_DETAIL_SNPRINTF_HPP_INCLUDED_
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2007 - 2015.
|
||||
* Copyright Andrey Semashev 2007 - 2021.
|
||||
* 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)
|
||||
@@ -27,11 +27,12 @@
|
||||
#include <new>
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <boost/aligned_storage.hpp>
|
||||
#include <boost/atomic/atomic.hpp>
|
||||
#include <boost/move/core.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/type_traits/type_with_alignment.hpp>
|
||||
#include <boost/type_traits/aligned_storage.hpp>
|
||||
#include <boost/log/utility/use_std_allocator.hpp>
|
||||
#include <boost/log/detail/allocator_traits.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
@@ -42,32 +43,30 @@ BOOST_LOG_OPEN_NAMESPACE
|
||||
namespace aux {
|
||||
|
||||
//! Base class for the thread-safe queue implementation
|
||||
struct threadsafe_queue_impl
|
||||
class threadsafe_queue_impl
|
||||
{
|
||||
struct BOOST_LOG_MAY_ALIAS pointer_storage
|
||||
{
|
||||
union
|
||||
{
|
||||
void* data[2];
|
||||
type_with_alignment< 2 * sizeof(void*) >::type alignment;
|
||||
};
|
||||
};
|
||||
|
||||
public:
|
||||
struct node_base
|
||||
{
|
||||
pointer_storage next;
|
||||
boost::atomic< node_base* > next;
|
||||
};
|
||||
|
||||
protected:
|
||||
threadsafe_queue_impl();
|
||||
~threadsafe_queue_impl();
|
||||
|
||||
public:
|
||||
static BOOST_LOG_API threadsafe_queue_impl* create(node_base* first_node);
|
||||
static BOOST_LOG_API void destroy(threadsafe_queue_impl* impl) BOOST_NOEXCEPT;
|
||||
|
||||
static BOOST_LOG_API void* operator new (std::size_t size);
|
||||
static BOOST_LOG_API void operator delete (void* p, std::size_t);
|
||||
static BOOST_LOG_API node_base* reset_last_node(threadsafe_queue_impl* impl) BOOST_NOEXCEPT;
|
||||
static BOOST_LOG_API bool unsafe_empty(const threadsafe_queue_impl* impl) BOOST_NOEXCEPT;
|
||||
static BOOST_LOG_API void push(threadsafe_queue_impl* impl, node_base* p);
|
||||
static BOOST_LOG_API bool try_pop(threadsafe_queue_impl* impl, node_base*& node_to_free, node_base*& node_with_value);
|
||||
|
||||
virtual ~threadsafe_queue_impl() {}
|
||||
virtual node_base* reset_last_node() = 0;
|
||||
virtual bool unsafe_empty() = 0;
|
||||
virtual void push(node_base* p) = 0;
|
||||
virtual bool try_pop(node_base*& node_to_free, node_base*& node_with_value) = 0;
|
||||
// Copying and assignment is prohibited
|
||||
BOOST_DELETED_FUNCTION(threadsafe_queue_impl(threadsafe_queue_impl const&))
|
||||
BOOST_DELETED_FUNCTION(threadsafe_queue_impl& operator= (threadsafe_queue_impl const&))
|
||||
};
|
||||
|
||||
//! Thread-safe queue node type
|
||||
@@ -106,7 +105,7 @@ struct threadsafe_queue_node :
|
||||
*
|
||||
* The last requirement is not mandatory but is crucial for decent performance.
|
||||
*/
|
||||
template< typename T, typename AllocatorT = std::allocator< void > >
|
||||
template< typename T, typename AllocatorT = use_std_allocator >
|
||||
class threadsafe_queue :
|
||||
private boost::log::aux::rebind_alloc< AllocatorT, threadsafe_queue_node< T > >::type
|
||||
{
|
||||
@@ -161,7 +160,7 @@ public:
|
||||
allocator_type(alloc)
|
||||
{
|
||||
node* p = alloc_traits::allocate(get_allocator(), 1);
|
||||
if (p)
|
||||
if (BOOST_LIKELY(!!p))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -194,21 +193,21 @@ public:
|
||||
if (!unsafe_empty())
|
||||
{
|
||||
value_type value;
|
||||
while (try_pop(value));
|
||||
while (try_pop(value)) {}
|
||||
}
|
||||
|
||||
// Remove the last dummy node
|
||||
node* p = static_cast< node* >(m_pImpl->reset_last_node());
|
||||
node* p = static_cast< node* >(threadsafe_queue_impl::reset_last_node(m_pImpl));
|
||||
alloc_traits::destroy(get_allocator(), p);
|
||||
alloc_traits::deallocate(get_allocator(), p, 1);
|
||||
|
||||
delete m_pImpl;
|
||||
threadsafe_queue_impl::destroy(m_pImpl);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Checks if the queue is empty. Not thread-safe, the returned result may not be actual.
|
||||
*/
|
||||
bool unsafe_empty() const { return m_pImpl->unsafe_empty(); }
|
||||
bool unsafe_empty() const BOOST_NOEXCEPT { return threadsafe_queue_impl::unsafe_empty(m_pImpl); }
|
||||
|
||||
/*!
|
||||
* Puts a new element to the end of the queue. Thread-safe, can be called
|
||||
@@ -217,7 +216,7 @@ public:
|
||||
void push(const_reference value)
|
||||
{
|
||||
node* p = alloc_traits::allocate(get_allocator(), 1);
|
||||
if (p)
|
||||
if (BOOST_LIKELY(!!p))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -228,7 +227,7 @@ public:
|
||||
alloc_traits::deallocate(get_allocator(), p, 1);
|
||||
throw;
|
||||
}
|
||||
m_pImpl->push(p);
|
||||
threadsafe_queue_impl::push(m_pImpl, p);
|
||||
}
|
||||
else
|
||||
throw std::bad_alloc();
|
||||
@@ -242,7 +241,7 @@ public:
|
||||
bool try_pop(reference value)
|
||||
{
|
||||
threadsafe_queue_impl::node_base *dealloc, *destr;
|
||||
if (m_pImpl->try_pop(dealloc, destr))
|
||||
if (threadsafe_queue_impl::try_pop(m_pImpl, dealloc, destr))
|
||||
{
|
||||
node* p = static_cast< node* >(destr);
|
||||
auto_deallocate guard(static_cast< allocator_type* >(this), static_cast< node* >(dealloc), p);
|
||||
|
||||
@@ -41,7 +41,7 @@ class duration
|
||||
int64_t m_ticks;
|
||||
|
||||
public:
|
||||
explicit duration(int64_t ticks = 0) : m_ticks(ticks) {}
|
||||
explicit duration(int64_t ticks = 0) BOOST_NOEXCEPT : m_ticks(ticks) {}
|
||||
|
||||
#if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
int64_t milliseconds() const { return m_ticks; }
|
||||
@@ -58,7 +58,7 @@ class timestamp
|
||||
uint64_t m_ticks;
|
||||
|
||||
public:
|
||||
explicit timestamp(uint64_t ticks = 0) : m_ticks(ticks) {}
|
||||
explicit timestamp(uint64_t ticks = 0) BOOST_NOEXCEPT : m_ticks(ticks) {}
|
||||
|
||||
duration operator- (timestamp that) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user